14 #define _RPMDB_INTERNAL
21 #define _RPMFI_INTERNAL
24 #define _RPMTE_INTERNAL
27 #define _RPMTS_INTERNAL
62 const unsigned long long amount,
63 const unsigned long long total,
70 static int sharedCmp(
const void * one,
const void * two)
73 sharedFileInfo a = (sharedFileInfo) one;
74 sharedFileInfo b = (sharedFileInfo) two;
76 if (a->otherPkg < b->otherPkg)
78 else if (a->otherPkg > b->otherPkg)
97 sharedFileInfo shared,
98 int sharedCount,
int reportConflicts)
107 const char * altNEVRA = NULL;
108 rpmfi otherFi = NULL;
118 &shared->otherPkg,
sizeof(shared->otherPkg));
142 fi->replaced =
xcalloc(sharedCount,
sizeof(*fi->replaced));
145 for (i = 0; i < sharedCount; i++, shared++) {
146 int otherFileNum, fileNum;
148 otherFileNum = shared->otherFileNum;
154 fileNum = shared->pkgFileNum;
172 if (S_ISREG(omode) && (omode & 06000) != 0)
182 rConflicts = reportConflicts;
184 if (tscolor != 0 && FColor != 0 && FColor != oFColor)
186 if (oFColor & prefcolor) {
190 if (FColor & prefcolor) {
207 if (!shared->isRemoved)
208 fi->replaced[numReplaced++] = *shared;
218 fi->actions[fileNum] = action;
220 fi->replacedSizes[fileNum] =
rpmfiFSize(otherFi);
224 altNEVRA =
_free(altNEVRA);
227 fi->replaced =
xrealloc(fi->replaced,
228 sizeof(*fi->replaced) * (numReplaced + 1));
229 fi->replaced[numReplaced].otherPkg = 0;
239 sharedFileInfo shared,
int sharedCount)
245 const char * otherStates;
251 &shared->otherPkg,
sizeof(shared->otherPkg));
262 if (otherStates != NULL)
263 for (i = 0; i < sharedCount; i++, shared++) {
264 int otherFileNum, fileNum;
265 otherFileNum = shared->otherFileNum;
266 fileNum = shared->pkgFileNum;
271 fi->actions[fileNum] =
FA_SKIP;
280 #define ISROOT(_d) (((_d)[0] == '/' && (_d)[1] == '\0') ? "" : (_d))
296 char * afn, * bfn, * t;
299 if (adnlen == 1 && asnlen != 0) adnlen = 0;
300 if (bdnlen == 1 && bsnlen != 0) bdnlen = 0;
303 afn = t =
alloca(adnlen+asnlen+abnlen+2);
308 if (afn[0] ==
'/' && afn[1] ==
'/') afn++;
310 bfn = t =
alloca(bdnlen+bsnlen+bbnlen+2);
315 if (bfn[0] ==
'/' && bfn[1] ==
'/') bfn++;
318 rc = strcmp(afn, bfn);
336 for (otherFileNum = 0; otherFileNum < otherFc; otherFileNum++, otherFps++) {
339 if (fiFps == otherFps)
344 if (
FP_EQUAL((*fiFps), (*otherFps)))
356 bingoFps = bsearch(fiFps, otherFps, otherFc,
sizeof(*otherFps),
fpsCompare);
358 if (bingoFps == NULL)
362 if (!(fiFps == bingoFps ||
FP_EQUAL((*fiFps), (*bingoFps))))
365 otherFileNum = (bingoFps != NULL ? (bingoFps - otherFps) : 0);
394 int otherPkgNum, otherFileNum;
420 (
const void ***) &
recs, &numRecs, NULL);
444 for (j = 0; j < numRecs && recs[j] != fi; j++)
450 for (otherPkgNum = j - 1; otherPkgNum >= 0; otherPkgNum--) {
454 otherFi = recs[otherPkgNum];
460 otherFps = otherFi->fps;
463 otherFileNum =
findFps(fiFps, otherFps, otherFc);
467 if (otherFi->actions[otherFileNum] !=
FA_UNKNOWN)
477 {
int reportConflicts =
481 if (otherPkgNum < 0) {
495 assert(otherFi != NULL);
500 rConflicts = reportConflicts;
503 if (FColor & prefcolor) {
507 if (strcmp(fn,
"/usr/sbin/libgcc_post_upgrade")
508 && strcmp(fn,
"/usr/sbin/glibc_post_upgrade"))
514 if (oFColor & prefcolor) {
517 otherFi->actions[otherFileNum] =
FA_CREATE;
521 if (FColor == 0 && oFColor == 0) {
523 otherFi->actions[otherFileNum] =
FA_CREATE;
553 if (otherPkgNum >= 0) {
554 assert(otherFi != NULL);
556 if (otherFi->actions[otherFileNum] !=
FA_ERASE) {
562 otherFi->actions[otherFileNum] =
FA_SKIP;
578 const unsigned char * digest =
rpmfiDigest(fi, &dalgo, &dlen);
579 unsigned char * fdigest;
580 assert(digest != NULL);
584 if (!
dodigest(dalgo, fn, fdigest, 0, NULL)
585 && memcmp(digest, fdigest, dlen))
587 fdigest =
_free(fdigest);
595 fi->replacedSizes[i], fixupSize, fi->actions[i]);
620 if (p == NULL || h == NULL)
640 const char * altNEVR =
hGetNEVR(h, NULL);
646 altNEVR =
_free(altNEVR);
672 char ** netsharedPaths = NULL;
673 const char ** languages;
674 const char * dn, * bn;
675 int dnlen, bnlen, ix;
685 {
const char *tmpPath =
rpmExpand(
"%{_netsharedpath}", NULL);
687 if (tmpPath && *tmpPath !=
'%')
688 netsharedPaths =
splitString(tmpPath, strlen(tmpPath),
':');
690 tmpPath =
_free(tmpPath);
693 s =
rpmExpand(
"%{_install_langs}", NULL);
695 if (!(s && *s !=
'%'))
698 languages = (
const char **)
splitString(s, strlen(s),
':');
706 drc =
alloca(dc *
sizeof(*drc));
707 memset(drc, 0, dc *
sizeof(*drc));
708 dff =
alloca(dc *
sizeof(*dff));
709 memset(dff, 0, dc *
sizeof(*dff));
729 drc[ix]--; dff[ix] = 1;
735 if (tscolor && FColor && !(tscolor & FColor)) {
736 drc[ix]--; dff[ix] = 1;
746 for (nsp = netsharedPaths; nsp && *nsp; nsp++) {
751 if (strncmp(dn, *nsp, len))
754 if (!(dn[len] ==
'/' || dn[len] ==
'\0'))
757 if (len < (dnlen + bnlen))
759 if (strncmp(dn, *nsp, dnlen))
762 if ((s = strchr((*nsp) + dnlen,
'/')) != NULL && s[1] !=
'\0')
764 if (strncmp(bn, (*nsp) + dnlen, bnlen))
768 if (!((*nsp)[len] ==
'/' || (*nsp)[len] ==
'\0'))
776 drc[ix]--; dff[ix] = 1;
784 if (languages != NULL && fi->flangs != NULL && *fi->flangs[i]) {
785 const char **
lang, *l, *le;
786 for (lang = languages; *lang != NULL; lang++) {
787 if (!strcmp(*lang,
"all"))
789 for (l = fi->flangs[i]; *l !=
'\0'; l = le) {
790 for (le = l; *le !=
'\0' && *le !=
'|'; le++)
792 if ((le-l) > 0 && !strncmp(*lang, l, (le-l)))
794 if (*le ==
'|') le++;
800 drc[ix]--; dff[ix] = 1;
810 drc[ix]--; dff[ix] = 1;
819 drc[ix]--; dff[ix] = 1;
828 for (j = 0; j < dc; j++)
835 if (drc[j])
continue;
836 if (!dff[j])
continue;
839 dn = fi->dnl[j]; dnlen = strlen(dn) - 1;
840 bn = dn + dnlen; bnlen = 0;
841 while (bn > dn && bn[-1] !=
'/') {
851 const char * fdn, * fbn;
862 if (strlen(fdn) != dnlen)
864 if (strncmp(fdn, dn, dnlen))
867 if (strlen(fbn) != bnlen)
869 if (strncmp(fbn, bn, bnlen))
898 if (tsi != NULL && tsi->ocsave != -1) {
902 if (te != NULL && (fi = te->fi) != NULL)
953 const char * semfn = NULL;
956 QVA_t ia = memset(
alloca(
sizeof(*ia)), 0,
sizeof(*ia));
965 if (arbgoal == 0xffffffff)
969 if (!running && arbgoal == 0xffffffff)
985 if(!te->u.removed.dboffset)
989 te->u.removed.dboffset, NULL, NULL);
1008 ttid = (time_t)arbgoal;
1010 ctime(&ttid), arbgoal);
1035 ia->
rbtid = arbgoal;
1048 semfn =
rpmExpand(
"%{?semaphore_backout}", NULL);
1049 if (semfn && *semfn) {
1061 if (semfn && *semfn)
1063 semfn =
_free(semfn);
1080 if (AV != NULL && B != NULL)
1081 for (a = AV; *a != NULL; a++) {
1082 if (**a && *B && !strcmp(*a, B))
1114 bingo =
cmpArgvStr(q->flink.Hdrid, p->hdrid);
1116 bingo =
cmpArgvStr(q->flink.Pkgid, p->pkgid);
1118 bingo =
cmpArgvStr(q->flink.NEVRA, p->NEVRA);
1123 q->linkFailed = p->linkFailed;
1130 #define NOTIFY(_ts, _al) if ((_ts)->notify) (void) (_ts)->notify _al
1137 int totalFileCount = 0;
1139 sharedFileInfo shared, sharedList;
1149 int rollbackFailures = 0;
1156 _(
"Invalid number of transaction elements.\n"));
1160 rollbackFailures =
rpmExpandNumeric(
"%{?_rollback_transaction_on_failure}");
1163 rollbackFailures = 0;
1166 rollbackFailures = 0;
1169 rollbackFailures = 0;
1177 lock = rpmtsAcquireLock(ts);
1196 ? O_RDONLY : (O_RDWR|O_CREAT);
1200 lock = rpmtsFreeLock(lock);
1205 ts->ignoreSet = ignoreSet;
1208 currDir =
_free(currDir);
1276 totalFileCount += fc;
1291 totalFileCount += fc;
1300 (okProbs == NULL ||
rpmpsTrim(ts->probs, okProbs)))))
1309 if (fi->pretrans == NULL)
1349 assert(psm != NULL);
1379 numAdded = numRemoved = 0;
1404 fi->fps = (fc > 0 ?
xmalloc(fc *
sizeof(*fi->fps)) : NULL);
1410 static int openall_before_chroot = -1;
1412 if (openall_before_chroot < 0)
1417 if (rootDir != NULL && strcmp(rootDir,
"/") && *rootDir ==
'/') {
1418 if (openall_before_chroot)
1443 fpLookupList(fpc, fi->dnl, fi->bnl, fi->dil, fc, fi->fps);
1451 htAddEntry(ts->ht, fi->fps + i, (
void *) fi);
1461 NULL, ts->notifyData));
1472 unsigned int exclude;
1483 ts->orderCount, NULL, ts->notifyData));
1485 if (fc == 0)
continue;
1489 matches =
xcalloc(fc,
sizeof(*matches));
1493 lock = rpmtsFreeLock(lock);
1500 struct stat sb, *st = &sb;
1507 if ((512 * st->st_blocks) < st->st_size)
1514 shared = sharedList =
xcalloc((numShared + 1),
sizeof(*sharedList));
1535 shared->pkgFileNum = i;
1538 shared->isRemoved = (knownBad == ro);
1543 numShared = shared - sharedList;
1544 shared->otherPkg = -1;
1545 matches =
_free(matches);
1548 qsort(sharedList, numShared,
sizeof(*shared),
sharedCmp);
1553 for (i = 0; i < numShared; i = nexti) {
1556 shared = sharedList + i;
1559 for (nexti = i + 1; nexti < numShared; nexti++) {
1560 if (sharedList[nexti].otherPkg != shared->otherPkg)
1566 if (ts->removedPackages != NULL)
1567 for (j = 0; j < ts->numRemovedPackages; j++) {
1568 if (ts->removedPackages[j] != shared->otherPkg)
1614 if (rootDir != NULL && strcmp(rootDir,
"/") && *rootDir ==
'/')
1618 if (currDir != NULL)
1619 xx =
Chdir(currDir);
1623 NULL, ts->notifyData));
1634 fi->fps =
_free(fi->fps);
1646 (okProbs == NULL ||
rpmpsTrim(ts->probs, okProbs)))
1649 lock = rpmtsFreeLock(lock);
1650 return ts->orderCount;
1671 if (!(
rpmtsFlags(ts) & RPMTRANS_FLAG_REPACKAGE))
1675 7, numRemoved, NULL, ts->notifyData));
1678 numRemoved, NULL, ts->notifyData));
1688 assert(psm != NULL);
1703 NULL, ts->notifyData));
1724 assert(psm != NULL);
1769 if (
rpmteFd(p) != NULL) gotfd = 1;
1784 char * fstates = fi->fstates;
1786 int mapflags = fi->mapflags;
1802 fi->fstates =
_free(fi->fstates);
1803 fi->fstates = fstates;
1804 fi->actions =
_free(fi->actions);
1805 fi->actions = actions;
1844 if (p->linkFailed == 0) {
1872 if (ourrc && rollbackFailures) {
1881 if (!(
rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)) {
1890 haspostscript = (fi->posttrans != NULL ? 1 : 0);
1911 0, 0,
rpmteKey(p), ts->notifyData);
1929 assert(psm != NULL);
1949 lock = rpmtsFreeLock(lock);