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
70 #define PATT_ISDIR(patt, len) ((patt[0] == '/' && patt[len-1] == '/') || \
71 (patt[0] == '^' && patt[len-1] == '$' && patt[len-2] == '/'))
94 GENfree(const struct stat *)
108 const rpmts ts = psm->ts;
111 sharedFileInfo replaced = (te ? te->replaced : NULL);
120 if (!(
rpmfiFC(fi) > 0 && replaced != NULL))
124 for (sfi = replaced; sfi->otherPkg; sfi++) {
125 if (prev && prev == sfi->otherPkg)
127 prev = sfi->otherPkg;
133 offsets = (uint32_t *)
alloca(num *
sizeof(*offsets));
136 for (sfi = replaced; sfi->otherPkg; sfi++) {
137 if (prev && prev == sfi->otherPkg)
139 prev = sfi->otherPkg;
140 offsets[num++] = sfi->otherPkg;
161 while (sfi->otherPkg && sfi->otherPkg == prev) {
162 assert(sfi->otherFileNum < he->
c);
190 t[strlen(t)-1] =
'\0';
197 Chown(N, fi->uid, fi->gid);
210 const char ** specFilePtr,
const char ** cookie)
251 assert(p->h == NULL);
255 p->fd =
fdLink(fd, __FUNCTION__);
266 fi->fmapflags =
_free(fi->fmapflags);
271 #if defined(RPM_VENDOR_OPENPKG)
283 if ((muid_str =
rpmExpand(
"%{l_muid}", NULL)) != NULL)
284 if ((muid = (uid_t)strtol(muid_str, (
char **)NULL, 10)) > 0)
286 if ((mgid_str =
rpmExpand(
"%{l_mgid}", NULL)) != NULL)
287 if ((mgid = (gid_t)strtol(mgid_str, (
char **)NULL, 10)) > 0)
291 for (i = 0; i < (int)fi->fc; i++)
300 fi->apath = he->
p.
argv;
304 #if defined(RPM_VENDOR_OPENPKG)
305 if (
createDir(ts, fi, NULL,
"%{_topdir}")
306 ||
createDir(ts, fi, NULL,
"%{_builddir}")
308 ||
createDir(ts, fi, NULL,
"%{_srcrpmdir}")
309 ||
createDir(ts, fi, NULL,
"%{_sourcedir}")
310 ||
createDir(ts, fi, NULL,
"%{_specdir}"))
312 if (
createDir(ts, NULL, NULL,
"%{_topdir}")
313 ||
createDir(ts, NULL, NULL,
"%{_builddir}")
314 ||
createDir(ts, NULL, NULL,
"%{_rpmdir}")
315 ||
createDir(ts, NULL, NULL,
"%{_srcrpmdir}")
316 ||
createDir(ts, NULL, NULL,
"%{_sourcedir}")
317 ||
createDir(ts, NULL, NULL,
"%{_specdir}"))
338 if (*specFilePtr == NULL) {
353 if (specFilePtr) *specFilePtr =
_free(*specFilePtr);
354 if (cookie) *cookie =
_free(*cookie);
380 "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin";
409 return "%unknownscript";
451 const rpmts ts = psm->ts;
455 msecs = psm->sq.op.usecs/1000;
459 D_(
"%s: waitpid(%d) rc %d status %x secs %u.%03u\n"),
460 psm->stepName, (
unsigned)psm->sq.child,
461 (
unsigned)psm->sq.reaped, psm->sq.status,
462 (
unsigned)msecs/1000, (
unsigned)msecs%1000);
464 if (psm->sstates != NULL)
467 *ssp |= (psm->sq.status & 0xffff);
471 return psm->sq.reaped;
487 const char *script,
int arg1,
int arg2)
503 for (i = 0; i < (int)Phe->
c && Phe->
p.
argv[i]; i++) {
523 xx =
snprintf(buf, BUFSIZ,
"%s(%s)", sln, psm->NVRA);
539 #if defined(_WITH_EMBEDDED)
540 static int enterChroot(
rpmpsm psm,
int * pwdFdnop,
int * rootFdnop)
544 const rpmts ts = psm->ts;
550 (*pwdFdnop) = open(
".", O_RDONLY, 0);
554 (*rootFdnop) = open(
"/", O_RDONLY, 0);
561 if (rootDir != NULL && strcmp(rootDir,
"/") && *rootDir ==
'/') {
575 static int exitChroot(
rpmpsm psm,
int inChroot,
int pwdFdno,
int rootFdno)
579 const rpmts ts = psm->ts;
584 xx = fchdir(rootFdno);
586 if (rootDir != NULL && strcmp(rootDir,
"/") && *rootDir ==
'/') {
591 xx = fchdir(pwdFdno);
593 xx = fchdir(pwdFdno);
595 xx = close(rootFdno);
613 const char *script,
int arg1,
int arg2,
ARGV_t matches)
623 int inChroot = enterChroot(psm, &pwdFdno, &rootFdno);
624 size_t len = 4 + (matches ?
argvCount(matches) : 0);
626 if (psm->sstates != NULL)
627 ssp = psm->sstates +
tag2slx(psm->scriptTag);
631 av =
alloca(len *
sizeof(*av));
633 (void) sprintf((av[1] = (
char *)
alloca(32)),
"%d", arg1);
637 (void) sprintf((av[2] = (
char *)
alloca(32)),
"%d", arg2);
645 #if defined(WITH_LUA)
646 if (!strcmp(Phe->
p.
argv[0],
"<lua>")) {
647 rc = runLuaScript(psm, sln, Phe, script, arg1, arg2);
650 #if defined(WITH_AUGEAS)
651 if (!strcmp(Phe->
p.
argv[0],
"<augeas>")) {
654 rc = rpmaugRun(aug, script, NULL) ==
RPMRC_OK
656 aug = rpmaugFree(aug);
659 #if defined(WITH_FICL)
660 if (!strcmp(Phe->
p.
argv[0],
"<ficl>")) {
661 rpmficl ficl = rpmficlNew((
char **)av, 0);
662 rc = rpmficlRun(ficl, script, NULL) ==
RPMRC_OK
664 ficl = rpmficlFree(ficl);
667 #if defined(WITH_GPSEE)
668 if (!strcmp(Phe->
p.
argv[0],
"<js>")) {
675 #if defined(WITH_PERLEMBED)
676 if (!strcmp(Phe->
p.
argv[0],
"<perl>")) {
683 #if defined(WITH_PYTHONEMBED)
684 if (!strcmp(Phe->
p.
argv[0],
"<python>")) {
691 #if defined(WITH_RUBY)
692 if (!strcmp(Phe->
p.
argv[0],
"<ruby>")) {
699 #if defined(WITH_SEMANAGE)
700 if (!strcmp(Phe->
p.
argv[0],
"<spook>")) {
707 rc = rpmsmRun(sm, (
char **)av, NULL) ==
RPMRC_OK
712 #if defined(WITH_SQLITE)
713 if (!strcmp(Phe->
p.
argv[0],
"<sql>")) {
715 const char ** Pav = (
const char **)
xmalloc((Pac + 1) *
sizeof(*Pav));
716 const char * result = NULL;
722 for (i = 0; i < Pac; i++)
733 #if defined(WITH_SQUIRREL)
734 if (!strcmp(Phe->
p.
argv[0],
"<squirrel>")) {
741 #if defined(WITH_TCL)
742 if (!strcmp(Phe->
p.
argv[0],
"<tcl>")) {
753 *ssp |= (xx & 0xffff);
757 xx = exitChroot(psm, inChroot, pwdFdno, rootFdno);
788 const char * script,
int arg1,
int arg2,
ARGV_t matches)
794 const rpmts ts = psm->ts;
795 const char * NVRA = psm->NVRA;
796 HE_t IPhe = psm->IPhe;
797 const char ** argv = NULL;
799 const char **
IP = NULL;
801 size_t maxPrefixLength;
803 char * prefixBuf = NULL;
804 const char * fn = NULL;
805 FD_t scriptFd = NULL;
808 const char * body = NULL;
810 int ix =
tag2slx(psm->scriptTag);
817 ssp = psm->sstates + ix;
821 if (Phe->
p.
argv == NULL && script == NULL)
832 assert(he->
p.
str != NULL);
833 psm->NVRA = NVRA = he->
p.
str;
840 if (!strcmp(Phe->
p.
argv[0],
"<lua>")
841 || !strcmp(Phe->
p.
argv[0],
"<augeas>")
842 || !strcmp(Phe->
p.
argv[0],
"<ficl>")
843 || !strcmp(Phe->
p.
argv[0],
"<js>")
844 || !strcmp(Phe->
p.
argv[0],
"<perl>")
845 || !strcmp(Phe->
p.
argv[0],
"<python>")
846 || !strcmp(Phe->
p.
argv[0],
"<ruby>")
847 || !strcmp(Phe->
p.
argv[0],
"<sql>")
848 || !strcmp(Phe->
p.
argv[0],
"<squirrel>")
849 || !strcmp(Phe->
p.
argv[0],
"<tcl>"))
851 #if defined(_WITH_EMBEDDED)
853 D_(
"%s: %s(%s) running %s scriptlet.\n"),
854 psm->stepName,
tag2sln(psm->scriptTag), NVRA, Phe->
p.
argv[0]);
855 rc = runEmbeddedScript(psm, sln, Phe, body, arg1, arg2, matches);
865 if (ldconfig_path && Phe->
p.
argv != NULL &&
F_ISSET(psm, UNORDERED)) {
866 if (ldconfig_done && !strcmp(Phe->
p.
argv[0], ldconfig_path)) {
868 D_(
"%s: %s(%s) skipping redundant \"%s\".\n"),
869 psm->stepName,
tag2sln(psm->scriptTag), NVRA,
877 D_(
"%s: %s(%s) %ssynchronous scriptlet start\n"),
878 psm->stepName,
tag2sln(psm->scriptTag), NVRA,
879 (
F_ISSET(psm, UNORDERED) ?
"a" :
""));
881 if (Phe->
p.
argv == NULL) {
882 argv =
alloca(5 + (matches ?
argvCount(matches) : 0 ) *
sizeof(*argv));
887 argv =
alloca((Phe->
c + 4) + (matches ? argvCount(matches) : 0 ) *
sizeof(*argv));
888 memcpy(argv, Phe->
p.
argv, Phe->
c *
sizeof(*argv));
890 ldconfig_done = (ldconfig_path && !strcmp(argv[0], ldconfig_path)
895 if (IPhe->
tag == 0) {
903 const char ** av = (
const char **)
905 char * t = (
char *) &av[1];
925 for (i = 0; i < nIP; i++) {
927 if (len > maxPrefixLength) maxPrefixLength = len;
929 prefixBuf = (
char *)
alloca(maxPrefixLength + 50);
940 (!strcmp(argv[0],
"/bin/sh") || !strcmp(argv[0],
"/bin/bash")))
942 static const char set_x[] =
"set -x\n";
943 nw =
Fwrite(set_x,
sizeof(set_x[0]),
sizeof(set_x)-1, fd);
946 if (ldconfig_path && strstr(body, ldconfig_path) != NULL)
949 nw =
Fwrite(body,
sizeof(body[0]), strlen(body), fd);
952 {
const char * sn = fn;
954 !(rootDir[0] ==
'/' && rootDir[1] ==
'\0'))
956 sn += strlen(rootDir)-1;
962 char *av = (
char *)
alloca(20);
963 sprintf(av,
"%d", arg1);
967 char *av = (
char *)
alloca(20);
968 sprintf(av,
"%d", arg2);
980 switch (psm->scriptTag) {
998 if (scriptFd != NULL) {
1002 out =
Fopen(
"/dev/null",
"w.fdio");
1008 out =
fdDup(STDOUT_FILENO);
1014 if (psm->sq.child == 0) {
1019 pipes[0] = pipes[1] = 0;
1022 xx = close(pipes[1]);
1023 xx = dup2(pipes[0], STDIN_FILENO);
1024 xx = close(pipes[0]);
1027 for (fdno = 3; fdno < 100; fdno++) {
1028 flag = fcntl(fdno, F_GETFD);
1029 if (flag == -1 || (flag & FD_CLOEXEC))
1032 D_(
"%s: %s(%s)\tfdno(%d) missing FD_CLOEXEC\n"),
1033 psm->stepName, sln, NVRA,
1035 xx = fcntl(fdno, F_SETFD, FD_CLOEXEC);
1039 if (scriptFd != NULL) {
1040 int sfdno =
Fileno(scriptFd);
1042 if (sfdno != STDERR_FILENO)
1043 xx = dup2(sfdno, STDERR_FILENO);
1044 if (ofdno != STDOUT_FILENO)
1045 xx = dup2(ofdno, STDOUT_FILENO);
1047 if (ofdno > STDERR_FILENO && ofdno != sfdno)
1049 if (sfdno > STDERR_FILENO && ofdno != sfdno)
1053 {
const char *ipath =
rpmExpand(
"PATH=%{_install_script_path}", NULL);
1056 if (ipath && ipath[5] !=
'%')
1061 ipath =
_free(ipath);
1066 for (i = 0; i < nIP; i++) {
1067 sprintf(prefixBuf,
"RPM_INSTALL_PREFIX%d=%s", i, IP[i]);
1072 sprintf(prefixBuf,
"RPM_INSTALL_PREFIX=%s", IP[i]);
1079 !(rootDir[0] ==
'/' && rootDir[1] ==
'\0'))
1087 psm->stepName, sln, NVRA,
1088 argv[0], (
unsigned)getpid());
1103 xx = execv(argv[0], (
char *
const *)argv);
1115 if (psm->sq.child == (pid_t)-1) {
1123 if (!(psm->sq.reaped >= 0 && !strcmp(argv[0],
"/usr/sbin/glibc_post_upgrade") && WEXITSTATUS(psm->sq.status) == 110)) {
1125 if (psm->sq.reaped < 0) {
1127 _(
"%s(%s) scriptlet failed, waitpid(%d) rc %d: %s\n"),
1128 sln, NVRA, (
int)psm->sq.child, (
int)psm->sq.reaped,
1132 if (!WIFEXITED(psm->sq.status) || WEXITSTATUS(psm->sq.status)) {
1133 if (WIFSIGNALED(psm->sq.status)) {
1135 psm->scriptTag, WTERMSIG(psm->sq.status));
1137 _(
"%s(%s) scriptlet failed, signal %d\n"),
1138 sln, NVRA, WTERMSIG(psm->sq.status));
1141 psm->scriptTag, WEXITSTATUS(psm->sq.status));
1143 _(
"%s(%s) scriptlet failed, exit status %d\n"),
1144 sln, NVRA, WEXITSTATUS(psm->sq.status));
1154 static unsigned int scale = 1000;
1157 psm->smetrics[ix] += op->
usecs / scale;
1186 const char * argv0 = NULL;
1189 assert(fi->h != NULL);
1190 She->
tag = psm->scriptTag;
1194 Phe->
tag = psm->progTag;
1200 const char * s = Phe->
p.
str;
1202 Phe->
p.
argv = (
const char **)
1204 Phe->
p.
argv[0] = t = (
char *) &Phe->
p.
argv[1];
1211 if (Phe->
p.
argv[0][0] ==
'%')
1215 She->
p.
str, psm->scriptArg, -1, NULL);
1218 argv0 =
_free(argv0);
1241 static int scareMem = 0;
1247 const rpmts ts = psm->ts;
1252 const char * sourceName;
1253 const char * triggerName;
1261 sourceName = he->
p.
str;
1265 triggerName = he->
p.
str;
1273 arg1 += psm->countCorrection;
1300 if (!(Flags & psm->sense))
1304 depName = (
char *)
rpmdsN(Tds);
1305 if (depName[0] ==
'^' || depName[0] ==
'/') {
1306 size_t nb = strlen(depName);
1325 const char * N =
rpmdsN(ds);
1364 {
int index = Ihe->
p.
ui32p[i];
1365 const char * s = Phe->
p.
argv[index];
1371 he->
p.
argv = (
const char **)
1377 if (
runScript(psm, triggeredH,
"%trigger", he,
1378 She->
p.
argv[index], arg1, arg2, matches))
1400 triggerName =
_free(triggerName);
1401 sourceName =
_free(sourceName);
1411 const rpmts ts = psm->ts;
1419 for (i = 0; i < nkeys; i++) {
1420 char * t = (
char *) keys[i];
1424 (
miRE *)&psm->Tmires, &psm->nTmires);
1444 static int scareMem = 0;
1445 const rpmts ts = psm->ts;
1448 char * depName = NULL;
1459 const char * Name =
rpmdsN(ds);
1460 size_t nName = strlen(Name);
1461 unsigned prev, instance;
1465 depName =
_free(depName);
1466 if (!strcmp(Name,
"/"))
1469 depName =
xmalloc(nName + 1 + 1);
1470 (void)
stpcpy(depName, Name);
1473 depName[nName+1] =
'\0';
1476 if (depName[0] ==
'/' && psm->Tmires != NULL) {
1481 for (j = 0, mire = (
miRE)psm->Tmires; j < psm->nTmires; j++, mire++) {
1482 const char * pattern = psm->Tpats[j];
1483 if (depName[nName-1] !=
'/') {
1484 size_t npattern = strlen(pattern);
1485 depName[nName] =
PATT_ISDIR(pattern, npattern) ?
'/' :
'\0';
1491 depName =
_free(depName);
1503 xx =
rpmmiPrune(mi, (uint32_t *)vals, nvals, 1);
1506 while((triggeredH =
rpmmiNext(mi)) != NULL) {
1508 if (prev == instance)
1513 xx =
argiAdd(&instances, -1, instance);
1521 depName =
_free(depName);
1539 const rpmts ts = psm->ts;
1546 if (_trigger_tag == 0) {
1547 const char * t =
rpmExpand(
"%{?_trigger_tag}", NULL);
1555 assert(psm->te != NULL);
1556 {
const char * N =
rpmteN(psm->te);
1559 numPackage += psm->countCorrection;
1564 assert(fi->h != NULL);
1567 {
int countCorrection = psm->countCorrection;
1569 psm->countCorrection = 0;
1591 psm->countCorrection = countCorrection;
1609 const rpmts ts = psm->ts;
1611 rpmds triggers = NULL;
1622 assert(fi->h != NULL);
1625 if (_trigger_tag == 0) {
1626 const char * t =
rpmExpand(
"%{?_trigger_tag}", NULL);
1635 triggers =
rpmdsLink(psm->triggers,
"ImmedTriggers");
1637 if (triggers == NULL)
1642 if (!(xx && Ihe->
p.
ui32p && Ihe->
c))
goto exit;
1646 if (triggers != NULL)
1647 while ((i =
rpmdsNext(triggers)) >= 0) {
1649 const char * N =
rpmdsN(triggers);
1650 const char * EVR =
rpmdsEVR(triggers);
1653 if (!(Flags & psm->sense))
1658 size_t nb = strlen(N);
1660 if (N[0] ==
'^' || N[0] ==
'/')
1664 if ((EVR == NULL || *EVR ==
'\0') && (N[0] ==
'^' ||
Glob_pattern_p(N, 0)))
1674 for (i = 0; (Name = keys[i]) != NULL; i++) {
1675 unsigned prev, instance;
1681 size_t nb = strlen(Name);
1683 if (Name[0] ==
'^' || Name[0] ==
'/')
1693 xx =
rpmmiPrune(mi, (uint32_t *)vals, nvals, 1);
1696 while((sourceH =
rpmmiNext(mi)) != NULL) {
1700 if (prev == instance)
1708 xx =
argiAdd(&instances, -1, instance);
1758 default:
return "???";
1765 assert(psm != NULL);
1767 psm->unorderedSuccessor = async;
1770 F_SET(psm, UNORDERED);
1772 F_CLR(psm, UNORDERED);
1778 assert(psm != NULL);
1779 psm->scriptTag = scriptTag;
1780 psm->progTag = progTag;
1782 switch (scriptTag) {
1810 psm->IPhe->p.ptr =
_free(psm->IPhe->p.ptr);
1811 psm->IPhe =
_free(psm->IPhe);
1812 psm->NVRA =
_free(psm->NVRA);
1814 psm->triggers = NULL;
1828 if (_psmPool == NULL) {
1834 memset(((
char *)psm)+
sizeof(psm->_item), 0,
sizeof(*psm)-
sizeof(psm->_item));
1840 static const char msg[] =
"rpmpsmNew";
1846 if (te) psm->te = rpmteLink(te, msg);
1849 if (te) psm->te = te;
1855 psm->triggers = NULL;
1857 psm->IPhe = (
HE_t)
xcalloc(1,
sizeof(*psm->IPhe));
1858 memset(psm->sstates, 0,
sizeof(psm->sstates));
1859 memset(psm->smetrics, 0,
sizeof(psm->smetrics));
1929 he->
p.
argv = &chain_end;
1941 he->
p.
argv = &chain_end;
1953 he->
p.
argv = &chain_end;
1988 he->
p.
argv = &chain_end;
2003 he->
p.
argv = &chain_end;
2018 he->
p.
argv = &chain_end;
2047 assert(fi->h != NULL);
2049 {
struct timeval tv;
2050 xx = gettimeofday(&tv, NULL);
2056 he->
p.
ui32p = &installTime[0];
2062 memcpy(originTime, uip,
sizeof(originTime));
2063 if (originTime[0] == 0)
2064 memcpy(originTime, installTime,
sizeof(originTime));
2067 he->
p.
ui32p = originTime;
2072 memcpy(originTid, uip,
sizeof(originTid));
2073 if (originTid[0] == 0)
2074 memcpy(originTid, ts->tid,
sizeof(originTid));
2108 if (digest != NULL) {
2121 if (st->st_mode == 0 && st->st_mtime == 0 && st->st_size == 0)
2124 if (st->st_mode != 0) {
2127 he->
p.
ptr = (
void *)st;
2160 he->
p.
ui32p = psm->sstates;
2165 he->
p.
ui32p = psm->smetrics;
2170 if (fi->fstates != NULL && fc > 0) {
2173 he->
p.
ui8p = fi->fstates;
2181 #if defined(WITH_PTHREADS)
2182 static void * rpmpsmThread(
void * _psm)
2197 psm->nstage = nstage;
2198 #if defined(WITH_PTHREADS)
2213 const rpmts ts = psm->ts;
2219 int non_pre_scripts_dont_fail = 0;
2220 #if defined(RPM_VENDOR_MANDRIVA)
2221 non_pre_scripts_dont_fail =
rpmExpandNumeric(
"%{?_legacy_compat_non_pre_scripts_dont_fail}");
2226 if (fi->h == NULL && fi->te && ((
rpmte)fi->te)->h != NULL) fi->h =
headerLink(((
rpmte)fi->te)->h);
2243 if (psm->npkgs_installed < 0) {
2249 assert(psm->te != NULL);
2253 if (psm->te->downgrade)
2254 psm->npkgs_installed--;
2264 psm->scriptArg = psm->npkgs_installed + 1;
2266 assert(psm->mi == NULL);
2268 if (hdrid != NULL) {
2279 #ifdef RPM_VENDOR_MANDRIVA
2291 while ((psm->oh =
rpmmiNext(psm->mi)) != NULL) {
2301 if (fi->fstates == NULL && fc > 0) {
2306 xx = rpmtxnBegin(
rpmtsGetRdb(ts), ts->txn, &psm->te->txn);
2318 fi->striplen = (xx && he->
p.
str ? strlen(he->
p.
str) + 1 : 1);
2328 assert(he->
p.
argv != NULL);
2329 fi->apath = he->
p.
argv;
2331 if (fi->fuser == NULL) {
2334 fi->fuser = he->
p.
argv;
2336 if (fi->fgroup == NULL) {
2339 fi->fgroup = he->
p.
argv;
2344 psm->scriptArg = psm->npkgs_installed - 1;
2348 xx = rpmtxnBegin(
rpmtsGetRdb(ts), ts->txn, &psm->te->txn);
2364 bfmt =
rpmGetPath(tiddn,
"/",
"%{_repackage_name_fmt}", NULL);
2368 psm->pkgURL =
rpmGenPath(
"%{?_repackage_root}",
2369 "%{?_repackage_dir}",
2371 pkgbn =
_free(pkgbn);
2372 (void)
urlPath(psm->pkgURL, &psm->pkgfn);
2373 pkgdn_buf =
xstrdup(psm->pkgfn);
2375 pkgdn = dirname(pkgdn_buf);
2378 pkgdn_buf =
_free(pkgdn_buf);
2381 psm->fd =
Fopen(psm->pkgfn,
"w.fdio");
2382 if (psm->fd == NULL ||
Ferror(psm->fd)) {
2390 if (
rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)
break;
2394 {
static int oneshot = 0;
2409 psm->sense = RPMSENSE_TRIGGERPREIN;
2410 psm->countCorrection = 0;
2427 _(
"%s: %s scriptlet failed (%d), skipping %s\n"),
2428 psm->stepName,
tag2sln(psm->scriptTag), rc,
2438 psm->sense = RPMSENSE_TRIGGERUN;
2439 psm->countCorrection = -1;
2444 if(rc && !non_pre_scripts_dont_fail)
break;
2448 if(rc && !non_pre_scripts_dont_fail)
break;
2455 int noArchiveSize = 0;
2456 const char * origin = NULL;
2457 const char * digest = NULL;
2458 const struct stat * st = NULL;
2459 size_t nstbytes = 0;
2470 if (xx && he->
p.
str != NULL)
2474 if (xx && he->
p.
ptr != NULL && (
size_t)he->
c ==
sizeof(*st)) {
2475 st = (
struct stat *) he->
p.
ptr;
2483 if (xx && uh != NULL) {
2490 if (xx && uh != NULL) {
2524 {
static const char item[] =
"Lead";
2531 void * l = memset(
alloca(nb), 0, nb);
2543 {
static const char item[] =
"Signature";
2561 if (psm->oh != NULL)
2571 if (origin != NULL) {
2577 origin =
_free(origin);
2579 if (digest != NULL) {
2585 digest =
_free(digest);
2590 he->
p.
ptr = (
void *)st;
2602 assert(psm->te != NULL);
2607 {
const char item[] =
"Header";
2608 const char * msg = NULL;
2612 (msg && *msg ? msg :
"write failed\n"));
2619 if (
rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)
break;
2644 if (psm->cfd == NULL) {
2649 xx = rpmtxnBegin(
rpmtsGetRdb(ts), psm->te->txn, NULL);
2652 ts, fi, psm->cfd, NULL, &psm->failedFile);
2672 rpmtxn _txn = (db ? db->db_txn : NULL);
2675 xx = rpmtxnAbort(_txn);
2677 xx = rpmtxnCommit(_txn);
2684 psm->amount = (fi->archiveSize ? fi->archiveSize : 100);
2685 psm->total = psm->amount;
2691 _(
"unpacking of archive failed%s%s: %s\n"),
2692 (psm->failedFile != NULL ?
_(
" on file ") :
""),
2693 (psm->failedFile != NULL ? psm->failedFile :
""),
2715 psm->total = (fc ? fc : 100);
2720 ts, fi, NULL, NULL, &psm->failedFile);
2725 psm->amount = (fc ? fc : 100);
2726 psm->total = (fc ? fc : 100);
2737 if (psm->fd == NULL) {
2745 if (psm->cfd == NULL) {
2751 ts, fi, psm->cfd, NULL, &psm->failedFile);
2767 psm->amount = (fi->archiveSize ? fi->archiveSize : 100);
2768 psm->total = psm->amount;
2771 fi->action = (int) action;
2772 fi->actions = (
int *) actions;
2782 psm->sense = RPMSENSE_TRIGGERIN;
2783 psm->countCorrection = 0;
2787 if(rc && !non_pre_scripts_dont_fail)
break;
2792 if(rc && !non_pre_scripts_dont_fail)
break;
2796 if(rc && !non_pre_scripts_dont_fail)
break;
2816 rc = markReplacedFiles(psm);
2824 psm->sense = RPMSENSE_TRIGGERPOSTUN;
2825 psm->countCorrection = -1;
2829 if(rc && !non_pre_scripts_dont_fail)
break;
2835 if(rc && !non_pre_scripts_dont_fail)
break;
2839 if(rc && !non_pre_scripts_dont_fail)
break;
2857 if (psm->fd != NULL) {
2867 if (!rc && ts && ts->notify == NULL) {
2869 (psm->pkgURL ? psm->pkgURL :
"???"));
2875 if (psm->failedFile)
2877 _(
"%s failed on file %s: %s\n"),
2878 psm->stepName, psm->failedFile, msg);
2881 psm->stepName, msg);
2891 if (psm->te->txn != NULL) {
2892 xx = rpmtxnAbort(psm->te->txn);
2893 psm->te->txn = NULL;
2896 if (psm->te->txn != NULL) {
2897 xx = rpmtxnCommit(psm->te->txn);
2898 psm->te->txn = NULL;
2903 if (psm->te != NULL)
2905 if (fi->h != NULL) {
2912 psm->pkgURL =
_free(psm->pkgURL);
2913 psm->rpmio_flags =
_free(psm->rpmio_flags);
2914 psm->payload_format =
_free(psm->payload_format);
2915 psm->failedFile =
_free(psm->failedFile);
2917 fi->fgroup =
_free(fi->fgroup);
2918 fi->fuser =
_free(fi->fuser);
2919 fi->apath =
_free(fi->apath);
2920 fi->fstates =
_free(fi->fstates);
2944 ptr =
rpmtsNotify(ts, psm->te, psm->what, psm->amount, psm->total);
2954 ts, fi, NULL, NULL, &psm->failedFile);
2961 if (rootDir != NULL && !(rootDir[0] ==
'/' && rootDir[1] ==
'\0')
2964 static int _pw_loaded = 0;
2965 static int _gr_loaded = 0;
2968 (void)getpwnam(
"root");
2973 (void)getgrnam(
"root");
2980 if (rootDir != NULL && strcmp(rootDir,
"/") && *rootDir ==
'/')
2983 F_SET(psm, CHROOTDONE);
2989 if (
F_ISSET(psm, CHROOTDONE)) {
2993 if (rootDir != NULL && strcmp(rootDir,
"/") && *rootDir ==
'/')
2996 F_CLR(psm, CHROOTDONE);
2998 if (currDir != NULL)
2999 xx =
Chdir(currDir);
3004 { rpmtxn _parent = (psm && psm->te ? psm->te->txn : NULL);
3015 if (
rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)
break;
3020 if (
rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)
break;
3021 if (!
F_ISSET(psm, GOTTRIGGERS)) {
3023 F_SET(psm, GOTTRIGGERS);
3025 if (psm->triggers != NULL)
3030 {
const char * payload_compressor = NULL;
3031 const char * payload_format = NULL;
3036 payload_compressor = he->
p.
str;
3037 if (payload_compressor == NULL)
3038 payload_compressor =
xstrdup(
"gzip");
3040 psm->rpmio_flags = t = (
char *)
xmalloc(
sizeof(
"w9.gzdio"));
3043 if (!strcmp(payload_compressor,
"gzip"))
3045 if (!strcmp(payload_compressor,
"bzip2"))
3047 if (!strcmp(payload_compressor,
"lzma"))
3049 if (!strcmp(payload_compressor,
"xz"))
3051 payload_compressor =
_free(payload_compressor);
3055 payload_format = he->
p.
str;
3056 if (!xx || payload_format == NULL || !(
3057 !strcmp(payload_format,
"tar") || !strcmp(payload_format,
"ustar")
3058 #
if defined(SUPPORT_AR_PAYLOADS)
3059 || !strcmp(payload_format,
"ar")
3063 payload_format =
_free(payload_format);
3064 payload_format =
xstrdup(
"cpio");
3066 psm->payload_format =
_free(psm->payload_format);
3067 psm->payload_format = payload_format;
3072 assert(psm->mi == NULL);
3074 &fi->record,
sizeof(fi->record));
3082 if (fi->h != NULL) {
3091 if (fi->isSource)
break;
3092 if (fi->h == NULL)
break;
3094 xx = rpmtxnBegin(
rpmtsGetRdb(ts), psm->te->txn, NULL);
3106 #if defined(HAVE_SYSLOG_H) && defined(RPM_VENDOR_MANDRIVA)
3112 syslog(LOG_NOTICE,
"[RPM] %s installed\n", s);
3127 assert(psm->te != NULL);
3130 psm->te->installed = 1;
3138 if (
rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)
break;
3141 xx = rpmtxnBegin(
rpmtsGetRdb(ts), psm->te->txn, NULL);
3146 #if defined(HAVE_SYSLOG_H) && defined(RPM_VENDOR_MANDRIVA)
3152 syslog(LOG_NOTICE,
"[RPM] %s removed\n", s);
3167 if (psm->te != NULL)
3168 psm->te->u.removed.dboffset = 0;