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 56 #define _RPMDS_INTERNAL 59 #define _RPMTE_INTERNAL 62 #define _RPMTS_INTERNAL 71 #define PATT_ISDIR(patt, len) ((patt[0] == '/' && patt[len-1] == '/') || \ 72 (patt[0] == '^' && patt[len-1] == '$' && patt[len-2] == '/')) 95 GENfree(const struct stat *)
109 const rpmts ts = psm->ts;
112 sharedFileInfo replaced = (te ? te->replaced : NULL);
121 if (!(
rpmfiFC(fi) > 0 && replaced != NULL))
125 for (sfi = replaced; sfi->otherPkg; sfi++) {
126 if (prev && prev == sfi->otherPkg)
128 prev = sfi->otherPkg;
134 offsets = (uint32_t *)
alloca(num *
sizeof(*offsets));
137 for (sfi = replaced; sfi->otherPkg; sfi++) {
138 if (prev && prev == sfi->otherPkg)
140 prev = sfi->otherPkg;
141 offsets[num++] = sfi->otherPkg;
162 while (sfi->otherPkg && sfi->otherPkg == prev) {
163 assert(sfi->otherFileNum < he->
c);
191 t[strlen(t)-1] =
'\0';
198 Chown(N, fi->uid, fi->gid);
211 const char ** specFilePtr,
const char ** cookie)
252 assert(p->h == NULL);
256 p->fd =
fdLink(fd, __FUNCTION__);
267 fi->fmapflags =
_free(fi->fmapflags);
272 #if defined(RPM_VENDOR_OPENPKG) 284 if ((muid_str =
rpmExpand(
"%{l_muid}", NULL)) != NULL)
285 if ((muid = (uid_t)strtol(muid_str, (
char **)NULL, 10)) > 0)
287 if ((mgid_str =
rpmExpand(
"%{l_mgid}", NULL)) != NULL)
288 if ((mgid = (gid_t)strtol(mgid_str, (
char **)NULL, 10)) > 0)
292 for (i = 0; i < (int)fi->fc; i++)
301 fi->apath = he->
p.
argv;
305 #if defined(RPM_VENDOR_OPENPKG) 306 if (
createDir(ts, fi, NULL,
"%{_topdir}")
307 ||
createDir(ts, fi, NULL,
"%{_builddir}")
309 ||
createDir(ts, fi, NULL,
"%{_srcrpmdir}")
310 ||
createDir(ts, fi, NULL,
"%{_sourcedir}")
311 ||
createDir(ts, fi, NULL,
"%{_specdir}"))
313 if (
createDir(ts, NULL, NULL,
"%{_topdir}")
314 ||
createDir(ts, NULL, NULL,
"%{_builddir}")
315 ||
createDir(ts, NULL, NULL,
"%{_rpmdir}")
316 ||
createDir(ts, NULL, NULL,
"%{_srcrpmdir}")
317 ||
createDir(ts, NULL, NULL,
"%{_sourcedir}")
318 ||
createDir(ts, NULL, NULL,
"%{_specdir}"))
339 if (*specFilePtr == NULL) {
354 if (specFilePtr) *specFilePtr =
_free(*specFilePtr);
355 if (cookie) *cookie =
_free(*cookie);
381 "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin";
414 return "%unknownscript";
460 const rpmts ts = psm->ts;
464 msecs = psm->sq.op.usecs/1000;
468 D_(
"%s: waitpid(%d) rc %d status %x secs %u.%03u\n"),
469 psm->stepName, (
unsigned)psm->sq.child,
470 (
unsigned)psm->sq.reaped, psm->sq.status,
471 (
unsigned)msecs/1000, (
unsigned)msecs%1000);
473 if (psm->sstates != NULL)
476 *ssp |= (psm->sq.status & 0xffff);
480 return psm->sq.reaped;
496 const char *script,
int arg1,
int arg2)
512 for (i = 0; i < (int)Phe->
c && Phe->
p.
argv[i]; i++) {
532 xx =
snprintf(buf, BUFSIZ,
"%s(%s)", sln, psm->NVRA);
548 #if defined(_WITH_EMBEDDED) 549 static int enterChroot(
rpmpsm psm,
int * pwdFdnop,
int * rootFdnop)
553 const rpmts ts = psm->ts;
559 (*pwdFdnop) = open(
".", O_RDONLY, 0);
563 (*rootFdnop) = open(
"/", O_RDONLY, 0);
570 if (rootDir != NULL && strcmp(rootDir,
"/") && *rootDir ==
'/') {
584 static int exitChroot(
rpmpsm psm,
int inChroot,
int pwdFdno,
int rootFdno)
588 const rpmts ts = psm->ts;
593 xx = fchdir(rootFdno);
595 if (rootDir != NULL && strcmp(rootDir,
"/") && *rootDir ==
'/') {
600 xx = fchdir(pwdFdno);
602 xx = fchdir(pwdFdno);
604 xx = close(rootFdno);
622 const char *script,
int arg1,
int arg2,
ARGV_t matches)
632 int inChroot = enterChroot(psm, &pwdFdno, &rootFdno);
633 size_t len = 4 + (matches ?
argvCount(matches) : 0);
635 if (psm->sstates != NULL)
636 ssp = psm->sstates +
tag2slx(psm->scriptTag);
640 av =
alloca(len *
sizeof(*av));
642 (void) sprintf((av[1] = (
char *)
alloca(32)),
"%d", arg1);
646 (void) sprintf((av[2] = (
char *)
alloca(32)),
"%d", arg2);
654 #if defined(WITH_LUA) 655 if (!strcmp(Phe->
p.
argv[0],
"<lua>")) {
656 rc = runLuaScript(psm, sln, Phe, script, arg1, arg2);
659 #if defined(WITH_AUGEAS) 660 if (!strcmp(Phe->
p.
argv[0],
"<augeas>")) {
663 rc = rpmaugRun(aug, script, NULL) ==
RPMRC_OK 665 aug = rpmaugFree(aug);
668 #if defined(WITH_FICL) 669 if (!strcmp(Phe->
p.
argv[0],
"<ficl>")) {
670 rpmficl ficl = rpmficlNew((
char **)av, 0);
671 rc = rpmficlRun(ficl, script, NULL) ==
RPMRC_OK 673 ficl = rpmficlFree(ficl);
676 #if defined(WITH_GPSEE) 677 if (!strcmp(Phe->
p.
argv[0],
"<js>")) {
684 #if defined(WITH_PERLEMBED) 685 if (!strcmp(Phe->
p.
argv[0],
"<perl>")) {
692 #if defined(WITH_PYTHONEMBED) 693 if (!strcmp(Phe->
p.
argv[0],
"<python>")) {
700 #if defined(WITH_RUBY) 701 if (!strcmp(Phe->
p.
argv[0],
"<ruby>")) {
708 #if defined(WITH_SEMANAGE) 709 if (!strcmp(Phe->
p.
argv[0],
"<spook>")) {
716 rc = rpmsmRun(sm, (
char **)av, NULL) ==
RPMRC_OK 721 #if defined(WITH_SQLITE) 722 if (!strcmp(Phe->
p.
argv[0],
"<sql>")) {
724 const char ** Pav = (
const char **)
xmalloc((Pac + 1) *
sizeof(*Pav));
725 const char * result = NULL;
731 for (i = 0; i < Pac; i++)
742 #if defined(WITH_SQUIRREL) 743 if (!strcmp(Phe->
p.
argv[0],
"<squirrel>")) {
750 #if defined(WITH_TCL) 751 if (!strcmp(Phe->
p.
argv[0],
"<tcl>")) {
762 *ssp |= (xx & 0xffff);
766 xx = exitChroot(psm, inChroot, pwdFdno, rootFdno);
797 const char * script,
int arg1,
int arg2,
ARGV_t matches)
803 const rpmts ts = psm->ts;
804 const char * NVRA = psm->NVRA;
805 HE_t IPhe = psm->IPhe;
806 const char ** argv = NULL;
808 const char **
IP = NULL;
810 size_t maxPrefixLength;
812 char * prefixBuf = NULL;
813 const char * fn = NULL;
814 FD_t scriptFd = NULL;
817 const char * body = NULL;
819 int ix =
tag2slx(psm->scriptTag);
826 ssp = psm->sstates + ix;
830 if (Phe->
p.
argv == NULL && script == NULL)
841 assert(he->
p.
str != NULL);
842 psm->NVRA = NVRA = he->
p.
str;
851 if (!strcmp(Phe->
p.
argv[0],
"<lua>")
852 || !strcmp(Phe->
p.
argv[0],
"<augeas>")
853 || !strcmp(Phe->
p.
argv[0],
"<ficl>")
854 || !strcmp(Phe->
p.
argv[0],
"<js>")
855 || !strcmp(Phe->
p.
argv[0],
"<perl>")
856 || !strcmp(Phe->
p.
argv[0],
"<python>")
857 || !strcmp(Phe->
p.
argv[0],
"<ruby>")
858 || !strcmp(Phe->
p.
argv[0],
"<sql>")
859 || !strcmp(Phe->
p.
argv[0],
"<squirrel>")
860 || !strcmp(Phe->
p.
argv[0],
"<tcl>"))
862 #if defined(_WITH_EMBEDDED) 864 D_(
"%s: %s(%s) running %s scriptlet.\n"),
865 psm->stepName,
tag2sln(psm->scriptTag), NVRA, Phe->
p.
argv[0]);
866 rc = runEmbeddedScript(psm, sln, Phe, body, arg1, arg2, matches);
876 if (ldconfig_path && Phe->
p.
argv != NULL &&
F_ISSET(psm, UNORDERED)) {
877 if (ldconfig_done && !strcmp(Phe->
p.
argv[0], ldconfig_path)) {
879 D_(
"%s: %s(%s) skipping redundant \"%s\".\n"),
880 psm->stepName,
tag2sln(psm->scriptTag), NVRA,
888 D_(
"%s: %s(%s) %ssynchronous scriptlet start\n"),
889 psm->stepName,
tag2sln(psm->scriptTag), NVRA,
890 (
F_ISSET(psm, UNORDERED) ?
"a" :
""));
892 if (Phe->
p.
argv == NULL) {
893 argv =
alloca(5 + (matches ?
argvCount(matches) : 0 ) *
sizeof(*argv));
898 argv =
alloca((Phe->
c + 4) + (matches ?
argvCount(matches) : 0 ) *
sizeof(*argv));
899 memcpy(argv, Phe->
p.
argv, Phe->
c *
sizeof(*argv));
901 ldconfig_done = (ldconfig_path && !strcmp(argv[0], ldconfig_path)
906 if (IPhe->
tag == 0) {
914 const char ** av = (
const char **)
916 char * t = (
char *) &av[1];
936 for (i = 0; i < nIP; i++) {
938 if (len > maxPrefixLength) maxPrefixLength = len;
940 prefixBuf = (
char *)
alloca(maxPrefixLength + 50);
951 (!strcmp(argv[0],
"/bin/sh") || !strcmp(argv[0],
"/bin/bash")))
953 static const char set_x[] =
"set -x\n";
954 nw =
Fwrite(set_x,
sizeof(set_x[0]),
sizeof(set_x)-1, fd);
957 if (ldconfig_path && strstr(body, ldconfig_path) != NULL)
960 nw =
Fwrite(body,
sizeof(body[0]), strlen(body), fd);
963 {
const char * sn = fn;
965 !(rootDir[0] ==
'/' && rootDir[1] ==
'\0'))
967 sn += strlen(rootDir)-1;
973 char *av = (
char *)
alloca(20);
974 sprintf(av,
"%d", arg1);
978 char *av = (
char *)
alloca(20);
979 sprintf(av,
"%d", arg2);
991 switch (psm->scriptTag) {
1008 if (scriptFd == NULL)
1010 if (scriptFd != NULL) {
1014 out =
Fopen(
"/dev/null",
"w.fdio");
1020 out =
fdDup(STDOUT_FILENO);
1026 if (psm->sq.child == 0) {
1031 pipes[0] = pipes[1] = 0;
1034 xx = close(pipes[1]);
1035 xx = dup2(pipes[0], STDIN_FILENO);
1036 xx = close(pipes[0]);
1039 for (fdno = 3; fdno < 100; fdno++) {
1040 flag = fcntl(fdno, F_GETFD);
1041 if (flag == -1 || (flag & FD_CLOEXEC))
1044 D_(
"%s: %s(%s)\tfdno(%d) missing FD_CLOEXEC\n"),
1045 psm->stepName, sln, NVRA,
1047 xx = fcntl(fdno, F_SETFD, FD_CLOEXEC);
1051 if (scriptFd != NULL) {
1052 int sfdno =
Fileno(scriptFd);
1054 if (sfdno != STDERR_FILENO)
1055 xx = dup2(sfdno, STDERR_FILENO);
1056 if (ofdno != STDOUT_FILENO)
1057 xx = dup2(ofdno, STDOUT_FILENO);
1059 if (ofdno > STDERR_FILENO && ofdno != sfdno)
1061 if (sfdno > STDERR_FILENO && ofdno != sfdno)
1065 {
const char *ipath =
rpmExpand(
"PATH=%{_install_script_path}", NULL);
1068 if (ipath && ipath[5] !=
'%')
1073 ipath =
_free(ipath);
1078 for (i = 0; i < nIP; i++) {
1079 sprintf(prefixBuf,
"RPM_INSTALL_PREFIX%d=%s", i, IP[i]);
1084 sprintf(prefixBuf,
"RPM_INSTALL_PREFIX=%s", IP[i]);
1091 !(rootDir[0] ==
'/' && rootDir[1] ==
'\0'))
1099 psm->stepName, sln, NVRA,
1100 argv[0], (
unsigned)getpid());
1115 xx = execv(argv[0], (
char *
const *)argv);
1127 if (psm->sq.child == (pid_t)-1) {
1135 if (!(psm->sq.reaped >= 0 && !strcmp(argv[0],
"/usr/sbin/glibc_post_upgrade") && WEXITSTATUS(psm->sq.status) == 110)) {
1137 if (psm->sq.reaped < 0) {
1139 _(
"%s(%s) scriptlet failed, waitpid(%d) rc %d: %s\n"),
1140 sln, NVRA, (
int)psm->sq.child, (
int)psm->sq.reaped,
1144 if (!WIFEXITED(psm->sq.status) || WEXITSTATUS(psm->sq.status)) {
1145 if (WIFSIGNALED(psm->sq.status)) {
1147 psm->scriptTag, WTERMSIG(psm->sq.status));
1149 _(
"%s(%s) scriptlet failed, signal %d\n"),
1150 sln, NVRA, WTERMSIG(psm->sq.status));
1153 psm->scriptTag, WEXITSTATUS(psm->sq.status));
1155 _(
"%s(%s) scriptlet failed, exit status %d\n"),
1156 sln, NVRA, WEXITSTATUS(psm->sq.status));
1166 static unsigned int scale = 1000;
1169 psm->smetrics[ix] += op->
usecs / scale;
1200 const char * argv0 = NULL;
1203 assert(fi->h != NULL);
1204 She->
tag = psm->scriptTag;
1208 Phe->
tag = psm->progTag;
1214 const char * s = Phe->
p.
str;
1216 Phe->
p.
argv = (
const char **)
1218 Phe->
p.
argv[0] = t = (
char *) &Phe->
p.
argv[1];
1225 if (Phe->
p.
argv[0][0] ==
'%')
1229 She->
p.
str, psm->scriptArg, -1, NULL);
1232 argv0 =
_free(argv0);
1255 static int scareMem = 0;
1261 const rpmts ts = psm->ts;
1266 const char * triggerName;
1274 triggerName = he->
p.
str;
1282 arg1 += psm->countCorrection;
1309 if (!(Flags & psm->sense))
1313 depName = (
char *)
rpmdsN(Tds);
1314 if (depName[0] ==
'^' || depName[0] ==
'/') {
1315 size_t nb = strlen(depName);
1334 const char * N =
rpmdsN(ds);
1373 {
int index = Ihe->
p.
ui32p[i];
1374 const char * s = Phe->
p.
argv[index];
1380 he->
p.
argv = (
const char **)
1386 if (
runScript(psm, triggeredH,
"%trigger", he,
1387 She->
p.
argv[index], arg1, arg2, matches))
1409 triggerName =
_free(triggerName);
1419 const rpmts ts = psm->ts;
1427 for (i = 0; i < nkeys; i++) {
1428 char * t = (
char *) keys[i];
1432 (
miRE *)&psm->Tmires, &psm->nTmires);
1452 static int scareMem = 0;
1453 const rpmts ts = psm->ts;
1456 char * depName = NULL;
1467 const char * Name =
rpmdsN(ds);
1468 size_t nName = strlen(Name);
1469 unsigned prev, instance;
1473 depName =
_free(depName);
1474 if (!strcmp(Name,
"/"))
1477 depName =
xmalloc(nName + 1 + 1);
1478 (void)
stpcpy(depName, Name);
1481 depName[nName+1] =
'\0';
1484 if (depName[0] ==
'/' && psm->Tmires != NULL) {
1489 for (j = 0, mire = (
miRE)psm->Tmires; j < psm->nTmires; j++, mire++) {
1490 const char * pattern = psm->Tpats[j];
1491 if (depName[nName-1] !=
'/') {
1492 size_t npattern = strlen(pattern);
1493 depName[nName] =
PATT_ISDIR(pattern, npattern) ?
'/' :
'\0';
1499 depName =
_free(depName);
1511 xx =
rpmmiPrune(mi, (uint32_t *)vals, nvals, 1);
1514 while((triggeredH =
rpmmiNext(mi)) != NULL) {
1516 if (prev == instance)
1521 xx =
argiAdd(&instances, -1, instance);
1529 depName =
_free(depName);
1547 const rpmts ts = psm->ts;
1554 if (_trigger_tag == 0) {
1555 const char * t =
rpmExpand(
"%{?_trigger_tag}", NULL);
1563 assert(psm->te != NULL);
1564 {
const char * N =
rpmteN(psm->te);
1567 numPackage += psm->countCorrection;
1572 assert(fi->h != NULL);
1575 {
int countCorrection = psm->countCorrection;
1577 psm->countCorrection = 0;
1599 psm->countCorrection = countCorrection;
1617 const rpmts ts = psm->ts;
1619 rpmds triggers = NULL;
1630 assert(fi->h != NULL);
1633 if (_trigger_tag == 0) {
1634 const char * t =
rpmExpand(
"%{?_trigger_tag}", NULL);
1643 triggers =
rpmdsLink(psm->triggers,
"ImmedTriggers");
1645 if (triggers == NULL)
1650 if (!(xx && Ihe->
p.
ui32p && Ihe->
c))
goto exit;
1654 if (triggers != NULL)
1655 while ((i =
rpmdsNext(triggers)) >= 0) {
1657 const char * N =
rpmdsN(triggers);
1658 const char * EVR =
rpmdsEVR(triggers);
1661 if (!(Flags & psm->sense))
1666 size_t nb = strlen(N);
1668 if (N[0] ==
'^' || N[0] ==
'/')
1672 if ((EVR == NULL || *EVR ==
'\0') && (N[0] ==
'^' ||
Glob_pattern_p(N, 0)))
1682 for (i = 0; (Name = keys[i]) != NULL; i++) {
1683 unsigned prev, instance;
1689 size_t nb = strlen(Name);
1691 if (Name[0] ==
'^' || Name[0] ==
'/')
1701 xx =
rpmmiPrune(mi, (uint32_t *)vals, nvals, 1);
1704 while((sourceH =
rpmmiNext(mi)) != NULL) {
1708 if (prev == instance)
1716 xx =
argiAdd(&instances, -1, instance);
1742 if (tsi != NULL && tsi->ocsave != -1) {
1746 if (te != NULL && (fi = te->fi) != NULL)
1769 static int scareMem = 0;
1770 HE_t he = memset(
alloca(
sizeof(*he)), 0,
sizeof(*he));
1771 HE_t Ihe = memset(
alloca(
sizeof(*Ihe)), 0,
sizeof(*Ihe));
1772 HE_t She = memset(
alloca(
sizeof(*She)), 0,
sizeof(*She));
1773 HE_t Phe = memset(
alloca(
sizeof(*Phe)), 0,
sizeof(*Phe));
1775 const rpmts ts = psm->ts;
1777 const char * triggerName;
1785 triggerName = he->
p.
str;
1793 arg1 += psm->countCorrection;
1820 if (!((Flags & psm->sense) & RPMSENSE_TRIGGERTRANS))
1824 depName = (
char *)
rpmdsN(Tds);
1833 char * N = (
char *) sourceDs->N[sourceDs->i];
1854 {
int index = Ihe->
p.
ui32p[i];
1855 const char * s = Phe->
p.
argv[index];
1866 rc |=
runScript(psm, triggeredH,
"%trigger", he,
1867 She->
p.
argv[index], arg1, arg2, matches);
1869 rpmlog(
RPMLOG_DEBUG,
"--> %s:%d runScript: %s arg1: %d arg2: %d matches: %d rc: %d\n", __FUNCTION__, __LINE__, She->
p.
argv[index], arg1, arg2, matches, rc);
1884 triggerName =
_free(triggerName);
1902 static int scareMem = 0;
1903 const rpmts ts = psm->ts;
1905 rpmds sourceDs = memset(
alloca(
sizeof(*sourceDs)), 0,
sizeof(*sourceDs));
1906 char * depName = NULL;
1908 char * evr_allocated = NULL;
1920 n = (psm->goal ==
PSM_PKGINSTALL) ? ts->numAddedFiles : ts->numErasedFiles;
1924 sourceDs->tagN = tagno;
1925 sourceDs->Type =
tagName(tagno);
1926 sourceDs->Count = n;
1931 ptr = evr = evr_allocated = calloc(n * 64,
sizeof(*evr));
1934 sourceDs->N = calloc(n,
sizeof(*sourceDs->N));
1937 sourceDs->EVR = calloc(n,
sizeof(*sourceDs->EVR));
1940 sourceDs->Flags = calloc(n,
sizeof(*sourceDs->Flags));
1941 if (!sourceDs->Flags)
1947 if (p->isSource)
continue;
1962 sourceDs->N[++sourceDs->i] =
rpmteN(p);
1963 sourceDs->EVR[sourceDs->i] = evr++;
1971 if (sourceDs->i == -1)
1975 for(sourceDs->i = 0; sourceDs->i < (
int)sourceDs->Count; sourceDs->i++) {
1976 const char * depName = sourceDs->N[sourceDs->i];
1977 unsigned prev, instance;
1982 if (!depName || !*depName)
1986 rpmlog(
RPMLOG_DEBUG,
"--> %s:%d depName: %s tagno: %d ix: %d\n", __FUNCTION__, __LINE__, depName, tagno, sourceDs->i);
1988 if (depName[0] ==
'/' && psm->Tmires != NULL) {
1993 for (j = 0, mire = psm->Tmires; j < psm->nTmires; j++, mire++) {
1994 const char * pattern = psm->Tpats[j];
1995 size_t npattern = strlen(pattern);
2012 xx =
rpmmiPrune(mi, (uint32_t *)vals, nvals, 1);
2015 while((triggeredH =
rpmmiNext(mi)) != NULL) {
2017 if (prev == instance)
2021 xx =
argiAdd(&instances, -1, instance);
2030 free(sourceDs->Flags);
2031 free(sourceDs->EVR);
2033 free(evr_allocated);
2055 if (_trigger_tag == 0) {
2056 const char * t =
rpmExpand(
"%{?_trigger_tag}", NULL);
2065 {
int countCorrection = psm->countCorrection;
2067 psm->countCorrection = 0;
2080 psm->Tmires =
mireFreeAll(psm->Tmires, psm->nTmires);
2084 psm->countCorrection = countCorrection;
2128 default:
return "???";
2135 assert(psm != NULL);
2137 psm->unorderedSuccessor = async;
2140 F_SET(psm, UNORDERED);
2142 F_CLR(psm, UNORDERED);
2148 assert(psm != NULL);
2149 psm->scriptTag = scriptTag;
2150 psm->progTag = progTag;
2152 switch (scriptTag) {
2163 switch (scriptTag) {
2192 psm->IPhe->p.ptr =
_free(psm->IPhe->p.ptr);
2193 psm->IPhe =
_free(psm->IPhe);
2194 psm->NVRA =
_free(psm->NVRA);
2196 psm->triggers = NULL;
2210 if (_psmPool == NULL) {
2216 memset(((
char *)psm)+
sizeof(psm->_item), 0,
sizeof(*psm)-
sizeof(psm->_item));
2222 static const char msg[] =
"rpmpsmNew";
2228 if (te) psm->te = rpmteLink(te, msg);
2231 if (te) psm->te = te;
2237 psm->triggers = NULL;
2239 psm->IPhe = (
HE_t)
xcalloc(1,
sizeof(*psm->IPhe));
2240 memset(psm->sstates, 0,
sizeof(psm->sstates));
2241 memset(psm->smetrics, 0,
sizeof(psm->smetrics));
2311 he->
p.
argv = &chain_end;
2323 he->
p.
argv = &chain_end;
2335 he->
p.
argv = &chain_end;
2370 he->
p.
argv = &chain_end;
2385 he->
p.
argv = &chain_end;
2400 he->
p.
argv = &chain_end;
2429 assert(fi->h != NULL);
2431 {
struct timeval tv;
2432 xx = gettimeofday(&tv, NULL);
2438 he->
p.
ui32p = &installTime[0];
2444 memcpy(originTime, uip,
sizeof(originTime));
2445 if (originTime[0] == 0)
2446 memcpy(originTime, installTime,
sizeof(originTime));
2449 he->
p.
ui32p = originTime;
2454 memcpy(originTid, uip,
sizeof(originTid));
2455 if (originTid[0] == 0)
2456 memcpy(originTid, ts->tid,
sizeof(originTid));
2490 if (digest != NULL) {
2503 if (st->st_mode == 0 && st->st_mtime == 0 && st->st_size == 0)
2506 if (st->st_mode != 0) {
2509 he->
p.
ptr = (
void *)st;
2542 he->
p.
ui32p = psm->sstates;
2547 he->
p.
ui32p = psm->smetrics;
2552 if (fi->fstates != NULL && fc > 0) {
2555 he->
p.
ui8p = fi->fstates;
2563 #if defined(WITH_PTHREADS) 2564 static void * rpmpsmThread(
void * _psm)
2579 psm->nstage = nstage;
2580 #if defined(WITH_PTHREADS) 2595 const rpmts ts = psm->ts;
2604 if (fi != NULL && fi->h == NULL && fi->te && ((
rpmte)fi->te)->h != NULL) fi->h =
headerLink(((
rpmte)fi->te)->h);
2621 if (psm->npkgs_installed < 0) {
2627 assert(psm->te != NULL);
2631 if (psm->te->downgrade)
2632 psm->npkgs_installed--;
2642 psm->scriptArg = psm->npkgs_installed + 1;
2644 assert(psm->mi == NULL);
2646 if (hdrid != NULL) {
2657 #ifdef RPM_VENDOR_MANDRIVA 2669 while ((psm->oh =
rpmmiNext(psm->mi)) != NULL) {
2679 if (fi->fstates == NULL && fc > 0) {
2684 xx = rpmtxnBegin(
rpmtsGetRdb(ts), ts->txn, &psm->te->txn);
2696 fi->striplen = (xx && he->
p.
str ? strlen(he->
p.
str) + 1 : 1);
2706 assert(he->
p.
argv != NULL);
2707 fi->apath = he->
p.
argv;
2709 if (fi->fuser == NULL) {
2712 fi->fuser = he->
p.
argv;
2714 if (fi->fgroup == NULL) {
2717 fi->fgroup = he->
p.
argv;
2722 psm->scriptArg = psm->npkgs_installed - 1;
2726 xx = rpmtxnBegin(
rpmtsGetRdb(ts), ts->txn, &psm->te->txn);
2742 bfmt =
rpmGetPath(tiddn,
"/",
"%{_repackage_name_fmt}", NULL);
2746 psm->pkgURL =
rpmGenPath(
"%{?_repackage_root}",
2747 "%{?_repackage_dir}",
2749 pkgbn =
_free(pkgbn);
2750 (void)
urlPath(psm->pkgURL, &psm->pkgfn);
2751 pkgdn_buf =
xstrdup(psm->pkgfn);
2753 pkgdn = dirname(pkgdn_buf);
2756 pkgdn_buf =
_free(pkgdn_buf);
2759 psm->fd =
Fopen(psm->pkgfn,
"w.fdio");
2760 if (psm->fd == NULL ||
Ferror(psm->fd)) {
2768 if (
rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)
break;
2772 {
static int oneshot = 0;
2787 psm->sense = RPMSENSE_TRIGGERPREIN;
2788 psm->countCorrection = 0;
2805 _(
"%s: %s scriptlet failed (%d), skipping %s\n"),
2806 psm->stepName,
tag2sln(psm->scriptTag), rc,
2816 psm->sense = RPMSENSE_TRIGGERUN;
2817 psm->countCorrection = -1;
2833 int noArchiveSize = 0;
2834 const char * origin = NULL;
2835 const char * digest = NULL;
2836 const struct stat * st = NULL;
2837 size_t nstbytes = 0;
2848 if (xx && he->
p.
str != NULL)
2852 if (xx && he->
p.
ptr != NULL && (
size_t)he->
c ==
sizeof(*st)) {
2853 st = (
struct stat *) he->
p.
ptr;
2861 if (xx && uh != NULL) {
2868 if (xx && uh != NULL) {
2902 {
static const char item[] =
"Lead";
2909 void * l = memset(
alloca(nb), 0, nb);
2921 {
static const char item[] =
"Signature";
2939 if (psm->oh != NULL)
2949 if (origin != NULL) {
2955 origin =
_free(origin);
2957 if (digest != NULL) {
2963 digest =
_free(digest);
2968 he->
p.
ptr = (
void *)st;
2980 assert(psm->te != NULL);
2985 {
const char item[] =
"Header";
2986 const char * msg = NULL;
2990 (msg && *msg ? msg :
"write failed\n"));
2997 if (
rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)
break;
3022 if (psm->cfd == NULL) {
3027 xx = rpmtxnBegin(
rpmtsGetRdb(ts), psm->te->txn, NULL);
3030 ts, fi, psm->cfd, NULL, &psm->failedFile);
3050 rpmtxn _txn = (db ? db->db_txn : NULL);
3053 xx = rpmtxnAbort(_txn);
3055 xx = rpmtxnCommit(_txn);
3062 psm->amount = (fi->archiveSize ? fi->archiveSize : 100);
3063 psm->total = psm->amount;
3069 _(
"unpacking of archive failed%s%s: %s\n"),
3070 (psm->failedFile != NULL ?
_(
" on file ") :
""),
3071 (psm->failedFile != NULL ? psm->failedFile :
""),
3093 psm->total = (fc ? fc : 100);
3098 ts, fi, NULL, NULL, &psm->failedFile);
3103 psm->amount = (fc ? fc : 100);
3104 psm->total = (fc ? fc : 100);
3115 if (psm->fd == NULL) {
3123 if (psm->cfd == NULL) {
3129 ts, fi, psm->cfd, NULL, &psm->failedFile);
3145 psm->amount = (fi->archiveSize ? fi->archiveSize : 100);
3146 psm->total = psm->amount;
3149 fi->action = (int) action;
3150 fi->actions = (
int *) actions;
3160 psm->sense = RPMSENSE_TRIGGERIN;
3161 psm->countCorrection = 1;
3194 rc = markReplacedFiles(psm);
3202 psm->sense = RPMSENSE_TRIGGERPOSTUN;
3203 psm->countCorrection = -1;
3235 if (psm->fd != NULL) {
3245 if (!rc && ts && ts->notify == NULL) {
3247 (psm->pkgURL ? psm->pkgURL :
"???"));
3253 if (psm->failedFile)
3255 _(
"%s failed on file %s: %s\n"),
3256 psm->stepName, psm->failedFile, msg);
3259 psm->stepName, msg);
3269 if (psm->te->txn != NULL) {
3270 xx = rpmtxnAbort(psm->te->txn);
3271 psm->te->txn = NULL;
3274 if (psm->te->txn != NULL) {
3275 xx = rpmtxnCommit(psm->te->txn);
3276 psm->te->txn = NULL;
3281 if (psm->te != NULL)
3283 if (fi->h != NULL) {
3290 psm->pkgURL =
_free(psm->pkgURL);
3291 psm->rpmio_flags =
_free(psm->rpmio_flags);
3292 psm->payload_format =
_free(psm->payload_format);
3293 psm->failedFile =
_free(psm->failedFile);
3295 fi->fgroup =
_free(fi->fgroup);
3296 fi->fuser =
_free(fi->fuser);
3297 fi->apath =
_free(fi->apath);
3298 fi->fstates =
_free(fi->fstates);
3322 ptr =
rpmtsNotify(ts, psm->te, psm->what, psm->amount, psm->total);
3332 ts, fi, NULL, NULL, &psm->failedFile);
3339 if (rootDir != NULL && !(rootDir[0] ==
'/' && rootDir[1] ==
'\0')
3342 static int _pw_loaded = 0;
3343 static int _gr_loaded = 0;
3346 (void)getpwnam(
"root");
3351 (void)getgrnam(
"root");
3358 if (rootDir != NULL && strcmp(rootDir,
"/") && *rootDir ==
'/')
3361 F_SET(psm, CHROOTDONE);
3367 if (
F_ISSET(psm, CHROOTDONE)) {
3371 if (rootDir != NULL && strcmp(rootDir,
"/") && *rootDir ==
'/')
3374 F_CLR(psm, CHROOTDONE);
3376 if (currDir != NULL)
3377 xx =
Chdir(currDir);
3382 { rpmtxn _parent = (psm && psm->te ? psm->te->txn : NULL);
3392 { rpmtxn _parent = (psm && psm->te ? psm->te->txn : NULL);
3396 psm->sense = psm->goal ==
PSM_PKGINSTALL ? (RPMSENSE_TRIGGERTRANS|RPMSENSE_TRIGGERPREIN) : (RPMSENSE_TRIGGERTRANS|RPMSENSE_TRIGGERUN);
3397 psm->countCorrection = 0;
3406 { rpmtxn _parent = (psm && psm->te ? psm->te->txn : NULL);
3410 psm->sense = psm->goal ==
PSM_PKGINSTALL ? (RPMSENSE_TRIGGERTRANS|RPMSENSE_TRIGGERIN) : (RPMSENSE_TRIGGERTRANS|RPMSENSE_TRIGGERPOSTUN);
3411 psm->countCorrection = 0;
3421 if (
rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)
break;
3426 if (
rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)
break;
3427 if (!
F_ISSET(psm, GOTTRIGGERS)) {
3429 F_SET(psm, GOTTRIGGERS);
3431 if (psm->triggers != NULL)
3436 {
const char * payload_compressor = NULL;
3437 const char * payload_format = NULL;
3442 payload_compressor = he->
p.
str;
3443 if (payload_compressor == NULL)
3444 payload_compressor =
xstrdup(
"gzip");
3446 psm->rpmio_flags = t = (
char *)
xmalloc(
sizeof(
"w9.gzdio"));
3449 if (!strcmp(payload_compressor,
"gzip"))
3451 if (!strcmp(payload_compressor,
"bzip2"))
3453 if (!strcmp(payload_compressor,
"lzma"))
3455 if (!strcmp(payload_compressor,
"xz"))
3457 payload_compressor =
_free(payload_compressor);
3461 payload_format = he->
p.
str;
3462 if (!xx || payload_format == NULL || !(
3463 !strcmp(payload_format,
"tar") || !strcmp(payload_format,
"ustar")
3464 #
if defined(SUPPORT_AR_PAYLOADS)
3465 || !strcmp(payload_format,
"ar")
3469 payload_format =
_free(payload_format);
3470 payload_format =
xstrdup(
"cpio");
3472 psm->payload_format =
_free(psm->payload_format);
3473 psm->payload_format = payload_format;
3478 assert(psm->mi == NULL);
3480 &fi->record,
sizeof(fi->record));
3488 if (fi->h != NULL) {
3497 if (fi->isSource)
break;
3498 if (fi->h == NULL)
break;
3500 xx = rpmtxnBegin(
rpmtsGetRdb(ts), psm->te->txn, NULL);
3512 #if defined(HAVE_SYSLOG_H) && defined(RPM_VENDOR_MANDRIVA) 3518 syslog(LOG_NOTICE,
"[RPM] %s installed\n", s);
3533 assert(psm->te != NULL);
3536 psm->te->installed = 1;
3544 if (
rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)
break;
3547 xx = rpmtxnBegin(
rpmtsGetRdb(ts), psm->te->txn, NULL);
3552 #if defined(HAVE_SYSLOG_H) && defined(RPM_VENDOR_MANDRIVA) 3558 syslog(LOG_NOTICE,
"[RPM] %s removed\n", s);
3573 if (psm->te != NULL)
3574 psm->te->u.removed.dboffset = 0;
rpmuint32_t rpmfiFFlags(rpmfi fi)
Return current file flags from file info set.
int rpmmiPrune(rpmmi mi, uint32_t *hdrNums, int nHdrNums, int sorted)
Remove items from set of package instances to iterate.
static void rpmpsmFini(void *_psm)
evrFlags rpmdsFlags(const rpmds ds)
Return current dependency flags.
int rpmteClose(rpmte te, rpmts ts, int reset_fi)
FD_t rpmteFd(rpmte te)
Retrieve file handle from transaction element.
static rpmRC createDir(rpmts ts, rpmfi fi, const char **fn, const char *name)
rpmds rpmdsInit(rpmds ds)
Initialize dependency set iterator.
headerTagTableEntry rpmTagTable
Automatically generated table of tag name/value pairs.
pid_t rpmsqWait(rpmsq sq)
Wait for child process to be reaped.
rpmuint32_t rpmteColor(rpmte te)
Retrieve color bits of transaction element.
miRE mireNew(rpmMireMode mode, int tag)
Create pattern container.
rpmtime_t rpmswExit(rpmop op, ssize_t rc)
Exit timed operation.
pid_t rpmsqFork(rpmsq sq)
Fork a child process.
void * rpmtsNotify(rpmts ts, rpmte te, rpmCallbackType what, rpmuint64_t amount, rpmuint64_t total)
Perform transaction progress notify callback.
rpmte rpmteFree(rpmte te)
Destroy a transaction element.
ARGI_t argiFree(ARGI_t argi)
Destroy an argi array.
void * mireFreeAll(miRE mire, int nmire)
Destroy compiled patterns.
const char * rpmtsRootDir(rpmts ts)
Get transaction rootDir, i.e.
rpmte rpmtsElement(rpmts ts, int ix)
Return (ordered) transaction set element.
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.
uint32_t rpmmiInstance(rpmmi mi)
Return header instance for current position of rpmdb iterator.
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.
int rpmtsAddInstallElement(rpmts ts, Header h, fnpyKey key, int upgrade, rpmRelocation relocs)
Add package to be installed to transaction set.
rpmjs rpmjsFree(rpmjs js)
Destroy a js interpreter.
char * rpmGetPath(const char *path,...)
Return (malloc'ed) expanded, canonicalized, file path.
Structure(s) used for file info tag sets.
void rpmluavSetListMode(rpmluav var, int flag)
int Access(const char *path, int amode)
access(2) clone.
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.
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.
rpmtime_t rpmswAdd(rpmop to, rpmop from)
Sum statistic counters.
void * rpmsqThread(void *(*start)(void *arg), void *arg)
Call a function in a thread.
const char * rpmteN(rpmte te)
Retrieve name string of transaction element.
int Stat(const char *path, struct stat *st)
stat(2) clone.
struct rpmpsm_s * rpmpsm
Package state machine data.
FD_t fdLink(void *cookie, const char *msg)
int Fflush(FD_t fd)
fflush(3) clone.
#define F_SET(_psm, _FLAG)
static rpmRC runScriptTriggersLoop(rpmpsm psm, rpmTag tagno, int arg2)
Run a dependency set loop against rpmdb triggers.
rpmfi rpmfiFree(rpmfi fi)
Destroy a file info set.
rpmTag rpmdsTagN(const rpmds ds)
Return current dependency type.
rpmop rpmtsOp(rpmts ts, rpmtsOpX opx)
Retrieve operation timestamp from a transaction set.
const char * rpmfiFN(rpmfi fi)
Return current file name from file info set.
int rpmtsSetChrootDone(rpmts ts, int chrootDone)
Set chrootDone flag, i.e.
rpmtsi rpmtsiFree(rpmtsi tsi)
Destroy transaction element iterator.
struct rpmtsi_s * rpmtsi
Transaction element iterator.
rpmTSType rpmtsType(rpmts ts)
Return the type of a transaction.
static void rpmlog(int code, const char *fmt,...)
const char * rpmteA(rpmte te)
Retrieve arch string of transaction element.
static rpmRC runScript(rpmpsm psm, Header h, const char *sln, HE_t Phe, const char *script, int arg1, int arg2, ARGV_t matches)
Run scriptlet with args.
rpmts rpmtsLink(rpmts ts, const char *msg)
Reference a transaction set instance.
int doputenv(const char *str)
Like the libc function, but malloc()'s the space needed.
struct rpmds_s * rpmds
Dependency tag sets from a header, so that a header can be discarded early.
int argiCount(ARGI_t argi)
Return no.
rpmds rpmdsFree(rpmds ds)
Destroy a dependency set.
char * headerSprintf(Header h, const char *fmt, headerTagTableEntry tags, headerSprintfExtension exts, errmsg_t *errmsg)
Return formatted output string from header tags.
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.
struct rpmte_s * rpmte
An element of a transaction set, i.e.
static rpmop fdstat_op(FD_t fd, fdOpX opx)
const char * rpmteE(rpmte te)
Retrieve epoch string of transaction element.
static int postPopulateInstallHeader(const rpmts ts, const rpmpsm psm, rpmfi fi)
Add fi->states to an install header.
const char * rpmtsCurrDir(rpmts ts)
Get transaction currDir, i.e.
int rpmmiGrow(rpmmi mi, const uint32_t *hdrNums, int nHdrNums)
Append items to set of package instances to iterate.
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 Chown(const char *path, uid_t owner, gid_t group)
chown(2) clone.
miRE mireFree(miRE mire)
Free pattern container.
const char * rpmteV(rpmte te)
Retrieve version string of transaction element.
const char * Fstrerror(FD_t fd)
strerror(3) clone.
const char * rpmteNEVR(rpmte te)
Retrieve name-version-release string from transaction element.
void * xcalloc(size_t nmemb, size_t size)
const char * rpmfiDN(rpmfi fi)
Return current directory name from file info set.
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.
rpmfi rpmteFI(rpmte te, rpmTag tag)
Retrieve file info tag set from transaction element.
size_t rpmpkgSizeof(const char *fn, const void *ptr)
Return size of item in bytes.
unsigned char rpmuint8_t
Private int typedefs to avoid C99 portability issues.
struct rpmfi_s * rpmfi
File info tag sets from a header, so that a header can be discarded early.
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.
int rpmdbRemove(rpmdb db, int rid, uint32_t hdrNum, rpmts ts)
Remove package header from rpm database and indices.
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 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.
const char * rpmdsEVR(const rpmds ds)
Return current dependency epoch-version-release.
const char * tagName(rpmTag tag)
Return tag name from value.
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.
int rpmdsNext(rpmds ds)
Return next dependency set iterator index.
Structure(s) used for dependency tag sets.
rpmpython rpmpythonNew(char **av, uint32_t flags)
Create and load a python interpreter.
The FD_t File Handle data structure.
rpmmi rpmtsInitIterator(const rpmts ts, rpmTag rpmtag, const void *keyp, size_t keylen)
Return transaction database iterator.
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.
const char * rpmteD(rpmte te)
Retrieve distepoch string of transaction element.
struct rpmdb_s * rpmdb
Database of headers and tag value indices.
rpmpsm rpmpsmNew(rpmts ts, rpmte te, rpmfi fi)
Create and load a package state machine.
int rpmtsChrootDone(rpmts ts)
Get chrootDone flag, i.e.
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.
int rpmdbMireApply(rpmdb db, rpmTag tag, rpmMireMode mode, const char *pat, const char ***argvp)
Return array of keys matching a pattern.
Generate and verify rpm package signatures.
int mireRegexec(miRE mire, const char *val, size_t vallen)
Execute pattern match.
Header headerFree(Header h)
Dereference a header instance.
static int hSaveBlinks(Header h, const struct rpmChainLink_s *blink)
Save backward link(s) of an upgrade chain into a header.
int rpmswEnter(rpmop op, ssize_t rc)
Enter timed operation.
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)
int rpmdsCount(const rpmds ds)
Return dependency set count.
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,...)
Header headerRegenSigHeader(const Header h, int noArchiveSize)
Regenerate signature header.
rpmRC rpmpsmStage(rpmpsm psm, pkgStage stage)
Package state machine driver.
void unsetenv(const char *name)
const char * rpmteO(rpmte te)
Retrieve os string of transaction element.
const char * rpmteHdrid(rpmte te)
Retrieve hdrid string from transaction element.
#define F_ISSET(_psm, _FLAG)
Header rpmteSetHeader(rpmte te, Header h)
Save header into transaction element.
const char * rpmdsN(const rpmds ds)
Return current dependency name.
rpmmi rpmmiFree(rpmmi mi)
Destroy rpm database iterator.
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.
char * iosmStrerror(int rc)
Return formatted error message on payload handling failure.
int fsmTeardown(void *_fsm)
Clean file state machine.
rpmte rpmtsiNext(rpmtsi tsi, rpmElementType type)
Return next transaction element of type.
struct rpmruby_s * rpmruby
rpmuint32_t * rpmteOriginTid(rpmte te)
Retrieve transaction start time that package was first installed.
int rpmfiNext(rpmfi fi)
Return next file iterator index.
static rpmRC handleOneScriptTrigger(const rpmpsm psm, rpmds sourceDs, Header triggeredH, int arg2)
Execute triggers.
Header headerLink(Header h)
Reference a header instance.
#define PATT_ISDIR(patt, len)
rpmuint32_t * rpmteOriginTime(rpmte te)
Retrieve time that package was first installed.
static const char * SCRIPT_PATH
rpmdb rpmtsGetRdb(rpmts ts)
Get transaction set database handle.
rpmruby rpmrubyFree(rpmruby ruby)
Destroys a Ruby interpreter instance.
struct rpmsquirrel_s * rpmsquirrel
enum rpmRC_e rpmRC
RPM return codes.
int Ferror(FD_t fd)
ferror(3) clone.
int rpmmiAddPattern(rpmmi mi, rpmTag tag, rpmMireMode mode, const char *pattern)
Add pattern to iterator selector.
rpmsql rpmsqlFree(rpmsql sql)
Destroy a sql interpreter.
int rpmmiSetRewrite(rpmmi mi, int rewrite)
Prepare iterator for lazy writes.
rpmfi rpmfiInit(rpmfi fi, int fx)
Initialize file iterator index.
rpmuint32_t rpmtsColor(rpmts ts)
Retrieve color bits of transaction set.
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)
urltype urlPath(const char *url, const char **pathp)
Return path component of URL.
static int snprintf(char *buf, int nb, const char *fmt,...)
rpmfi rpmfiLink(rpmfi fi, const char *msg)
Reference a file info set instance.
rpmts rpmtsFree(rpmts ts)
Destroy transaction set, closing the database as well.
rpmds rpmdsLink(rpmds ds, const char *msg)
Reference a dependency 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.
int rpmdbCountPackages(rpmdb db, const char *N)
Return number of instances of package in Name index.
char * stpcpy(char *dest, const char *src)
struct rpmts_s * rpmts
The RPM Transaction Set.
void rpmluaSetVar(rpmlua _lua, rpmluav var)
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
int rpmmiSetModified(rpmmi mi, int modified)
Modify iterator to mark header for lazy write on release.
Structures and prototypes used for an "rpmts" transaction set.
Header rpmmiNext(rpmmi mi)
Return next package header from iteration.
FD_t Fdopen(FD_t ofd, const char *fmode)
rpmVSFlags rpmtsVSFlags(rpmts ts)
Get verify signatures flag(s).
static rpmScriptID tag2slx(rpmTag tag)
Return scriptlet id from tag.
File state machine to handle a payload within an rpm package.
static rpmfi rpmtsiFi(const rpmtsi tsi)
Return transaction element's file info.
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 rpmdsIx(const rpmds ds)
Return dependency set index.
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.
int rpmdsMatch(const rpmds A, rpmds B)
Compare A against every member of B, looking for 1st match.
rpmpsm rpmpsmFree(rpmpsm psm, const char *msg)
Destroy a package state machine.
int Fileno(FD_t fd)
fileno(3) clone.
static rpmRC runInstScript(rpmpsm psm)
Retrieve and run scriptlet from header.
rpmRC rpmrubyRun(rpmruby ruby, const char *str, const char **resultp)
Evaluates Ruby code stored in a string.
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
int rpmdbAdd(rpmdb db, int iid, Header h, rpmts ts)
Add package header to rpm database and indices.
void rpmteSetDBInstance(rpmte te, unsigned int instance)
Set last instance installed to the database.
int rpmtsSELinuxEnabled(rpmts ts)
Get selinuxEnabled flag, i.e.
static rpmRC runTriggersLoop(rpmpsm psm, rpmTag tagno, int arg2)
Run a dependency set loop against rpmdb triggers.
rpmuint32_t rpmtsGetTid(rpmts ts)
Get transaction id, i.e.
rpmRC rpmjsRun(rpmjs js, const char *str, const char **resultp)
Execute js string.
rpmtsi rpmtsiInit(rpmts ts)
Create transaction element iterator.
Access RPM indices using Berkeley DB interface(s).
rpmds rpmdsNew(Header h, rpmTag tagN, int flags)
Create and load a dependency set.
int rpmdsSetNoPromote(rpmds ds, int nopromote)
Set "Don't promote Epoch:" flag.
rpmtransFlags rpmtsFlags(rpmts ts)
Get transaction flags, i.e.
rpmsquirrel rpmsquirrelNew(char **av, uint32_t flags)
Create and load a squirrel interpreter.
rpmperl rpmperlFree(rpmperl perl)
Destroy a perl interpreter.
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.
unsigned int rpmmiCount(rpmmi mi)
Return number of elements in rpm database iterator.
rpmRC rpmperlRun(rpmperl perl, const char *str, const char **resultp)
Execute perl string.
int rpmdsSetIx(rpmds ds, int ix)
Set dependency set index.
const char * rpmteR(rpmte te)
Retrieve release string of transaction element.
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 rpmdsNegateRC(const rpmds ds, int rc)
Negate return code for negated comparisons.
int rpmluaRunScript(rpmlua _lua, const char *script, const char *name)
static rpmRC runScriptTriggers(rpmpsm psm)
Run trigger scripts in the database that are fired by this header.
void rpmtsClean(rpmts ts)
Free memory needed only for dependency checks and ordering.
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.
#define F_CLR(_psm, _FLAG)
unsigned long int rpmtime_t
struct _dbiIndex * dbiIndex
void rpmpsmSetAsync(rpmpsm psm, int async)
int Unlink(const char *path)
unlink(2) clone.