28 #if defined(WITH_LUA) || defined(WITH_AUGEAS) || defined(WITH_FICL) || defined(WITH_GPSEE) || defined(WITH_PERLEMBED) || defined(WITH_PYTHONEMBED) || defined(WITH_RUBYEMBED) || defined(WITH_SEMANAGE) || defined(WITH_SQLITE) || defined(WITH_SQUIRREL) || defined(WITH_TCL)
29 #define _WITH_EMBEDDED
37 #define _RPMDB_INTERNAL
43 #define _RPMFI_INTERNAL
46 #define _RPMSQ_INTERNAL
47 #define _RPMPSM_INTERNAL
49 #define F_ISSET(_psm, _FLAG) ((_psm)->flags & (RPMPSM_FLAGS_##_FLAG))
50 #define F_SET(_psm, _FLAG) \
51 (*((unsigned *)&(_psm)->flags) |= (RPMPSM_FLAGS_##_FLAG))
52 #define F_CLR(_psm, _FLAG) \
53 (*((unsigned *)&(_psm)->flags) &= ~(RPMPSM_FLAGS_##_FLAG))
55 #define _RPMEVR_INTERNAL
58 #define _RPMTE_INTERNAL
61 #define _RPMTS_INTERNAL
91 GENfree(const struct stat *)
105 const rpmts ts = psm->ts;
108 sharedFileInfo replaced = (te ? te->replaced :
NULL);
121 for (sfi = replaced; sfi->otherPkg; sfi++) {
122 if (prev && prev == sfi->otherPkg)
124 prev = sfi->otherPkg;
130 offsets = (uint32_t *)
alloca(num *
sizeof(*offsets));
133 for (sfi = replaced; sfi->otherPkg; sfi++) {
134 if (prev && prev == sfi->otherPkg)
136 prev = sfi->otherPkg;
137 offsets[num++] = sfi->otherPkg;
158 while (sfi->otherPkg && sfi->otherPkg == prev) {
159 assert(sfi->otherFileNum < he->
c);
187 t[strlen(t)-1] =
'\0';
193 else if (fi &&
Chown(N, fi->uid, fi->gid))
207 const char ** specFilePtr,
const char **
cookie)
252 p->fd =
fdLink(fd, __FUNCTION__);
263 fi->fmapflags =
_free(fi->fmapflags);
268 #if defined(RPM_VENDOR_OPENPKG)
281 if ((muid = (uid_t)strtol(muid_str, (
char **)
NULL, 10)) > 0)
284 if ((mgid = (gid_t)strtol(mgid_str, (
char **)
NULL, 10)) > 0)
288 for (i = 0; i < (
int)fi->fc; i++)
297 fi->apath = he->
p.
argv;
301 #if defined(RPM_VENDOR_OPENPKG)
335 if (*specFilePtr ==
NULL) {
350 if (specFilePtr) *specFilePtr =
_free(*specFilePtr);
351 if (cookie) *cookie =
_free(*cookie);
377 "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin";
406 return "%unknownscript";
448 const rpmts ts = psm->ts;
452 msecs = psm->sq.op.usecs/1000;
456 D_(
"%s: waitpid(%d) rc %d status %x secs %u.%03u\n"),
457 psm->stepName, (
unsigned)psm->sq.child,
458 (
unsigned)psm->sq.reaped, psm->sq.status,
459 (
unsigned)msecs/1000, (
unsigned)msecs%1000);
461 if (psm->sstates !=
NULL)
464 *ssp |= (psm->sq.status & 0xffff);
468 return psm->sq.reaped;
484 const char *script,
int arg1,
int arg2)
500 for (i = 0; i < (
int)Phe->
c && Phe->
p.
argv[i]; i++) {
520 xx =
snprintf(buf, BUFSIZ,
"%s(%s)", sln, psm->NVRA);
536 #if defined(_WITH_EMBEDDED)
537 static int enterChroot(
rpmpsm psm,
int * pwdFdnop,
int * rootFdnop)
541 const rpmts ts = psm->ts;
547 (*pwdFdnop) = open(
".", O_RDONLY, 0);
551 (*rootFdnop) = open(
"/", O_RDONLY, 0);
558 if (rootDir !=
NULL &&
strcmp(rootDir,
"/") && *rootDir ==
'/') {
572 static int exitChroot(
rpmpsm psm,
int inChroot,
int pwdFdno,
int rootFdno)
576 const rpmts ts = psm->ts;
581 xx = fchdir(rootFdno);
583 if (rootDir !=
NULL &&
strcmp(rootDir,
"/") && *rootDir ==
'/') {
588 xx = fchdir(pwdFdno);
590 xx = fchdir(pwdFdno);
592 xx = close(rootFdno);
610 const char *script,
int arg1,
int arg2)
620 int inChroot = enterChroot(psm, &pwdFdno, &rootFdno);
622 if (psm->sstates !=
NULL)
623 ssp = psm->sstates +
tag2slx(psm->scriptTag);
627 av[0] = (
char *) Phe->
p.
argv[0];
630 av[1] = (
char *)
alloca(32);
634 av[2] = (
char *)
alloca(32);
638 #if defined(WITH_LUA)
640 rc = runLuaScript(psm, sln, Phe, script, arg1, arg2);
643 #if defined(WITH_AUGEAS)
649 aug = rpmaugFree(aug);
652 #if defined(WITH_FICL)
654 rpmficl ficl = rpmficlNew((
char **)av, 0);
657 ficl = rpmficlFree(ficl);
660 #if defined(WITH_GPSEE)
668 #if defined(WITH_PERLEMBED)
676 #if defined(WITH_PYTHONEMBED)
684 #if defined(WITH_RUBY)
692 #if defined(WITH_SEMANAGE)
705 #if defined(WITH_SQLITE)
708 const char ** Pav = (
const char **)
xmalloc((Pac + 1) *
sizeof(*Pav));
715 for (i = 0; i < Pac; i++)
726 #if defined(WITH_SQUIRREL)
734 #if defined(WITH_TCL)
746 *ssp |= (xx & 0xffff);
750 xx = exitChroot(psm, inChroot, pwdFdno, rootFdno);
781 const char * script,
int arg1,
int arg2)
787 const rpmts ts = psm->ts;
788 const char * NVRA = psm->NVRA;
789 HE_t IPhe = psm->IPhe;
794 size_t maxPrefixLength;
796 char * prefixBuf =
NULL;
801 const char * body =
NULL;
810 ssp = psm->sstates +
ix;
826 psm->NVRA = NVRA = he->
p.
str;
844 #if defined(_WITH_EMBEDDED)
846 D_(
"%s: %s(%s) running %s scriptlet.\n"),
847 psm->stepName,
tag2sln(psm->scriptTag), NVRA, Phe->
p.
argv[0]);
848 rc = runEmbeddedScript(psm, sln, Phe, body, arg1, arg2);
859 if (ldconfig_done && !
strcmp(Phe->
p.
argv[0], ldconfig_path)) {
861 D_(
"%s: %s(%s) skipping redundant \"%s\".\n"),
862 psm->stepName,
tag2sln(psm->scriptTag), NVRA,
870 D_(
"%s: %s(%s) %ssynchronous scriptlet start\n"),
871 psm->stepName,
tag2sln(psm->scriptTag), NVRA,
872 (
F_ISSET(psm, UNORDERED) ?
"a" :
""));
875 argv = (
const char **)
alloca(5 *
sizeof(*argv));
880 argv = (
const char **)
alloca((Phe->
c + 4) *
sizeof(*argv));
881 memcpy(argv, Phe->
p.
argv, Phe->
c *
sizeof(*argv));
883 ldconfig_done = (ldconfig_path && !
strcmp(argv[0], ldconfig_path)
888 if (IPhe->
tag == 0) {
896 const char ** av = (
const char **)
898 char *
t = (
char *) &av[1];
918 for (i = 0; i < nIP; i++) {
920 if (len > maxPrefixLength) maxPrefixLength =
len;
922 prefixBuf = (
char *)
alloca(maxPrefixLength + 50);
933 (!
strcmp(argv[0],
"/bin/sh") || !
strcmp(argv[0],
"/bin/bash")))
935 static const char set_x[] =
"set -x\n";
936 nw =
Fwrite(set_x,
sizeof(set_x[0]),
sizeof(set_x)-1, fd);
939 if (ldconfig_path && strstr(body, ldconfig_path) !=
NULL)
942 nw =
Fwrite(body,
sizeof(body[0]), strlen(body), fd);
945 {
const char * sn =
fn;
947 !(rootDir[0] ==
'/' && rootDir[1] ==
'\0'))
949 sn += strlen(rootDir)-1;
955 char *av = (
char *)
alloca(20);
960 char *av = (
char *)
alloca(20);
969 switch (psm->scriptTag) {
987 if (scriptFd !=
NULL) {
991 out =
Fopen(
"/dev/null",
"w.fdio");
997 out =
fdDup(STDOUT_FILENO);
1003 if (psm->sq.child == 0) {
1008 pipes[0] = pipes[1] = 0;
1011 xx = close(pipes[1]);
1012 xx = dup2(pipes[0], STDIN_FILENO);
1013 xx = close(pipes[0]);
1016 for (fdno = 3; fdno < 100; fdno++) {
1017 flag = fcntl(fdno, F_GETFD);
1018 if (flag == -1 || (flag & FD_CLOEXEC))
1021 D_(
"%s: %s(%s)\tfdno(%d) missing FD_CLOEXEC\n"),
1022 psm->stepName, sln, NVRA,
1024 xx = fcntl(fdno, F_SETFD, FD_CLOEXEC);
1028 if (scriptFd !=
NULL) {
1029 int sfdno =
Fileno(scriptFd);
1031 if (sfdno != STDERR_FILENO)
1032 xx = dup2(sfdno, STDERR_FILENO);
1033 if (ofdno != STDOUT_FILENO)
1034 xx = dup2(ofdno, STDOUT_FILENO);
1036 if (ofdno > STDERR_FILENO && ofdno != sfdno)
1038 if (sfdno > STDERR_FILENO && ofdno != sfdno)
1042 {
const char *ipath =
rpmExpand(
"PATH=%{_install_script_path}",
NULL);
1045 if (ipath && ipath[5] !=
'%')
1050 ipath =
_free(ipath);
1055 for (i = 0; i < nIP; i++) {
1056 sprintf(prefixBuf,
"RPM_INSTALL_PREFIX%d=%s", i, IP[i]);
1061 sprintf(prefixBuf,
"RPM_INSTALL_PREFIX=%s", IP[i]);
1068 !(rootDir[0] ==
'/' && rootDir[1] ==
'\0'))
1076 psm->stepName, sln, NVRA,
1077 argv[0], (
unsigned)getpid());
1092 xx = execv(argv[0], (
char *
const *)argv);
1104 if (psm->sq.child == (pid_t)-1) {
1112 if (!(psm->sq.reaped >= 0 && !
strcmp(argv[0],
"/usr/sbin/glibc_post_upgrade") && WEXITSTATUS(psm->sq.status) == 110)) {
1114 if (psm->sq.reaped < 0) {
1116 _(
"%s(%s) scriptlet failed, waitpid(%d) rc %d: %s\n"),
1117 sln, NVRA, (
int)psm->sq.child, (
int)psm->sq.reaped,
1121 if (!WIFEXITED(psm->sq.status) || WEXITSTATUS(psm->sq.status)) {
1122 if (WIFSIGNALED(psm->sq.status)) {
1124 psm->scriptTag, WTERMSIG(psm->sq.status));
1126 _(
"%s(%s) scriptlet failed, signal %d\n"),
1127 sln, NVRA, WTERMSIG(psm->sq.status));
1130 psm->scriptTag, WEXITSTATUS(psm->sq.status));
1132 _(
"%s(%s) scriptlet failed, exit status %d\n"),
1133 sln, NVRA, WEXITSTATUS(psm->sq.status));
1143 static unsigned int scale = 1000;
1146 psm->smetrics[
ix] += op->
usecs / scale;
1175 const char * argv0 =
NULL;
1179 She->
tag = psm->scriptTag;
1182 Phe->
tag = psm->progTag;
1188 const char *
s = Phe->
p.
str;
1190 Phe->
p.
argv = (
const char **)
1192 Phe->
p.
argv[0] = t = (
char *) &Phe->
p.
argv[1];
1199 if (Phe->
p.
argv[0][0] ==
'%')
1203 She->
p.
str, psm->scriptArg, -1);
1206 argv0 =
_free(argv0);
1229 static int scareMem = 0;
1235 const rpmts ts = psm->ts;
1240 const char * sourceName;
1241 const char * triggerName;
1249 sourceName = he->
p.
str;
1253 triggerName = he->
p.
str;
1261 arg1 += psm->countCorrection;
1287 if (!(Flags & psm->sense))
1291 depName = (
char *)
rpmdsN(Tds);
1292 if (depName[0] ==
'/') {
1293 size_t nb = strlen(depName);
1296 if (depName[nb-1] ==
'/') {
1325 if (!bingo && depName[nb-1] ==
'/') {
1352 {
int index = Ihe->
p.
ui32p[
i];
1353 const char *
s = Phe->
p.
argv[index];
1359 he->
p.
argv = (
const char **)
1365 if (
runScript(psm, triggeredH,
"%trigger", he,
1366 She->
p.
argv[index], arg1, arg2))
1387 triggerName =
_free(triggerName);
1388 sourceName =
_free(sourceName);
1398 const rpmts ts = psm->ts;
1406 for (i = 0; i < nkeys; i++) {
1407 char *
t = (
char *) keys[i];
1411 (
miRE *)&psm->Tmires, &psm->nTmires);
1431 static int scareMem = 0;
1432 const rpmts ts = psm->ts;
1435 char * depName =
NULL;
1446 const char * Name =
rpmdsN(ds);
1447 size_t nName = strlen(Name);
1448 unsigned prev, instance;
1452 depName =
_free(depName);
1456 depName =
xmalloc(nName + 1 + 1);
1460 depName[nName+1] =
'\0';
1463 if (depName[0] ==
'/' && psm->Tmires !=
NULL) {
1468 for (j = 0, mire = (
miRE)psm->Tmires; j < psm->nTmires; j++, mire++) {
1469 const char *
pattern = psm->Tpats[
j];
1470 if (depName[nName-1] !=
'/') {
1471 size_t npattern = strlen(pattern);
1472 depName[nName] = (pattern[npattern-1] ==
'/') ?
'/' :
'\0';
1478 depName =
_free(depName);
1490 xx =
rpmmiPrune(mi, (uint32_t *)vals, nvals, 1);
1495 if (prev == instance)
1500 xx =
argiAdd(&instances, -1, instance);
1508 depName =
_free(depName);
1526 const rpmts ts = psm->ts;
1533 if (_trigger_tag == 0) {
1543 {
const char *
N =
rpmteN(psm->te);
1546 numPackage += psm->countCorrection;
1554 {
int countCorrection = psm->countCorrection;
1556 psm->countCorrection = 0;
1578 psm->countCorrection = countCorrection;
1596 const rpmts ts = psm->ts;
1612 if (_trigger_tag == 0) {
1622 triggers =
rpmdsLink(psm->triggers,
"ImmedTriggers");
1624 if (triggers ==
NULL)
1633 if (triggers !=
NULL)
1634 while ((i =
rpmdsNext(triggers)) >= 0) {
1636 const char *
N =
rpmdsN(triggers);
1640 if (!(Flags & psm->sense))
1647 tagno = (N[strlen(N)-1] ==
'/')
1661 for (i = 0; (Name = keys[
i]) !=
NULL; i++) {
1662 unsigned prev, instance;
1670 tagno = (Name[strlen(Name)-1] ==
'/')
1680 xx =
rpmmiPrune(mi, (uint32_t *)vals, nvals, 1);
1687 if (prev == instance)
1695 xx =
argiAdd(&instances, -1, instance);
1745 default:
return "???";
1754 psm->unorderedSuccessor = async;
1757 F_SET(psm, UNORDERED);
1759 F_CLR(psm, UNORDERED);
1766 psm->scriptTag = scriptTag;
1767 psm->progTag = progTag;
1769 switch (scriptTag) {
1797 psm->IPhe->p.ptr =
_free(psm->IPhe->p.ptr);
1798 psm->IPhe =
_free(psm->IPhe);
1799 psm->NVRA =
_free(psm->NVRA);
1801 psm->triggers =
NULL;
1815 if (_psmPool ==
NULL) {
1821 memset(((
char *)psm)+
sizeof(psm->_item), 0,
sizeof(*psm)-
sizeof(psm->_item));
1827 static const char msg[] =
"rpmpsmNew";
1833 if (te) psm->te = rpmteLink(te, msg);
1836 if (te) psm->te =
te;
1842 psm->triggers =
NULL;
1844 psm->IPhe = (
HE_t)
xcalloc(1,
sizeof(*psm->IPhe));
1845 memset(psm->sstates, 0,
sizeof(psm->sstates));
1846 memset(psm->smetrics, 0,
sizeof(psm->smetrics));
1916 he->
p.
argv = &chain_end;
1928 he->
p.
argv = &chain_end;
1940 he->
p.
argv = &chain_end;
1975 he->
p.
argv = &chain_end;
1990 he->
p.
argv = &chain_end;
2005 he->
p.
argv = &chain_end;
2036 {
struct timeval tv;
2037 xx = gettimeofday(&tv,
NULL);
2043 he->
p.
ui32p = &installTime[0];
2049 memcpy(originTime, uip,
sizeof(originTime));
2050 if (originTime[0] == 0)
2051 memcpy(originTime, installTime,
sizeof(originTime));
2054 he->
p.
ui32p = originTime;
2059 memcpy(originTid, uip,
sizeof(originTid));
2060 if (originTid[0] == 0)
2061 memcpy(originTid, ts->tid,
sizeof(originTid));
2095 if (digest !=
NULL) {
2108 if (st->st_mode == 0 && st->st_mtime == 0 && st->st_size == 0)
2111 if (st->st_mode != 0) {
2114 he->
p.
ptr = (
void *)st;
2147 he->
p.
ui32p = psm->sstates;
2152 he->
p.
ui32p = psm->smetrics;
2157 if (fi->fstates !=
NULL && fc > 0) {
2160 he->
p.
ui8p = fi->fstates;
2168 #if defined(WITH_PTHREADS)
2169 static void * rpmpsmThread(
void * _psm)
2184 psm->nstage = nstage;
2185 #if defined(WITH_PTHREADS)
2200 const rpmts ts = psm->ts;
2226 if (psm->npkgs_installed < 0) {
2236 if (psm->te->downgrade)
2237 psm->npkgs_installed--;
2247 psm->scriptArg = psm->npkgs_installed + 1;
2251 if (hdrid !=
NULL) {
2262 #ifdef RPM_VENDOR_MANDRIVA
2284 if (fi->fstates ==
NULL && fc > 0) {
2289 xx = rpmtxnBegin(
rpmtsGetRdb(ts), ts->txn, &psm->te->txn);
2301 fi->striplen = (xx && he->
p.
str ? strlen(he->
p.
str) + 1 : 1);
2312 fi->apath = he->
p.
argv;
2314 if (fi->fuser ==
NULL) {
2317 fi->fuser = he->
p.
argv;
2319 if (fi->fgroup ==
NULL) {
2322 fi->fgroup = he->
p.
argv;
2327 psm->scriptArg = psm->npkgs_installed - 1;
2331 xx = rpmtxnBegin(
rpmtsGetRdb(ts), ts->txn, &psm->te->txn);
2351 psm->pkgURL =
rpmGenPath(
"%{?_repackage_root}",
2352 "%{?_repackage_dir}",
2354 pkgbn =
_free(pkgbn);
2356 pkgdn_buf =
xstrdup(psm->pkgfn);
2358 pkgdn = dirname(pkgdn_buf);
2361 pkgdn_buf =
_free(pkgdn_buf);
2364 psm->fd =
Fopen(psm->pkgfn,
"w.fdio");
2373 if (
rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)
break;
2377 {
static int oneshot = 0;
2392 psm->sense = RPMSENSE_TRIGGERPREIN;
2393 psm->countCorrection = 0;
2410 _(
"%s: %s scriptlet failed (%d), skipping %s\n"),
2411 psm->stepName,
tag2sln(psm->scriptTag), rc,
2421 psm->sense = RPMSENSE_TRIGGERUN;
2422 psm->countCorrection = -1;
2438 int noArchiveSize = 0;
2439 const char * origin =
NULL;
2441 const struct stat *
st =
NULL;
2442 size_t nstbytes = 0;
2457 if (xx && he->
p.
ptr !=
NULL && (
size_t)he->
c ==
sizeof(*st)) {
2458 st = (
struct stat *) he->
p.
ptr;
2466 if (xx && uh !=
NULL) {
2473 if (xx && uh !=
NULL) {
2507 {
static const char item[] =
"Lead";
2529 {
static const char item[] =
"Signature";
2547 if (psm->oh !=
NULL)
2557 if (origin !=
NULL) {
2563 origin =
_free(origin);
2565 if (digest !=
NULL) {
2571 digest =
_free(digest);
2576 he->
p.
ptr = (
void *)st;
2593 {
const char item[] =
"Header";
2598 (msg && *msg ? msg :
"write failed\n"));
2605 if (
rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)
break;
2630 if (psm->cfd ==
NULL) {
2638 ts, fi, psm->cfd,
NULL, &psm->failedFile);
2658 rpmtxn _txn = (db ? db->db_txn :
NULL);
2661 xx = rpmtxnAbort(_txn);
2663 xx = rpmtxnCommit(_txn);
2670 psm->amount = (fi->archiveSize ? fi->archiveSize : 100);
2671 psm->total = psm->amount;
2677 _(
"unpacking of archive failed%s%s: %s\n"),
2678 (psm->failedFile !=
NULL ?
_(
" on file ") :
""),
2679 (psm->failedFile !=
NULL ? psm->failedFile :
""),
2701 psm->total = (fc ? fc : 100);
2706 ts, fi,
NULL,
NULL, &psm->failedFile);
2711 psm->amount = (fc ? fc : 100);
2712 psm->total = (fc ? fc : 100);
2723 if (psm->fd ==
NULL) {
2731 if (psm->cfd ==
NULL) {
2737 ts, fi, psm->cfd,
NULL, &psm->failedFile);
2753 psm->amount = (fi->archiveSize ? fi->archiveSize : 100);
2754 psm->total = psm->amount;
2757 fi->action = (
int) action;
2758 fi->actions = (
int *) actions;
2768 psm->sense = RPMSENSE_TRIGGERIN;
2769 psm->countCorrection = 1;
2802 rc = markReplacedFiles(psm);
2810 psm->sense = RPMSENSE_TRIGGERPOSTUN;
2811 psm->countCorrection = -1;
2843 if (psm->fd !=
NULL) {
2853 if (!rc && ts && ts->notify ==
NULL) {
2855 (psm->pkgURL ? psm->pkgURL :
"???"));
2861 if (psm->failedFile)
2863 _(
"%s failed on file %s: %s\n"),
2864 psm->stepName, psm->failedFile, msg);
2867 psm->stepName, msg);
2877 if (psm->te->txn !=
NULL) {
2878 xx = rpmtxnAbort(psm->te->txn);
2879 psm->te->txn =
NULL;
2882 if (psm->te->txn !=
NULL) {
2883 xx = rpmtxnCommit(psm->te->txn);
2884 psm->te->txn =
NULL;
2889 if (psm->te !=
NULL)
2891 if (fi->h !=
NULL) {
2898 psm->pkgURL =
_free(psm->pkgURL);
2899 psm->rpmio_flags =
_free(psm->rpmio_flags);
2900 psm->payload_format =
_free(psm->payload_format);
2901 psm->failedFile =
_free(psm->failedFile);
2903 fi->fgroup =
_free(fi->fgroup);
2904 fi->fuser =
_free(fi->fuser);
2905 fi->apath =
_free(fi->apath);
2906 fi->fstates =
_free(fi->fstates);
2930 ptr =
rpmtsNotify(ts, psm->te, psm->what, psm->amount, psm->total);
2940 ts, fi,
NULL,
NULL, &psm->failedFile);
2947 if (rootDir !=
NULL && !(rootDir[0] ==
'/' && rootDir[1] ==
'\0')
2950 static int _pw_loaded = 0;
2951 static int _gr_loaded = 0;
2954 (
void)getpwnam(
"root");
2959 (
void)getgrnam(
"root");
2966 if (rootDir !=
NULL &&
strcmp(rootDir,
"/") && *rootDir ==
'/')
2969 F_SET(psm, CHROOTDONE);
2975 if (
F_ISSET(psm, CHROOTDONE)) {
2979 if (rootDir !=
NULL &&
strcmp(rootDir,
"/") && *rootDir ==
'/')
2982 F_CLR(psm, CHROOTDONE);
2984 if (currDir !=
NULL)
2985 xx =
Chdir(currDir);
2990 { rpmtxn _parent = (psm && psm->te ? psm->te->txn :
NULL);
3001 if (
rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)
break;
3006 if (
rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)
break;
3007 if (!
F_ISSET(psm, GOTTRIGGERS)) {
3009 F_SET(psm, GOTTRIGGERS);
3011 if (psm->triggers !=
NULL)
3016 {
const char * payload_compressor =
NULL;
3017 const char * payload_format =
NULL;
3022 payload_compressor = he->
p.
str;
3023 if (payload_compressor ==
NULL)
3024 payload_compressor =
xstrdup(
"gzip");
3026 psm->rpmio_flags = t = (
char *)
xmalloc(
sizeof(
"w9.gzdio"));
3029 if (!
strcmp(payload_compressor,
"gzip"))
3031 if (!
strcmp(payload_compressor,
"bzip2"))
3033 if (!
strcmp(payload_compressor,
"lzma"))
3035 if (!
strcmp(payload_compressor,
"xz"))
3037 payload_compressor =
_free(payload_compressor);
3041 payload_format = he->
p.
str;
3042 if (!xx || payload_format ==
NULL || !(
3043 !
strcmp(payload_format,
"tar") || !
strcmp(payload_format,
"ustar")
3044 #
if defined(SUPPORT_AR_PAYLOADS)
3045 || !
strcmp(payload_format,
"ar")
3049 payload_format =
_free(payload_format);
3050 payload_format =
xstrdup(
"cpio");
3052 psm->payload_format =
_free(psm->payload_format);
3053 psm->payload_format = payload_format;
3060 &fi->record,
sizeof(fi->record));
3068 if (fi->h !=
NULL) {
3077 if (fi->isSource)
break;
3078 if (fi->h ==
NULL)
break;
3092 #if defined(HAVE_SYSLOG_H) && defined(RPM_VENDOR_MANDRIVA)
3098 syslog(LOG_NOTICE,
"[RPM] %s installed\n", s);
3116 psm->te->installed = 1;
3124 if (
rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)
break;
3132 #if defined(HAVE_SYSLOG_H) && defined(RPM_VENDOR_MANDRIVA)
3138 syslog(LOG_NOTICE,
"[RPM] %s removed\n", s);
3153 if (psm->te !=
NULL)
3154 psm->te->u.removed.dboffset = 0;
const char * rpmteV(rpmte te)
Retrieve version string of transaction element.
int rpmdsNext(rpmds ds)
Return next dependency set iterator index.
rpmuint32_t rpmfiFFlags(rpmfi fi)
Return current file flags from file info set.
static void rpmpsmFini(void *_psm)
int rpmtsChrootDone(rpmts ts)
Get chrootDone flag, i.e.
char * iosmStrerror(int rc)
Return formatted error message on payload handling failure.
rpmop rpmtsOp(rpmts ts, rpmtsOpX opx)
Retrieve operation timestamp from a transaction set.
rpmuint32_t * rpmteOriginTime(rpmte te)
Retrieve time that package was first installed.
static rpmRC createDir(rpmts ts, rpmfi fi, const char **fn, const char *name)
headerTagTableEntry rpmTagTable
Automatically generated table of tag name/value pairs.
unsigned long int rpmtime_t
pid_t rpmsqWait(rpmsq sq)
Wait for child process to be reaped.
miRE mireNew(rpmMireMode mode, int tag)
Create pattern container.
pid_t rpmsqFork(rpmsq sq)
Fork a child process.
struct rpmdb_s * rpmdb
Database of headers and tag value indices.
rpmlog(RPMLOG_ERR,"%s\n", buf)
rpmuint32_t rpmteColor(rpmte te)
Retrieve color bits of transaction element.
int rpmdsNegateRC(const rpmds ds, int rc)
Negate return code for negated comparisons.
struct rpmte_s * rpmte
An element of a transaction set, i.e.
rpmtime_t rpmswAdd(rpmop to, rpmop from)
Sum statistic counters.
ARGI_t argiFree(ARGI_t argi)
Destroy an argi array.
void * mireFreeAll(miRE mire, int nmire)
Destroy compiled patterns.
struct rpmpsm_s * rpmpsm
Package state machine data.
void rpmluavSetValueNum(rpmluav var, double value)
rpmRC rpmpkgWrite(const char *fn, FD_t fd, void *ptr, const char **msg)
Write item onto file descriptor.
enum iosmFileAction_e iosmFileAction
File disposition(s) during package install/erase processing.
rpmsquirrel rpmsquirrelFree(rpmsquirrel squirrel)
Destroy a squirrel interpreter.
int Chroot(const char *path)
chroot(2) clone.
Structures used for an "rpmte" transaction element.
size_t Fwrite(const void *buf, size_t size, size_t nmemb, FD_t fd)
fwrite(3) clone.
static const char * tag2sln(rpmTag tag)
Return scriptlet name from tag.
char * xstrdup(const char *str)
void * rpmluavFree(rpmluav var)
FD_t Fopen(const char *path, const char *_fmode)
fopen(3) clone.
rpmjs rpmjsFree(rpmjs js)
Destroy a js interpreter.
char * rpmGetPath(const char *path,...)
Return (malloc'ed) expanded, canonicalized, file path.
uint32_t rpmmiInstance(rpmmi mi)
Return header instance for current position of rpmdb iterator.
Structure(s) used for file info tag sets.
rpmfi rpmteFI(rpmte te, rpmTag tag)
Retrieve file info tag set from transaction element.
static char *size_t nb
fgets(3) analogue that reads \ continuations.
void rpmluavSetListMode(rpmluav var, int flag)
int Access(const char *path, int amode)
access(2) clone.
rpmuint32_t * rpmteOriginTid(rpmte te)
Retrieve transaction start time that package was first installed.
struct rpmts_s * rpmts
The RPM Transaction Set.
evrFlags rpmdsFlags(const rpmds ds)
Return current dependency flags.
rpmdb rpmtsGetRdb(rpmts ts)
Get transaction set database handle.
static int populateInstallHeader(const rpmts ts, const rpmte te, rpmfi fi)
Add per-transaction data to an install header.
enum rpmScriptID_e rpmScriptID
Scriptlet identifiers.
rpmts rpmtsFree(rpmts ts)
Destroy transaction set, closing the database as well.
int mireRegcomp(miRE mire, const char *pattern)
Compile pattern match.
static int hCopyTag(Header sh, Header th, rpmTag tag)
Copy a tag from a source to a target header.
static rpmTag _trigger_tag
int mireClean(miRE mire)
Deallocate pattern match memory.
void * rpmsqThread(void *(*start)(void *arg), void *arg)
Call a function in a thread.
int Stat(const char *path, struct stat *st)
stat(2) clone.
FD_t fdLink(void *cookie, const char *msg)
int Fflush(FD_t fd)
fflush(3) clone.
#define F_SET(_psm, _FLAG)
rpmTSType rpmtsType(rpmts ts)
Return the type of a transaction.
rpmfi rpmfiFree(rpmfi fi)
Destroy a file info set.
const char * rpmfiFN(rpmfi fi)
Return current file name from file info set.
FD_t rpmteFd(rpmte te)
Retrieve file handle from transaction element.
const char * rpmteN(rpmte te)
Retrieve name string of transaction element.
int rpmdbAdd(rpmdb db, int iid, Header h, rpmts ts)
Add package header to rpm database and indices.
int rpmmiSetModified(rpmmi mi, int modified)
Modify iterator to mark header for lazy write on release.
rpmds rpmdsNew(Header h, rpmTag tagN, int flags)
Create and load a dependency set.
int doputenv(const char *str)
Like the libc function, but malloc()'s the space needed.
rpmuint32_t rpmtsGetTid(rpmts ts)
Get transaction id, i.e.
int argiCount(ARGI_t argi)
Return no.
void rpmluaPushTable(rpmlua _lua, const char *key,...)
void rpmluavSetValue(rpmluav var, rpmluavType type, const void *value)
static rpmuint32_t hLoadTID(Header h, rpmTag tag)
Load a transaction id from a header.
int rpmfiFC(rpmfi fi)
Return file count from file info set.
int rpmdbRemove(rpmdb db, int rid, uint32_t hdrNum, rpmts ts)
Remove package header from rpm database and indices.
unsigned char rpmuint8_t
Private int typedefs to avoid C99 portability issues.
const char * rpmteA(rpmte te)
Retrieve arch string of transaction element.
sprintf(t," (%u)",(unsigned) dig->nbytes)
static int postPopulateInstallHeader(const rpmts ts, const rpmpsm psm, rpmfi fi)
Add fi->states to an install header.
rpmsql rpmsqlNew(char **av, uint32_t flags)
Create and load a sql interpreter.
rpmpython rpmpythonFree(rpmpython python)
Destroy a python interpreter.
enum evrFlags_e evrFlags
Dependency Attributes.
int rpmdbCountPackages(rpmdb db, const char *N)
Return number of instances of package in Name index.
int Chown(const char *path, uid_t owner, gid_t group)
chown(2) clone.
enum rpmRC_e rpmRC
RPM return codes.
int rpmmiGrow(rpmmi mi, const uint32_t *hdrNums, int nHdrNums)
Append items to set of package instances to iterate.
memset(_r, 0, sizeof(*_r))
rpmts rpmtsLink(rpmts ts, const char *msg)
Reference a transaction set instance.
miRE mireFree(miRE mire)
Free pattern container.
const char * Fstrerror(FD_t fd)
strerror(3) clone.
void * xcalloc(size_t nmemb, size_t size)
assert(key->size==sizeof(hdrNum))
rpmmi rpmmiFree(rpmmi mi)
Destroy rpm database iterator.
rpmruby rpmrubyNew(char **av, uint32_t flags)
Creates and initializes a Ruby interpreter.
rpmioItem rpmioGetPool(rpmioPool pool, size_t size)
Get unused item from pool, or alloc a new item.
rpmRC rpmpythonRun(rpmpython python, const char *str, const char **resultp)
Execute python string.
unsigned int rpmmiCount(rpmmi mi)
Return number of elements in rpm database iterator.
size_t rpmpkgSizeof(const char *fn, const void *ptr)
Return size of item in bytes.
static int hSaveFlinks(Header h, const struct rpmChainLink_s *flink)
Save forward link(s) of an upgrade chain into a header.
int rpmTempFile(const char *prefix, const char **fnptr, void *fdptr)
Return file handle for a temporaray file.
int argvCount(const ARGV_t argv)
Return no.
ARGV_t argvData(ARGV_t argv)
Return data from argv array.
rpmRC rpmInstallSourcePackage(rpmts ts, void *_fd, const char **specFilePtr, const char **cookie)
Install source package.
int rpmdsMatch(const rpmds A, rpmds B)
Compare A against every member of B, looking for 1st match.
int rpmsqJoin(void *thread)
Wait for thread to terminate.
struct rpmperl_s * rpmperl
ARGV_t argvFree(ARGV_t argv)
Destroy an argv array.
struct rpmluav_s * rpmluav
rpmperl rpmperlNew(char **av, uint32_t flags)
Create and load a perl interpreter.
rpmjs rpmjsNew(char **av, uint32_t flags)
Create and load a js interpreter.
struct rpmpython_s * rpmpython
static int rpmdbTriggerGlobs(rpmpsm psm)
rpmRC rpmReadPackageFile(rpmts ts, FD_t fd, const char *fn, Header *hdrp)
Return package header from file handle, verifying digests/signatures.
int Glob_pattern_p(const char *pattern, int quote)
glob_pattern_p(3) clone.
int headerMacrosLoad(Header h)
Define per-header macros.
Header rpmmiNext(rpmmi mi)
Return next package header from iteration.
rpmuint32_t rpmtsColor(rpmts ts)
Retrieve color bits of transaction set.
Structure(s) used for dependency tag sets.
int rpmmiAddPattern(rpmmi mi, rpmTag tag, rpmMireMode mode, const char *pattern)
Add pattern to iterator selector.
void * rpmtsNotify(rpmts ts, rpmte te, rpmCallbackType what, rpmuint64_t amount, rpmuint64_t total)
Perform transaction progress notify callback.
int rpmtsAddInstallElement(rpmts ts, Header h, fnpyKey key, int upgrade, rpmRelocation relocs)
Add package to be installed to transaction set.
rpmpython rpmpythonNew(char **av, uint32_t flags)
Create and load a python interpreter.
The FD_t File Handle data structure.
const char * rpmGenPath(const char *urlroot, const char *urlmdir, const char *urlfile)
Merge 3 args into path, any or all of which may be a url.
rpmpsm rpmpsmNew(rpmts ts, rpmte te, rpmfi fi)
Create and load a package state machine.
int argiSort(ARGI_t argi, int(*compar)(ARGint_t *, ARGint_t *))
Sort an argi array.
int argvAdd(ARGV_t *argvp, ARGstr_t val)
Add a string to an argv array.
const char * rpmtsRootDir(rpmts ts)
Get transaction rootDir, i.e.
Generate and verify rpm package signatures.
int mireRegexec(miRE mire, const char *val, size_t vallen)
Execute pattern match.
static int hSaveBlinks(Header h, const struct rpmChainLink_s *blink)
Save backward link(s) of an upgrade chain into a header.
rpmRC rpmsquirrelRun(rpmsquirrel squirrel, const char *str, const char **resultp)
Execute squirrel string.
char * rpmExpand(const char *arg,...)
Return (malloc'ed) concatenated macro expansion(s).
int Chdir(const char *path)
chdir(2) clone.
static rpmpsm rpmpsmGetPool(rpmioPool pool)
static const char * pkgStageString(pkgStage a)
int rpmsxExec(rpmsx sx, int verified, const char **argv)
Execute a package scriptlet within SELinux context.
rpmRC rpmMkdirPath(const char *dpath, const char *dname)
Create directory if it does not exist, and make sure path is writable.
Embedded Ruby interpreter.
void rpmluaDelVar(rpmlua _lua, const char *key,...)
rpmte rpmtsElement(rpmts ts, int ix)
Return (ordered) transaction set element.
rpmRC rpmpsmStage(rpmpsm psm, pkgStage stage)
Package state machine driver.
void unsetenv(const char *name)
#define F_ISSET(_psm, _FLAG)
int Fclose(FD_t fd)
fclose(3) clone.
static rpmRC runImmedTriggers(rpmpsm psm)
Run triggers from this header that are fired by headers in the database.
Cumulative statistics for an operation.
int fsmTeardown(void *_fsm)
Clean file state machine.
struct rpmds_s * rpmds
Dependency tag sets from a header, so that a header can be discarded early.
struct rpmruby_s * rpmruby
Header rpmteSetHeader(rpmte te, Header h)
Save header into transaction element.
int rpmfiNext(rpmfi fi)
Return next file iterator index.
static rpmRC runScript(rpmpsm psm, Header h, const char *sln, HE_t Phe, const char *script, int arg1, int arg2)
Run scriptlet with args.
rpmds rpmdsFree(rpmds ds)
Destroy a dependency set.
const char * rpmteD(rpmte te)
Retrieve distepoch string of transaction element.
static const char * SCRIPT_PATH
rpmruby rpmrubyFree(rpmruby ruby)
Destroys a Ruby interpreter instance.
struct rpmsquirrel_s * rpmsquirrel
int Ferror(FD_t fd)
ferror(3) clone.
rpmsql rpmsqlFree(rpmsql sql)
Destroy a sql interpreter.
rpmfi rpmfiInit(rpmfi fi, int fx)
Initialize file iterator index.
void rpmtsClean(rpmts ts)
Free memory needed only for dependency checks and ordering.
return strcmp(ame->name, bme->name)
void rpmteSetDBInstance(rpmte te, unsigned int instance)
Set last instance installed to the database.
Package state machine to handle a package from a transaction set.
static rpmRC runTriggers(rpmpsm psm)
Run trigger scripts in the database that are fired by this header.
static int rpmpsmNext(rpmpsm psm, pkgStage nstage)
int rpmtsSELinuxEnabled(rpmts ts)
Get selinuxEnabled flag, i.e.
urltype urlPath(const char *url, const char **pathp)
Return path component of URL.
const char * rpmteO(rpmte te)
Retrieve os string of transaction element.
static int snprintf(char *buf, int nb, const char *fmt,...)
rpmfi rpmfiLink(rpmfi fi, const char *msg)
Reference a file info set instance.
dbiIndex dbiOpen(rpmdb db, rpmTag tag, unsigned int flags)
Methods to handle package elements.
rpmioPool rpmioNewPool(const char *name, size_t size, int limit, int flags, char *(*dbg)(void *item), void(*init)(void *item), void(*fini)(void *item))
Create a memory pool.
const char * rpmteE(rpmte te)
Retrieve epoch string of transaction element.
char * stpcpy(char *dest, const char *src)
rpmds rpmdsInit(rpmds ds)
Initialize dependency set iterator.
void rpmluaSetVar(rpmlua _lua, rpmluav var)
rpmtransFlags rpmtsFlags(rpmts ts)
Get transaction flags, i.e.
rpmds rpmdsLink(rpmds ds, const char *msg)
Reference a dependency set instance.
Structures and prototypes used for an "rpmts" transaction set.
FD_t Fdopen(FD_t ofd, const char *fmode)
const char * rpmdsEVR(const rpmds ds)
Return current dependency epoch-version-release.
static rpmScriptID tag2slx(rpmTag tag)
Return scriptlet id from tag.
File state machine to handle a payload within an rpm package.
int rpmmiSetRewrite(rpmmi mi, int rewrite)
Prepare iterator for lazy writes.
rpmVSFlags rpmtsVSFlags(rpmts ts)
Get verify signatures flag(s).
int argiAdd(ARGI_t *argip, int ix, int val)
Add an int to an argi array.
rpmRC rpmsqlRun(rpmsql sql, const char *str, const char **resultp)
Execute sql from STRING | FILE | STDIN | INTERACTIVE.
int fsmSetup(void *_fsm, iosmFileStage goal, const char *afmt, const void *_ts, const void *_fi, FD_t cfd, unsigned int *archiveSize, const char **failedFile)
Load external data into file state machine.
static rpmRC handleOneTrigger(const rpmpsm psm, Header sourceH, Header triggeredH, int arg2)
Execute triggers.
rpmtcl rpmtclFree(rpmtcl tcl)
Destroy a tcl interpreter.
const char * rpmtsCurrDir(rpmts ts)
Get transaction currDir, i.e.
rpmpsm rpmpsmFree(rpmpsm psm, const char *msg)
Destroy a package state machine.
int Fileno(FD_t fd)
fileno(3) clone.
static void
Print copy of spec file, filling in Group/Description/Summary from specspo.
static rpmRC runInstScript(rpmpsm psm)
Retrieve and run scriptlet from header.
int rpmtsSetChrootDone(rpmts ts, int chrootDone)
Set chrootDone flag, i.e.
rpmRC rpmrubyRun(rpmruby ruby, const char *str, const char **resultp)
Evaluates Ruby code stored in a string.
char * buf
Parse (and execute) macro undefinition.
int mireAppend(rpmMireMode mode, int tag, const char *pattern, const unsigned char *table, miRE *mirep, int *nmirep)
Append pattern to array.
static const char * ldconfig_path
const char * rpmteNEVR(rpmte te)
Retrieve name-version-release string from transaction element.
static rpmop fdstat_op(FD_t fd, fdOpX opx)
int
Save source and expand field into target.
struct rpmfi_s * rpmfi
File info tag sets from a header, so that a header can be discarded early.
const char * rpmteR(rpmte te)
Retrieve release string of transaction element.
int rpmmiPrune(rpmmi mi, uint32_t *hdrNums, int nHdrNums, int sorted)
Remove items from set of package instances to iterate.
const char * rpmdsN(const rpmds ds)
Return current dependency name.
static rpmRC runTriggersLoop(rpmpsm psm, rpmTag tagno, int arg2)
Run a dependency set loop against rpmdb triggers.
rpmRC rpmjsRun(rpmjs js, const char *str, const char **resultp)
Execute js string.
Access RPM indices using Berkeley DB interface(s).
rpmte rpmteFree(rpmte te)
Destroy a transaction element.
rpmsquirrel rpmsquirrelNew(char **av, uint32_t flags)
rpmperl rpmperlFree(rpmperl perl)
Destroy a perl interpreter.
int rpmdbMireApply(rpmdb db, rpmTag tag, rpmMireMode mode, const char *pat, const char ***argvp)
Return array of keys matching a pattern.
rpmmi rpmtsInitIterator(const rpmts ts, rpmTag rpmtag, const void *keyp, size_t keylen)
Return transaction database iterator.
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
rpmtcl rpmtclNew(char **av, uint32_t flags)
Create and load a tcl interpreter.
rpmRC rpmpsmScriptStage(rpmpsm psm, rpmTag scriptTag, rpmTag progTag)
Run rpmpsmStage(PSM_SCRIPT) for scriptTag and progTag.
rpmRC rpmperlRun(rpmperl perl, const char *str, const char **resultp)
Execute perl string.
ARGint_t argiData(ARGI_t argi)
Return data from argi array.
In Memoriam: Steve Taylor staylor@redhat.com was here, now he's not.
rpmpsm rpmpsmLink(rpmpsm psm, const char *msg)
Reference a package state machine instance.
#define RPMDBI_PACKAGES
Pseudo-tags used by the rpmdb and rpmgi iterator API's.
FD_t rpmtsScriptFd(rpmts ts)
int rpmluaRunScript(rpmlua _lua, const char *script, const char *name)
static pid_t psmWait(rpmpsm psm)
Wait for child process to be reaped.
rpmRC rpmtclRun(rpmtcl tcl, const char *str, const char **resultp)
Execute tcl string.
int rpmdsSetNoPromote(rpmds ds, int nopromote)
Set "Don't promote Epoch:" flag.
const char * rpmteHdrid(rpmte te)
Retrieve hdrid string from transaction element.
static PyObject *rpmds ds
#define F_CLR(_psm, _FLAG)
struct _dbiIndex * dbiIndex
const unsigned char * digest
void rpmpsmSetAsync(rpmpsm psm, int async)
int Unlink(const char *path)
unlink(2) clone.