From: jbj Date: Sat, 14 Aug 1999 20:01:38 +0000 (+0000) Subject: fix: don't remove file until last occurence in transaction (#4291). X-Git-Tag: rpm-4.4-release~2699 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f12ab9fac151d0dadcfb49fb16f5e495c00c5774;p=platform%2Fupstream%2Frpm.git fix: don't remove file until last occurence in transaction (#4291). CVS patchset: 3225 CVS date: 1999/08/14 20:01:38 --- diff --git a/CHANGES b/CHANGES index a131199..a4e8410 100644 --- a/CHANGES +++ b/CHANGES @@ -22,6 +22,7 @@ expand %# just like %{#} (and with same value as shell analogues). macro defaults for *, 0, and # if no args specified. getopt on non-linux requires optind to be saved/restored. + - fix: don't remove file until last occurence in transaction (#4291). 3.0.1 -> 3.0.2 - eliminate armv4 entries from rpmrc (Andrew E. Mileski). diff --git a/lib/rpmdb.c b/lib/rpmdb.c index e9a30ec..4fd2d58 100644 --- a/lib/rpmdb.c +++ b/lib/rpmdb.c @@ -820,14 +820,14 @@ int rpmdbFindFpList(rpmdb db, fingerPrint * fpList, dbiIndexSet * matchList, im = intMatches + start; - /* Find the end of the set of files matched in this package. */ + /* Find the end of the set of matched files in this package. */ for (end = start + 1; end < numIntMatches; end++) { if (im->rec.recOffset != intMatches[end].rec.recOffset) break; } num = end - start; - /* Compute fingerprints for each file match in this package */ + /* Compute fingerprints for each file match in this package. */ h = rpmdbGetRecord(db, im->rec.recOffset); if (!h) { free(intMatches); @@ -849,7 +849,7 @@ int rpmdbFindFpList(rpmdb db, fingerPrint * fpList, dbiIndexSet * matchList, free(fl); } - /* Add (recnum,filenum) to list for fingerprint matches */ + /* Add db (recnum,filenum) to list for fingerprint matches. */ for (i = 0; i < num; i++) { j = im[i].fpNum; if (FP_EQUAL(fps[i], fpList[j])) diff --git a/lib/transaction.c b/lib/transaction.c index 15dc506..482000a 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -661,8 +661,10 @@ static int handleRmvdInstalledFiles(struct fileInfo * fi, rpmdb db, otherFileNum = shared->otherFileNum; fileNum = shared->pkgFileNum; - if (otherStates[otherFileNum] == RPMFILE_STATE_NORMAL) - fi->actions[fileNum] = FA_SKIP; + if (otherStates[otherFileNum] != RPMFILE_STATE_NORMAL) + continue; + + fi->actions[fileNum] = FA_SKIP; } headerFree(h); @@ -674,16 +676,14 @@ static void handleOverlappedFiles(struct fileInfo * fi, hashTable ht, rpmProblemSet probs, struct diskspaceInfo * dsl) { int i, j; - struct fileInfo ** recs; - int numRecs; - int otherPkgNum, otherFileNum; - struct stat sb; - char mdsum[50]; - int rc; struct diskspaceInfo * ds = NULL; uint_32 fixupSize = 0; for (i = 0; i < fi->fc; i++) { + int otherPkgNum, otherFileNum; + struct fileInfo ** recs; + int numRecs; + if (fi->actions[i] == FA_SKIP || fi->actions[i] == FA_SKIPNSTATE) continue; @@ -704,8 +704,10 @@ static void handleOverlappedFiles(struct fileInfo * fi, hashTable ht, otherFileNum = -1; /* keep gcc quiet */ for (otherPkgNum = j - 1; otherPkgNum >= 0; otherPkgNum--) { +#if XXX_REMOVED_PACKAGES_LAST if (recs[otherPkgNum]->type != TR_ADDED) continue; +#endif /* TESTME: there are more efficient searches in the world... */ for (otherFileNum = 0; otherFileNum < recs[otherPkgNum]->fc; @@ -719,17 +721,17 @@ static void handleOverlappedFiles(struct fileInfo * fi, hashTable ht, switch (fi->type) { case TR_ADDED: - if (otherPkgNum < 0) { - if (fi->actions[i] == FA_UNKNOWN) { - if ((fi->fflags[i] & RPMFILE_CONFIG) && - !lstat(fi->fl[i], &sb)) { + if (otherPkgNum < 0) { + struct stat sb; + if (fi->actions[i] != FA_UNKNOWN) + break; + if ((fi->fflags[i] & RPMFILE_CONFIG) && !lstat(fi->fl[i], &sb)) fi->actions[i] = (fi->fflags[i] & RPMFILE_NOREPLACE) ? FA_ALTNAME : FA_BACKUP; - } else { + else fi->actions[i] = FA_CREATE; - } + break; } - } else { if (probs && filecmp(recs[otherPkgNum]->fmodes[otherFileNum], recs[otherPkgNum]->fmd5s[otherFileNum], recs[otherPkgNum]->flinks[otherFileNum], @@ -746,29 +748,34 @@ static void handleOverlappedFiles(struct fileInfo * fi, hashTable ht, file handling choice we already made, which may very well be exactly right. What about noreplace files?? */ fi->actions[i] = FA_CREATE; - } - break; + break; case TR_REMOVED: - if (otherPkgNum >= 0) { - fi->actions[i] = FA_SKIP; - } else { - if (fi->actions[i] != FA_SKIP && fi->actions[i] != FA_SKIPNSTATE && - fi->fstates[i] == RPMFILE_STATE_NORMAL ) { - if (S_ISREG(fi->fmodes[i]) && - (fi->fflags[i] & RPMFILE_CONFIG)) { - rc = mdfile(fi->fl[i], mdsum); - if (!rc && strcmp(fi->fmd5s[i], mdsum)) { - fi->actions[i] = FA_BACKUP; - } else { - /* FIXME: config files may need to be saved */ - fi->actions[i] = FA_REMOVE; - } - } else { - fi->actions[i] = FA_REMOVE; + if (otherPkgNum >= 0) { +#if XXX_REMOVED_PACKAGES_LAST + fi->actions[i] = FA_SKIP; + break; +#else + recs[otherPkgNum]->actions[otherFileNum] = FA_SKIP; +#endif + } + if (fi->actions[i] == FA_SKIP || fi->actions[i] == FA_SKIPNSTATE) + break; + if (fi->fstates[i] != RPMFILE_STATE_NORMAL) + break; + if (!(S_ISREG(fi->fmodes[i]) && (fi->fflags[i] & RPMFILE_CONFIG))) { + fi->actions[i] = FA_REMOVE; + break; + } + + { char mdsum[50]; + if (!mdfile(fi->fl[i], mdsum) && strcmp(fi->fmd5s[i], mdsum)) { + fi->actions[i] = FA_BACKUP; + break; } } - } - break; + /* FIXME: config files may need to be saved */ + fi->actions[i] = FA_REMOVE; + break; } if (ds) { @@ -1057,7 +1064,7 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify, if (headerGetEntry(h, RPMTAG_FILENAMES, NULL, NULL, &fileCount)) totalFileCount += fileCount; - headerFree(h); /* XXX ==> LEAK */ + headerFree(h); } } @@ -1191,7 +1198,7 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify, NOTIFY((NULL, RPMCALLBACK_TRANS_START, 6, flEntries, NULL, notifyData)); /* =============================================== - * Identify shared files: + * Compute file disposition for each package in transaction set. */ for (fi = flList; (fi - flList) < flEntries; fi++) { int knownBad; @@ -1199,23 +1206,25 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify, NOTIFY((NULL, RPMCALLBACK_TRANS_PROGRESS, (fi - flList), flEntries, NULL, notifyData)); + /* Extract file info for all files in this package from the database. */ matches = malloc(sizeof(*matches) * fi->fc); if (rpmdbFindFpList(ts->db, fi->fps, matches, fi->fc)) return 1; - /* Count number of shared files in this package. */ numShared = 0; for (i = 0; i < fi->fc; i++) numShared += matches[i].count; - /* Build sorted shared file info list for this package. */ + /* Build sorted file info list for this package. */ shared = sharedList = malloc(sizeof(*sharedList) * (numShared + 1)); - knownBad = 0; for (i = 0; i < fi->fc; i++) { - /* Take care not to mark files as replaced in packages that will - have been removed before we got here. */ + /* + * Take care not to mark files as replaced in packages that will + * have been removed before we will get here. + */ for (j = 0; j < matches[i].count; j++) { int k, ro; ro = matches[i].recs[j].recOffset; + knownBad = 0; for (k = 0; ro != knownBad && k < ts->orderCount; k++) { switch (ts->order[k].type) { case TR_REMOVED: @@ -1239,36 +1248,40 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify, shared->otherPkg = -1; free(matches); + /* Sort file info by other package index (otherPkg) */ qsort(sharedList, numShared, sizeof(*shared), sharedCmp); - /* Deal with files shared between packages. */ + /* For all files from this package that are in the database ... */ for (i = 0; i < numShared; i = nexti) { int beingRemoved; - /* Find the start of the next package with shared files. */ + shared = sharedList + i; + + /* Find the end of the files in the other package. */ for (nexti = i + 1; nexti < numShared; nexti++) { - if (sharedList[nexti].otherPkg != sharedList[i].otherPkg) + if (sharedList[nexti].otherPkg != shared->otherPkg) break; } - /* Is this package being removed? */ + /* Is this file from a package being removed? */ + beingRemoved = 0; for (j = 0; j < ts->numRemovedPackages; j++) { - if (ts->removedPackages[j] == sharedList[i].otherPkg) - break; + if (ts->removedPackages[j] != shared->otherPkg) + continue; + beingRemoved = 1; + break; } - beingRemoved = (j < ts->numRemovedPackages); - /* Special handling for all shared files from this package */ + /* Determine the fate of each file. */ switch (fi->type) { case TR_ADDED: - handleInstInstalledFiles(fi, ts->db, sharedList + i, nexti - i, - !(beingRemoved || - (ignoreSet & RPMPROB_FILTER_REPLACEOLDFILES)), + handleInstInstalledFiles(fi, ts->db, shared, nexti - i, + !(beingRemoved || (ignoreSet & RPMPROB_FILTER_REPLACEOLDFILES)), probs); break; case TR_REMOVED: if (!beingRemoved) - handleRmvdInstalledFiles(fi, ts->db, sharedList + i, nexti - i); + handleRmvdInstalledFiles(fi, ts->db, shared, nexti - i); break; } } diff --git a/po/rpm.pot b/po/rpm.pot index a939230..80a38b4 100644 --- a/po/rpm.pot +++ b/po/rpm.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 1999-08-13 15:41-0400\n" +"POT-Creation-Date: 1999-08-14 15:43-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -2658,8 +2658,8 @@ msgstr "" msgid "rebuilding database in rootdir %s\n" msgstr "" -#: ../lib/rebuilddb.c:23 ../lib/rpmdb.c:81 ../lib/rpmdb.c:99 -#: ../lib/rpmdb.c:115 +#: ../lib/rebuilddb.c:23 ../lib/rpmdb.c:65 ../lib/rpmdb.c:84 +#: ../lib/rpmdb.c:101 msgid "no dbpath has been set" msgstr "" @@ -2794,105 +2794,105 @@ msgstr "" msgid "OK" msgstr "" -#: ../lib/rpmdb.c:176 +#: ../lib/rpmdb.c:163 #, c-format msgid "opening database mode 0x%x in %s\n" msgstr "" -#: ../lib/rpmdb.c:186 ../lib/url.c:421 +#: ../lib/rpmdb.c:173 ../lib/url.c:421 #, c-format msgid "failed to open %s\n" msgstr "" -#: ../lib/rpmdb.c:199 ../lib/rpmdb.c:206 +#: ../lib/rpmdb.c:186 ../lib/rpmdb.c:193 #, c-format msgid "cannot get %s lock on database" msgstr "" -#: ../lib/rpmdb.c:200 +#: ../lib/rpmdb.c:187 msgid "exclusive" msgstr "" -#: ../lib/rpmdb.c:207 +#: ../lib/rpmdb.c:194 msgid "shared" msgstr "" -#: ../lib/rpmdb.c:234 +#: ../lib/rpmdb.c:221 msgid "" "old format database is present; use --rebuilddb to generate a new format " "database" msgstr "" -#: ../lib/rpmdb.c:393 +#: ../lib/rpmdb.c:384 #, c-format msgid "package %s not listed in %s" msgstr "" -#: ../lib/rpmdb.c:404 +#: ../lib/rpmdb.c:395 #, c-format msgid "package %s not found in %s" msgstr "" -#: ../lib/rpmdb.c:428 ../lib/uninstall.c:89 +#: ../lib/rpmdb.c:420 ../lib/uninstall.c:89 #, c-format msgid "cannot read header at %d for uninstall" msgstr "" -#: ../lib/rpmdb.c:436 +#: ../lib/rpmdb.c:428 msgid "package has no name" msgstr "" -#: ../lib/rpmdb.c:438 +#: ../lib/rpmdb.c:430 msgid "removing name index\n" msgstr "" -#: ../lib/rpmdb.c:443 +#: ../lib/rpmdb.c:435 msgid "package has no group\n" msgstr "" -#: ../lib/rpmdb.c:445 +#: ../lib/rpmdb.c:437 msgid "removing group index\n" msgstr "" -#: ../lib/rpmdb.c:452 +#: ../lib/rpmdb.c:444 #, c-format msgid "removing provides index for %s\n" msgstr "" -#: ../lib/rpmdb.c:467 +#: ../lib/rpmdb.c:459 #, c-format msgid "removing requiredby index for %s\n" msgstr "" -#: ../lib/rpmdb.c:479 +#: ../lib/rpmdb.c:471 #, c-format msgid "removing trigger index for %s\n" msgstr "" -#: ../lib/rpmdb.c:490 +#: ../lib/rpmdb.c:482 #, c-format msgid "removing conflict index for %s\n" msgstr "" -#: ../lib/rpmdb.c:507 +#: ../lib/rpmdb.c:499 #, c-format msgid "removing file index for %s\n" msgstr "" -#: ../lib/rpmdb.c:516 +#: ../lib/rpmdb.c:508 msgid "package has no files\n" msgstr "" -#: ../lib/rpmdb.c:589 +#: ../lib/rpmdb.c:583 msgid "cannot allocate space for database" msgstr "" -#: ../lib/rpmdb.c:660 +#: ../lib/rpmdb.c:656 #, c-format msgid "cannot read header at %d for update" msgstr "" -#: ../lib/rpmdb.c:669 +#: ../lib/rpmdb.c:665 msgid "header changed size!" msgstr "" diff --git a/rpm.spec b/rpm.spec index 62a0e96..4dade99 100644 --- a/rpm.spec +++ b/rpm.spec @@ -2,7 +2,7 @@ Summary: The Red Hat package management system. Name: rpm %define version 3.0.3 Version: %{version} -Release: 0.11 +Release: 0.12 Group: System Environment/Base Source: ftp://ftp.rpm.org/pub/rpm/dist/rpm-3.0.x/rpm-%{version}.tar.gz Copyright: GPL