From f93e0d2f61381f2ff87674b365b664510943eb1c Mon Sep 17 00:00:00 2001 From: ewt Date: Sun, 7 Feb 1999 21:20:04 +0000 Subject: [PATCH] added fdScript stuff CVS patchset: 2783 CVS date: 1999/02/07 21:20:04 --- lib/depends.c | 1 + lib/depends.h | 1 + lib/install.c | 10 +++++----- lib/install.h | 8 ++++---- lib/rpmlib.h | 3 ++- lib/uninstall.c | 26 ++++++++++++++------------ 6 files changed, 27 insertions(+), 22 deletions(-) diff --git a/lib/depends.c b/lib/depends.c index 09667d3..67ad6dc 100644 --- a/lib/depends.c +++ b/lib/depends.c @@ -202,6 +202,7 @@ rpmTransactionSet rpmtransCreateSet(rpmdb db, const char * root) { rpmdep = malloc(sizeof(*rpmdep)); rpmdep->db = db; + rpmdep->scriptFd = NULL; rpmdep->numRemovedPackages = 0; rpmdep->allocedRemovedPackages = 5; rpmdep->removedPackages = malloc(sizeof(int) * diff --git a/lib/depends.h b/lib/depends.h index 1a9f98c..a0ae634 100644 --- a/lib/depends.h +++ b/lib/depends.h @@ -41,6 +41,7 @@ struct rpmTransactionSet_s { int numRemovedPackages, allocedRemovedPackages; struct availableList addedPackages, availablePackages; char * root; + FD_t scriptFd; }; struct problemsSet { diff --git a/lib/install.c b/lib/install.c index 4da3f6a..a12f42a 100644 --- a/lib/install.c +++ b/lib/install.c @@ -263,7 +263,7 @@ int installBinaryPackage(const char * rootdir, rpmdb db, FD_t fd, Header h, int flags, rpmCallbackFunction notify, void * notifyData, const void * pkgKey, enum fileActions * actions, - struct sharedFileInfo * sharedList) { + struct sharedFileInfo * sharedList, FD_t scriptFd) { int rc; char * name, * version, * release; int fileCount, type, count; @@ -355,7 +355,7 @@ int installBinaryPackage(const char * rootdir, rpmdb db, FD_t fd, Header h, rpmMessage(RPMMESS_DEBUG, _("running preinstall script (if any)\n")); if (runInstScript("/", h, RPMTAG_PREIN, RPMTAG_PREINPROG, scriptArg, - flags & RPMINSTALL_NOSCRIPTS, 0)) { + flags & RPMINSTALL_NOSCRIPTS, scriptFd)) { if (freeFileMem) freeFileMemory(fileMem); if (rootdir) { @@ -509,19 +509,19 @@ int installBinaryPackage(const char * rootdir, rpmdb db, FD_t fd, Header h, rpmMessage(RPMMESS_DEBUG, _("running postinstall script (if any)\n")); if (runInstScript(rootdir, h, RPMTAG_POSTIN, RPMTAG_POSTINPROG, scriptArg, - flags & RPMINSTALL_NOSCRIPTS, 0)) { + flags & RPMINSTALL_NOSCRIPTS, scriptFd)) { return 2; } if (!(flags & RPMINSTALL_NOTRIGGERS)) { /* Run triggers this package sets off */ - if (runTriggers(rootdir, db, RPMSENSE_TRIGGERIN, h, 0)) { + if (runTriggers(rootdir, db, RPMSENSE_TRIGGERIN, h, 0, scriptFd)) { return 2; } /* Run triggers in this package which are set off by other things in the database. */ - if (runImmedTriggers(rootdir, db, RPMSENSE_TRIGGERIN, h, 0)) { + if (runImmedTriggers(rootdir, db, RPMSENSE_TRIGGERIN, h, 0, scriptFd)) { return 2; } } diff --git a/lib/install.h b/lib/install.h index d2c5c57..8896fa1 100644 --- a/lib/install.h +++ b/lib/install.h @@ -21,21 +21,21 @@ enum fileActions { UNKNOWN = 0, CREATE, BACKUP, SAVE, SKIP, ALTNAME, REMOVE, enum fileTypes { XDIR, BDEV, CDEV, SOCK, PIPE, REG, LINK } ; int removeBinaryPackage(char * root, rpmdb db, unsigned int offset, int flags, - enum fileActions * actions); + enum fileActions * actions, FD_t scriptFd); int runInstScript(const char * prefix, Header h, int scriptTag, int progTag, int arg, int norunScripts, FD_t err); /* this looks for triggers in the database which h would set off */ int runTriggers(const char * root, rpmdb db, int sense, Header h, - int countCorrection); + int countCorrection, FD_t scriptFd); /* while this looks for triggers in h which are set off by things in the db database to calculate arguments to the trigger */ int runImmedTriggers(const char * root, rpmdb db, int sense, Header h, - int countCorrection); + int countCorrection, FD_t scriptFd); int installBinaryPackage(const char * rootdir, rpmdb db, FD_t fd, Header h, int flags, rpmCallbackFunction notify, void * notifyData, const void * pkgKey, enum fileActions * actions, - struct sharedFileInfo * sharedList); + struct sharedFileInfo * sharedList, FD_t scriptFd); const char * fileActionString(enum fileActions a); #endif /* H_INSTALL */ diff --git a/lib/rpmlib.h b/lib/rpmlib.h index e481147..1e33aa6 100644 --- a/lib/rpmlib.h +++ b/lib/rpmlib.h @@ -288,7 +288,7 @@ typedef /*@abstract@*/ struct rpmdb_s * rpmdb; typedef enum rpmCallbackType_e { RPMCALLBACK_INST_PROGRESS, RPMCALLBACK_INST_START, - RPMCALLBACK_INST_OPEN_FILE, RPMCALLBACK_INST_CLOSE_FILE + RPMCALLBACK_INST_OPEN_FILE, RPMCALLBACK_INST_CLOSE_FILE, } rpmCallbackType; typedef void * (*rpmCallbackFunction)(const Header h, const rpmCallbackType what, @@ -367,6 +367,7 @@ int rpmtransAddPackage(rpmTransactionSet rpmdep, Header h, FD_t fd, void rpmtransAvailablePackage(rpmTransactionSet rpmdep, Header h, void * key); void rpmtransRemovePackage(rpmTransactionSet rpmdep, int dboffset); void rpmtransFree(/*@only@*/ rpmTransactionSet rpmdep); +void rpmtransSetScriptFd(rpmTransactionSet ts, FD_t fd); /* this checks for dependency satisfaction, but *not* ordering */ int rpmdepCheck(rpmTransactionSet rpmdep, diff --git a/lib/uninstall.c b/lib/uninstall.c index 145bea8..adaf752 100644 --- a/lib/uninstall.c +++ b/lib/uninstall.c @@ -17,7 +17,7 @@ static int runScript(Header h, const char * root, int progArgc, const char ** pr const char * script, int arg1, int arg2, FD_t errfd); int removeBinaryPackage(char * prefix, rpmdb db, unsigned int offset, - int flags, enum fileActions * actions) { + int flags, enum fileActions * actions, FD_t scriptFd) { Header h; int i; int fileCount; @@ -59,18 +59,18 @@ int removeBinaryPackage(char * prefix, rpmdb db, unsigned int offset, if (!(flags & RPMUNINSTALL_NOTRIGGERS)) { /* run triggers from this package which are keyed on installed packages */ - if (runImmedTriggers(prefix, db, RPMSENSE_TRIGGERUN, h, -1)) { + if (runImmedTriggers(prefix, db, RPMSENSE_TRIGGERUN, h, -1, scriptFd)) { return 2; } /* run triggers which are set off by the removal of this package */ - if (runTriggers(prefix, db, RPMSENSE_TRIGGERUN, h, -1)) + if (runTriggers(prefix, db, RPMSENSE_TRIGGERUN, h, -1, scriptFd)) return 1; } if (!(flags & RPMUNINSTALL_TEST)) { if (runInstScript(prefix, h, RPMTAG_PREUN, RPMTAG_PREUNPROG, scriptArg, - flags & RPMUNINSTALL_NOSCRIPTS, 0)) { + flags & RPMUNINSTALL_NOSCRIPTS, scriptFd)) { headerFree(h); return 1; } @@ -123,12 +123,12 @@ int removeBinaryPackage(char * prefix, rpmdb db, unsigned int offset, if (!(flags & RPMUNINSTALL_TEST)) { rpmMessage(RPMMESS_DEBUG, _("running postuninstall script (if any)\n")); runInstScript(prefix, h, RPMTAG_POSTUN, RPMTAG_POSTUNPROG, scriptArg, - flags & RPMUNINSTALL_NOSCRIPTS, 0); + flags & RPMUNINSTALL_NOSCRIPTS, scriptFd); } if (!(flags & RPMUNINSTALL_NOTRIGGERS)) { /* Run postun triggers which are set off by this package's removal */ - if (runTriggers(prefix, db, RPMSENSE_TRIGGERPOSTUN, h, 0)) { + if (runTriggers(prefix, db, RPMSENSE_TRIGGERPOSTUN, h, 0, scriptFd)) { return 2; } } @@ -377,7 +377,7 @@ static int removeFile(char * file, unsigned int flags, short mode, static int handleOneTrigger(const char * root, rpmdb db, int sense, Header sourceH, Header triggeredH, int arg1correction, int arg2, - char * triggersAlreadyRun) { + char * triggersAlreadyRun, FD_t scriptFd) { const char ** triggerNames; const char ** triggerVersions; const char ** triggerScripts; @@ -438,7 +438,8 @@ static int handleOneTrigger(const char * root, rpmdb db, int sense, Header sourc if (!triggersAlreadyRun || !triggersAlreadyRun[index]) { rc = runScript(triggeredH, root, 1, triggerProgs + index, triggerScripts[index], - dbiIndexSetCount(matches) + arg1correction, arg2, 0); + dbiIndexSetCount(matches) + arg1correction, arg2, + scriptFd); if (triggersAlreadyRun) triggersAlreadyRun[index] = 1; } @@ -456,7 +457,7 @@ static int handleOneTrigger(const char * root, rpmdb db, int sense, Header sourc } int runTriggers(const char * root, rpmdb db, int sense, Header h, - int countCorrection) { + int countCorrection, FD_t scriptFd) { char * packageName; dbiIndexSet matches, otherMatches; Header triggeredH; @@ -482,7 +483,7 @@ int runTriggers(const char * root, rpmdb db, int sense, Header h, return 1; rc |= handleOneTrigger(root, db, sense, h, triggeredH, 0, numPackage, - NULL); + NULL, scriptFd); headerFree(triggeredH); } @@ -494,7 +495,7 @@ 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 countCorrection, FD_t scriptFd) { int rc = 0; dbiIndexSet matches; char ** triggerNames; @@ -525,7 +526,8 @@ int runImmedTriggers(const char * root, rpmdb db, int sense, Header h, if ((sourceH = rpmdbGetRecord(db, recOffset)) == NULL) return 1; rc |= handleOneTrigger(root, db, sense, sourceH, h, - countCorrection, dbiIndexSetCount(matches), triggersRun); + countCorrection, dbiIndexSetCount(matches), + triggersRun, scriptFd); headerFree(sourceH); if (triggersRun[triggerIndices[i]]) break; } -- 2.7.4