44 volatile sig_atomic_t shutdownPipeRead{-1};
45 volatile sig_atomic_t shutdownPipeWrite{-1};
47 bool makeShutdownPipe() {
48 int pipeFds[]{ -1, -1 };
50 if ( ::pipe2( pipeFds, O_CLOEXEC ) != 0 )
53 if ( ::pipe( pipeFds ) != 0 )
55 ::fcntl( pipeFds[0], F_SETFD, O_CLOEXEC );
56 ::fcntl( pipeFds[1], F_SETFD, O_CLOEXEC );
58 shutdownPipeRead = pipeFds[0];
59 shutdownPipeWrite = pipeFds[1];
63 const bool ensureShutdownPipe() {
64 static auto pipesInitialized = makeShutdownPipe();
65 return pipesInitialized;
68 const int shutdownPipeReadFd() {
69 if ( !ensureShutdownPipe() )
71 return static_cast<int>(shutdownPipeRead);
74 const int shutdownPipeWriteFd() {
75 return static_cast<int>(shutdownPipeWrite);
90 if ( condition_r && ! (
_guard = globalguard.lock()) )
121 if ( !ensureShutdownPipe() )
122 WAR <<
"Failed to create shutdown pipe" << std::endl;
125 MIL <<
"Initializing keyring..." << std::endl;
177 INT <<
"2 active targets at the same time must not happen!" << endl;
180 resolver()->setDefaultSolverFlags(
false );
185 MIL <<
"initTarget( " << root << (doRebuild_r?
", rebuilddb":
"") <<
")" << endl;
188 MIL <<
"Repeated call to initializeTarget()" << endl;
213 if ( getenv(
"ZYPP_TESTSUITE_FAKE_ARCH") )
218 MIL <<
"Attempt to commit (" << policy_r <<
")" << endl;
230 if (
const char *
env = getenv(
"GLIBC_TUNABLES");
env ) {
234 val +=
"glibc.cpu.hwcap_mask=0";
255 MIL <<
"Commit (" << policy_r <<
") returned: "
264 _target->_pimpl->installSrcPackage( srcPackage_r );
271 return _target->_pimpl->provideSrcPackage( srcPackage_r );
290 int sigFd = shutdownPipeWriteFd();
302 int sigFd = shutdownPipeWriteFd();
320 return str <<
"ZYppImpl";
326 const auto shutdownFd = shutdownPipeReadFd();
327 if (shutdownFd == -1) {
338 OnScopeExit removeShutdownFd( [&](){ fds.pop_back(); } );
343 if ( fds.back().revents )
Compute disk space occupied by packages across partitions/directories.
static MountPointSet detectMountPoints(const std::string &rootdir="/")
Get mountpoints of system below rootdir If we happen to detect snapshotting btrfs partitions,...
std::set< MountPoint > MountPointSet
Base class for Exception.
Dependency resolver interface.
Base for exceptions caused by explicit user request.
void notifyTargetChanged()
internal
static ZConfig & instance()
Singleton ctor.
std::ostream & about(std::ostream &str) const
Print some detail about the current libzypp version.
Options and policies for ZYpp::commit.
ZYppCommitPolicy & syncPoolAfterCommit(bool yesNo_r)
Kepp pool in sync with the Target databases after commit (default: true)
ZYppCommitPolicy & dryRun(bool yesNo_r)
Set dry run (default: false).
Result returned from ZYpp::commit.
static Pool instance()
Singleton ctor.
static const std::string & systemRepoAlias()
Reserved system repository alias @System .
DiskUsageCounter::MountPointSet getPartitions() const
void setPartitions(const DiskUsageCounter::MountPointSet &mp)
Target_Ptr target() const
void setHomePath(const Pathname &path)
set the home, if you need to change it
Resolver_Ptr resolver() const
Pathname tmpPath() const
Get the path where zypp related plugins store tmp data.
ZYppCommitResult commit(const ZYppCommitPolicy &policy_r)
Commit changes and transactions.
static void setShutdownSignal()
Enable the shutdown signal for zypp_poll calls.
void installSrcPackage(const SrcPackage_constPtr &srcPackage_r)
Install a source package on the Target.
shared_ptr< DiskUsageCounter > _disk_usage
defined mount points, used for disk usage counting
ManagedFile provideSrcPackage(const SrcPackage_constPtr &srcPackage_r)
Install a source package on the Target.
void changeTargetTo(const Target_Ptr &newtarget_r)
Hook for actions to trigger if the Target changes (initialize/finish)
Pathname homePath() const
Get the path where zypp related plugins store persistent data and caches.
DiskUsageCounter::MountPointSet diskUsage()
static void clearShutdownSignal()
Disable the shutdown signal for zypp_poll calls.
void initializeTarget(const Pathname &root, bool doRebuild_r)
String related utilities and Regular expression matching.
Namespace intended to collect all environment variables we use.
std::string numstring(char n, int w=0)
std::ostream & operator<<(std::ostream &str, const ZYppImpl &obj)
int zypp_poll(std::vector< GPollFD > &fds, int timeout)
Small wrapper around g_poll that additionally listens to the shutdown FD returned by ZYpp::shutdownSi...
Easy-to use interface to the ZYPP dependency resolver.
Pathname myTmpDir()
Global access to the zypp.TMPDIR (created on demand, deleted when libzypp is unloaded)
AutoDispose< const Pathname > ManagedFile
A Pathname plus associated cleanup code to be executed when path is no longer needed.
AutoDispose< void > OnScopeExit
auto eintrSafeCall(Fun &&function, Args &&... args)
static callback::SendReport< JobReport > & instance()
Singleton sender instance.
Temporarily connect a ReceiveReport then restore the previous one.
Temporarily set/unset an environment variable.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.