#include <rpmmacro.h> /* XXX for rpmExpand */
+#include "fsm.h"
#include "psm.h"
-#include "rpmps.h"
+#include "rpmdb.h"
#include "rpmds.h"
#define _RPMTS_INTERNAL
#include "rpmts.h"
-#include "rpmdb.h"
+#include "cpio.h"
#include "fprint.h"
#include "legacy.h" /* XXX domd5 */
#include "misc.h" /* XXX stripTrailingChar, splitString, currentDirectory */
#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 @*/
/**
*/
+/*@-boundsread@*/
static fileAction decideFileFate(const rpmts ts,
const rpmfi ofi, rpmfi nfi)
- /*@globals fileSystem @*/
- /*@modifies nfi, fileSystem @*/
+ /*@globals fileSystem, internalState @*/
+ /*@modifies nfi, fileSystem, internalState @*/
{
const char * fn = rpmfiFN(nfi);
int newFlags = rpmfiFFlags(nfi);
}
}
- diskWhat = whatis(sb.st_mode);
- dbWhat = whatis(ofi->fmodes[ofi->i]);
- newWhat = whatis(nfi->fmodes[nfi->i]);
+ diskWhat = whatis((int_16)sb.st_mode);
+ dbWhat = whatis(rpmfiFMode(ofi));
+ newWhat = whatis(rpmfiFMode(nfi));
/*
* RPM >= 2.3.10 shouldn't create config directories -- we'll ignore
* possible in case something else (like the timestamp) has changed.
*/
if (dbWhat == REG) {
-#ifdef DYING
- if (ofi->md5s != NULL && nfi->md5s != NULL) {
-#endif
- const unsigned char * omd5 = ofi->md5s + (16 * ofi->i);
- const unsigned char * nmd5 = nfi->md5s + (16 * nfi->i);
- if (domd5(fn, buffer, 0))
- return FA_CREATE; /* assume file has been removed */
- if (!memcmp(omd5, buffer, 16))
- return FA_CREATE; /* unmodified config file, replace. */
- if (!memcmp(omd5, nmd5, 16))
- return FA_SKIP; /* identical file, don't bother. */
-#ifdef DYING
- } else {
- const char * omd5 = ofi->fmd5s[ofi->i];
- const char * nmd5 = nfi->fmd5s[nfi->i];
- if (domd5(fn, buffer, 1))
- return FA_CREATE; /* assume file has been removed */
- if (!strcmp(omd5, buffer))
- return FA_CREATE; /* unmodified config file, replace. */
- if (!strcmp(omd5, nmd5))
- return FA_SKIP; /* identical file, don't bother. */
- }
-#endif
+ const unsigned char * omd5, * nmd5;
+ if (domd5(fn, buffer, 0, NULL))
+ return FA_CREATE; /* assume file has been removed */
+ omd5 = rpmfiMD5(ofi);
+ if (omd5 && !memcmp(omd5, buffer, 16))
+ return FA_CREATE; /* unmodified config file, replace. */
+ nmd5 = rpmfiMD5(nfi);
+/*@-nullpass@*/
+ if (omd5 && nmd5 && !memcmp(omd5, nmd5, 16))
+ return FA_SKIP; /* identical file, don't bother. */
+/*@=nullpass@*/
} else /* dbWhat == LINK */ {
+ const char * oFLink, * nFLink;
memset(buffer, 0, sizeof(buffer));
if (readlink(fn, buffer, sizeof(buffer) - 1) == -1)
return FA_CREATE; /* assume file has been removed */
- if (!strcmp(ofi->flinks[ofi->i], buffer))
+ oFLink = rpmfiFLink(ofi);
+ if (oFLink && !strcmp(oFLink, buffer))
return FA_CREATE; /* unmodified config file, replace. */
- if (!strcmp(ofi->flinks[ofi->i], nfi->flinks[nfi->i]))
+ nFLink = rpmfiFLink(nfi);
+/*@-nullpass@*/
+ 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
*/
return save;
}
+/*@=boundsread@*/
/**
*/
+/*@-boundsread@*/
static int filecmp(rpmfi afi, rpmfi bfi)
/*@*/
{
- fileTypes awhat = whatis(afi->fmodes[afi->i]);
- fileTypes bwhat = whatis(bfi->fmodes[bfi->i]);
+ fileTypes awhat = whatis(rpmfiFMode(afi));
+ fileTypes bwhat = whatis(rpmfiFMode(bfi));
if (awhat != bwhat) return 1;
if (awhat == LINK) {
- const char * alink = afi->flinks[afi->i];
- const char * blink = bfi->flinks[bfi->i];
+ const char * alink = rpmfiFLink(afi);
+ const char * blink = rpmfiFLink(bfi);
+ if (alink == blink) return 0;
+ if (alink == NULL) return 1;
+ if (blink == NULL) return -1;
return strcmp(alink, blink);
} else if (awhat == REG) {
-#ifdef DYING
- if (afi->md5s != NULL && bfi->md5s != NULL) {
-#endif
- const unsigned char * amd5 = afi->md5s + (16 * afi->i);
- const unsigned char * bmd5 = bfi->md5s + (16 * bfi->i);
- return memcmp(amd5, bmd5, 16);
-#ifdef DYING
- } else {
- const char * amd5 = afi->fmd5s[afi->i];
- const char * bmd5 = bfi->fmd5s[bfi->i];
- return strcmp(amd5, bmd5);
- }
-#endif
+ const unsigned char * amd5 = rpmfiMD5(afi);
+ const unsigned char * bmd5 = rpmfiMD5(bfi);
+ if (amd5 == bmd5) return 0;
+ if (amd5 == NULL) return 1;
+ if (bmd5 == NULL) return -1;
+ return memcmp(amd5, bmd5, 16);
}
return 0;
}
+/*@=boundsread@*/
/**
*/
/* XXX only ts->{probs,rpmdb} modified */
+/*@-bounds@*/
static int handleInstInstalledFiles(const rpmts ts,
rpmte p, rpmfi fi,
sharedFileInfo shared,
int sharedCount, int reportConflicts)
- /*@globals fileSystem @*/
- /*@modifies ts, fi, fileSystem @*/
+ /*@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;
ps = rpmtsProblems(ts);
for (i = 0; i < sharedCount; i++, shared++) {
int otherFileNum, fileNum;
+ int isCfgFile;
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);
#ifdef DYING
/* XXX another tedious segfault, assume file state normal. */
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),
altNEVR,
0);
}
- if (!(rpmfiFFlags(otherFi) | rpmfiFFlags(fi)) & RPMFILE_CONFIG) {
+ if (!isCfgFile) {
/*@-assignexpose@*/ /* FIX: p->replaced, not fi */
if (!shared->isRemoved)
fi->replaced[numReplaced++] = *shared;
}
}
- if ((rpmfiFFlags(otherFi) | rpmfiFFlags(fi)) & RPMFILE_CONFIG) {
+ if (isCfgFile) {
fileAction action;
action = decideFileFate(ts, otherFi, fi);
fi->actions[fileNum] = action;
}
- fi->replacedSizes[fileNum] = otherFi->fsizes[otherFi->i];
-
+ fi->replacedSizes[fileNum] = rpmfiFSize(otherFi);
}
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));
return 0;
}
+/*@=bounds@*/
/**
*/
/* XXX only ts->rpmdb modified */
static int handleRmvdInstalledFiles(const rpmts ts, rpmfi fi,
sharedFileInfo shared, int sharedCount)
- /*@globals fileSystem @*/
- /*@modifies ts, fi, fileSystem @*/
+ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
+ /*@modifies ts, fi, rpmGlobalMacroContext, fileSystem, internalState @*/
{
HGE_t hge = fi->hge;
Header h;
xx = hge(h, RPMTAG_FILESTATES, NULL, (void **) &otherStates, NULL);
+/*@-boundswrite@*/
for (i = 0; i < sharedCount; i++, shared++) {
int otherFileNum, fileNum;
otherFileNum = shared->otherFileNum;
fi->actions[fileNum] = FA_SKIP;
}
+/*@=boundswrite@*/
mi = rpmdbFreeIterator(mi);
#define ISROOT(_d) (((_d)[0] == '/' && (_d)[1] == '\0') ? "" : (_d))
/*@unchecked@*/
-static int _fps_debug = 0;
+int _fps_debug = 0;
static int fpsCompare (const void * one, const void * two)
/*@*/
if (adnlen == 1 && asnlen != 0) adnlen = 0;
if (bdnlen == 1 && bsnlen != 0) bdnlen = 0;
+/*@-boundswrite@*/
afn = t = alloca(adnlen+asnlen+abnlen+2);
if (adnlen) t = stpcpy(t, a->entry->dirName);
*t++ = '/';
if (b->subDir && bsnlen) t = stpcpy(t, b->subDir);
if (bbnlen) t = stpcpy(t, b->baseName);
if (bfn[0] == '/' && bfn[1] == '/') bfn++;
+/*@=boundswrite@*/
rc = strcmp(afn, bfn);
/*@-modfilesys@*/
if (otherFileNum == otherFc) {
/*@-modfilesys@*/
if (_fps_debug)
-fprintf(stderr, "*** NULL %s/%s%s\n",
+fprintf(stderr, "*** FP_EQUAL NULL %s/%s%s\n",
ISROOT(fiFps->entry->dirName),
(fiFps->subDir ? fiFps->subDir : ""),
fiFps->baseName);
const struct fingerPrint_s * bingoFps;
+/*@-boundswrite@*/
bingoFps = bsearch(fiFps, otherFps, otherFc, sizeof(*otherFps), fpsCompare);
+/*@=boundswrite@*/
if (bingoFps == NULL) {
/*@-modfilesys@*/
-fprintf(stderr, "*** NULL %s/%s%s\n",
+if (_fps_debug)
+fprintf(stderr, "*** bingoFps NULL %s/%s%s\n",
ISROOT(fiFps->entry->dirName),
(fiFps->subDir ? fiFps->subDir : ""),
fiFps->baseName);
/*@-nullpass@*/ /* LCL: looks good to me */
if (!(fiFps == bingoFps || FP_EQUAL((*fiFps), (*bingoFps)))) {
/*@-modfilesys@*/
+if (_fps_debug)
fprintf(stderr, "*** BAD %s/%s%s\n",
ISROOT(bingoFps->entry->dirName),
(bingoFps->subDir ? bingoFps->subDir : ""),
/* XXX only ts->{probs,di} modified */
static void handleOverlappedFiles(const rpmts ts,
const rpmte p, rpmfi fi)
- /*@globals fileSystem @*/
- /*@modifies ts, fi, fileSystem @*/
+ /*@globals fileSystem, internalState @*/
+ /*@modifies ts, fi, fileSystem, internalState @*/
{
uint_32 fixupSize = 0;
rpmps ps;
struct fingerPrint_s * fiFps;
int otherPkgNum, otherFileNum;
rpmfi otherFi;
+ int_32 FFlags;
+ int_16 FMode;
const rpmfi * recs;
int numRecs;
fn = rpmfiFN(fi);
fiFps = fi->fps + i;
+ FFlags = rpmfiFFlags(fi);
+ FMode = rpmfiFMode(fi);
fixupSize = 0;
otherFileNum = findFps(fiFps, otherFps, otherFc);
(void) rpmfiSetFX(otherFi, otherFileNum);
- /* XXX is this test still necessary? */
-assert(otherFi->actions[otherFileNum] != FA_UNKNOWN);
+ /* XXX Happens iff fingerprint for incomplete package install. */
if (otherFi->actions[otherFileNum] != FA_UNKNOWN)
/*@innerbreak@*/ break;
}
+/*@-boundswrite@*/
switch (rpmteType(p)) {
case TR_ADDED:
{ struct stat sb;
/* XXX is this test still necessary? */
if (fi->actions[i] != FA_UNKNOWN)
/*@switchbreak@*/ break;
- if ((rpmfiFFlags(fi) & RPMFILE_CONFIG) &&
- !lstat(fn, &sb)) {
+ if ((FFlags & RPMFILE_CONFIG) && !lstat(fn, &sb)) {
/* Here is a non-overlapped pre-existing config file. */
- fi->actions[i] = (rpmfiFFlags(fi) & RPMFILE_NOREPLACE)
+ fi->actions[i] = (FFlags & RPMFILE_NOREPLACE)
? FA_ALTNAME : FA_BACKUP;
} else {
fi->actions[i] = FA_CREATE;
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,
}
/* Try to get the disk accounting correct even if a conflict. */
- fixupSize = otherFi->fsizes[otherFileNum];
+ fixupSize = rpmfiFSize(otherFi);
- if ((rpmfiFFlags(fi) & RPMFILE_CONFIG) && !lstat(fn, &sb)) {
+ if ((FFlags & RPMFILE_CONFIG) && !lstat(fn, &sb)) {
/* Here is an overlapped pre-existing config file. */
- fi->actions[i] = (rpmfiFFlags(fi) & RPMFILE_NOREPLACE)
+ fi->actions[i] = (FFlags & RPMFILE_NOREPLACE)
? FA_ALTNAME : FA_SKIP;
} else {
fi->actions[i] = FA_CREATE;
}
if (XFA_SKIPPING(fi->actions[i]))
/*@switchbreak@*/ break;
- if (fi->fstates && fi->fstates[i] != RPMFILE_STATE_NORMAL)
+ if (rpmfiFState(fi) != RPMFILE_STATE_NORMAL)
/*@switchbreak@*/ break;
- if (!(S_ISREG(fi->fmodes[i]) && (rpmfiFFlags(fi) & RPMFILE_CONFIG))) {
+ if (!(S_ISREG(FMode) && (FFlags & RPMFILE_CONFIG))) {
fi->actions[i] = FA_ERASE;
/*@switchbreak@*/ break;
}
/* Here is a pre-existing modified config file that needs saving. */
{ char md5sum[50];
- const unsigned char * md5 = fi->md5s + (16 * i);
- if (!domd5(fn, md5sum, 0) && memcmp(md5, md5sum, 16)) {
+ const unsigned char * MD5 = rpmfiMD5(fi);
+ if (!domd5(fn, md5sum, 0, NULL) && memcmp(MD5, md5sum, 16)) {
fi->actions[i] = FA_BACKUP;
/*@switchbreak@*/ break;
}
fi->actions[i] = FA_ERASE;
/*@switchbreak@*/ break;
}
+/*@=boundswrite@*/
/* Update disk space info for a file. */
- rpmtsUpdateDSI(ts, fi->fps[i].entry->dev,
- fi->fsizes[i], fi->replacedSizes[i], fixupSize, fi->actions[i]);
+ rpmtsUpdateDSI(ts, fiFps->entry->dev, rpmfiFSize(fi),
+ fi->replacedSizes[i], fixupSize, fi->actions[i]);
}
ps = rpmpsFree(ps);
if (p == NULL || h == NULL)
return 1;
+/*@-boundswrite@*/
nb = strlen(rpmteNEVR(p)) + (rpmteE(p) != NULL ? strlen(rpmteE(p)) : 0) + 1;
t = alloca(nb);
*t = '\0';
if (rpmteV(p) != NULL) t = stpcpy(t, rpmteV(p));
*t++ = '-';
if (rpmteR(p) != NULL) t = stpcpy(t, rpmteR(p));
+/*@=boundswrite@*/
req = rpmdsSingle(RPMTAG_REQUIRENAME, rpmteN(p), reqEVR, reqFlags);
- rc = headerMatchesDepFlags(h, req);
+ rc = rpmdsNVRMatchesDep(h, req, _rpmds_nopromote);
req = rpmdsFree(req);
if (rc == 0) {
}
/**
+ * 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)) {
fi = rpmfiInit(fi, 0);
if (fi != NULL) /* XXX lclint */
while ((i = rpmfiNext(fi)) >= 0) {
- const char * dir;
+ const char * fdn, * fbn;
+ int_16 fFMode;
if (XFA_SKIPPING(fi->actions[i]))
/*@innercontinue@*/ continue;
- if (whatis(fi->fmodes[i]) != XDIR)
+
+ fFMode = rpmfiFMode(fi);
+
+ if (whatis(fFMode) != XDIR)
/*@innercontinue@*/ continue;
- dir = fi->dnl[fi->dil[i]];
- if (strlen(dir) != dnlen)
+ fdn = rpmfiDN(fi);
+ if (strlen(fdn) != dnlen)
/*@innercontinue@*/ continue;
- if (strncmp(dir, dn, dnlen))
+ if (strncmp(fdn, dn, dnlen))
/*@innercontinue@*/ continue;
- if (strlen(fi->bnl[i]) != bnlen)
+ fbn = rpmfiBN(fi);
+ if (strlen(fbn) != bnlen)
/*@innercontinue@*/ continue;
- if (strncmp(fi->bnl[i], bn, bnlen))
+ if (strncmp(fbn, bn, bnlen))
/*@innercontinue@*/ continue;
rpmMessage(RPMMESS_DEBUG, _("excluding directory %s\n"), dn);
fi->actions[i] = FA_SKIPNSTATE;
}
}
+/*@-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);
ts->probs = rpmpsCreate();
+ /* XXX Make sure the database is open RDWR for package install/erase. */
+ { int dbmode = (rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)
+ ? O_RDONLY : (O_RDWR|O_CREAT);
+
+ /* Open database RDWR for installing packages. */
+ if (rpmtsOpenDB(ts, dbmode))
+ return -1; /* XXX W2DO? */
+ }
+
ts->ignoreSet = ignoreSet;
{ const char * currDir = currentDirectory();
rpmtsSetCurrDir(ts, currDir);
(void) rpmtsSetTid(ts, tid);
}
- memset(psm, 0, sizeof(*psm));
- psm->ts = rpmtsLink(ts, "tsRun");
-
/* Get available space on mounted file systems. */
xx = rpmtsInitDSI(ts);
* For packages being removed:
* - count files.
*/
+
+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,
* calling fpLookupList only once. I'm not sure that the speedup is
* 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;
continue; /* XXX can't happen */
fc = rpmfiFC(fi);
-#ifdef DYING /* XXX W2DO? this is now done in rpmtsiFi, okay ??? */
- fi->magic = RPMFIMAGIC;
- fi->te = p;
-#endif
-
/*@-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);
/* ===============================================
* Compute file disposition for each package in transaction set.
*/
+rpmMessage(RPMMESS_DEBUG, _("computing file dispositions\n"));
ps = rpmtsProblems(ts);
pi = rpmtsiInit(ts);
while ((p = rpmtsiNext(pi, 0)) != NULL) {
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.
*/
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");
- xx = psmStage(psm, PSM_PKGSAVE);
- (void) rpmfiUnlink(fi, "tsRepackage");
- psm->fi = NULL;
- psm->te = NULL;
+ 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 */
+ 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.
*/
- 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),
- "rpmtsRun", &p->h);
+ 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, "TR_ADDED fi->h free");
+/*@=nullstate@*/
} else {
ourrc++;
- lastKey = pkgKey;
+ lastFailKey = pkgKey;
}
- p->h = headerFree(p->h, "TR_ADDED h free");
-
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;