lib/psm.c - Package state machine to handle a package from a transaction set.
#include 'system.h'
#include 'psm.h'
#include 'rpmmacro.h'
#include 'rpmurl.h'
#include 'depends.h'
#include 'rpmlead.h'
#include 'signature.h'
#include 'ugid.h'
#include 'misc.h'
#include 'rpmdb.h'
#include 'debug.h'
struct tagMacro
Macros to be defined from per-header tag values.
int rpmVersionCompare (Header first, Header second)
Compare headers to determine which header is 'newer'.
void loadFi (Header h, TFI_t fi)
Load data from header into transaction file element info.
void freeFi (TFI_t fi)
Destroy transaction element file info.
const char *const fiTypeString (TFI_t fi)
Return formatted string representation of package disposition.
int rpmInstallLoadMacros (TFI_t fi, Header h)
Define per-header macros.
int mergeFiles (TFI_t fi, Header h, Header newH)
Copy file data from h to newH.
int markReplacedFiles (PSM_t psm)
Mark files in database shared with this package as 'replaced'.
rpmRC chkdir (const char *dpath, const char *dname)
Create directory if it does not exist, make sure path is writable.
rpmRC rpmInstallSourcePackage (const char *rootDir, FD_t fd, const char **specFilePtr, rpmCallbackFunction notify, rpmCallbackData notifyData, char **cookie)
Install source package.
const char *const tag2sln (int tag)
Return scriptlet name from tag.
int runScript (PSM_t psm, Header h, const char *sln, int progArgc, const char **progArgv, const char *script, int arg1, int arg2)
Run scriptlet with args.
rpmRC runInstScript (PSM_t psm)
Retrieve and run scriptlet from header.
int handleOneTrigger (PSM_t psm, Header sourceH, Header triggeredH, int arg2, unsigned char *triggersAlreadyRun)
int runTriggers (PSM_t psm)
Run trigger scripts in the database that are fired by this header.
int runImmedTriggers (PSM_t psm)
Run triggers from this header that are fired by headers in the database.
const char *const pkgStageString (pkgStage a)
int psmStage (PSM_t psm, pkgStage stage)
Package state machine driver.
tagMacro tagMacros []
Macros to be defined from per-header tag values.
char * SCRIPT_PATH
Package state machine to handle a package from a transaction set.
Create directory if it does not exist, make sure path is writable.
Note: This will only create last component of directory path.
Parameters:
Returns: rpmRC return code
Definition at line 577 of file psm.c.
References _, Access(), errno, Mkdir(), RPMERR_CREATE, rpmError, rpmRC, RPMRC_FAIL, RPMRC_OK, Stat(), URL_IS_DASH, URL_IS_FTP, URL_IS_HTTP, URL_IS_PATH, URL_IS_UNKNOWN, urlPath(), and W_OK.
Referenced by rpmInstallSourcePackage().
Return formatted string representation of package disposition.
Parameters:
Returns: formatted string
Definition at line 235 of file psm.c.
References transactionFileInfo_s::type.
Destroy transaction element file info.
Parameters:
Definition at line 188 of file psm.c.
References _free(), transactionFileInfo_s::actions, transactionFileInfo_s::apath, transactionFileInfo_s::bnl, transactionFileInfo_s::dil, transactionFileInfo_s::dnl, transactionFileInfo_s::fflags, transactionFileInfo_s::fgids, transactionFileInfo_s::fgroup, transactionFileInfo_s::flangs, transactionFileInfo_s::flinks, transactionFileInfo_s::fmapflags, transactionFileInfo_s::fmd5s, transactionFileInfo_s::fmodes, freeFSM(), transactionFileInfo_s::fsizes, transactionFileInfo_s::fsm, transactionFileInfo_s::fstates, transactionFileInfo_s::fuids, transactionFileInfo_s::fuser, transactionFileInfo_s::h, headerFree(), transactionFileInfo_s::hfd, HFD_t, transactionFileInfo_s::name, transactionFileInfo_s::obnl, transactionFileInfo_s::odnl, transactionFileInfo_s::release, transactionFileInfo_s::replaced, transactionFileInfo_s::replacedSizes, transactionFileInfo_s::type, and transactionFileInfo_s::version.
Referenced by freeFl(), freePackage(), freeSpec(), rpmInstallSourcePackage(), and rpmVerifyScript().
Parameters:
Definition at line 1105 of file psm.c.
References headerMatchesDepFlags(), headerNVR(), transactionFileInfo_s::hfd, HFD_t, transactionFileInfo_s::hge, HGE_t, int_32, rpmTransactionSet_s::rpmdb, rpmdbCountPackages(), rpmRC, RPMRC_FAIL, RPMRC_OK, RPMTAG_TRIGGERFLAGS, RPMTAG_TRIGGERINDEX, RPMTAG_TRIGGERNAME, RPMTAG_TRIGGERSCRIPTPROG, RPMTAG_TRIGGERSCRIPTS, RPMTAG_TRIGGERVERSION, rpmTagType, and runScript().
Referenced by runImmedTriggers(), and runTriggers().
Load data from header into transaction file element info.
Parameters:
Definition at line 72 of file psm.c.
References transactionFileInfo_s::action, transactionFileInfo_s::actions, transactionFileInfo_s::archiveSize, transactionFileInfo_s::bnl, transactionFileInfo_s::bnlmax, CPIO_ALL_HARDLINKS, CPIO_MAP_ABSOLUTE, CPIO_MAP_ADDDOT, CPIO_MAP_GID, CPIO_MAP_MODE, CPIO_MAP_PATH, CPIO_MAP_UID, transactionFileInfo_s::dc, transactionFileInfo_s::dil, transactionFileInfo_s::dnl, transactionFileInfo_s::dnlmax, transactionFileInfo_s::dperms, transactionFileInfo_s::epoch, FA_UNKNOWN, transactionFileInfo_s::fc, transactionFileInfo_s::fflags, transactionFileInfo_s::flags, transactionFileInfo_s::flangs, transactionFileInfo_s::flinks, transactionFileInfo_s::fmd5s, transactionFileInfo_s::fmodes, transactionFileInfo_s::fmtimes, transactionFileInfo_s::fperms, transactionFileInfo_s::frdevs, transactionFileInfo_s::fsizes, transactionFileInfo_s::fsm, transactionFileInfo_s::fstates, transactionFileInfo_s::h, transactionFileInfo_s::hae, headerFree(), headerLink(), transactionFileInfo_s::hfd, HFD_t, transactionFileInfo_s::hge, HGE_t, transactionFileInfo_s::hme, transactionFileInfo_s::hre, transactionFileInfo_s::mapflags, transactionFileInfo_s::name, newFSM(), transactionFileInfo_s::release, transactionFileInfo_s::replacedSizes, RPMTAG_ARCHIVESIZE, RPMTAG_BASENAMES, RPMTAG_DIRINDEXES, RPMTAG_DIRNAMES, RPMTAG_EPOCH, RPMTAG_FILEFLAGS, RPMTAG_FILELANGS, RPMTAG_FILELINKTOS, RPMTAG_FILEMD5S, RPMTAG_FILEMODES, RPMTAG_FILEMTIMES, RPMTAG_FILERDEVS, RPMTAG_FILESIZES, RPMTAG_FILESTATES, RPMTAG_NAME, RPMTAG_RELEASE, RPMTAG_VERSION, transactionFileInfo_s::type, uint_32, transactionFileInfo_s::version, xcalloc(), xmalloc(), and xstrdup().
Referenced by genCpioListAndHeader(), rpmInstallSourcePackage(), rpmRunTransactions(), and rpmVerifyScript().
Mark files in database shared with this package as 'replaced'.
Parameters:
Returns: 0 always
Definition at line 497 of file psm.c.
References alloca(), transactionFileInfo_s::fc, transactionFileInfo_s::hge, HGE_t, sharedFileInfo::otherFileNum, sharedFileInfo::otherPkg, transactionFileInfo_s::replaced, rpmTransactionSet_s::rpmdb, rpmdbAppendIterator(), rpmdbFreeIterator(), rpmdbGetIteratorOffset(), RPMDBI_PACKAGES, rpmdbInitIterator(), rpmdbNextIterator(), rpmdbSetIteratorModified(), rpmdbSetIteratorRewrite(), RPMFILE_STATE_REPLACED, and RPMTAG_FILESTATES.
Copy file data from h to newH.
Parameters:
Returns: 0 on success, 1 on failure
Definition at line 314 of file psm.c.
References _, FA_SKIPMULTILIB, fileAction, headerAddOrAppendEntry(), HFD_t, HGE_t, HME_t, int_16, int_32, int_8, isDependsMULTILIB, RPM_CHAR_TYPE, RPM_INT16_TYPE, RPM_INT32_TYPE, RPM_INT8_TYPE, RPM_STRING_ARRAY_TYPE, RPMERR_DATATYPE, rpmError, RPMSENSE_SENSEMASK, rpmTag, RPMTAG_BASENAMES, RPMTAG_CONFLICTFLAGS, RPMTAG_CONFLICTNAME, RPMTAG_CONFLICTVERSION, RPMTAG_DIRINDEXES, RPMTAG_DIRNAMES, RPMTAG_FILEDEVICES, RPMTAG_FILEFLAGS, RPMTAG_FILEGROUPNAME, RPMTAG_FILEINODES, RPMTAG_FILELANGS, RPMTAG_FILELINKTOS, RPMTAG_FILEMD5S, RPMTAG_FILEMODES, RPMTAG_FILEMTIMES, RPMTAG_FILERDEVS, RPMTAG_FILESIZES, RPMTAG_FILESTATES, RPMTAG_FILEUSERNAME, RPMTAG_FILEVERIFYFLAGS, RPMTAG_PROVIDEFLAGS, RPMTAG_PROVIDENAME, RPMTAG_PROVIDEVERSION, RPMTAG_REQUIREFLAGS, RPMTAG_REQUIRENAME, RPMTAG_REQUIREVERSION, RPMTAG_SIZE, rpmTagType, uint_32, and xcalloc().
Definition at line 1310 of file psm.c.
References pkgStage, PSM_CHROOT_IN, PSM_CHROOT_OUT, PSM_COMMIT, PSM_CREATE, PSM_DESTROY, PSM_FINI, PSM_IMMED_TRIGGERS, PSM_INIT, PSM_NOTIFY, PSM_PKGCOMMIT, PSM_PKGERASE, PSM_PKGINSTALL, PSM_PKGSAVE, PSM_POST, PSM_PRE, PSM_PROCESS, PSM_RPMDB_ADD, PSM_RPMDB_LOAD, PSM_RPMDB_REMOVE, PSM_RPMIO_FLAGS, PSM_SCRIPT, PSM_TRIGGERS, PSM_UNDO, and PSM_UNKNOWN.
Package state machine driver.
Todo:
Packages w/o files never get a callback, hence don't get displayed on install with -v.
Definition at line 1354 of file psm.c.
References _, _free(), transactionFileInfo_s::action, transactionFileInfo_s::actions, psm_s::amount, transactionFileInfo_s::ap, transactionFileInfo_s::apath, transactionFileInfo_s::archiveSize, rpmlead::archnum, buildOrigFileList(), psm_s::cfd, rpmTransactionSet_s::chrootDone, psm_s::chrootDone, psm_s::countCorrection, CPIO_MAP_GID, CPIO_MAP_MODE, CPIO_MAP_PATH, CPIO_MAP_UID, cpioStrerror(), rpmTransactionSet_s::currDir, rpmdb_s::db_chrootDone, transactionFileInfo_s::epoch, errno, FA_COPYOUT, psm_s::failedFile, transactionFileInfo_s::fc, Fclose(), psm_s::fd, availablePackage::fd, fdDup(), Fdopen(), Ferror(), Fflush(), transactionFileInfo_s::fgids, transactionFileInfo_s::fgroup, psm_s::fi, fileAction, Fileno(), transactionFileInfo_s::fmodes, Fopen(), transactionFileInfo_s::fsm, FSM_PKGBUILD, FSM_PKGCOMMIT, FSM_PKGERASE, FSM_PKGINSTALL, fsmSetup(), fsmTeardown(), transactionFileInfo_s::fstates, Fstrerror(), transactionFileInfo_s::fuids, transactionFileInfo_s::fuser, transactionFileInfo_s::gid, gnameToGid(), psm_s::goal, transactionFileInfo_s::h, HEADER_MAGIC_YES, headerAddEntry(), headerCopy(), headerCopyLoad(), headerFree(), headerFreeData(), headerFreeIterator(), headerGetEntry(), headerInitIterator(), headerIsEntry(), headerLink(), headerNew(), headerNextIterator(), headerRegenSigHeader(), headerSprintf(), headerWrite(), transactionFileInfo_s::hfd, HFD_t, transactionFileInfo_s::hge, HGE_t, transactionFileInfo_s::hme, HME_t, hPTR_t, rpmTransactionSet_s::id, int_32, availablePackage::key, rpmlead::major, transactionFileInfo_s::mapflags, markReplacedFiles(), mergeFiles(), psm_s::mi, rpmlead::minor, transactionFileInfo_s::name, rpmlead::name, rpmTransactionSet_s::notify, rpmTransactionSet_s::notifyData, psm_s::npkgs_installed, psm_s::oh, rpmlead::osnum, psm_s::pkgfn, pkgStage, pkgStageString(), psm_s::pkgURL, psm_s::progTag, PSM_CHROOT_IN, PSM_CHROOT_OUT, PSM_COMMIT, PSM_CREATE, PSM_DESTROY, PSM_FINI, PSM_IMMED_TRIGGERS, PSM_INIT, PSM_NOTIFY, PSM_PKGCOMMIT, PSM_PKGERASE, PSM_PKGINSTALL, PSM_PKGSAVE, PSM_POST, PSM_PRE, PSM_PROCESS, PSM_RPMDB_ADD, PSM_RPMDB_LOAD, PSM_RPMDB_REMOVE, PSM_RPMIO_FLAGS, PSM_SCRIPT, PSM_TRIGGERS, PSM_UNDO, PSM_UNKNOWN, psm_s::rc, transactionFileInfo_s::record, transactionFileInfo_s::release, rpmTransactionSet_s::rootDir, RPM_CHAR_TYPE, RPM_INT32_TYPE, rpmBuildFileList(), RPMCALLBACK_CPIO_ERROR, RPMCALLBACK_INST_PROGRESS, RPMCALLBACK_UNINST_START, RPMCALLBACK_UNINST_STOP, RPMCALLBACK_UNPACK_ERROR, rpmTransactionSet_s::rpmdb, rpmdbAdd(), rpmdbCountPackages(), rpmdbFreeIterator(), rpmdbGetIteratorOffset(), RPMDBI_PACKAGES, rpmdbInitIterator(), rpmdbNextIterator(), rpmdbRemove(), rpmdbSetIteratorRE(), RPMERR_CPIO, RPMERR_NOSPACE, RPMERR_SCRIPT, rpmError, RPMFILE_STATE_NORMAL, rpmFreeSignature(), rpmGenPath(), rpmGetArchInfo(), rpmGetOsInfo(), rpmGetPath(), psm_s::rpmio_flags, RPMLEAD_BINARY, RPMMESS_DEBUG, RPMMESS_VERBOSE, RPMMESS_WARNING, rpmMessage, RPMMIRE_DEFAULT, rpmRC, RPMRC_FAIL, RPMRC_OK, RPMSENSE_TRIGGERIN, RPMSENSE_TRIGGERPOSTUN, RPMSENSE_TRIGGERUN, RPMSIGTYPE_HEADERSIG, RPMTAG_DEFAULTPREFIX, RPMTAG_FILEGROUPNAME, RPMTAG_FILESTATES, RPMTAG_FILEUSERNAME, RPMTAG_HEADERIMAGE, RPMTAG_HEADERIMMUTABLE, RPMTAG_INSTALLTIME, RPMTAG_MULTILIBS, RPMTAG_NAME, RPMTAG_ORIGBASENAMES, RPMTAG_PAYLOADCOMPRESSOR, RPMTAG_POSTIN, RPMTAG_POSTINPROG, RPMTAG_POSTUN, RPMTAG_POSTUNPROG, RPMTAG_PREIN, RPMTAG_PREINPROG, RPMTAG_PREUN, RPMTAG_PREUNPROG, RPMTAG_RELEASE, RPMTAG_REMOVETID, RPMTAG_VERSION, RPMTRANS_FLAG_APPLYONLY, RPMTRANS_FLAG_JUSTDB, RPMTRANS_FLAG_MULTILIB, RPMTRANS_FLAG_NOPOST, RPMTRANS_FLAG_NOPOSTUN, RPMTRANS_FLAG_NOPRE, RPMTRANS_FLAG_NOPREUN, RPMTRANS_FLAG_NOTRIGGERIN, RPMTRANS_FLAG_NOTRIGGERPOSTUN, RPMTRANS_FLAG_NOTRIGGERPREIN, RPMTRANS_FLAG_NOTRIGGERUN, RPMTRANS_FLAG_PKGCOMMIT, RPMTRANS_FLAG_TEST, rpmWriteSignature(), runImmedTriggers(), runInstScript(), runTriggers(), psm_s::scriptArg, psm_s::scriptTag, psm_s::sense, rpmlead::signature_type, psm_s::stepName, stpcpy(), transactionFileInfo_s::striplen, tag2sln(), psm_s::total, rpmTransactionSet_s::transFlags, psm_s::ts, rpmlead::type, transactionFileInfo_s::uid, uint_32, unameToUid(), urlPath(), transactionFileInfo_s::version, psm_s::what, writeLead(), xcalloc(), and xmalloc().
Referenced by rpmInstallSourcePackage(), rpmRunTransactions(), and rpmVerifyScript().
Define per-header macros.
Parameters:
Returns: 0 always
Definition at line 267 of file psm.c.
References addMacro(), HGE_t, int_32, tagMacro::macroname, RPM_BIN_TYPE, RPM_CHAR_TYPE, RPM_I18NSTRING_TYPE, RPM_INT16_TYPE, RPM_INT32_TYPE, RPM_INT8_TYPE, RPM_NULL_TYPE, RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, rpmTagType, tagMacro::tag, and tagMacros.
Referenced by rpmInstallSourcePackage().
Install source package.
Parameters:
Return values:
Parameters:
Return values:
Returns: rpmRC return code
Definition at line 612 of file psm.c.
References _, _free(), transactionFileInfo_s::actions, rpmTransactionSet_s::addedPackages, transactionFileInfo_s::ap, transactionFileInfo_s::apath, transactionFileInfo_s::astriplen, transactionFileInfo_s::bnl, chkdir(), CPIO_MAP_GID, CPIO_MAP_MODE, CPIO_MAP_PATH, CPIO_MAP_UID, transactionFileInfo_s::dc, transactionFileInfo_s::dil, transactionFileInfo_s::dnl, FA_CREATE, transactionFileInfo_s::fc, transactionFileInfo_s::fflags, transactionFileInfo_s::fgids, transactionFileInfo_s::fmapflags, transactionFileInfo_s::fmd5s, freeFi(), transactionFileInfo_s::fuids, transactionFileInfo_s::gid, transactionFileInfo_s::h, headerFree(), headerIsEntry(), transactionFileInfo_s::hfd, HFD_t, transactionFileInfo_s::hge, HGE_t, availableList_s::list, loadFi(), transactionFileInfo_s::mapflags, rpmTransactionSet_s::notify, rpmTransactionSet_s::notifyData, PSM_FINI, PSM_PKGINSTALL, PSM_PROCESS, psmStage(), rpmTransactionSet_s::rootDir, rpmBuildFileList(), rpmCallbackData, rpmCallbackFunction, RPMERR_NOSPEC, RPMERR_NOTSRPM, rpmError, RPMFILE_SPECFILE, rpmGenPath(), rpmInstallLoadMacros(), rpmRC, RPMRC_FAIL, RPMRC_OK, rpmReadPackageHeader(), RPMTAG_COOKIE, rpmtransAddPackage(), rpmtransCreateSet(), rpmtransFree(), stpcpy(), transactionFileInfo_s::striplen, transactionFileInfo_s::type, transactionFileInfo_s::uid, xcalloc(), xmalloc(), and xstrdup().
Referenced by rpmInstall(), and rpmInstallSource().
Compare headers to determine which header is 'newer'.
Parameters:
Returns: result of comparison
Definition at line 36 of file psm.c.
References headerGetEntry(), int_32, RPMTAG_EPOCH, RPMTAG_RELEASE, RPMTAG_VERSION, and rpmvercmp().
Referenced by alAddPackage(), ensureOlder(), findUpgradePackages(), pkgCompareVer(), rpmInstall(), rpmtransAddPackage(), and unmarkPackagesAlreadyInstalled().
Run triggers from this header that are fired by headers in the database.
Parameters:
Returns: 0 on success, 1 on error
Definition at line 1258 of file psm.c.
References alloca(), transactionFileInfo_s::h, handleOneTrigger(), transactionFileInfo_s::hfd, HFD_t, transactionFileInfo_s::hge, HGE_t, int_32, rpmTransactionSet_s::rpmdb, rpmdbFreeIterator(), rpmdbInitIterator(), rpmdbNextIterator(), rpmRC, RPMRC_OK, RPMTAG_NAME, RPMTAG_TRIGGERINDEX, RPMTAG_TRIGGERNAME, and rpmTagType.
Retrieve and run scriptlet from header.
Parameters:
Returns: rpmRC return code
Definition at line 1058 of file psm.c.
References alloca(), transactionFileInfo_s::h, transactionFileInfo_s::hfd, HFD_t, transactionFileInfo_s::hge, HGE_t, RPM_STRING_TYPE, rpmRC, RPMRC_OK, rpmTagType, runScript(), and tag2sln().
Run scriptlet with args.
Run a script with an interpreter. If the interpreter is not specified, /bin/sh will be used. If the interpreter is /bin/sh, then the args from the header will be ignored, passing instead arg1 and arg2.
Parameters:
Returns: 0 on success, 1 on error
Definition at line 825 of file psm.c.
References _, _free(), alloca(), rpmTransactionSet_s::chrootDone, doputenv(), dosetenv(), errno, Fclose(), fdDup(), fdLink, Ferror(), Fileno(), Fopen(), Fwrite(), headerNVR(), transactionFileInfo_s::hfd, HFD_t, transactionFileInfo_s::hge, HGE_t, makeTempFile(), rpmTransactionSet_s::rootDir, RPMERR_SCRIPT, rpmError, rpmExpand(), rpmIsDebug, rpmIsVerbose, rpmRC, RPMRC_FAIL, RPMRC_OK, RPMTAG_INSTALLPREFIX, RPMTAG_INSTPREFIXES, rpmTagType, SCRIPT_PATH, rpmTransactionSet_s::scriptFd, URL_IS_PATH, URL_IS_UNKNOWN, and urlIsURL().
Referenced by handleOneTrigger(), and runInstScript().
Run trigger scripts in the database that are fired by this header.
Parameters:
Returns: 0 on success, 1 on error
Definition at line 1221 of file psm.c.
References transactionFileInfo_s::h, handleOneTrigger(), transactionFileInfo_s::name, rpmTransactionSet_s::rpmdb, rpmdbCountPackages(), rpmdbFreeIterator(), rpmdbInitIterator(), rpmdbNextIterator(), rpmRC, RPMRC_OK, and RPMTAG_TRIGGERNAME.
Return scriptlet name from tag.
Parameters:
Returns: name of scriptlet
Definition at line 794 of file psm.c.
References RPMTAG_POSTIN, RPMTAG_POSTUN, RPMTAG_PREIN, RPMTAG_PREUN, and RPMTAG_VERIFYSCRIPT.
Referenced by psmStage(), and runInstScript().
Initial value:
'PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin'
Definition at line 786 of file psm.c.
Macros to be defined from per-header tag values.
Todo:
Should other macros be added from header when installing a package?
Referenced by rpmInstallLoadMacros().
Generated automatically by Doxygen for rpm from the source code.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |