diff options
author | jbj <devnull@localhost> | 2000-08-20 21:39:13 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2000-08-20 21:39:13 +0000 |
commit | d0581d13d46920e263b6dfc30b5035259553ad0d (patch) | |
tree | d564ad4022de661d179546affa4740390f7da16f /lib | |
parent | e372c808d2acdb101de76f025b7047fe94a9a582 (diff) | |
download | librpm-tizen-d0581d13d46920e263b6dfc30b5035259553ad0d.tar.gz librpm-tizen-d0581d13d46920e263b6dfc30b5035259553ad0d.tar.bz2 librpm-tizen-d0581d13d46920e263b6dfc30b5035259553ad0d.zip |
- add callbacks on package erasure.
- fix: preserve cpio errno when using Fclose with libio.
- fix: initialize sigs everywhere in python header object.
CVS patchset: 4097
CVS date: 2000/08/20 21:39:13
Diffstat (limited to 'lib')
-rw-r--r-- | lib/install.h | 13 | ||||
-rw-r--r-- | lib/transaction.c | 30 | ||||
-rw-r--r-- | lib/uninstall.c | 92 |
3 files changed, 78 insertions, 57 deletions
diff --git a/lib/install.h b/lib/install.h index ca2c7d2e9..8f6197d5e 100644 --- a/lib/install.h +++ b/lib/install.h @@ -25,8 +25,6 @@ enum fileTypes { XDIR, BDEV, CDEV, SOCK, PIPE, REG, LINK } ; extern "C" { #endif -int removeBinaryPackage(const char * root, rpmdb db, unsigned int offset, - int flags, 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 */ @@ -36,12 +34,21 @@ int runTriggers(const char * root, rpmdb db, int sense, Header h, database to calculate arguments to the trigger */ int runImmedTriggers(const char * root, rpmdb db, int sense, Header h, int countCorrection, FD_t scriptFd); + +/*@observer@*/ const char *const fileActionString(enum fileActions a); + 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, FD_t scriptFd); -/*@observer@*/ const char *const fileActionString(enum fileActions a); +int removeBinaryPackage(const char * root, rpmdb db, unsigned int offset, + Header h, + int flags, rpmCallbackFunction notify, + void * notifyData, const void * pkgKey, + enum fileActions * actions, + FD_t scriptFd); + #ifdef __cplusplus } diff --git a/lib/transaction.c b/lib/transaction.c index d1bedddc1..c7743c676 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -1714,12 +1714,36 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify, notifyData); break; case TR_REMOVED: + { unsigned int offset = fi->record; + Header dbh; + + /* If install failed, then we shouldn't erase. */ if (ts->order[oc].u.removed.dependsOnIndex == lastFailed) break; - if (removeBinaryPackage(ts->rootDir, ts->rpmdb, fi->record, - transFlags, fi->actions, ts->scriptFd)) + + { rpmdbMatchIterator mi = NULL; + + mi = rpmdbInitIterator(ts->rpmdb, RPMDBI_PACKAGES, + &offset, sizeof(offset)); + + dbh = rpmdbNextIterator(mi); + if (dbh == NULL) { + rpmdbFreeIterator(mi); + ourrc++; + break; + } + dbh = headerLink(dbh); + rpmdbFreeIterator(mi); + } + + if (removeBinaryPackage(ts->rootDir, ts->rpmdb, offset, dbh, + transFlags, + notify, notifyData, dbh, fi->actions, + ts->scriptFd)) ourrc++; - break; + + headerFree(dbh); + } break; } (void) rpmdbSync(ts->rpmdb); } diff --git a/lib/uninstall.c b/lib/uninstall.c index cada5f0f0..5ee47d968 100644 --- a/lib/uninstall.c +++ b/lib/uninstall.c @@ -75,67 +75,48 @@ static int removeFile(const char * file, unsigned int flags, short mode, } /** */ -int removeBinaryPackage(const char * prefix, rpmdb db, unsigned int offset, - int flags, enum fileActions * actions, FD_t scriptFd) +int removeBinaryPackage(const char * prefix, rpmdb db, unsigned int offset, + Header h, + int flags, rpmCallbackFunction notify, + void * notifyData, const void * pkgKey, + enum fileActions * actions, FD_t scriptFd) { - rpmdbMatchIterator mi = NULL; - Header h = NULL; - int i; - int fileCount; const char * name, * version, * release; const char ** baseNames; - int type; int scriptArg; int rc = 0; + int fileCount; + int i; if (flags & RPMTRANS_FLAG_JUSTDB) flags |= RPMTRANS_FLAG_NOSCRIPTS; - mi = rpmdbInitIterator(db, RPMDBI_PACKAGES, &offset, sizeof(offset)); - h = rpmdbNextIterator(mi); - if (h == NULL) { - rpmError(RPMERR_DBCORRUPT, _("%s: cannot read header at 0x%x"), - "findMatches", offset); - rpmdbFreeIterator(mi); - rc = 1; - goto exit; - } - h = headerLink(h); - rpmdbFreeIterator(mi); - headerNVR(h, &name, &version, &release); /* * When we run scripts, we pass an argument which is the number of * versions of this package that will be installed when we are finished. */ - if ((scriptArg = rpmdbCountPackages(db, name)) < 0) { - rc = 1; - goto exit; - } + if ((scriptArg = rpmdbCountPackages(db, name)) < 0) + return 1; scriptArg -= 1; if (!(flags & RPMTRANS_FLAG_NOTRIGGERS)) { /* run triggers from this package which are keyed on installed packages */ - if (runImmedTriggers(prefix, db, RPMSENSE_TRIGGERUN, h, -1, scriptFd)) { - rc = 2; - goto exit; - } + 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, scriptFd)) { - rc = 1; - goto exit; - } + if (runTriggers(prefix, db, RPMSENSE_TRIGGERUN, h, -1, scriptFd)) + return 1; } if (!(flags & RPMTRANS_FLAG_TEST)) { - if (runInstScript(prefix, h, RPMTAG_PREUN, RPMTAG_PREUNPROG, scriptArg, - flags & RPMTRANS_FLAG_NOSCRIPTS, scriptFd)) { - rc = 1; - goto exit; - } + rc = runInstScript(prefix, h, RPMTAG_PREUN, RPMTAG_PREUNPROG, scriptArg, + (flags & RPMTRANS_FLAG_NOSCRIPTS), scriptFd); + if (rc) + return 1; } rpmMessage(RPMMESS_DEBUG, _("will remove files test = %d\n"), @@ -149,6 +130,7 @@ int removeBinaryPackage(const char * prefix, rpmdb db, unsigned int offset, int_16 * fileModesList; const char ** dirNames; int_32 * dirIndexes; + int type; char * fileName; int fnmaxlen; int prefixlen = (prefix && !(prefix[0] == '/' && prefix[1] == '\0')) @@ -186,6 +168,11 @@ int removeBinaryPackage(const char * prefix, rpmdb db, unsigned int offset, headerGetEntry(h, RPMTAG_FILEMODES, &type, (void **) &fileModesList, &fileCount); + if (notify) { + (void)notify(h, RPMCALLBACK_UNINST_START, fileCount, fileCount, + pkgKey, notifyData); + } + /* Traverse filelist backwards to help insure that rmdir() will work. */ for (i = fileCount - 1; i >= 0; i--) { @@ -195,9 +182,19 @@ int removeBinaryPackage(const char * prefix, rpmdb db, unsigned int offset, rpmMessage(RPMMESS_DEBUG, _(" file: %s action: %s\n"), fileName, fileActionString(actions[i])); - if (!(flags & RPMTRANS_FLAG_TEST)) + if (!(flags & RPMTRANS_FLAG_TEST)) { + if (notify) { + (void)notify(h, RPMCALLBACK_UNINST_PROGRESS, + i, actions[i], fileName, notifyData); + } removeFile(fileName, fileFlagsList[i], fileModesList[i], actions[i]); + } + } + + if (notify) { + (void)notify(h, RPMCALLBACK_UNINST_STOP, 0, fileCount, + pkgKey, notifyData); } free(baseNames); @@ -207,29 +204,22 @@ int removeBinaryPackage(const char * prefix, rpmdb db, unsigned int offset, if (!(flags & RPMTRANS_FLAG_TEST)) { rpmMessage(RPMMESS_DEBUG, _("running postuninstall script (if any)\n")); - runInstScript(prefix, h, RPMTAG_POSTUN, RPMTAG_POSTUNPROG, scriptArg, - flags & RPMTRANS_FLAG_NOSCRIPTS, scriptFd); + rc = runInstScript(prefix, h, RPMTAG_POSTUN, RPMTAG_POSTUNPROG, + scriptArg, (flags & RPMTRANS_FLAG_NOSCRIPTS), scriptFd); + /* XXX postun failures are not cause for erasure failure. */ } if (!(flags & RPMTRANS_FLAG_NOTRIGGERS)) { /* Run postun triggers which are set off by this package's removal. */ - if (runTriggers(prefix, db, RPMSENSE_TRIGGERPOSTUN, h, -1, scriptFd)) { - rc = 2; - goto exit; - } + rc = runTriggers(prefix, db, RPMSENSE_TRIGGERPOSTUN, h, -1, scriptFd); + if (rc) + return 2; } if (!(flags & RPMTRANS_FLAG_TEST)) rpmdbRemove(db, offset); - rc = 0; - - exit: - if (h) { - headerFree(h); - h = NULL; - } - return rc; + return 0; } static int runScript(Header h, const char * root, int progArgc, const char ** progArgv, |