Package state machine to handle a package from a transaction set. More...
#include "system.h"#include <rpmio_internal.h>#include <rpmlib.h>#include <rpmmacro.h>#include <rpmurl.h>#include <rpmlua.h>#include "cpio.h"#include "fsm.h"#include "psm.h"#include "rpmds.h"#include "rpmfi.h"#include "rpmte.h"#include "rpmts.h"#include "rpmlead.h"#include "signature.h"#include "legacy.h"#include "misc.h"#include "rpmdb.h"#include "debug.h"Go to the source code of this file.
Data Structures | |
| struct | tagMacro |
| Macros to be defined from per-header tag values. More... | |
Defines | |
| #define | _RPMFI_INTERNAL |
| #define | _RPMTE_INTERNAL |
| #define | _RPMTS_INTERNAL |
| #define | _PSM_DEBUG 0 |
Functions | |
| int | rpmVersionCompare (Header first, Header second) |
| Compare headers to determine which header is "newer". | |
| static int | rpmInstallLoadMacros (rpmfi fi, Header h) |
| Define per-header macros. | |
| static rpmRC | markReplacedFiles (const rpmpsm psm) |
| Mark files in database shared with this package as "replaced". | |
| rpmRC | rpmInstallSourcePackage (rpmts ts, FD_t fd, const char **specFilePtr, const char **cookie) |
| Install source package. | |
| static const char *const | tag2sln (int tag) |
| Return scriptlet name from tag. | |
| static pid_t | psmWait (rpmpsm psm) |
| Wait for child process to be reaped. | |
| static rpmRC | runLuaScript (rpmpsm psm, Header h, const char *sln, int progArgc, const char **progArgv, const char *script, int arg1, int arg2) |
| Run internal Lua script. | |
| static rpmRC | runScript (rpmpsm psm, Header h, const char *sln, int progArgc, const char **progArgv, const char *script, int arg1, int arg2) |
| Run scriptlet with args. | |
| static rpmRC | runInstScript (rpmpsm psm) |
| Retrieve and run scriptlet from header. | |
| static rpmRC | handleOneTrigger (const rpmpsm psm, Header sourceH, Header triggeredH, int arg2, unsigned char *triggersAlreadyRun) |
| Execute triggers. | |
| static rpmRC | runTriggers (rpmpsm psm) |
| Run trigger scripts in the database that are fired by this header. | |
| static rpmRC | runImmedTriggers (rpmpsm psm) |
| Run triggers from this header that are fired by headers in the database. | |
| static const char *const | pkgStageString (pkgStage a) |
| rpmpsm | XrpmpsmUnlink (rpmpsm psm, const char *msg, const char *fn, unsigned ln) |
| rpmpsm | XrpmpsmLink (rpmpsm psm, const char *msg, const char *fn, unsigned ln) |
| rpmpsm | rpmpsmFree (rpmpsm psm) |
| Destroy a package state machine. | |
| rpmpsm | rpmpsmNew (rpmts ts, rpmte te, rpmfi fi) |
| Create and load a package state machine. | |
| static void * | rpmpsmThread (void *arg) |
| static int | rpmpsmNext (rpmpsm psm, pkgStage nstage) |
| rpmRC | rpmpsmStage (rpmpsm psm, pkgStage stage) |
| Package state machine driver. | |
Variables | |
| int | _psm_debug = 0 |
| int | _psm_threads = 0 |
| unsigned int | myinstall_instance |
| static struct tagMacro | tagMacros [] |
| Macros to be defined from per-header tag values. | |
| static char * | SCRIPT_PATH = "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin" |
| static int | ldconfig_done = 0 |
| static const char * | ldconfig_path = "/sbin/ldconfig" |
Package state machine to handle a package from a transaction set.
Definition in file psm.c.
| static rpmRC handleOneTrigger | ( | const rpmpsm | psm, | |
| Header | sourceH, | |||
| Header | triggeredH, | |||
| int | arg2, | |||
| unsigned char * | triggersAlreadyRun | |||
| ) | [static] |
Execute triggers.
| psm | package state machine data | |
| sourceH | ||
| triggeredH | ||
| arg2 | ||
| triggersAlreadyRun |
Definition at line 1030 of file psm.c.
References rpmpsm_s::countCorrection, rpmpsm_s::fi, headerFreeData(), headerNVR(), rpmfi_s::hfd, rpmfi_s::hge, rpmpsm_s::rc, rpmdbCountPackages(), rpmdsAnyMatchesDep(), rpmdsFlags(), rpmdsFree(), rpmdsInit(), rpmdsN(), rpmdsNew(), rpmdsNext(), rpmdsSetNoPromote(), RPMRC_FAIL, RPMRC_OK, rpmtsGetRdb(), runScript(), rpmpsm_s::sense, and rpmpsm_s::ts.
Referenced by runImmedTriggers(), and runTriggers().
Mark files in database shared with this package as "replaced".
| psm | package state machine data |
Definition at line 163 of file psm.c.
References rpmpsm_s::fi, rpmfi_s::hge, rpmfi_s::replaced, rpmdbAppendIterator(), rpmdbFreeIterator(), rpmdbGetIteratorOffset(), RPMDBI_PACKAGES, rpmdbNextIterator(), rpmdbSetIteratorModified(), rpmdbSetIteratorRewrite(), rpmfiFC(), RPMFILE_STATE_REPLACED, RPMRC_OK, rpmtsInitIterator(), and rpmpsm_s::ts.
Referenced by rpmpsmStage().
| static const char* const pkgStageString | ( | pkgStage | a | ) | [static] |
Definition at line 1228 of file psm.c.
References 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.
Referenced by rpmpsmStage().
| static pid_t psmWait | ( | rpmpsm | psm | ) | [static] |
Wait for child process to be reaped.
| psm | package state machine data |
Definition at line 477 of file psm.c.
References _, rpmsqElem::child, rpmsqElem::op, rpmsqElem::reaped, RPMMESS_DEBUG, rpmMessage, rpmsqWait(), rpmswAdd(), RPMTS_OP_SCRIPTLETS, rpmtsOp(), rpmpsm_s::sq, rpmsqElem::status, rpmpsm_s::stepName, rpmpsm_s::ts, and rpmop_s::usecs.
Referenced by runScript().
Define per-header macros.
| fi | transaction element file info | |
| h | header |
Definition at line 115 of file psm.c.
References rpmfi_s::hge.
Referenced by rpmInstallSourcePackage().
| rpmRC rpmInstallSourcePackage | ( | rpmts | ts, | |
| FD_t | fd, | |||
| const char ** | specFilePtr, | |||
| const char ** | cookie | |||
| ) |
Install source package.
| ts | transaction set | |
| fd | file handle |
| specFilePtr | address of spec file name (or NULL) | |
| cookie | address of cookie pointer (or NULL) |
Definition at line 238 of file psm.c.
References _, _free(), rpmfi_s::actions, rpmfi_s::apath, rpmfi_s::astriplen, rpmfi_s::bnl, CPIO_MAP_GID, CPIO_MAP_MODE, CPIO_MAP_PATH, CPIO_MAP_UID, rpmfi_s::dc, rpmfi_s::dil, rpmfi_s::dnl, FA_CREATE, rpmfi_s::fc, Fclose(), rpmte_s::fd, fdLink, rpmfi_s::fflags, rpmfi_s::fmapflags, rpmfi_s::fmd5s, rpmfi_s::gid, rpmfi_s::h, rpmte_s::h, headerFree(), headerIsEntry(), headerLink(), rpmfi_s::hfd, rpmfi_s::hge, rpmfi_s::mapflags, PSM_FINI, PSM_PKGINSTALL, PSM_PROCESS, RPMERR_NOSPEC, RPMERR_NOTSRPM, rpmError, rpmfiBuildFNames(), rpmfiFree(), RPMFILE_SPECFILE, rpmfiLink, rpmfiNew(), rpmGenPath(), rpmInstallLoadMacros(), rpmMkdirPath(), rpmpsmStage(), RPMRC_FAIL, RPMRC_NOKEY, RPMRC_NOTTRUSTED, RPMRC_OK, rpmReadPackageFile(), rpmtsAddInstallElement(), rpmtsClean(), rpmtsElement(), rpmtsFree(), rpmtsLink, rpmtsRootDir(), rpmfi_s::striplen, rpmfi_s::te, rpmfi_s::uid, xmalloc(), and xstrdup().
Referenced by rpmInstall(), and rpmInstallSource().
Destroy a package state machine.
| psm | package state machine |
Definition at line 1292 of file psm.c.
References _free(), rpmpsm_s::fi, rpmpsm_s::nrefs, rpmfiFree(), rpmpsmUnlink, rpmteFree(), rpmtsFree(), rpmpsm_s::te, and rpmpsm_s::ts.
Referenced by rpmtsRun(), and rpmVerifyScript().
Create and load a package state machine.
| ts | transaction set | |
| te | transaction set element | |
| fi | file info set |
Definition at line 1325 of file psm.c.
References rpmpsm_s::fi, rpmfiLink, rpmpsmLink, rpmtsLink, rpmpsm_s::te, rpmpsm_s::ts, and xcalloc().
Referenced by rpmtsRun(), and rpmVerifyScript().
Definition at line 1353 of file psm.c.
References _psm_threads, rpmpsm_s::nstage, rpmpsmStage(), rpmpsmThread(), rpmsqJoin(), and rpmsqThread().
Referenced by rpmpsmStage().
Package state machine driver.
Definition at line 1368 of file psm.c.
References _, _free(), rpmfi_s::action, rpmfi_s::actions, rpmpsm_s::amount, rpmfi_s::apath, rpmfi_s::archiveSize, rpmlead::archnum, rpmpsm_s::cfd, rpmpsm_s::chrootDone, rpmpsm_s::countCorrection, CPIO_MAP_GID, CPIO_MAP_MODE, CPIO_MAP_PATH, CPIO_MAP_UID, CPIO_SBIT_CHECK, cpioStrerror(), dbiOpen(), rpmtsScoreEntry_s::erased, errno, FA_COPYOUT, rpmpsm_s::failedFile, Fclose(), rpmpsm_s::fd, fdDup(), Fdopen(), FDSTAT_DIGEST, fdstat_op(), FDSTAT_READ, FDSTAT_WRITE, Ferror(), Fflush(), rpmfi_s::fgroup, rpmpsm_s::fi, Fileno(), Fopen(), rpmfi_s::fsm, FSM_PKGBUILD, FSM_PKGCOMMIT, FSM_PKGERASE, FSM_PKGINSTALL, fsmSetup(), fsmTeardown(), rpmfi_s::fstates, Fstrerror(), rpmfi_s::fuser, rpmpsm_s::goal, rpmte_s::h, rpmfi_s::h, HEADER_MAGIC_YES, headerAddEntry(), headerCheck(), headerCopyLoad(), headerFree(), headerFreeData(), headerFreeIterator(), headerGetEntry(), headerInitIterator(), headerIsEntry(), headerLink(), headerNew(), headerNextIterator(), headerRegenSigHeader(), headerReload(), headerSprintf(), headerWrite(), rpmfi_s::hfd, rpmfi_s::hge, rpmtsScoreEntry_s::installed, rpmlead::major, rpmfi_s::mapflags, markReplacedFiles(), rpmpsm_s::mi, rpmlead::minor, myinstall_instance, rpmlead::name, rpmts_s::notify, rpmpsm_s::npkgs_installed, rpmpsm_s::oh, rpmlead::osnum, rpmpsm_s::pkgfn, pkgStageString(), rpmpsm_s::pkgURL, rpmpsm_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, rpmpsm_s::rc, rpmfi_s::record, RPMCALLBACK_CPIO_ERROR, RPMCALLBACK_INST_PROGRESS, RPMCALLBACK_INST_START, RPMCALLBACK_UNINST_START, RPMCALLBACK_UNINST_STOP, RPMCALLBACK_UNPACK_ERROR, rpmdbAdd(), rpmdbCountPackages(), rpmdbFreeIterator(), rpmdbGetIteratorOffset(), RPMDBI_PACKAGES, rpmdbNextIterator(), rpmdbRemove(), rpmdbSetIteratorRE(), RPMERR_CPIO, RPMERR_NOSPACE, RPMERR_SCRIPT, rpmError, rpmfiBuildFNames(), rpmfiFC(), RPMFILE_STATE_NORMAL, rpmFreeSignature(), rpmGenPath(), rpmGetArchInfo(), rpmGetOsInfo(), rpmGetPath(), rpmHeaderFormats, rpmpsm_s::rpmio_flags, RPMLEAD_BINARY, RPMMESS_DEBUG, RPMMESS_VERBOSE, rpmMessage, RPMMIRE_STRCMP, rpmpsmNext(), RPMRC_FAIL, RPMRC_OK, RPMSENSE_TRIGGERIN, RPMSENSE_TRIGGERPOSTUN, RPMSENSE_TRIGGERPREIN, RPMSENSE_TRIGGERUN, RPMSIGTYPE_HEADERSIG, rpmswAdd(), rpmswEnter(), rpmswExit(), RPMTAG_HEADERIMAGE, RPMTAG_HEADERIMMUTABLE, RPMTAG_HEADERSIGNATURES, rpmTagTable, rpmteA(), rpmteE(), rpmteFd(), rpmteN(), rpmteNEVR(), rpmteO(), rpmteR(), rpmteSetDBInstance(), rpmteV(), RPMTRANS_FLAG_APPLYONLY, RPMTRANS_FLAG_JUSTDB, 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, RPMTRANS_TYPE_AUTOROLLBACK, RPMTRANS_TYPE_ROLLBACK, RPMTS_OP_COMPRESS, RPMTS_OP_DBADD, RPMTS_OP_DBREMOVE, RPMTS_OP_DIGEST, RPMTS_OP_UNCOMPRESS, rpmtsChrootDone(), rpmtsColor(), rpmtsCurrDir(), rpmtsFlags(), rpmtsGetRdb(), rpmtsGetScore(), rpmtsGetTid(), rpmtsGetType(), rpmtsInitIterator(), rpmtsNotify(), rpmtsOp(), rpmtsRootDir(), rpmtsScoreGetEntry(), rpmtsSetChrootDone(), rpmtsVSFlags(), RPMVSF_NOHDRCHK, rpmWriteSignature(), runImmedTriggers(), runInstScript(), runTriggers(), rpmpsm_s::scriptArg, rpmpsm_s::scriptTag, rpmpsm_s::sense, rpmlead::signature_type, rpmpsm_s::stepName, rpmfi_s::striplen, tag2sln(), rpmfi_s::te, rpmpsm_s::te, rpmtsScoreEntry_s::te_types, rpmpsm_s::total, TR_ADDED, TR_REMOVED, rpmpsm_s::ts, rpmlead::type, urlPath(), rpmpsm_s::what, writeLead(), and xmalloc().
Referenced by rpmInstallSourcePackage(), rpmpsmNext(), rpmpsmThread(), rpmtsRun(), and rpmVerifyScript().
| static void* rpmpsmThread | ( | void * | arg | ) | [static] |
Definition at line 1343 of file psm.c.
References rpmpsm_s::nstage, and rpmpsmStage().
Referenced by rpmpsmNext().
Compare headers to determine which header is "newer".
| first | 1st header | |
| second | 2nd header |
Definition at line 61 of file psm.c.
References headerGetEntry(), and rpmvercmp().
Referenced by hdr_compare(), rpmInstall(), and rpmtsAddInstallElement().
Run triggers from this header that are fired by headers in the database.
| psm | package state machine data |
Definition at line 1174 of file psm.c.
References rpmpsm_s::fi, rpmfi_s::h, handleOneTrigger(), headerFreeData(), rpmfi_s::hfd, rpmfi_s::hge, rpmpsm_s::mi, rpmpsm_s::rc, rpmdbFreeIterator(), rpmdbGetIteratorCount(), rpmdbNextIterator(), RPMRC_OK, rpmtsInitIterator(), and rpmpsm_s::ts.
Referenced by rpmpsmStage().
Retrieve and run scriptlet from header.
| psm | package state machine data |
Definition at line 971 of file psm.c.
References rpmpsm_s::fi, getenv, rpmfi_s::h, headerFreeData(), rpmfi_s::hfd, rpmfi_s::hge, rpmpsm_s::progTag, rpmpsm_s::rc, RPMRC_OK, runScript(), rpmpsm_s::scriptArg, rpmpsm_s::scriptTag, and tag2sln().
Referenced by rpmpsmStage().
| static rpmRC runLuaScript | ( | rpmpsm | psm, | |
| Header | h, | |||
| const char * | sln, | |||
| int | progArgc, | |||
| const char ** | progArgv, | |||
| const char * | script, | |||
| int | arg1, | |||
| int | arg2 | |||
| ) | [static] |
Run internal Lua script.
Definition at line 501 of file psm.c.
References headerNVR(), rpmpsm_s::rc, RPMRC_FAIL, RPMRC_OK, rpmtsChrootDone(), rpmtsRootDir(), rpmtsSetChrootDone(), and rpmpsm_s::ts.
Referenced by runScript().
| static rpmRC runScript | ( | rpmpsm | psm, | |
| Header | h, | |||
| const char * | sln, | |||
| int | progArgc, | |||
| const char ** | progArgv, | |||
| const char * | script, | |||
| int | arg1, | |||
| int | arg2 | |||
| ) | [static] |
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.
| psm | package state machine data | |
| h | header | |
| sln | name of scriptlet section | |
| progArgc | no. of args from header | |
| progArgv | args from header, progArgv[0] is the interpreter to use | |
| script | scriptlet from header | |
| arg1 | no. instances of package installed after scriptlet exec (-1 is no arg) | |
| arg2 | ditto, but for the target package |
Definition at line 608 of file psm.c.
References _, _free(), rpmsqElem::child, doputenv(), environ, errno, Fclose(), rpmpsm_s::fd, fdDup(), Ferror(), rpmpsm_s::fi, Fileno(), Fopen(), Fwrite(), headerFreeData(), headerNVR(), headerSprintf(), rpmfi_s::hfd, rpmfi_s::hge, ipath, makeTempFile(), psmWait(), rpmpsm_s::rc, rpmsqElem::reaped, rpmsqElem::reaper, rpmts_s::rootDir, rpm_execcon, RPMERR_FORK, RPMERR_SCRIPT, rpmError, rpmExpand(), rpmGetPath(), rpmHeaderFormats, rpmIsDebug, rpmIsVerbose, RPMMESS_DEBUG, rpmMessage, RPMRC_FAIL, RPMRC_OK, rpmsqFork(), rpmTagTable, rpmtsChrootDone(), rpmtsRootDir(), rpmtsScriptFd(), rpmtsSELinuxEnabled(), runLuaScript(), rpmpsm_s::scriptTag, rpmpsm_s::sq, rpmsqElem::status, rpmpsm_s::stepName, tag2sln(), rpmpsm_s::ts, rpmpsm_s::unorderedSuccessor, URL_IS_DASH, URL_IS_FTP, URL_IS_HKP, URL_IS_HTTP, URL_IS_HTTPS, 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.
| psm | package state machine data |
Definition at line 1132 of file psm.c.
References rpmpsm_s::countCorrection, rpmpsm_s::fi, rpmfi_s::h, handleOneTrigger(), rpmpsm_s::mi, rpmpsm_s::rc, rpmdbCountPackages(), rpmdbFreeIterator(), rpmdbNextIterator(), RPMRC_NOTFOUND, RPMRC_OK, rpmteN(), rpmtsGetRdb(), rpmtsInitIterator(), rpmpsm_s::te, and rpmpsm_s::ts.
Referenced by rpmpsmStage().
| static const char* const tag2sln | ( | int | tag | ) | [static] |
Return scriptlet name from tag.
| tag | scriptlet tag |
Definition at line 453 of file psm.c.
Referenced by rpmpsmStage(), runInstScript(), and runScript().
Definition at line 1279 of file psm.c.
References _psm_debug, and rpmpsm_s::nrefs.
Definition at line 1268 of file psm.c.
References _psm_debug, and rpmpsm_s::nrefs.
| int _psm_debug = 0 |
Definition at line 38 of file psm.c.
Referenced by XrpmpsmLink(), and XrpmpsmUnlink().
| int _psm_threads = 0 |
Definition at line 40 of file psm.c.
Referenced by rpmpsmNext().
int ldconfig_done = 0 [static] |
const char* ldconfig_path = "/sbin/ldconfig" [static] |
| unsigned int myinstall_instance |
Definition at line 69 of file rpmdb.c.
Referenced by rpmdbAdd(), and rpmpsmStage().
char* SCRIPT_PATH = "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin" [static] |
1.6.1