20#include <solv/pool_snapshot.h>
22#include <solv/solvable.h>
56 {
return myPool()->nsolvables; }
74 {
return !
myPool()->urepos; }
77 {
return myPool()->urepos; }
100 if ( ! it->solvablesEmpty() )
114 ret += it->solvablesSize();
128 pool_whatmatchesdep(
get(), attr.
id(), cap.
id(), q, 0);
135 pool_whatmatchessolvable(
get(), attr.
id(),
static_cast<Id
>( solv.
id() ), q, 0 );
142 pool_whatcontainsdep(
get(), attr.
id(), cap.
id(), q, 0 );
157 info.setAlias( alias_r );
158 info.setName( alias_r );
159 info.setAutorefresh(
true );
160 info.setEnabled(
true );
170 if ( alias_r == it->alias() )
190 ::pool_reserve_ids(
get(), numid_r, numrel_r );
193 namespace {
bool & snapshotMappedFlag() {
static bool _f =
false;
return _f; } }
196 {
return snapshotMappedFlag(); }
205 return std::string();
206 unsigned char buf[4096];
207 unsigned int len =
sizeof(buf);
208 if ( ::pool_snapshot_read_cookie( fp, buf, &len ) != 0 )
209 return std::string();
210 return std::string(
reinterpret_cast<char*
>(buf), len );
215 if ( cookie_r.empty() )
219 snapshotMappedFlag() =
true;
232 if ( ::pool_snapshot_write(
get(), fp,
reinterpret_cast<const unsigned char*
>(cookie_r.data()), cookie_r.size() ) != 0
233 || ::fflush( fp ) != 0 )
235 ::unlink( tmp.
c_str() );
238 ::fchmod( ::fileno( fp ), 0644 );
240 if ( ::rename( tmp.
c_str(), path_r.
c_str() ) != 0 )
242 ::unlink( tmp.
c_str() );
245 MIL <<
"Wrote pool snapshot " << path_r << endl;
254 tmprepo->addSolv( file_r );
278 tmprepo->addHelix( file_r );
340 return str <<
"sat::pool(" << obj.
serial() <<
")["
347 #undef ZYPP_BASE_LOGGER_LOGGROUP
348 #define ZYPP_BASE_LOGGER_LOGGROUP "solvidx"
356 ERR <<
"Can't open solv-file: " << solv << endl;
361 if ( ::unlink( solvidxfile.c_str() ) == -1 && errno != ENOENT )
363 ERR <<
"Can't unlink solv-idx: " <<
Errno() << endl;
367 int fd = ::open( solvidxfile.c_str(), O_CREAT|O_EXCL|O_WRONLY|O_TRUNC, 0644 );
370 ERR <<
"Can't create solv-idx: " <<
Errno() << endl;
375 std::ofstream idx( solvidxfile.c_str() );
380 if ( ::repo_add_solv( _repo, solv, 0 ) == 0 )
384 FOR_REPO_SOLVABLES( _repo, _id, _solv )
389#define idstr(V) pool_id2str( _pool, _solv->V )
390 if ( _solv->arch == ARCH_SRC || _solv->arch == ARCH_NOSRC )
391 idx <<
"srcpackage:" <<
idstr(name) <<
SEP <<
idstr(evr) <<
SEP <<
"noarch" << endl;
399 ERR <<
"Can't read solv-file: " << ::pool_errstr( _pool ) << endl;
401 ::repo_free( _repo, 0 );
402 ::pool_free( _pool );
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
void resetDispose()
Set no dispose function.
void reset()
Reset to default Ctor values.
sat::detail::IdType id() const
Expert backdoor.
Convenience errno wrapper.
'Language[_Country]' codes.
What is known about a repository.
void setInfo(const RepoInfo &info_r)
Set RepoInfo for this repository.
bool isSystemRepo() const
Return whether this is the system repository.
Simple serial number provider.
Pathname extend(const std::string &r) const
Append string r to the last component of the path.
const char * c_str() const
String representation.
const std::string & asString() const
String representation.
std::string basename() const
Return the last component of this path.
std::string alias() const
unique identifier for this source.
const SerialNumber & serialIDs() const
Serial number changing whenever resusePoolIDs==true was used.
Queue autoInstalled() const
Get ident list of all autoinstalled solvables.
RepositoryIterator reposEnd() const
Iterator behind the last Repository.
bool addRequestedLocale(const Locale &locale_r)
Add one Locale to the set of requested locales.
detail::SolvableIterator SolvableIterator
size_type reposSize() const
Number of repos in Pool.
const MultiversionList & multiversion() const
const LocaleSet & getAvailableLocales() const
Get the set of available locales.
void setSnapshotCandidate(const Pathname &path_r, const std::string &cookie_r, const std::vector< std::string > &aliases_r)
Arm snapshot writing: once the pool holds exactly the repos in aliases_r (sorted),...
void setAutoInstalled(const Queue &autoInstalled_r)
Set ident list of all autoinstalled solvables.
Queue whatMatchesSolvable(const SolvAttr &attr, const Solvable &solv) const
Iterable< RepositoryIterator > repos() const
Iterate the repositories.
const LocaleSet & getRemovedRequestedLocales() const
Removed since last initRequestedLocales.
Queue whatContainsDep(const SolvAttr &attr, const Capability &cap) const
bool solvablesEmpty() const
Whether Pool contains solvables.
bool isRequestedLocale(const Locale &locale_r) const
Whether this Locale is in the set of requested locales.
Repository findSystemRepo() const
Return the system repository if it is on the pool.
size_type capacity() const
Internal array size for stats only.
SolvableIterator solvablesEnd() const
Iterator behind the last Solvable.
void setTextLocale(const Locale &locale_r)
Set the default language for retrieving translated texts.
Pathname rootDir() const
Get rootdir (for file conflicts check)
SolvableSet MultiversionList
detail::size_type size_type
RepositoryIterator reposBegin() const
Iterator to the first Repository.
static std::string snapshotCookie(const Pathname &path_r)
Cookie stored in the snapshot, empty if unreadable.
Repository reposFind(const std::string &alias_r) const
Find a Repository named alias_r.
size_type solvablesSize() const
Number of solvables in Pool.
const SerialNumber & serial() const
Housekeeping data serial number.
Repository addRepoSolv(const Pathname &file_r, const std::string &name_r)
Load Solvables from a solv-file into a Repository named name_r.
bool eraseRequestedLocale(const Locale &locale_r)
Erase one Locale from the set of requested locales.
bool isAvailableLocale(const Locale &locale_r) const
Whether this Locale is in the set of available locales.
Queue whatMatchesDep(const SolvAttr &attr, const Capability &cap) const
static const std::string & systemRepoAlias()
Reserved system repository alias @System .
Repository addRepoHelix(const Pathname &file_r, const std::string &name_r)
Load Solvables from a helix-file into a Repository named name_r.
zypp::detail::RepositoryIterator RepositoryIterator
SolvableIterator solvablesBegin() const
Iterator to the first Solvable.
Repository reposInsert(const std::string &alias_r)
Return a Repository named alias_r.
void prepare() const
Update housekeeping data if necessary (e.g.
bool writeSnapshot(const Pathname &path_r, const std::string &cookie_r) const
bool mapSnapshot(const Pathname &path_r, const std::string &cookie_r)
void setNeedrebootSpec(sat::SolvableSpec needrebootSpec_r)
Solvables which should trigger the reboot-needed hint if installed/updated.
detail::CPool * get() const
Expert backdoor.
void reserveIds(unsigned numid_r, unsigned numrel_r)
Size the pool's id hash tables for the given number of new string and rel ids that upcoming addRepoSo...
static bool snapshotMapped()
Whether mapSnapshot succeeded in this process.
void setRequestedLocales(const LocaleSet &locales_r)
Set the requested locales.
Repository systemRepo()
Return the system repository, create it if missing.
const LocaleSet & getRequestedLocales() const
Return the requested locales.
const LocaleSet & getAddedRequestedLocales() const
Added since last initRequestedLocales.
bool reposEmpty() const
Whether Pool contains repos.
void initRequestedLocales(const LocaleSet &locales_r)
Start tracking changes based on this locales_r.
Libsolv Id queue wrapper.
A Solvable object within the sat Pool.
IdType id() const
Expert backdoor.
Pathname rootDir() const
Get rootdir (for file conflicts check)
StringQueue autoInstalled() const
Get ident list of all autoinstalled solvables.
void setTextLocale(const Locale &locale_r)
void initRequestedLocales(const LocaleSet &locales_r)
Start tracking changes based on this locales_r.
const LocaleSet & getAvailableLocales() const
All Locales occurring in any repo.
bool isRequestedLocale(const Locale &locale_r) const
const SerialNumber & serialIDs() const
Serial number changing whenever resusePoolIDs==true was used.
bool eraseRequestedLocale(const Locale &locale_r)
User change (tracked).
const LocaleSet & getRequestedLocales() const
Current set of requested Locales.
void setRequestedLocales(const LocaleSet &locales_r)
User change (tracked).
const LocaleSet & getRemovedRequestedLocales() const
Removed since last initRequestedLocales.
void setNeedrebootSpec(sat::SolvableSpec needrebootSpec_r)
Set new Solvable specs.
const MultiversionList & multiversionList() const
bool isAvailableLocale(const Locale &locale_r) const
void setSnapshotCandidate(const Pathname &path_r, const std::string &cookie_r, const std::vector< std::string > &aliases_r)
const LocaleSet & getAddedRequestedLocales() const
Added since last initRequestedLocales.
void setAutoInstalled(const StringQueue &autoInstalled_r)
Set ident list of all autoinstalled solvables.
bool addRequestedLocale(const Locale &locale_r)
User change (tracked).
void prepare() const
Update housekeeping data (e.g.
static const std::string & systemRepoAlias()
Reserved system repository alias @System .
const SerialNumber & serial() const
Serial number changing whenever the content changes.
nullptr CURL handle void p CURLversion nullptr struct curl_slist list CURLM CURLM_INTERNAL_ERROR CURLM CURL CURLM_INTERNAL_ERROR CURLM curl_socket_t int int CURLM_INTERNAL_ERROR CURLINFO info
String related utilities and Regular expression matching.
::s_Repo CRepo
Wrapped libsolv C data type exposed as backdoor.
::s_Solvable CSolvable
Wrapped libsolv C data type exposed as backdoor.
::s_Pool CPool
Wrapped libsolv C data type exposed as backdoor.
std::ostream & operator<<(std::ostream &str, const FileConflicts &obj)
relates: FileConflicts Stream output
void updateSolvFileIndex(const Pathname &solvfile_r)
Create solv file content digest for zypper bash completion.
std::string numstring(char n, int w=0)
Easy-to use interface to the ZYPP dependency resolver.
std::unordered_set< Locale > LocaleSet
AutoDispose<FILE*> calling fclose
Functor removing Repository from its Pool.
static PoolImpl & myPool()