17 #define _RPMDB_INTERNAL
21 #define _RPMFI_INTERNAL
25 #define _RPMTE_INTERNAL
27 #define _RPMTS_INTERNAL
30 #define _RPMSQ_INTERNAL
39 #if defined(RPM_VENDOR_MANDRIVA)
40 #include "filetriggers.h"
44 #include <rpmrollback.h>
69 static int sharedCmp(
const void * one,
const void * two)
72 sharedFileInfo a = (sharedFileInfo) one;
73 sharedFileInfo b = (sharedFileInfo) two;
75 if (a->otherPkg < b->otherPkg)
77 else if (a->otherPkg > b->otherPkg)
97 sharedFileInfo shared,
98 int sharedCount,
int reportConflicts)
102 HE_t he = memset(
alloca(
sizeof(*he)), 0,
sizeof(*he));
103 const char * altNVRA = NULL;
109 rpmfi otherFi = NULL;
119 &shared->otherPkg,
sizeof(shared->otherPkg));
123 assert(he->
p.
str != NULL);
146 p->replaced =
xcalloc(sharedCount,
sizeof(*p->replaced));
150 for (i = 0; i < sharedCount; i++, shared++) {
151 int otherFileNum, fileNum;
153 otherFileNum = shared->otherFileNum;
159 fileNum = shared->pkgFileNum;
177 if (S_ISREG(omode) && (omode & 06000) != 0)
187 rConflicts = reportConflicts;
189 if (tscolor != 0 && FColor != 0 && FColor != oFColor)
191 if (oFColor & prefcolor) {
195 if (FColor & prefcolor) {
200 #if defined(RPM_VENDOR_MANDRIVA)
203 if (rConflicts && tscolor != 0 && FColor == 0 && oFColor == 0) {
204 const char *ignorelist[] = {
206 "/usr/share/gtk-doc/html/",
207 "/usr/share/gnome/html/",
212 for (dnp = ignorelist; *dnp != NULL; dnp++) {
213 if (strstr(fn, *dnp) == fn) {
233 if (!shared->isRemoved)
234 p->replaced[p->nreplaced++] = *shared;
244 fi->actions[fileNum] = action;
246 fi->replacedSizes[fileNum] =
rpmfiFSize(otherFi);
250 altNVRA =
_free(altNVRA);
254 sizeof(*p->replaced) * (p->nreplaced + 1));
255 memset(p->replaced + p->nreplaced, 0,
sizeof(*p->replaced));
264 sharedFileInfo shared,
int sharedCount)
268 HE_t he = memset(
alloca(
sizeof(*he)), 0,
sizeof(*he));
270 const unsigned char * otherStates;
276 &shared->otherPkg,
sizeof(shared->otherPkg));
285 otherStates = he->
p.
ptr;
288 if (otherStates != NULL)
289 for (i = 0; i < sharedCount; i++, shared++) {
290 int otherFileNum, fileNum;
291 otherFileNum = shared->otherFileNum;
292 fileNum = shared->pkgFileNum;
297 fi->actions[fileNum] =
FA_SKIP;
305 #define ISROOT(_d) (((_d)[0] == '/' && (_d)[1] == '\0') ? "" : (_d))
317 size_t abnlen = strlen(a->
baseName);
320 size_t bbnlen = strlen(b->
baseName);
321 char * afn, * bfn, * t;
324 if (adnlen == 1 && asnlen != 0) adnlen = 0;
325 if (bdnlen == 1 && bsnlen != 0) bdnlen = 0;
327 afn = t =
alloca(adnlen+asnlen+abnlen+2);
332 if (afn[0] ==
'/' && afn[1] ==
'/') afn++;
334 bfn = t =
alloca(bdnlen+bsnlen+bbnlen+2);
339 if (bfn[0] ==
'/' && bfn[1] ==
'/') bfn++;
341 rc = strcmp(afn, bfn);
359 for (otherFileNum = 0; otherFileNum < otherFc; otherFileNum++, otherFps++) {
362 if (fiFps == otherFps)
367 if (
FP_EQUAL((*fiFps), (*otherFps)))
378 bingoFps = bsearch(fiFps, otherFps, otherFc,
sizeof(*otherFps),
fpsCompare);
379 if (bingoFps == NULL)
383 if (!(fiFps == bingoFps ||
FP_EQUAL((*fiFps), (*bingoFps))))
386 otherFileNum = (bingoFps != NULL ? (bingoFps - otherFps) : 0);
415 int otherPkgNum, otherFileNum;
440 (void)
htGetEntry(ts->ht, fiFps, &recs, &numRecs, NULL);
464 for (j = 0; j < numRecs && recs[j] != fi; j++)
470 for (otherPkgNum = j - 1; otherPkgNum >= 0; otherPkgNum--) {
474 otherFi = recs[otherPkgNum];
480 otherFps = otherFi->fps;
483 otherFileNum =
findFps(fiFps, otherFps, otherFc);
487 if (otherFi->actions[otherFileNum] !=
FA_UNKNOWN)
496 {
int reportConflicts =
500 if (otherPkgNum < 0) {
514 assert(otherFi != NULL);
519 rConflicts = reportConflicts;
522 if (FColor & prefcolor) {
526 if (strcmp(fn,
"/usr/sbin/libgcc_post_upgrade")
527 && strcmp(fn,
"/usr/sbin/glibc_post_upgrade"))
533 if (oFColor & prefcolor) {
536 otherFi->actions[otherFileNum] =
FA_CREATE;
540 if (FColor == 0 && oFColor == 0) {
542 otherFi->actions[otherFileNum] =
FA_CREATE;
572 if (otherPkgNum >= 0) {
573 assert(otherFi != NULL);
575 if (otherFi->actions[otherFileNum] !=
FA_ERASE) {
581 otherFi->actions[otherFileNum] =
FA_SKIP;
597 const unsigned char * digest =
rpmfiDigest(fi, &dalgo, &dlen);
598 unsigned char * fdigest;
599 assert(digest != NULL);
603 if (!
dodigest(dalgo, fn, fdigest, 0, NULL)
604 && memcmp(digest, fdigest, dlen))
606 fdigest =
_free(fdigest);
613 fi->replacedSizes[i], fixupSize, fi->actions[i]);
632 HE_t he = memset(
alloca(
sizeof(*he)), 0,
sizeof(*he));
640 if (p == NULL || h == NULL)
644 #ifdef RPM_VENDOR_MANDRIVA
645 nb += (rpmteD(p) != NULL ? strlen(rpmteD(p)) + 1 : 0);
654 #ifdef RPM_VENDOR_MANDRIVA
655 if (rpmteD(p) != NULL) *t++ =
':', t =
stpcpy(t, rpmteD(p));
667 assert(he->
p.
str != NULL);
698 ARGV_t netsharedPaths = NULL;
700 const char * dn, * bn;
710 #if defined(RPM_VENDOR_OPENPKG)
721 {
const char *tmpPath =
rpmExpand(
"%{?_netsharedpath}", NULL);
722 if (tmpPath && *tmpPath)
723 xx =
argvSplit(&netsharedPaths, tmpPath,
":");
724 tmpPath =
_free(tmpPath);
727 s =
rpmExpand(
"%{?_install_langs}", NULL);
737 drc =
alloca(dc *
sizeof(*drc));
738 memset(drc, 0, dc *
sizeof(*drc));
739 dff =
alloca(dc *
sizeof(*dff));
740 memset(dff, 0, dc *
sizeof(*dff));
760 drc[ix]--; dff[ix] = 1;
766 if (tscolor && FColor && !(tscolor & FColor)) {
767 drc[ix]--; dff[ix] = 1;
777 for (nsp = netsharedPaths; nsp && *nsp; nsp++) {
782 if (strncmp(dn, *nsp, len))
785 if (!(dn[len] ==
'/' || dn[len] ==
'\0'))
788 if (len < (dnlen + bnlen))
790 if (strncmp(dn, *nsp, dnlen))
793 if ((s = strchr((*nsp) + dnlen,
'/')) != NULL && s[1] !=
'\0')
795 if (strncmp(bn, (*nsp) + dnlen, bnlen))
799 if (!((*nsp)[len] ==
'/' || (*nsp)[len] ==
'\0'))
807 drc[ix]--; dff[ix] = 1;
815 if (languages != NULL && fi->flangs != NULL && *fi->flangs[i]) {
818 for (lang = languages; *lang != NULL; lang++) {
819 if (!strcmp(*lang,
"all"))
821 for (l = fi->flangs[i]; *l !=
'\0'; l = le) {
822 for (le = l; *le !=
'\0' && *le !=
'|'; le++)
824 if ((le-l) > 0 && !strncmp(*lang, l, (le-l)))
826 if (*le ==
'|') le++;
832 drc[ix]--; dff[ix] = 1;
842 drc[ix]--; dff[ix] = 1;
851 drc[ix]--; dff[ix] = 1;
860 for (j = 0; j <
dc; j++)
867 if (drc[j])
continue;
868 if (!dff[j])
continue;
871 dn = fi->dnl[j]; dnlen = strlen(dn) - 1;
872 bn = dn + dnlen; bnlen = 0;
873 while (bn > dn && bn[-1] !=
'/') {
883 const char * fdn, * fbn;
891 if (!S_ISDIR(fFMode))
894 if (strlen(fdn) != dnlen)
896 if (strncmp(fdn, dn, dnlen))
899 if (strlen(fbn) != bnlen)
901 if (strncmp(fbn, bn, bnlen))
910 netsharedPaths =
argvFree(netsharedPaths);
929 if (tsi != NULL && tsi->ocsave != -1) {
933 if (te != NULL && (fi = te->fi) != NULL)
973 psm =
rpmpsmFree(psm,
"_processFailedPackage");
984 const char * semfn = NULL;
987 QVA_t ia = memset(
alloca(
sizeof(*ia)), 0,
sizeof(*ia));
996 if (arbgoal == 0xffffffff)
1000 if (!running && arbgoal == 0xffffffff)
1016 if (te->isSource)
continue;
1017 if(!te->u.removed.dboffset)
1021 te->u.removed.dboffset, NULL);
1040 ttid = (time_t)arbgoal;
1042 ctime(&ttid), arbgoal);
1067 ia->
rbtid = arbgoal;
1080 semfn =
rpmExpand(
"%{?semaphore_backout}", NULL);
1081 if (semfn && *semfn) {
1093 if (semfn && *semfn)
1095 semfn =
_free(semfn);
1112 if (AV != NULL && B != NULL)
1113 for (a = AV; *a != NULL; a++) {
1114 if (**a && *B && !strcmp(*a, B))
1146 bingo =
cmpArgvStr(q->flink.Hdrid, p->hdrid);
1148 bingo =
cmpArgvStr(q->flink.Pkgid, p->pkgid);
1150 bingo =
cmpArgvStr(q->flink.NEVRA, p->NEVRA);
1155 q->linkFailed = p->linkFailed;
1164 static const char msg[] =
"rpmtsRun";
1168 int totalFileCount = 0;
1170 sharedFileInfo shared, sharedList;
1180 int rollbackFailures = 0;
1188 _(
"Invalid number of transaction elements.\n"));
1192 rollbackFailures =
rpmExpandNumeric(
"%{?_rollback_transaction_on_failure}");
1195 rollbackFailures = 0;
1198 rollbackFailures = 0;
1201 rollbackFailures = 0;
1208 lock = rpmtsAcquireLock(ts);
1226 const char * fn =
rpmGetPath(
"%{?_install_file_context_path}", NULL);
1238 {
int dbmode = O_RDONLY;
1240 if (!(
rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)) {
1243 if (p->isSource)
continue;
1244 dbmode = (O_RDWR|O_CREAT);
1252 lock = rpmtsFreeLock(lock);
1257 ts->ignoreSet = ignoreSet;
1260 currDir =
_free(currDir);
1290 if (p->isSource)
continue;
1311 #ifdef RPM_VENDOR_MANDRIVA
1333 totalFileCount += fc;
1344 if (p->isSource)
continue;
1349 totalFileCount += fc;
1359 (okProbs == NULL ||
rpmpsTrim(ts->probs, okProbs))))))
1364 if (p->isSource)
continue;
1369 if (fi->pretrans == NULL)
1404 assert(psm != NULL);
1433 numAdded = numRemoved = 0;
1438 if (p->isSource)
continue;
1457 fi->fps = (fc > 0 ?
xmalloc(fc *
sizeof(*fi->fps)) : NULL);
1463 static int openall_before_chroot = -1;
1465 if (openall_before_chroot < 0)
1470 if (rootDir != NULL && strcmp(rootDir,
"/") && *rootDir ==
'/') {
1471 if (openall_before_chroot)
1491 if (p->isSource)
continue;
1497 fpLookupList(fpc, fi->dnl, fi->bnl, fi->dil, fc, fi->fps);
1504 htAddEntry(ts->ht, fi->fps + i, (
void *) fi);
1536 if (fc == 0)
continue;
1549 matches =
xcalloc(fc,
sizeof(*matches));
1553 lock = rpmtsFreeLock(lock);
1560 struct stat sb, *st = &sb;
1567 if ((512 * st->st_blocks) < st->st_size)
1574 shared = sharedList =
xcalloc((numShared + 1),
sizeof(*sharedList));
1595 shared->pkgFileNum = i;
1598 shared->isRemoved = (knownBad == ro);
1603 numShared = shared - sharedList;
1604 shared->otherPkg = -1;
1605 matches =
_free(matches);
1608 qsort(sharedList, numShared,
sizeof(*shared),
sharedCmp);
1612 for (i = 0; i < numShared; i = nexti) {
1615 shared = sharedList + i;
1618 for (nexti = i + 1; nexti < numShared; nexti++) {
1619 if (sharedList[nexti].otherPkg != shared->otherPkg)
1625 if (ts->removedPackages != NULL)
1626 for (j = 0; j < ts->numRemovedPackages; j++) {
1627 if (ts->removedPackages[j] != (
int)shared->otherPkg)
1672 if (rootDir != NULL && strcmp(rootDir,
"/") && *rootDir ==
'/')
1676 if (currDir != NULL)
1677 xx =
Chdir(currDir);
1687 if (p->isSource)
continue;
1692 fi->fps =
_free(fi->fps);
1704 (okProbs == NULL ||
rpmpsTrim(ts->probs, okProbs)))
1707 lock = rpmtsFreeLock(lock);
1708 return ts->orderCount;
1722 if (p->isSource)
continue;
1729 if (!(
rpmtsFlags(ts) & RPMTRANS_FLAG_REPACKAGE))
1736 progress, numRemoved);
1746 assert(psm != NULL);
1780 assert(psm != NULL);
1821 if (
rpmteFd(p) != NULL) gotfd = 1;
1838 int mapflags = fi->mapflags;
1854 fi->fstates =
_free(fi->fstates);
1855 fi->fstates = fstates;
1856 fi->actions =
_free(fi->actions);
1857 fi->actions = (
int *) actions;
1869 #if defined(RPM_VENDOR_MANDRIVA)
1872 xx = mayAddToFilesAwaitingFiletriggers(
rpmtsRootDir(ts), psm->
fi, 1);
1897 if (p->linkFailed == 0) {
1901 #if defined(RPM_VENDOR_MANDRIVA)
1904 xx = mayAddToFilesAwaitingFiletriggers(
rpmtsRootDir(ts), psm->
fi, 0);
1933 if (ourrc && rollbackFailures) {
1945 #if defined(RPM_VENDOR_MANDRIVA)
1958 haspostscript = (fi->posttrans || fi->posttransprog ? 1 : 0);
1997 assert(psm != NULL);
2018 if (!(
rpmtsFlags(ts) & RPMTRANS_FLAG_NOCONTEXTS))
2022 lock = rpmtsFreeLock(lock);