summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorewt <devnull@localhost>1999-10-21 02:40:57 +0000
committerewt <devnull@localhost>1999-10-21 02:40:57 +0000
commit1bcfa7ac608310ff018e9fca851f64d61ec99ddf (patch)
treeda2804992378fed7e5bcdecc169ddbe9579b32ec /lib
parente6698260f453b3f9418a8d7fdbbd6d764ef99606 (diff)
downloadrpm-1bcfa7ac608310ff018e9fca851f64d61ec99ddf.tar.gz
rpm-1bcfa7ac608310ff018e9fca851f64d61ec99ddf.tar.bz2
rpm-1bcfa7ac608310ff018e9fca851f64d61ec99ddf.zip
got installs/removes working with new file lists
CVS patchset: 3389 CVS date: 1999/10/21 02:40:57
Diffstat (limited to 'lib')
-rw-r--r--lib/fprint.c16
-rw-r--r--lib/fprint.h5
-rw-r--r--lib/install.c20
-rw-r--r--lib/misc.c20
-rw-r--r--lib/misc.h5
-rw-r--r--lib/rpmdb.c3
-rw-r--r--lib/transaction.c33
7 files changed, 61 insertions, 41 deletions
diff --git a/lib/fprint.c b/lib/fprint.c
index 3c5e3b618..7e575bf0e 100644
--- a/lib/fprint.c
+++ b/lib/fprint.c
@@ -26,7 +26,7 @@ static const struct fprintCacheEntry_s * cacheContainsDirectory(
}
static fingerPrint doLookup(fingerPrintCache cache, const char * dirName,
- char * baseName, int scareMemory) {
+ const char * baseName, int scareMemory) {
char dir[PATH_MAX];
const char * chptr1;
char * end, * bn;
@@ -140,8 +140,9 @@ int fpEqual(const void * key1, const void * key2)
return FP_EQUAL(*((const fingerPrint *) key1), *((fingerPrint *) key2));
}
-void fpLookupList(fingerPrintCache cache, char ** dirNames, char ** baseNames,
- int * dirIndexes, int fileCount, fingerPrint * fpList) {
+void fpLookupList(fingerPrintCache cache, const char ** dirNames,
+ const char ** baseNames, const int * dirIndexes,
+ int fileCount, fingerPrint * fpList) {
int i;
for (i = 0; i < fileCount; i++) {
@@ -160,12 +161,13 @@ void fpLookupList(fingerPrintCache cache, char ** dirNames, char ** baseNames,
void fpLookupHeader(fingerPrintCache cache, Header h, fingerPrint * fpList) {
int fileCount;
- char ** baseNames, ** dirNames;
+ const char ** baseNames, ** dirNames;
int_32 * dirIndexes;
- if (!headerGetEntry(h, RPMTAG_COMPFILELIST, NULL, (void **) &baseNames,
- &fileCount)) return;
- headerGetEntry(h, RPMTAG_COMPDIRLIST, NULL, (void **) &dirNames, NULL);
+ if (!headerGetEntryMinMemory(h, RPMTAG_COMPFILELIST, NULL,
+ (void **) &baseNames, &fileCount)) return;
+ headerGetEntryMinMemory(h, RPMTAG_COMPDIRLIST, NULL, (void **) &dirNames,
+ NULL);
headerGetEntry(h, RPMTAG_COMPFILEDIRS, NULL, (void **) &dirIndexes, NULL);
fpLookupList(cache, dirNames, baseNames, dirIndexes, fileCount, fpList);
diff --git a/lib/fprint.h b/lib/fprint.h
index aa0efc998..e94254eeb 100644
--- a/lib/fprint.h
+++ b/lib/fprint.h
@@ -48,8 +48,9 @@ unsigned int fpHashFunction(const void * key);
int fpEqual(const void * key1, const void * key2);
/* scareMemory is assumed for both of these! */
-void fpLookupList(fingerPrintCache cache, char ** dirNames, char ** baseNames,
- int * dirIndexes, int fileCount, fingerPrint * fpList);
+void fpLookupList(fingerPrintCache cache, const char ** dirNames,
+ const char ** baseNames, const int * dirIndexes,
+ int fileCount, fingerPrint * fpList);
void fpLookupHeader(fingerPrintCache cache, Header h, fingerPrint * fpList);
#ifdef __cplusplus
diff --git a/lib/install.c b/lib/install.c
index bc3468798..43d7cb5e1 100644
--- a/lib/install.c
+++ b/lib/install.c
@@ -106,17 +106,15 @@ static int assembleFileList(Header h, /*@out@*/ struct fileMemory ** memPtr,
*memPtr = mem;
- if (!headerGetEntry(h, RPMTAG_OLDFILENAMES, NULL, (void **) &mem->names,
- fileCountPtr))
- return 0;
+ if (!headerIsEntry(h, RPMTAG_COMPFILELIST)) return 0;
-#if 0
- if (!headerGetEntry(h, RPMTAG_ORIGFILENAMES, NULL,
- (void **) &mem->cpioNames, NULL))
- headerGetEntry(h, RPMTAG_OLDFILENAMES, NULL, (void **) &mem->cpioNames,
- fileCountPtr);
- headerRemoveEntry(h, RPMTAG_ORIGFILENAMES);
-#endif
+ buildFileList(h, (char ***) &mem->names, fileCountPtr);
+
+ if (headerIsEntry(h, RPMTAG_ORIGCOMPFILELIST)) {
+ buildOrigFileList(h, (char ***) &mem->cpioNames, fileCountPtr);
+ } else {
+ buildFileList(h, (char ***) &mem->cpioNames, fileCountPtr);
+ }
fileCount = *fileCountPtr;
@@ -589,7 +587,7 @@ int rpmVersionCompare(Header first, Header second)
return rpmvercmp(one, two);
}
-const char *const fileActionString(enum fileActions a)
+const char * fileActionString(enum fileActions a)
{
switch (a) {
case FA_UNKNOWN: return "unknown";
diff --git a/lib/misc.c b/lib/misc.c
index 921370a85..4c8eb75c9 100644
--- a/lib/misc.c
+++ b/lib/misc.c
@@ -464,7 +464,9 @@ void compressFilelist(Header h) {
/* this is pretty straight-forward. The only thing that even resembles a trick
is getting all of this into a single xmalloc'd block */
-void buildFileList(Header h, char *** fileListPtr, int * fileCountPtr) {
+static void doBuildFileList(Header h, char *** fileListPtr,
+ int * fileCountPtr, int baseNameTag,
+ int dirListTag, int dirIndexesTag) {
int * dirList;
char ** dirs;
char ** tails;
@@ -474,14 +476,14 @@ void buildFileList(Header h, char *** fileListPtr, int * fileCountPtr) {
char * data;
int i;
- if (!headerGetEntry(h, RPMTAG_COMPFILELIST, NULL, (void **) &tails,
+ if (!headerGetEntry(h, baseNameTag, NULL, (void **) &tails,
&count))
/* no file list */
return;
- headerGetEntry(h, RPMTAG_COMPDIRLIST, NULL, (void **) &dirs,
+ headerGetEntry(h, dirListTag, NULL, (void **) &dirs,
&count);
- headerGetEntry(h, RPMTAG_COMPFILEDIRS, NULL, (void **) &dirList,
+ headerGetEntry(h, dirIndexesTag, NULL, (void **) &dirList,
&count);
size = sizeof(*fileList) * count;
@@ -502,3 +504,13 @@ void buildFileList(Header h, char *** fileListPtr, int * fileCountPtr) {
*fileListPtr = fileList;
*fileCountPtr = count;
}
+
+void buildFileList(Header h, char *** fileListPtr, int * fileCountPtr) {
+ doBuildFileList(h, fileListPtr, fileCountPtr, RPMTAG_COMPFILELIST,
+ RPMTAG_COMPDIRLIST, RPMTAG_COMPFILEDIRS);
+}
+
+void buildOrigFileList(Header h, char *** fileListPtr, int * fileCountPtr) {
+ doBuildFileList(h, fileListPtr, fileCountPtr, RPMTAG_ORIGCOMPFILELIST,
+ RPMTAG_ORIGCOMPDIRLIST, RPMTAG_ORIGCOMPFILEDIRS);
+}
diff --git a/lib/misc.h b/lib/misc.h
index af0c15d52..7d263908f 100644
--- a/lib/misc.h
+++ b/lib/misc.h
@@ -36,7 +36,10 @@ int makeTempFile(const char * prefix, /*@out@*/ const char ** fnptr,
/*@out@*/ FD_t * fdptr);
char * currentDirectory(void); /* result needs to be freed */
void compressFilelist(Header h);
-void buildFileList(Header h, /*@out@*/ char *** fileListPtr, /*@out@*/ int * fileCountPtr);
+void buildFileList(Header h, /*@out@*/ char *** fileListPtr,
+ /*@out@*/ int * fileCountPtr);
+void buildOrigFileList(Header h, /*@out@*/ char *** fileListPtr,
+ /*@out@*/ int * fileCountPtr);
#ifdef __cplusplus
}
diff --git a/lib/rpmdb.c b/lib/rpmdb.c
index d71bf2f84..47b51c91d 100644
--- a/lib/rpmdb.c
+++ b/lib/rpmdb.c
@@ -843,7 +843,8 @@ int rpmdbFindFpList(rpmdb db, fingerPrint * fpList, dbiIndexSet * matchList,
int start, end;
int num;
int_32 fc;
- char ** dirNames, ** fullBaseNames, ** baseNames;
+ const char ** dirNames, ** baseNames;
+ const char ** fullBaseNames;
int_32 * dirIndexes, * fullDirIndexes;
fingerPrintCache fpc;
diff --git a/lib/transaction.c b/lib/transaction.c
index f3513c583..b9c80be14 100644
--- a/lib/transaction.c
+++ b/lib/transaction.c
@@ -183,9 +183,9 @@ static void psAppendFile(rpmProblemSet probs, rpmProblemType type,
const void * key, Header h, const char * dirName,
const char * baseName, Header altH, unsigned long ulong1)
{
- char * str = alloca(strlen(dirName) + strlen(baseName) + 2);
+ char * str = alloca(strlen(dirName) + strlen(baseName) + 1);
- sprintf(str, "%s/%s", dirName, baseName);
+ sprintf(str, "%s%s", dirName, baseName);
psAppend(probs, type, key, h, str, altH, ulong1);
}
@@ -448,7 +448,7 @@ static Header relocateFileList(struct availablePackage * alp,
int k;
haveRelocatedFile = 1;
- newDirList = xmalloc(sizeof(*newDirList) * (dirCount + 1));
+ newDirList = malloc(sizeof(*newDirList) * (dirCount + 1));
for (k = 0; k < dirCount; k++) {
newDirList[k] = alloca(strlen(dirNames[k]) + 1);
strcpy(newDirList[k], dirNames[k]);
@@ -456,7 +456,7 @@ static Header relocateFileList(struct availablePackage * alp,
free(dirNames);
dirNames = newDirList;
} else {
- dirNames = xrealloc(dirNames,
+ dirNames = realloc(dirNames,
sizeof(*dirNames) * (dirCount + 1));
}
@@ -469,6 +469,7 @@ static Header relocateFileList(struct availablePackage * alp,
/* Start off by relocating directories. */
for (i = dirCount - 1; i >= 0; i--) {
for (j = numRelocations - 1; j >= 0; j--) {
+ int len;
len = strlen(relocations[j].oldPath);
if (strncmp(relocations[j].oldPath, dirNames[i], len))
@@ -622,9 +623,9 @@ static enum fileActions decideFileFate(const char * dirName,
struct stat sb;
int i, rc;
int save = (newFlags & RPMFILE_NOREPLACE) ? FA_ALTNAME : FA_SAVE;
- char * filespec = alloca(strlen(dirName) + strlen(baseName) + 2);
+ char * filespec = alloca(strlen(dirName) + strlen(baseName) + 1);
- sprintf(filespec, "%s/%s", dirName, baseName);
+ sprintf(filespec, "%s%s", dirName, baseName);
if (lstat(filespec, &sb)) {
/*
@@ -858,13 +859,13 @@ static void handleOverlappedFiles(TFI_t * fi, hashTable ht,
if (XFA_SKIPPING(fi->actions[i]))
continue;
- j = strlen(strlen(fi->dnl[fi->dil[i]]) + fi->bnl[i] + 2);
+ j = strlen(fi->dnl[fi->dil[i]]) + strlen(fi->bnl[i]) + 1;
if (j > fileSpecAlloced) {
fileSpecAlloced = j * 2;
filespec = xrealloc(filespec, fileSpecAlloced);
}
- sprintf(filespec, "%s/%s", fi->dnl[fi->dil[i]], fi->bnl[i]);
+ sprintf(filespec, "%s%s", fi->dnl[fi->dil[i]], fi->bnl[i]);
if (dsl) {
ds = dsl;
@@ -1153,7 +1154,7 @@ static void skipFiles(TFI_t * fi, int noDocs)
if (languages) freeSplitString((char **)languages);
}
-#define NOTIFY(_x) if (notify) (void) notify _x
+#define NOTIFY(_x) if (notify) notify _x
/* Return -1 on error, > 0 if newProbs is set, 0 if everything happened */
@@ -1348,9 +1349,9 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify,
}
headerGetEntry(fi->h, RPMTAG_COMPFILEDIRS, NULL, (void **) &fi->dil,
- &fi->fc);
+ NULL);
headerGetEntry(fi->h, RPMTAG_COMPDIRLIST, NULL, (void **) &fi->dnl,
- &fi->fc);
+ NULL);
/* actions is initialized earlier for added packages */
if (fi->actions == NULL)
@@ -1379,6 +1380,8 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify,
fi->fmodes, fi->fc * sizeof(*fi->fmodes));
fi->fstates = memcpy(xmalloc(fi->fc * sizeof(*fi->fstates)),
fi->fstates, fi->fc * sizeof(*fi->fstates));
+ fi->dil = memcpy(xmalloc(fi->fc * sizeof(*fi->dil)),
+ fi->dil, fi->fc * sizeof(*fi->dil));
headerFree(fi->h);
fi->h = NULL;
break;
@@ -1408,7 +1411,7 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify,
}
chdir("/");
- /*@-unrecog@*/ chroot(ts->root); /*@=unrecog@*/
+ chroot(ts->root);
ht = htCreate(totalFileCount * 2, 0, fpHashFunction, fpEqual);
fpc = fpCacheCreate(totalFileCount);
@@ -1417,7 +1420,7 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify,
* Add fingerprint for each file not skipped.
*/
for (fi = flList; (fi - flList) < flEntries; fi++) {
- fpLookupHeader(fpc, fi->h, fi->fps);
+ fpLookupList(fpc, fi->dnl, fi->bnl, fi->dil, fi->fc, fi->fps);
for (i = 0; i < fi->fc; i++) {
if (XFA_SKIPPING(fi->actions[i]))
continue;
@@ -1605,7 +1608,7 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify,
headerFree(hdrs[i]);
rc = rpmReadPackageHeader(fd, &h, NULL, NULL, NULL);
if (rc) {
- (void)notify(fi->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0,
+ notify(fi->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0,
alp->key, notifyData);
ourrc++;
fd = NULL;
@@ -1633,7 +1636,7 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify,
headerFree(hdrs[i]);
if (alp->fd == NULL && fd)
- (void)notify(fi->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0, alp->key,
+ notify(fi->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0, alp->key,
notifyData);
break;
case TR_REMOVED: