17 #define _FPRINT_INTERNAL
20 #define _RPMDB_INTERNAL
24 #define _RPMFI_INTERNAL
28 #define _RPMTE_INTERNAL
30 #define _RPMTS_INTERNAL
33 #define _RPMSQ_INTERNAL
34 #define _RPMPSM_INTERNAL
43 #if defined(RPM_VENDOR_MANDRIVA)
44 #include "filetriggers.h"
48 #include <rpmrollback.h>
71 #if defined(RPM_VENDOR_MANDRIVA)
72 static int is_a_doc_conflict(
rpmfi fi)
74 const char *ignorelist[] = {
76 "/usr/share/gtk-doc/html/",
77 "/usr/share/gnome/html/",
82 for (dnp = ignorelist; *dnp != NULL; dnp++)
83 if (strstr(fn, *dnp) == fn)
return 1;
91 #define FF_ISSET(_fflags, _FLAG) ((_fflags) & (RPMFILE_##_FLAG))
93 #define QVA_ISSET(_qvaflags, _FLAG) ((_qvaflags) & (VERIFY_##_FLAG))
95 #define VSF_ISSET(_vsflags, _FLAG) ((_vsflags) & (RPMVSF_##_FLAG))
96 #define VSF_SET(_vsflags, _FLAG) \
97 (*((unsigned *)&(_vsflags)) |= (RPMVSF_##_FLAG))
98 #define VSF_CLR(_vsflags, _FLAG) \
99 (*((unsigned *)&(_vsflags)) &= ~(RPMVSF_##_FLAG))
101 #define TSF_ISSET(_tsflags, _FLAG) ((_tsflags) & (RPMTRANS_FLAG_##_FLAG))
102 #define TSF_SET(_tsflags, _FLAG) \
103 (*((unsigned *)&(_tsflags)) |= (RPMTRANS_FLAG_##_FLAG))
104 #define TSF_CLR(_tsflags, _FLAG) \
105 (*((unsigned *)&(_tsflags)) &= ~(RPMTRANS_FLAG_##_FLAG))
107 #define IIF_ISSET(_iflags, _FLAG) ((_iflags) & (INSTALL_##_FLAG))
108 #define IIF_SET(_iflags, _FLAG) \
109 (*((unsigned *)&(_iflags)) |= (INSTALL_##_FLAG))
110 #define IIF_CLR(_iflags, _FLAG) \
111 (*((unsigned *)&(_iflags)) &= ~(INSTALL_##_FLAG))
118 #define FF_ISSET(_fflags, _FLAG) ((_fflags) & (RPMFILE_##_FLAG))
120 #define QVA_ISSET(_qvaflags, _FLAG) ((_qvaflags) & (VERIFY_##_FLAG))
122 #define VSF_ISSET(_vsflags, _FLAG) ((_vsflags) & (RPMVSF_##_FLAG))
123 #define VSF_SET(_vsflags, _FLAG) (_vsflags) |= (RPMVSF_##_FLAG)
124 #define VSF_CLR(_vsflags, _FLAG) (_vsflags) &= ~(RPMVSF_##_FLAG)
126 #define TSF_ISSET(_tsflags, _FLAG) ((_tsflags) & (RPMTRANS_FLAG_##_FLAG))
127 #define TSF_SET(_tsflags, _FLAG) (_tsflags) |= (RPMTRANS_FLAG_##_FLAG)
128 #define TSF_CLR(_tsflags, _FLAG) (_tsflags) &= ~(RPMTRANS_FLAG_##_FLAG)
130 #define IIF_ISSET(_iflags, _FLAG) ((_iflags) & (INSTALL_##_FLAG))
131 #define IIF_SET(_iflags, _FLAG) (_iflags) |= (INSTALL_##_FLAG)
132 #define IIF_CLR(_iflags, _FLAG) (_iflags) &= ~(INSTALL_##_FLAG)
144 rpmfs fs = rpmteGetFileStates(p);
145 if (XFA_SKIPPING(rpmfsGetAction(fs, fx)))
156 rpm_color_t oFColor =
rpmfiFColor(otherFi) & tscolor;
167 if (tscolor != 0 && FColor != 0 && FColor != oFColor) {
168 if (oFColor & prefcolor) {
175 }
else if (FColor & prefcolor) {
185 #if defined(RPM_VENDOR_MANDRIVA)
189 if (rConflicts && is_a_doc_conflict(fi)) {
213 if ( !(isCfgFile || XFA_SKIPPING(rpmfsGetAction(fs, fx))) ) {
215 rpmfsAddReplaced(rpmteGetFileStates(p),
rpmfiFX(fi),
222 struct sharedFileInfo_s _shared;
224 p->replaced = (sharedFileInfo)
xrealloc(p->replaced,
225 sizeof(*p->replaced) * (p->nreplaced + 1));
226 memset(p->replaced + p->nreplaced, 0,
sizeof(*p->replaced));
228 _shared.pkgFileNum = fx;
229 _shared.otherFileNum =
rpmfiFX(otherFi);
231 _shared.isRemoved = 0;
232 p->replaced[p->nreplaced++] = _shared;
241 int skipMissing = (
TSF_ISSET(tsflags, ALLFILES) ? 0 : 1);
244 rpmfsSetAction(fs, fx, action);
250 rpmfiSetFReplacedSize(fi,
rpmfiFSize(otherFi));
258 #define ISROOT(_d) (((_d)[0] == '/' && (_d)[1] == '\0') ? "" : (_d))
262 #define FPSDEBUG(_debug, _list) if ((_debug) || _fps_debug) fprintf _list
272 uint32_t fixupSize = 0;
280 rpmfs fs = rpmteGetFileStates(p);
284 FPSDEBUG(0, (stderr,
"--> %s(%p,%p,%p)\n", __FUNCTION__, ts, p, fi));
292 int otherPkgNum, otherFileNum;
303 struct rpmffi_s **
recs;
331 (void) rpmFpHashGetEntry(ht, fiFps, &recs, &numRecs, NULL);
333 (void)
htGetEntry(ts->ht, fiFps, &recs, &numRecs, NULL);
357 for (j = 0; j < numRecs && recs[j]->p != p; j++) {
358 FPSDEBUG(0, (stderr,
"\trecs %p[%u:%u] te %p != %p\n", recs, (
unsigned)j, (
unsigned)numRecs, recs[j]->p, p));
360 FPSDEBUG(0, (stderr,
"*** got recs %p[%u:%u]\n", recs, (
unsigned)j, (
unsigned)numRecs));
370 for (otherPkgNum = j - 1; otherPkgNum >= 0; otherPkgNum--) {
371 FPSDEBUG(0, (stderr,
"\trecs %p[%u:%u] %p -> {%p,%d}\n", recs, (
unsigned)otherPkgNum, (
unsigned)numRecs, recs[otherPkgNum], recs[otherPkgNum]->p, recs[otherPkgNum]->fileno));
372 otherTe = recs[otherPkgNum]->p;
374 otherFileNum = recs[otherPkgNum]->fileno;
376 otherFs = rpmteGetFileStates(otherTe);
386 if (otherFi->actions[otherFileNum] !=
FA_UNKNOWN)
395 {
int reportConflicts =
399 if (otherPkgNum < 0) {
405 if (rpmfiConfigConflict(fi))
411 action =
FF_ISSET(FFlags, NOREPLACE)
417 rpmfsSetAction(fs, i, action);
419 fi->actions[i] = action;
424 assert(otherFi != NULL);
429 rConflicts = reportConflicts;
432 if (FColor & prefcolor) {
437 if (strcmp(fn,
"/usr/sbin/libgcc_post_upgrade")
438 && strcmp(fn,
"/usr/sbin/glibc_post_upgrade"))
445 if (oFColor & prefcolor) {
448 otherFi->actions[otherFileNum] =
FA_CREATE;
452 if (FColor == 0 && oFColor == 0) {
454 otherFi->actions[otherFileNum] =
FA_CREATE;
461 #if defined(RPM_VENDOR_MANDRIVA)
465 if (rConflicts && is_a_doc_conflict(fi)) {
485 if (rpmfiConfigConflict(fi))
491 fi->actions[i] =
FF_ISSET(FFlags, NOREPLACE)
500 if (otherPkgNum >= 0) {
501 assert(otherFi != NULL);
503 if (otherFi->actions[otherFileNum] !=
FA_ERASE) {
509 otherFi->actions[otherFileNum] =
FA_SKIP;
518 if (!(S_ISREG(FMode) &&
FF_ISSET(FFlags, CONFIG)))
525 const unsigned char * digest =
rpmfiDigest(fi, &dalgo, &dlen);
526 unsigned char * fdigest;
527 assert(digest != NULL);
529 fdigest = (
unsigned char *)
xcalloc(1, dlen);
531 if (!
dodigest(dalgo, fn, fdigest, 0, NULL)
532 && memcmp(digest, fdigest, dlen))
534 fdigest =
_free(fdigest);
542 rpmfiFReplacedSize(fi), fixupSize, rpmfsGetAction(fs, i));
545 fi->replacedSizes[i], fixupSize, fi->actions[i]);
573 FPSDEBUG(0, (stderr,
"--> %s(%p,%p,%p)\n", __FUNCTION__, ts, p, h));
574 if (p == NULL || h == NULL)
578 #ifdef RPM_VENDOR_MANDRIVA
588 #ifdef RPM_VENDOR_MANDRIVA
601 assert(he->
p.
str != NULL);
631 int noConfigs =
TSF_ISSET(tsflags, NOCONFIGS);
633 ARGV_t netsharedPaths = NULL;
635 const char * dn, * bn;
645 FPSDEBUG(0, (stderr,
"--> %s(%p,%p)\n", __FUNCTION__, ts, fi));
646 #if defined(RPM_VENDOR_OPENPKG)
657 {
const char *tmpPath =
rpmExpand(
"%{?_netsharedpath}", NULL);
658 if (tmpPath && *tmpPath)
659 xx =
argvSplit(&netsharedPaths, tmpPath,
":");
660 tmpPath =
_free(tmpPath);
663 s =
rpmExpand(
"%{?_install_langs}", NULL);
673 drc = (
int *)
alloca(dc *
sizeof(*drc));
674 memset(drc, 0, dc *
sizeof(*drc));
675 dff = (
char *)
alloca(dc *
sizeof(*dff));
676 memset(dff, 0, dc *
sizeof(*dff));
696 drc[ix]--; dff[ix] = 1;
702 if (tscolor && FColor && !(tscolor & FColor)) {
703 drc[ix]--; dff[ix] = 1;
713 for (nsp = netsharedPaths; nsp && *nsp; nsp++) {
718 if (strncmp(dn, *nsp, len))
721 if (!(dn[len] ==
'/' || dn[len] ==
'\0'))
724 if (len < (dnlen + bnlen))
726 if (strncmp(dn, *nsp, dnlen))
729 if ((s = strchr((*nsp) + dnlen,
'/')) != NULL && s[1] !=
'\0')
731 if (strncmp(bn, (*nsp) + dnlen, bnlen))
735 if (!((*nsp)[len] ==
'/' || (*nsp)[len] ==
'\0'))
743 drc[ix]--; dff[ix] = 1;
751 if (languages != NULL && fi->flangs != NULL && *fi->flangs[i]) {
754 for (lang = languages; *lang != NULL; lang++) {
755 if (!strcmp(*lang,
"all"))
757 for (l = fi->flangs[i]; *l !=
'\0'; l = le) {
758 for (le = l; *le !=
'\0' && *le !=
'|'; le++)
760 if ((le-l) > 0 && !strncmp(*lang, l, (le-l)))
762 if (*le ==
'|') le++;
768 drc[ix]--; dff[ix] = 1;
778 drc[ix]--; dff[ix] = 1;
787 drc[ix]--; dff[ix] = 1;
796 for (j = 0; j <
dc; j++)
803 if (drc[j])
continue;
804 if (!dff[j])
continue;
807 dn = fi->dnl[j]; dnlen = strlen(dn) - 1;
808 bn = dn + dnlen; bnlen = 0;
809 while (bn > dn && bn[-1] !=
'/') {
819 const char * fdn, * fbn;
827 if (!S_ISDIR(fFMode))
830 if (strlen(fdn) != dnlen)
832 if (strncmp(fdn, dn, dnlen))
835 if (strlen(fbn) != bnlen)
837 if (strncmp(fbn, bn, bnlen))
846 netsharedPaths =
argvFree(netsharedPaths);
865 if (tsi != NULL && tsi->ocsave != -1) {
869 if (te != NULL && (fi = te->fi) != NULL)
890 if (AV != NULL && B != NULL)
891 for (a = AV; *a != NULL; a++) {
892 if (**a && *B && !strcmp(*a, B))
932 q->linkFailed = p->linkFailed;
961 size_t n = (fileCount > 10 ? fileCount : 10);
962 static double e = 1.0e-4;
967 FPSDEBUG(0, (stderr,
"--> %s(%p,%u)\n", __FUNCTION__, ts, (
unsigned)fileCount));
968 rpmbfParams(n, e, &m, &k);
969 bf = rpmbfNew(m, k, 0);
978 if ((fi =
rpmteFI(p, _tag)) == NULL)
992 if (rpmbfChk(bf, s, ns))
997 xx = rpmbfAdd(bf, s, ns);
1032 const char * oldDir;
1034 rpmfi otherFi = NULL;
1035 unsigned int fileNum;
1039 FPSDEBUG(0, (stderr,
"--> %s(%p,%u,%p,%p)\n", __FUNCTION__, ts, (
unsigned)fileCount, ht, fpc));
1059 if (ts->removedPackages != NULL)
1060 for (j = 0; j < ts->numRemovedPackages; j++) {
1061 if (ts->removedPackages[j] != hdrNum)
1070 fc = (xx ? he->
c : 0);
1080 FSTATES.
ui8p = (xx ? he->
p.
ui8p : NULL);
1084 for (i = 0; i < (int)fc; i++) {
1085 const char * baseName = BN.
argv[i];
1088 struct rpmffi_s **
recs;
1093 if (baseKey != tagNum)
1099 if (dirName == oldDir) {
1103 fp =
fpLookup(fpc, dirName, baseName, 1);
1111 gotRecs = rpmFpHashGetEntry(ht, &fp, &recs, &numRecs, NULL);
1113 gotRecs = (
htGetEntry(ts->ht, &fp, &recs, &numRecs, NULL) == 0);
1116 for (j = 0; j < numRecs && gotRecs; j++) {
1123 if (otherFi == NULL) {
1124 static int scareMem = 0;
1132 if (!beingRemoved) {
1136 rpmfs fs = rpmteGetFileStates(p);
1137 rpmfsSetAction(fs, recs[j].fileno,
FA_SKIP);
1141 fi->actions[recs[j]->fileno] =
FA_SKIP;
1175 uint32_t totalFileCount = 0;
1178 FPSDEBUG(0, (stderr,
"--> %s(%p,%p)\n", __FUNCTION__, ts, tfcp));
1187 if (p->isSource)
continue;
1194 if (!archOkay(
rpmteA(p)))
1230 for (t = 0; t < 2; t++) {
1231 for (i = 0; i < nkeys; i++) {
1236 const char *val = NULL;
1241 if (val ? atoi(val) : 0 != he->
p.
ui32p ? *(he->
p.
ui32p) : 0)
1245 if (strcmp(he->
p.
str ? he->
p.
str :
"", val ? val :
""))
1274 totalFileCount += fc;
1283 if (p->isSource)
continue;
1288 totalFileCount += fc;
1293 *tfcp = totalFileCount;
1315 FPSDEBUG(0, (stderr,
"--> %s(%p,%s(%u))\n", __FUNCTION__, ts,
tagName(stag), (
unsigned)stag));
1326 if (p->isSource)
continue;
1364 FPSDEBUG(0, (stderr,
"--> %s(%p,%u,%p,%p)\n", __FUNCTION__, ts, (
unsigned)fileCount, ht, fpc));
1369 if (p->isSource)
continue;
1381 char const *linktarget;
1383 if (!(linktarget && *linktarget !=
'\0'))
1388 {
struct rpmffi_s ffi;
1394 {
struct rpmffi_s *ffip = (
struct rpmffi_s *)
alloca(
sizeof(*ffip));
1399 htAddEntry(symlinks, fi->fps + i, (
void *) ffip);
1418 if (p->isSource)
continue;
1425 if (XFA_SKIPPING(rpmfsGetAction(rpmteGetFileStates(p), i)))
1437 symlinks =
htFree(symlinks);
1449 FPSDEBUG(0, (stderr,
"--> %s(%p,0x%x,%p)\n", __FUNCTION__, ts, ignoreSet, (
void *)sxp));
1458 TSF_SET(tsflags, NOPOSTTRANS);
1460 TSF_SET(tsflags, NOTRIGGERPREIN);
1461 TSF_SET(tsflags, NOTRIGGERIN);
1462 TSF_SET(tsflags, NOTRIGGERUN);
1463 TSF_SET(tsflags, NOTRIGGERPOSTUN);
1469 TSF_SET(tsflags, NOTRIGGERPREIN);
1470 TSF_SET(tsflags, NOTRIGGERIN);
1471 TSF_SET(tsflags, NOTRIGGERUN);
1472 TSF_SET(tsflags, NOTRIGGERPOSTUN);
1483 TSF_SET(tsflags, NOPOSTTRANS);
1485 TSF_SET(tsflags, NOTRIGGERPREIN);
1486 TSF_SET(tsflags, NOTRIGGERIN);
1487 TSF_SET(tsflags, NOTRIGGERUN);
1488 TSF_SET(tsflags, NOTRIGGERPOSTUN);
1501 *sxp =
rpmsxNew(
"%{?_install_file_context_path}", 0);
1511 {
int dbmode = O_RDONLY;
1518 if (p->isSource)
continue;
1519 dbmode = (O_RDWR|O_CREAT);
1531 ts->ignoreSet = ignoreSet;
1536 currDir =
_free(currDir);
1555 FPSDEBUG(0, (stderr,
"--> %s(%p,%p)\n", __FUNCTION__, ts, sx));
1559 matchpathcon_fini();
1579 uint64_t fileCount = countFiles(ts);
1581 int dochroot = (rootDir != NULL && strcmp(rootDir,
"/") && *rootDir ==
'/');
1593 if ((fi =
rpmteFI(p)) == NULL)
1607 if (chroot(rootDir) == -1) {
1619 uint32_t numAdded = 0;
1620 uint32_t numRemoved = 0;
1622 FPSDEBUG(0, (stderr,
"--> %s(%p,%p,%u,%p)\n", __FUNCTION__, ts, sx, (
unsigned)fileCount, nrmvdp));
1629 if (p->isSource)
continue;
1649 (fc > 0 ?
xmalloc(fc *
sizeof(*fi->fps)) : NULL);
1654 *nrmvdp = numRemoved;
1658 static int openall_before_chroot = -1;
1660 if (openall_before_chroot < 0)
1665 if (rootDir != NULL && strcmp(rootDir,
"/") && *rootDir ==
'/') {
1666 if (openall_before_chroot)
1742 if (rootDir != NULL && strcmp(rootDir,
"/") && *rootDir ==
'/')
1746 if (currDir != NULL)
1747 xx =
Chdir(currDir);
1764 if (p->isSource)
continue;
1769 fi->fps =
_free(fi->fps);
1776 ht = rpmFpHashFree(ht);
1789 int rollbackFailures)
1797 FPSDEBUG(0, (stderr,
"--> %s(%p,0x%x,%d)\n", __FUNCTION__, ts, ignoreSet, rollbackFailures));
1851 if (gotfd &&
rpmteFd(p) != NULL) {
1858 int mapflags = fi->mapflags;
1876 fi->fstates =
_free(fi->fstates);
1877 fi->fstates = fstates;
1878 fi->actions =
_free(fi->actions);
1879 fi->actions = (
int *) actions;
1885 psm->fi =
rpmfiLink(p->fi, __FUNCTION__);
1918 #if defined(RPM_VENDOR_MANDRIVA)
1920 if (!failed && !
TSF_ISSET(tsflags, TEST)) {
1922 xx = mayAddToFilesAwaitingFiletriggers(
rpmtsRootDir(ts),
1936 rpmteMarkFailed(p, ts);
1942 if (rollbackFailures) {
1978 FPSDEBUG(0, (stderr,
"--> %s(%p,%u)\n", __FUNCTION__, ts, (
unsigned)numRemoved));
1984 if (p->isSource)
continue;
1998 progress, numRemoved);
2008 assert(psm != NULL);
2040 FPSDEBUG(0, (stderr,
"--> %s(%p,%p)\n", __FUNCTION__, ts, p));
2055 assert(psm != NULL);
2056 psm->stepName =
"failed";
2069 const char * semfn = NULL;
2076 FPSDEBUG(0, (stderr,
"--> %s(%p,0x%x,%d,%p)\n", __FUNCTION__, rbts, ignoreSet, running, rbte));
2082 if (arbgoal == 0xffffffff)
2086 if (!running && arbgoal == 0xffffffff)
2102 if (te->isSource)
continue;
2103 if(!te->u.removed.dboffset)
2107 te->u.removed.dboffset, NULL);
2126 ttid = (time_t)arbgoal;
2128 ctime(&ttid), arbgoal);
2137 #if defined(SUPPORT_NOSIGNATURES)
2139 VSF_SET(vsflags, NOSHA1HEADER);
2140 VSF_SET(vsflags, NOMD5HEADER);
2144 VSF_SET(vsflags, NODSAHEADER);
2145 VSF_SET(vsflags, NORSAHEADER);
2150 VSF_SET(vsflags, NEEDPAYLOAD);
2165 ia->
rbtid = arbgoal;
2179 semfn =
rpmExpand(
"%{?semaphore_backout}", NULL);
2180 if (semfn && *semfn) {
2192 if (semfn && *semfn)
2194 semfn =
_free(semfn);
2204 uint32_t totalFileCount = 0;
2207 uint32_t numRemoved;
2208 int rollbackFailures = 0;
2212 FPSDEBUG(0, (stderr,
"--> %s(%p,%p,0x%x)\n", __FUNCTION__, ts, okProbs, ignoreSet));
2214 fprintf(stderr,
"--> %s(%p,%p,0x%x) tsflags 0x%x\n", __FUNCTION__, ts, okProbs, (
unsigned) ignoreSet, tsflags);
2219 _(
"Invalid number of transaction elements.\n"));
2225 lock = rpmtsAcquireLock(ts);
2227 rollbackFailures =
rpmExpandNumeric(
"%{?_rollback_transaction_on_failure}");
2230 rollbackFailures = 0;
2233 rollbackFailures = 0;
2236 rollbackFailures = 0;
2263 (okProbs == NULL ||
rpmpsTrim(ts->probs, okProbs)))))
2281 (okProbs == NULL ||
rpmpsTrim(ts->probs, okProbs)))
2284 lock = rpmtsFreeLock(lock);
2286 return ts->orderCount;
2297 xx = rpmtxnBegin(
rpmtsGetRdb(ts), NULL, &ts->txn);
2311 #if defined(RPM_VENDOR_MANDRIVA)
2316 || !
TSF_ISSET(tsflags, NOTRIGGERPOSTUN))
2327 lock = rpmtsFreeLock(lock);
2331 if (ts->txn != NULL)
2332 xx = rpmtxnAbort(ts->txn);
2336 if (ts->txn != NULL)
2337 xx = rpmtxnCommit(ts->txn);