I'm too lazy to put these in a third time.

CVS patchset: 2691
CVS date: 1999/01/12 03:11:25
This commit is contained in:
ewt 1999-01-12 03:11:25 +00:00
parent 37a0fd968d
commit 33d610be38
6 changed files with 94 additions and 52 deletions

View File

@ -1,4 +1,6 @@
2.5.x -> 2.90
- package install/removal much smarter about symlinks
- redid install/remove API to allow transaction semantics
- support for GPG (Toshio Kuratomi <badger@prtr-13.ucsc.edu>)
- file lookup finally sane wrt symbolic links :-)
- fileindex format changed -- rebuilddb is necessary for rpm 2.90!!

View File

@ -9,10 +9,10 @@
static void printHash(const unsigned long amount, const unsigned long total);
static void printDepProblems(FILE * f, struct rpmDependencyConflict * conflicts,
int numConflicts);
static void showProgress(const Header h, const rpmNotifyType what,
const unsigned long amount,
const unsigned long total,
void * data);
static void * showProgress(const Header h, const rpmCallbackType what,
const unsigned long amount,
const unsigned long total,
const void * pkgKey, void * data);
static int hashesPrinted = 0;
@ -34,29 +34,33 @@ static void printHash(const unsigned long amount, const unsigned long total) {
}
}
static void showProgress(const Header h, const rpmNotifyType what,
const unsigned long amount,
const unsigned long total,
void * data) {
static void * showProgress(const Header h, const rpmCallbackType what,
const unsigned long amount,
const unsigned long total,
const void * pkgKey, void * data) {
char * s;
int flags = (int) data;
void * rc = NULL;
switch (what) {
case RPMNOTIFY_INST_START:
case RPMCALLBACK_INST_START:
hashesPrinted = 0;
if (flags & INSTALL_LABEL) {
s = headerSprintf(h, "%{NAME}-%{VERSION}-%{RELEASE}",
rpmTagTable, rpmHeaderFormats, NULL);
if (flags & INSTALL_HASH)
if (flags & INSTALL_HASH) {
s = headerSprintf(h, "%{NAME}",
rpmTagTable, rpmHeaderFormats, NULL);
printf("%-28s", s);
else
} else {
s = headerSprintf(h, "%{NAME}-%{VERSION}-%{RELEASE}",
rpmTagTable, rpmHeaderFormats, NULL);
printf("%s\n", s);
}
fflush(stdout);
free(s);
}
break;
case RPMNOTIFY_INST_PROGRESS:
case RPMCALLBACK_INST_PROGRESS:
if (flags & INSTALL_PERCENT) {
fprintf(stdout, "%%%% %f\n", (total
? ((float) ((((float) amount) / total) * 100))
@ -65,7 +69,13 @@ static void showProgress(const Header h, const rpmNotifyType what,
printHash(amount, total);
}
break;
case RPMCALLBACK_INST_OPEN_FILE: /* shouldn't happen */
case RPMCALLBACK_INST_CLOSE_FILE: /* shouldn't happen */
abort();
}
return rc;
}
int doInstall(const char * rootdir, const char ** argv, int installFlags,
@ -88,7 +98,7 @@ int doInstall(const char * rootdir, const char ** argv, int installFlags,
int numConflicts;
int stopInstall = 0;
size_t nb;
int notifyFlags = interfaceFlags | (rpmIsVerbose ? INSTALL_LABEL : 0 );
int notifyFlags = interfaceFlags | (rpmIsVerbose() ? INSTALL_LABEL : 0 );
int transFlags = 0;
rpmProblemSet probs, finalProbs;
int dbIsOpen = 0;
@ -269,6 +279,7 @@ int doInstall(const char * rootdir, const char ** argv, int installFlags,
if (numBinaryPackages) rpmtransFree(rpmdep);
if (numSourcePackages && !stopInstall) {
for (i = 0; i < numSourcePackages; i++) {
fd = fdOpen(sourcePackages[i], O_RDONLY, 0);

View File

@ -13,10 +13,11 @@
struct callbackInfo {
unsigned long archiveSize;
rpmNotifyFunction notify;
rpmCallbackFunction notify;
char ** specFilePtr;
Header h;
void * notifyData;
const void * pkgKey;
};
struct fileMemory {
@ -43,11 +44,11 @@ struct fileInfo {
} ;
static int installArchive(FD_t fd, struct fileInfo * files,
int fileCount, rpmNotifyFunction notify,
void * notifydb, Header h,
int fileCount, rpmCallbackFunction notify,
void * notifydb, const void * pkgKey, Header h,
char ** specFile, int archiveSize);
static int installSources(Header h, const char * rootdir, FD_t fd,
const char ** specFilePtr, rpmNotifyFunction notify,
const char ** specFilePtr, rpmCallbackFunction notify,
void * notifyData);
static int assembleFileList(Header h, struct fileMemory * mem,
int * fileCountPtr, struct fileInfo ** filesPtr,
@ -61,7 +62,7 @@ static int markReplacedFiles(rpmdb db, struct sharedFileInfo * replList);
/* 1 bad magic */
/* 2 error */
int rpmInstallSourcePackage(const char * rootdir, FD_t fd,
const char ** specFile, rpmNotifyFunction notify,
const char ** specFile, rpmCallbackFunction notify,
void * notifyData, char ** cookie) {
int rc, isSource;
Header h;
@ -258,8 +259,9 @@ static void trimChangelog(Header h) {
/* 1 bad magic */
/* 2 error */
int installBinaryPackage(const char * rootdir, rpmdb db, FD_t fd, Header h,
int flags, rpmNotifyFunction notify,
void * notifyData, enum fileActions * actions,
int flags, rpmCallbackFunction notify,
void * notifyData, const void * pkgKey,
enum fileActions * actions,
struct sharedFileInfo * sharedList) {
int rc;
char * name, * version, * release;
@ -437,11 +439,11 @@ int installBinaryPackage(const char * rootdir, rpmdb db, FD_t fd, Header h,
archiveSizePtr = NULL;
if (notify) {
notify(h, RPMNOTIFY_INST_START, 0, 0, notifyData);
notify(h, RPMCALLBACK_INST_START, 0, 0, pkgKey, notifyData);
}
/* the file pointer for fd is pointing at the cpio archive */
if (installArchive(fd, files, fileCount, notify, notifyData, h,
if (installArchive(fd, files, fileCount, notify, notifyData, pkgKey, h,
NULL, archiveSizePtr ? *archiveSizePtr : 0)) {
headerFree(h);
if (freeFileMem) freeFileMemory(fileMem);
@ -530,9 +532,10 @@ static void callback(struct cpioCallbackInfo * cpioInfo, void * data) {
char * chptr;
if (ourInfo->notify)
ourInfo->notify(ourInfo->h, RPMNOTIFY_INST_PROGRESS,
ourInfo->notify(ourInfo->h, RPMCALLBACK_INST_PROGRESS,
cpioInfo->bytesProcessed,
ourInfo->archiveSize, ourInfo->notifyData);
ourInfo->archiveSize, ourInfo->pkgKey,
ourInfo->notifyData);
if (ourInfo->specFilePtr) {
chptr = cpioInfo->file + strlen(cpioInfo->file) - 5;
@ -543,8 +546,8 @@ static void callback(struct cpioCallbackInfo * cpioInfo, void * data) {
/* NULL files means install all files */
static int installArchive(FD_t fd, struct fileInfo * files,
int fileCount, rpmNotifyFunction notify,
void * notifyData, Header h,
int fileCount, rpmCallbackFunction notify,
void * notifyData, const void * pkgKey, Header h,
char ** specFile, int archiveSize) {
int rc, i;
struct cpioFileMapping * map = NULL;
@ -565,6 +568,7 @@ static int installArchive(FD_t fd, struct fileInfo * files,
info.notifyData = notifyData;
info.specFilePtr = specFile;
info.h = h;
info.pkgKey = pkgKey;
if (specFile) *specFile = NULL;
@ -587,7 +591,8 @@ static int installArchive(FD_t fd, struct fileInfo * files,
}
if (notify)
notify(h, RPMNOTIFY_INST_PROGRESS, 0, archiveSize, notifyData);
notify(h, RPMCALLBACK_INST_PROGRESS, 0, archiveSize, pkgKey,
notifyData);
{ CFD_t cfdbuf, *cfd = &cfdbuf;
cfd->cpioIoType = cpioIoTypeGzFd;
@ -608,10 +613,10 @@ static int installArchive(FD_t fd, struct fileInfo * files,
}
if (notify && archiveSize)
notify(h, RPMNOTIFY_INST_PROGRESS, archiveSize, archiveSize,
notifyData);
notify(h, RPMCALLBACK_INST_PROGRESS, archiveSize, archiveSize,
pkgKey, notifyData);
else if (notify) {
notify(h, RPMNOTIFY_INST_PROGRESS, 100, 100, notifyData);
notify(h, RPMCALLBACK_INST_PROGRESS, 100, 100, pkgKey, notifyData);
}
return 0;
@ -621,7 +626,7 @@ static int installArchive(FD_t fd, struct fileInfo * files,
/* 1 bad magic */
/* 2 error */
static int installSources(Header h, const char * rootdir, FD_t fd,
const char ** specFilePtr, rpmNotifyFunction notify,
const char ** specFilePtr, rpmCallbackFunction notify,
void * notifyData) {
char * specFile;
int specFileIndex = -1;
@ -699,7 +704,7 @@ static int installSources(Header h, const char * rootdir, FD_t fd,
}
if (notify) {
notify(h, RPMNOTIFY_INST_START, 0, 0, notifyData);
notify(h, RPMCALLBACK_INST_START, 0, 0, NULL, notifyData);
}
currDirLen = 50;
@ -711,7 +716,7 @@ static int installSources(Header h, const char * rootdir, FD_t fd,
chdir(realSourceDir);
if (installArchive(fd, fileCount > 0 ? files : NULL,
fileCount, notify, notifyData, h,
fileCount, notify, notifyData, NULL, h,
specFileIndex >=0 ? NULL : &specFile,
archiveSizePtr ? *archiveSizePtr : 0)) {
if (fileCount > 0) freeFileMemory(fileMem);

View File

@ -31,8 +31,9 @@ int runTriggers(const char * root, rpmdb db, int sense, Header h,
int runImmedTriggers(const char * root, rpmdb db, int sense, Header h,
int countCorrection);
int installBinaryPackage(const char * rootdir, rpmdb db, FD_t fd, Header h,
int flags, rpmNotifyFunction notify,
void * notifyData, enum fileActions * actions,
int flags, rpmCallbackFunction notify,
void * notifyData, const void * pkgKey,
enum fileActions * actions,
struct sharedFileInfo * sharedList);
const char * fileActionString(enum fileActions a);

View File

@ -283,12 +283,15 @@ void rpmGetMachine(/*@out@*/char **arch, /*@out@*/char **os);
typedef /*@abstract@*/ struct rpmdb_s * rpmdb;
typedef enum rpmNotifyType_e
{ RPMNOTIFY_INST_PROGRESS, RPMNOTIFY_INST_START } rpmNotifyType;
typedef void (*rpmNotifyFunction)(const Header h, const rpmNotifyType what,
const unsigned long amount,
const unsigned long total,
void * data);
typedef enum rpmCallbackType_e
{ RPMCALLBACK_INST_PROGRESS, RPMCALLBACK_INST_START,
RPMCALLBACK_INST_OPEN_FILE, RPMCALLBACK_INST_CLOSE_FILE
} rpmCallbackType;
typedef void * (*rpmCallbackFunction)(const Header h,
const rpmCallbackType what,
const unsigned long amount,
const unsigned long total,
const void * pkgKey, void * data);
int rpmdbOpen (const char * root, rpmdb * dbp, int mode, int perms);
/* 0 on error */
@ -320,7 +323,7 @@ typedef struct rpmRelocation_s {
} rpmRelocation;
int rpmInstallSourcePackage(const char * root, FD_t fd, const char ** specFile,
rpmNotifyFunction notify, void * notifyData,
rpmCallbackFunction notify, void * notifyData,
char ** cookie);
int rpmVersionCompare(Header first, Header second);
int rpmdbRebuild(const char * root);
@ -368,7 +371,8 @@ int rpmdepOrder(rpmTransactionSet order, void *** keysListPtr);
void rpmdepFreeConflicts(struct rpmDependencyConflict * conflicts, int
numConflicts);
#define RPMTRANS_FLAG_TEST (1 << 0)
#define RPMTRANS_FLAG_TEST (1 << 0)
#define RPMTRANS_FLAG_BUILD_PROBS (1 << 1)
typedef enum rpmProblemType_e { RPMPROB_BADARCH,
RPMPROB_BADOS,
@ -397,7 +401,7 @@ typedef struct rpmProblemSet_s {
char * rpmProblemString(rpmProblem prob);
void rpmProblemSetFree(rpmProblemSet probs);
void rpmProblemSetFilter(rpmProblemSet ps, int flags);
int rpmRunTransactions(rpmTransactionSet ts, rpmNotifyFunction notify,
int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify,
void * notifyData, rpmProblemSet okProbs,
rpmProblemSet * newProbs, int flags);

View File

@ -61,7 +61,7 @@ void handleOverlappedFiles(struct fileInfo * fi, hashTable ht,
/* Return -1 on error, > 0 if newProbs is set, 0 if everything
happened */
int rpmRunTransactions(rpmTransactionSet ts, rpmNotifyFunction notify,
int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify,
void * notifyData, rpmProblemSet okProbs,
rpmProblemSet * newProbs, int flags) {
int i, j, numPackages;
@ -84,6 +84,7 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmNotifyFunction notify,
int last;
int beingRemoved;
char * currDir, * chptr;
FD_t fd;
/* FIXME: what if the same package is included in ts twice? */
@ -275,7 +276,8 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmNotifyFunction notify,
numPackages++;
}
if (probs->numProblems && (!okProbs || psTrim(okProbs, probs))) {
if ((flags & RPMTRANS_FLAG_BUILD_PROBS) ||
(probs->numProblems && (!okProbs || psTrim(okProbs, probs)))) {
*newProbs = probs;
for (i = 0; i < al->size; i++)
headerFree(hdrs[i]);
@ -292,17 +294,34 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmNotifyFunction notify,
numPackages = 0;
for (pkgNum = 0, alp = al->list; pkgNum < al->size; pkgNum++, alp++, fi++) {
fi = flList + numPackages;
if (installBinaryPackage(ts->root, ts->db, al->list[pkgNum].fd,
hdrs[pkgNum], instFlags, notify, notifyData,
fi->actions, fi->replaced))
if (al->list[pkgNum].fd) {
fd = al->list[pkgNum].fd;
} else {
fd = notify(fi->h, RPMCALLBACK_INST_OPEN_FILE, 0, 0,
al->list[pkgNum].key, notifyData);
}
if (fd) {
fi = flList + numPackages;
if (installBinaryPackage(ts->root, ts->db, fd, hdrs[pkgNum],
instFlags, notify, notifyData,
al->list[pkgNum].key, fi->actions,
fi->replaced))
ourrc++;
} else {
ourrc++;
}
headerFree(hdrs[pkgNum]);
if (alp->h == flList[numPackages].h) {
free(fi->actions);
numPackages++;
}
if (!al->list[pkgNum].fd && fd)
notify(fi->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0,
al->list[pkgNum].key, notifyData);
}
fi = flList + numPackages;