#include "debug.h"
-/*@access FD_t @*/ /* XXX compared with NULL */
-/*@access Header @*/ /* XXX compared with NULL */
+/*@access Header @*/ /* XXX ts->notify arg1 is void ptr */
/*@access rpmps @*/ /* XXX need rpmProblemSetOK() */
/*@access dbiIndexSet @*/
-/*@access rpmdb @*/
-/*@access PSM_t @*/
+/*@access rpmpsm @*/
/*@access alKey @*/
/*@access fnpyKey @*/
if (oFLink && nFLink && !strcmp(oFLink, nFLink))
return FA_SKIP; /* identical file, don't bother. */
/*@=nullpass@*/
- }
+ }
/*
* The config file on the disk has been modified, but
/*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
/*@modifies ts, fi, rpmGlobalMacroContext, fileSystem, internalState @*/
{
+ uint_32 tscolor = rpmtsColor(ts);
+ uint_32 otecolor, tecolor;
+ uint_32 oficolor, ficolor;
const char * altNEVR = NULL;
rpmfi otherFi = NULL;
int numReplaced = 0;
&shared->otherPkg, sizeof(shared->otherPkg));
while ((h = rpmdbNextIterator(mi)) != NULL) {
altNEVR = hGetNEVR(h, NULL);
- otherFi = rpmfiNew(ts, NULL, h, RPMTAG_BASENAMES, scareMem);
+ otherFi = rpmfiNew(ts, h, RPMTAG_BASENAMES, scareMem);
break;
}
mi = rpmdbFreeIterator(mi);
}
+ /* Compute package color. */
+ tecolor = rpmteColor(p);
+ tecolor &= tscolor;
+
+ /* Compute other pkg color. */
+ otecolor = 0;
+ otherFi = rpmfiInit(otherFi, 0);
+ if (otherFi != NULL)
+ while (rpmfiNext(otherFi) >= 0)
+ otecolor |= rpmfiFColor(otherFi);
+ otecolor &= tscolor;
+
if (otherFi == NULL)
return 1;
otherFileNum = shared->otherFileNum;
(void) rpmfiSetFX(otherFi, otherFileNum);
+ oficolor = rpmfiFColor(otherFi);
+ oficolor &= tscolor;
fileNum = shared->pkgFileNum;
(void) rpmfiSetFX(fi, fileNum);
+ ficolor = rpmfiFColor(fi);
+ ficolor &= tscolor;
isCfgFile = ((rpmfiFFlags(otherFi) | rpmfiFFlags(fi)) & RPMFILE_CONFIG);
continue;
if (filecmp(otherFi, fi)) {
+ /* Report conflicts only for packages/files of same color. */
+ if (tscolor == 0 || (tecolor == otecolor && ficolor == oficolor))
if (reportConflicts) {
rpmpsAppend(ps, RPMPROB_FILE_CONFLICT,
rpmteNEVR(p), rpmteKey(p),
ps = rpmpsFree(ps);
altNEVR = _free(altNEVR);
- otherFi = rpmfiFree(otherFi, 1);
+ otherFi = rpmfiFree(otherFi);
fi->replaced = xrealloc(fi->replaced, /* XXX memory leak */
sizeof(*fi->replaced) * (numReplaced + 1));
assert(otherFi != NULL);
/* Mark added overlapped non-identical files as a conflict. */
- if ((rpmtsFilterFlags(ts) & RPMPROB_FILTER_REPLACENEWFILES)
+ if (!(rpmtsFilterFlags(ts) & RPMPROB_FILTER_REPLACENEWFILES)
&& filecmp(otherFi, fi))
{
rpmpsAppend(ps, RPMPROB_NEW_FILE_CONFLICT,
/*@=boundswrite@*/
/* Update disk space info for a file. */
- rpmtsUpdateDSI(ts, fiFps->entry->dev,
- rpmfiFSize(fi), fi->replacedSizes[i], fixupSize, fi->actions[i]);
+ rpmtsUpdateDSI(ts, fiFps->entry->dev, rpmfiFSize(fi),
+ fi->replacedSizes[i], fixupSize, fi->actions[i]);
}
ps = rpmpsFree(ps);
}
/**
+ * Skip any files that do not match install policies.
+ * @param ts transaction set
+ * @param fi file info set
*/
/*@-mustmod@*/ /* FIX: fi->actions is modified. */
/*@-bounds@*/
/*@globals rpmGlobalMacroContext @*/
/*@modifies fi, rpmGlobalMacroContext @*/
{
+ uint_32 tscolor = rpmtsColor(ts);
+ uint_32 ficolor;
+ int noConfigs = (rpmtsFlags(ts) & RPMTRANS_FLAG_NOCONFIGS);
int noDocs = (rpmtsFlags(ts) & RPMTRANS_FLAG_NODOCS);
char ** netsharedPaths = NULL;
const char ** languages;
if (fi != NULL) /* XXX lclint */
while ((i = rpmfiNext(fi)) >= 0)
{
- char **nsp;
+ char ** nsp;
bn = rpmfiBN(fi);
bnlen = strlen(bn);
/* Don't bother with skipped files */
if (XFA_SKIPPING(fi->actions[i])) {
- drc[ix]--;
+ drc[ix]--; dff[ix] = 1;
+ continue;
+ }
+
+ /* Ignore colored files not in our rainbow. */
+ ficolor = rpmfiFColor(fi);
+ if (tscolor && ficolor && !(tscolor & ficolor)) {
+ drc[ix]--; dff[ix] = 1;
+ fi->actions[i] = FA_SKIPCOLOR;
continue;
}
/*
* Skip i18n language specific files.
*/
- if (fi->flangs && languages && *fi->flangs[i]) {
+ if (languages != NULL && fi->flangs != NULL && *fi->flangs[i]) {
const char **lang, *l, *le;
for (lang = languages; *lang != NULL; lang++) {
if (!strcmp(*lang, "all"))
}
/*
+ * Skip config files if requested.
+ */
+ if (noConfigs && (rpmfiFFlags(fi) & RPMFILE_CONFIG)) {
+ drc[ix]--; dff[ix] = 1;
+ fi->actions[i] = FA_SKIPNSTATE;
+ continue;
+ }
+
+ /*
* Skip documentation if requested.
*/
if (noDocs && (rpmfiFFlags(fi) & RPMFILE_DOC)) {
}
}
+/*@-dependenttrans@*/
if (netsharedPaths) freeSplitString(netsharedPaths);
#ifdef DYING /* XXX freeFi will deal with this later. */
fi->flangs = _free(fi->flangs);
#endif
if (languages) freeSplitString((char **)languages);
+/*@=dependenttrans@*/
}
/*@=bounds@*/
/*@=mustmod@*/
int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
{
+ uint_32 tscolor = rpmtsColor(ts);
int i, j;
int ourrc = 0;
int totalFileCount = 0;
sharedFileInfo shared, sharedList;
int numShared;
int nexti;
- alKey lastKey;
+ alKey lastFailKey;
fingerPrintCache fpc;
rpmps ps;
- PSM_t psm = memset(alloca(sizeof(*psm)), 0, sizeof(*psm));
+ rpmpsm psm;
rpmtsi pi; rpmte p;
rpmtsi qi; rpmte q;
+ int numAdded;
+ int numRemoved;
int xx;
- /* FIXME: what if the same package is included in ts twice? */
+ /* XXX programmer error segfault avoidance. */
+ if (rpmtsNElements(ts) <= 0)
+ return -1;
if (rpmtsFlags(ts) & RPMTRANS_FLAG_NOSCRIPTS)
(void) rpmtsSetFlags(ts, (rpmtsFlags(ts) | _noTransScripts | _noTransTriggers));
if (rpmtsFlags(ts) & RPMTRANS_FLAG_NOTRIGGERS)
(void) rpmtsSetFlags(ts, (rpmtsFlags(ts) | _noTransTriggers));
- /* XXX MULTILIB is broken, as packages can and do execute /sbin/ldconfig. */
- if (rpmtsFlags(ts) & (RPMTRANS_FLAG_JUSTDB | RPMTRANS_FLAG_MULTILIB))
+ if (rpmtsFlags(ts) & RPMTRANS_FLAG_JUSTDB)
(void) rpmtsSetFlags(ts, (rpmtsFlags(ts) | _noTransScripts | _noTransTriggers));
ts->probs = rpmpsFree(ts->probs);
(void) rpmtsSetTid(ts, tid);
}
- memset(psm, 0, sizeof(*psm));
- psm->ts = rpmtsLink(ts, "tsRun");
-
/* Get available space on mounted file systems. */
xx = rpmtsInitDSI(ts);
* - count files.
*/
-rpmMessage(RPMMESS_DEBUG, _("sanity checking %d elments\n"), rpmtsNElements(ts));
+rpmMessage(RPMMESS_DEBUG, _("sanity checking %d elements\n"), rpmtsNElements(ts));
ps = rpmtsProblems(ts);
/* The ordering doesn't matter here */
pi = rpmtsiInit(ts);
continue; /* XXX can't happen */
fc = rpmfiFC(fi);
- if (!(rpmtsFilterFlags(ts) & RPMPROB_FILTER_IGNOREARCH))
+ if (!(rpmtsFilterFlags(ts) & RPMPROB_FILTER_IGNOREARCH) && !tscolor)
if (!archOkay(rpmteA(p)))
rpmpsAppend(ps, RPMPROB_BADARCH,
rpmteNEVR(p), rpmteKey(p),
mi = rpmdbFreeIterator(mi);
}
- /* XXX multilib should not display "already installed" problems */
- if (!(rpmtsFilterFlags(ts) & RPMPROB_FILTER_REPLACEPKG) && !rpmteMultiLib(p)) {
+ if (!(rpmtsFilterFlags(ts) & RPMPROB_FILTER_REPLACEPKG)) {
mi = rpmtsInitIterator(ts, RPMTAG_NAME, rpmteN(p), 0);
+ xx = rpmdbSetIteratorRE(mi, RPMTAG_EPOCH, RPMMIRE_DEFAULT,
+ rpmteE(p));
xx = rpmdbSetIteratorRE(mi, RPMTAG_VERSION, RPMMIRE_DEFAULT,
rpmteV(p));
xx = rpmdbSetIteratorRE(mi, RPMTAG_RELEASE, RPMMIRE_DEFAULT,
rpmteR(p));
+ if (tscolor) {
+ xx = rpmdbSetIteratorRE(mi, RPMTAG_ARCH, RPMMIRE_DEFAULT,
+ rpmteA(p));
+ xx = rpmdbSetIteratorRE(mi, RPMTAG_OS, RPMMIRE_DEFAULT,
+ rpmteO(p));
+ }
while (rpmdbNextIterator(mi) != NULL) {
rpmpsAppend(ps, RPMPROB_PKG_INSTALLED,
* worth the trouble though.
*/
rpmMessage(RPMMESS_DEBUG, _("computing %d file fingerprints\n"), totalFileCount);
+
+ numAdded = numRemoved = 0;
pi = rpmtsiInit(ts);
while ((p = rpmtsiNext(pi, 0)) != NULL) {
int fc;
/*@-branchstate@*/
switch (rpmteType(p)) {
case TR_ADDED:
+ numAdded++;
fi->record = 0;
/* Skip netshared paths, not our i18n files, and excluded docs */
if (fc > 0)
skipFiles(ts, fi);
/*@switchbreak@*/ break;
case TR_REMOVED:
+ numRemoved++;
fi->record = rpmteDBOffset(p);
/*@switchbreak@*/ break;
}
while ((p = rpmtsiNext(pi, 0)) != NULL) {
int fc;
+ (void) rpmdbCheckSignals();
+
if ((fi = rpmtsiFi(pi)) == NULL)
continue; /* XXX can't happen */
fc = rpmfiFC(fi);
+ (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
fpLookupList(fpc, fi->dnl, fi->bnl, fi->dil, fc, fi->fps);
/*@-branchstate@*/
fi = rpmfiInit(fi, 0);
/*@=dependenttrans@*/
}
/*@=branchstate@*/
+ (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), fc);
+
}
pi = rpmtsiFree(pi);
int knownBad;
int fc;
+ (void) rpmdbCheckSignals();
+
if ((fi = rpmtsiFi(pi)) == NULL)
continue; /* XXX can't happen */
fc = rpmfiFC(fi);
if (fc == 0) continue;
+ (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
/* Extract file info for all files in this package from the database. */
matches = xcalloc(fc, sizeof(*matches));
if (rpmdbFindFpList(rpmtsGetRdb(ts), fi->fps, matches, fc)) {
- psm->ts = rpmtsUnlink(ts, "tsRun (rpmFindFpList fail)");
ps = rpmpsFree(ps);
return 1; /* XXX WTFO? */
}
case TR_REMOVED:
/*@switchbreak@*/ break;
}
+ (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), fc);
}
pi = rpmtsiFree(pi);
ps = rpmpsFree(ps);
(okProbs != NULL || rpmpsTrim(ts->probs, okProbs)))
)
{
- if (psm->ts != NULL)
- psm->ts = rpmtsUnlink(psm->ts, "tsRun (problems)");
return ts->orderCount;
}
/* ===============================================
* Save removed files before erasing.
*/
-rpmMessage(RPMMESS_DEBUG, _("repackage about-to-be-erased packages\n"));
if (rpmtsFlags(ts) & (RPMTRANS_FLAG_DIRSTASH | RPMTRANS_FLAG_REPACKAGE)) {
+ int progress;
+
+ progress = 0;
pi = rpmtsiInit(ts);
while ((p = rpmtsiNext(pi, 0)) != NULL) {
- fi = rpmtsiFi(pi);
+
+ (void) rpmdbCheckSignals();
+
+ if ((fi = rpmtsiFi(pi)) == NULL)
+ continue; /* XXX can't happen */
switch (rpmteType(p)) {
case TR_ADDED:
/*@switchbreak@*/ break;
case TR_REMOVED:
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_REPACKAGE))
/*@switchbreak@*/ break;
- psm->te = p;
- psm->fi = rpmfiLink(fi, "tsRepackage");
+ if (!progress)
+ NOTIFY(ts, (NULL, RPMCALLBACK_REPACKAGE_START,
+ 7, numRemoved, NULL, ts->notifyData));
+
+ NOTIFY(ts, (NULL, RPMCALLBACK_REPACKAGE_PROGRESS, progress,
+ numRemoved, NULL, ts->notifyData));
+ progress++;
+
+ (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_REPACKAGE), 0);
+
/* XXX TR_REMOVED needs CPIO_MAP_{ABSOLUTE,ADDDOT} CPIO_ALL_HARDLINKS */
- psm->fi->mapflags |= CPIO_MAP_ABSOLUTE;
- psm->fi->mapflags |= CPIO_MAP_ADDDOT;
- psm->fi->mapflags |= CPIO_ALL_HARDLINKS;
- xx = psmStage(psm, PSM_PKGSAVE);
- (void) rpmfiUnlink(fi, "tsRepackage");
- psm->fi = NULL;
- psm->te = NULL;
+ fi->mapflags |= CPIO_MAP_ABSOLUTE;
+ fi->mapflags |= CPIO_MAP_ADDDOT;
+ fi->mapflags |= CPIO_ALL_HARDLINKS;
+ psm = rpmpsmNew(ts, p, fi);
+ xx = rpmpsmStage(psm, PSM_PKGSAVE);
+ psm = rpmpsmFree(psm);
+ fi->mapflags &= ~CPIO_MAP_ABSOLUTE;
+ fi->mapflags &= ~CPIO_MAP_ADDDOT;
+ fi->mapflags &= ~CPIO_ALL_HARDLINKS;
+
+ (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_REPACKAGE), 0);
+
/*@switchbreak@*/ break;
}
}
pi = rpmtsiFree(pi);
+ if (progress) {
+ NOTIFY(ts, (NULL, RPMCALLBACK_REPACKAGE_STOP, 7, numRemoved,
+ NULL, ts->notifyData));
+ }
}
/* ===============================================
* Install and remove packages.
*/
-rpmMessage(RPMMESS_DEBUG, _("install/erase %d elements\n"), rpmtsNElements(ts));
- lastKey = (alKey)-2; /* erased packages have -1 */
+ lastFailKey = (alKey)-2; /* erased packages have -1 */
pi = rpmtsiInit(ts);
/*@-branchstate@*/ /* FIX: fi reload needs work */
while ((p = rpmtsiNext(pi, 0)) != NULL) {
alKey pkgKey;
int gotfd;
+ (void) rpmdbCheckSignals();
+
gotfd = 0;
if ((fi = rpmtsiFi(pi)) == NULL)
continue; /* XXX can't happen */
- psm->te = p;
- psm->fi = rpmfiLink(fi, "tsInstall");
+ psm = rpmpsmNew(ts, p, fi);
+assert(psm != NULL);
+ psm->unorderedSuccessor =
+ (rpmtsiOc(pi) >= rpmtsUnorderedSuccessors(ts, -1) ? 1 : 0);
+
switch (rpmteType(p)) {
case TR_ADDED:
+ (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_INSTALL), 0);
pkgKey = rpmteAddedKey(p);
/*@-type@*/ /* FIX: rpmte not opaque */
{
/*@-noeffectuncon@*/ /* FIX: notify annotations */
- p->fd = ts->notify(fi->h, RPMCALLBACK_INST_OPEN_FILE, 0, 0,
+ p->fd = ts->notify(p->h, RPMCALLBACK_INST_OPEN_FILE, 0, 0,
rpmteKey(p), ts->notifyData);
/*@=noeffectuncon@*/
if (rpmteFd(p) != NULL) {
+ rpmVSFlags ovsflags = rpmtsVSFlags(ts);
+ rpmVSFlags vsflags = ovsflags | RPMVSF_NEEDPAYLOAD;
rpmRC rpmrc;
+ ovsflags = rpmtsSetVSFlags(ts, vsflags);
rpmrc = rpmReadPackageFile(ts, rpmteFd(p),
rpmteNEVR(p), &p->h);
+ vsflags = rpmtsSetVSFlags(ts, ovsflags);
- if (!(rpmrc == RPMRC_OK || rpmrc == RPMRC_BADSIZE)) {
+ switch (rpmrc) {
+ default:
/*@-noeffectuncon@*/ /* FIX: notify annotations */
- p->fd = ts->notify(fi->h, RPMCALLBACK_INST_CLOSE_FILE,
+ p->fd = ts->notify(p->h, RPMCALLBACK_INST_CLOSE_FILE,
0, 0,
rpmteKey(p), ts->notifyData);
/*@=noeffectuncon@*/
p->fd = NULL;
ourrc++;
+ /*@innerbreak@*/ break;
+ case RPMRC_NOTTRUSTED:
+ case RPMRC_NOKEY:
+ case RPMRC_OK:
+ /*@innerbreak@*/ break;
}
if (rpmteFd(p) != NULL) gotfd = 1;
}
/*@=type@*/
if (rpmteFd(p) != NULL) {
+ /*
+ * XXX Sludge necessary to tranfer existing fstates/actions
+ * XXX around a recreated file info set.
+ */
+ psm->fi = rpmfiFree(psm->fi);
{
-char * fstates = fi->fstates;
-fileAction * actions = fi->actions;
-
-fi->fstates = NULL;
-fi->actions = NULL;
- psm->fi = rpmfiFree(psm->fi, 1);
- (void) rpmfiFree(fi, 0);
-/*@-usereleased@*/
-fi->magic = RPMFIMAGIC;
-fi->te = p;
-fi->record = 0;
- (void) rpmfiNew(ts, fi, p->h, RPMTAG_BASENAMES, 1);
- psm->fi = rpmfiLink(fi, "tsInstall");
-fi->fstates = _free(fi->fstates);
-fi->fstates = fstates;
-fi->actions = _free(fi->actions);
-fi->actions = actions;
-/*@=usereleased@*/
-
+ char * fstates = fi->fstates;
+ fileAction * actions = fi->actions;
+ rpmte savep;
+
+ fi->fstates = NULL;
+ fi->actions = NULL;
+/*@-nullstate@*/ /* FIX: fi->actions is NULL */
+ fi = rpmfiFree(fi);
+/*@=nullstate@*/
+
+ savep = rpmtsSetRelocateElement(ts, p);
+ fi = rpmfiNew(ts, p->h, RPMTAG_BASENAMES, 1);
+ (void) rpmtsSetRelocateElement(ts, savep);
+
+ if (fi != NULL) { /* XXX can't happen */
+ fi->te = p;
+ fi->fstates = _free(fi->fstates);
+ fi->fstates = fstates;
+ fi->actions = _free(fi->actions);
+ fi->actions = actions;
+ p->fi = fi;
+ }
}
- if (rpmteMultiLib(p))
- (void) rpmtsSetFlags(ts, (rpmtsFlags(ts) | RPMTRANS_FLAG_MULTILIB));
- else
- (void) rpmtsSetFlags(ts, (rpmtsFlags(ts) & ~RPMTRANS_FLAG_MULTILIB));
+ psm->fi = rpmfiLink(p->fi, NULL);
- if (psmStage(psm, PSM_PKGINSTALL)) {
+/*@-nullstate@*/ /* FIX: psm->fi may be NULL */
+ if (rpmpsmStage(psm, PSM_PKGINSTALL)) {
ourrc++;
- lastKey = pkgKey;
+ lastFailKey = pkgKey;
}
- fi->h = headerFree(fi->h);
+/*@=nullstate@*/
} else {
ourrc++;
- lastKey = pkgKey;
+ lastFailKey = pkgKey;
}
- p->h = headerFree(p->h);
-
if (gotfd) {
/*@-noeffectuncon @*/ /* FIX: check rc */
- (void) ts->notify(fi->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0,
+ (void) ts->notify(p->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0,
rpmteKey(p), ts->notifyData);
/*@=noeffectuncon @*/
/*@-type@*/
p->fd = NULL;
/*@=type@*/
}
+
+ p->h = headerFree(p->h);
+
+ (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_INSTALL), 0);
+
/*@switchbreak@*/ break;
+
case TR_REMOVED:
+ (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_ERASE), 0);
+
rpmMessage(RPMMESS_DEBUG, "========== --- %s\n", rpmteNEVR(p));
- /* If install failed, then we shouldn't erase. */
- if (rpmteDependsOnKey(p) != lastKey) {
- if (psmStage(psm, PSM_PKGERASE))
+ /*
+ * XXX This has always been a hack, now mostly broken.
+ * If install failed, then we shouldn't erase.
+ */
+ if (rpmteDependsOnKey(p) != lastFailKey) {
+ if (rpmpsmStage(psm, PSM_PKGERASE))
ourrc++;
}
+
+ (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_ERASE), 0);
+
/*@switchbreak@*/ break;
}
xx = rpmdbSync(rpmtsGetRdb(ts));
- (void) rpmfiUnlink(psm->fi, "tsInstall");
- psm->fi = NULL;
- psm->te = NULL;
+
+/*@-nullstate@*/ /* FIX: psm->fi may be NULL */
+ psm = rpmpsmFree(psm);
+/*@=nullstate@*/
+
/*@-type@*/ /* FIX: p is almost opaque */
- p->fi = rpmfiFree(fi, 1);
+ p->fi = rpmfiFree(p->fi);
/*@=type@*/
+
}
/*@=branchstate@*/
pi = rpmtsiFree(pi);
- psm->ts = rpmtsUnlink(psm->ts, "tsRun");
-
/*@-nullstate@*/ /* FIX: ts->flList may be NULL */
if (ourrc)
return -1;