diff options
author | jbj <devnull@localhost> | 1999-09-26 00:43:12 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 1999-09-26 00:43:12 +0000 |
commit | 861a7532cdc06f841d0a93e45e5b962033d35397 (patch) | |
tree | 5eebda34bcef3e58d0daab442644f5c92e797981 | |
parent | c63192d864acc8481c2afc2012d5c98efdb8abad (diff) | |
download | rpm-861a7532cdc06f841d0a93e45e5b962033d35397.tar.gz rpm-861a7532cdc06f841d0a93e45e5b962033d35397.tar.bz2 rpm-861a7532cdc06f841d0a93e45e5b962033d35397.zip |
fix: rpm-2.5.1 had file list w/o leading / fix.
CVS patchset: 3328
CVS date: 1999/09/26 00:43:12
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | lib/rpmdb.c | 52 | ||||
-rw-r--r-- | rpm.spec | 2 |
3 files changed, 50 insertions, 5 deletions
@@ -61,6 +61,7 @@ - fix: removed files fingerprint memory leak. - fix: resurrect allfiles flag from rpm-2.5.x. - fix: version compares compatible with epoch-less requires/conflicts. + - fix: rpm-2.5.1 had file list w/o leading / fix. 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 548bb8536..b0ee451a1 100644 --- a/lib/rpmdb.c +++ b/lib/rpmdb.c @@ -296,11 +296,55 @@ int rpmdbNextRecNum(rpmdb db, unsigned int lastOffset) { return faNextOffset(db->pkgs, lastOffset); } -Header rpmdbGetRecord(rpmdb db, unsigned int offset) -{ +static Header doGetRecord(rpmdb db, unsigned int offset, int pristine) { + Header h; + char ** fileList; + char ** newList; + int fileCount = 0; + int i; + (void)faLseek(db->pkgs, offset, SEEK_SET); - return headerRead(faFileno(db->pkgs), HEADER_MAGIC_NO); + h = headerRead(faFileno(db->pkgs), HEADER_MAGIC_NO); + + if (pristine) return h; + + /* the RPM used to buildmuch of RH 5.1 could produce packages whose + file lists did not have leading /'s. Now is a good time to fix + that */ + + if (!headerGetEntryMinMemory(h, RPMTAG_FILENAMES, NULL, + (void **) &fileList, &fileCount)) return h; + + for (i = 0; i < fileCount; i++) + if (*fileList[i] != '/') break; + + if (i == fileCount) { + free(fileList); + return h; + } + + /* bad header -- let's clean it up */ + newList = alloca(sizeof(*newList) * fileCount); + for (i = 0; i < fileCount; i++) { + newList[i] = alloca(strlen(fileList[i]) + 2); + if (*fileList[i] == '/') + strcpy(newList[i], fileList[i]); + else + sprintf(newList[i], "/%s", fileList[i]); + } + + free(fileList); + + headerModifyEntry(h, RPMTAG_FILENAMES, RPM_STRING_ARRAY_TYPE, + newList, fileCount); + + return h; +} + +Header rpmdbGetRecord(rpmdb db, unsigned int offset) +{ + return doGetRecord(db, offset, 0); } int rpmdbFindByFile(rpmdb db, const char * filespec, dbiIndexSet * matches) @@ -662,7 +706,7 @@ int rpmdbUpdateRecord(rpmdb db, int offset, Header newHeader) int oldSize; int rc = 0; - oldHeader = rpmdbGetRecord(db, offset); + oldHeader = doGetRecord(db, offset, 1); if (oldHeader == NULL) { rpmError(RPMERR_DBCORRUPT, _("cannot read header at %d for update"), offset); @@ -2,7 +2,7 @@ Summary: The Red Hat package management system. Name: rpm %define version 3.0.3 Version: %{version} -Release: 1 +Release: 2 Group: System Environment/Base Source: ftp://ftp.rpm.org/pub/rpm/dist/rpm-3.0.x/rpm-%{version}.tar.gz Copyright: GPL |