diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2008-03-17 11:53:27 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2008-03-17 11:53:27 +0200 |
commit | 37543ee0405c38a9d54a12bf0d54698773a3933c (patch) | |
tree | 90e26ec9afa8bb03b2e89c8b9223e3b1f0d7beaf /lib/rpminstall.c | |
parent | ed78cef2c3e14df29d95b476f00d51203fbe098e (diff) | |
download | librpm-tizen-37543ee0405c38a9d54a12bf0d54698773a3933c.tar.gz librpm-tizen-37543ee0405c38a9d54a12bf0d54698773a3933c.tar.bz2 librpm-tizen-37543ee0405c38a9d54a12bf0d54698773a3933c.zip |
Remove rollback support
- not possible to do reliably within rpm
- effort is better wasted on investigating fs-level snapshots, which
is way beyond rpm scope except for hooks to interact with the snapshot
mechanism to communicate beginning/end of transaction and such
Diffstat (limited to 'lib/rpminstall.c')
-rw-r--r-- | lib/rpminstall.c | 209 |
1 files changed, 0 insertions, 209 deletions
diff --git a/lib/rpminstall.c b/lib/rpminstall.c index 13ec4978b..38b22c0dc 100644 --- a/lib/rpminstall.c +++ b/lib/rpminstall.c @@ -12,7 +12,6 @@ #include <rpm/rpmts.h> #include <rpm/rpmlog.h> #include <rpm/rpmfileutil.h> -#include <rpm/idtx.h> #include "lib/manifest.h" #include "debug.h" @@ -838,211 +837,3 @@ int rpmInstallSource(rpmts ts, const char * arg, return rc; } -/** @todo Transaction handling, more, needs work. */ -int rpmRollback(rpmts ts, struct rpmInstallArguments_s * ia, const char ** argv) -{ - int ifmask= (INSTALL_UPGRADE|INSTALL_FRESHEN|INSTALL_INSTALL|INSTALL_ERASE); - unsigned thistid = 0xffffffff; - unsigned prevtid; - time_t tid; - IDTX itids = NULL; - IDTX rtids = NULL; - IDT rp; - int nrids = 0; - IDT ip; - int niids = 0; - int rc = 0; - rpmVSFlags vsflags, ovsflags; - int numAdded; - int numRemoved; - rpmps ps; - rpmtransFlags transFlags = ia->transFlags; - - if (argv != NULL && *argv != NULL) { - rc = -1; - goto exit; - } - - vsflags = rpmExpandNumeric("%{?_vsflags_erase}"); - if (ia->qva_flags & VERIFY_DIGEST) - vsflags |= _RPMVSF_NODIGESTS; - if (ia->qva_flags & VERIFY_SIGNATURE) - vsflags |= _RPMVSF_NOSIGNATURES; - if (ia->qva_flags & VERIFY_HDRCHK) - vsflags |= RPMVSF_NOHDRCHK; - vsflags |= RPMVSF_NEEDPAYLOAD; /* XXX no legacy signatures */ - ovsflags = rpmtsSetVSFlags(ts, vsflags); - - (void) rpmtsSetFlags(ts, transFlags); - - itids = IDTXload(ts, RPMTAG_INSTALLTID); - if (itids != NULL) { - ip = itids->idt; - niids = itids->nidt; - } else { - ip = NULL; - niids = 0; - } - - { char * globstr = rpmExpand("%{_repackage_dir}/*.rpm", NULL); - if (globstr == NULL || *globstr == '%') { - globstr = _free(globstr); - rc = -1; - goto exit; - } - rtids = IDTXglob(ts, globstr, RPMTAG_REMOVETID); - - if (rtids != NULL) { - rp = rtids->idt; - nrids = rtids->nidt; - } else { - rp = NULL; - nrids = 0; - } - globstr = _free(globstr); - } - - { int notifyFlags, xx; - notifyFlags = ia->installInterfaceFlags | (rpmIsVerbose() ? INSTALL_LABEL : 0 ); - xx = rpmtsSetNotifyCallback(ts, - rpmShowProgress, (void *) ((long)notifyFlags)); - } - - /* Run transactions until rollback goal is achieved. */ - do { - prevtid = thistid; - rc = 0; - rpmcliPackagesTotal = 0; - numAdded = 0; - numRemoved = 0; - ia->installInterfaceFlags &= ~ifmask; - - /* Find larger of the remaining install/erase transaction id's. */ - thistid = 0; - if (ip != NULL && ip->val.u32 > thistid) - thistid = ip->val.u32; - if (rp != NULL && rp->val.u32 > thistid) - thistid = rp->val.u32; - - /* If we've achieved the rollback goal, then we're done. */ - if (thistid == 0 || thistid < ia->rbtid) - break; - - rpmtsEmpty(ts); - (void) rpmtsSetFlags(ts, transFlags); - - /* Install the previously erased packages for this transaction. */ - while (rp != NULL && rp->val.u32 == thistid) { - - rpmlog(RPMLOG_DEBUG, "\t+++ install %s\n", - (rp->key ? rp->key : "???")); - - rc = rpmtsAddInstallElement(ts, rp->h, (fnpyKey)rp->key, - 0, ia->relocations); - if (rc != 0) - goto exit; - - numAdded++; - rpmcliPackagesTotal++; - if (!(ia->installInterfaceFlags & ifmask)) - ia->installInterfaceFlags |= INSTALL_UPGRADE; - -#ifdef NOTYET - rp->h = headerFree(rp->h); -#endif - nrids--; - if (nrids > 0) - rp++; - else - rp = NULL; - } - - /* Erase the previously installed packages for this transaction. */ - while (ip != NULL && ip->val.u32 == thistid) { - - rpmlog(RPMLOG_DEBUG, - "\t--- erase h#%u\n", ip->instance); - - rc = rpmtsAddEraseElement(ts, ip->h, ip->instance); - if (rc != 0) - goto exit; - - numRemoved++; - - if (!(ia->installInterfaceFlags & ifmask)) { - ia->installInterfaceFlags |= INSTALL_ERASE; - (void) rpmtsSetFlags(ts, (transFlags | RPMTRANS_FLAG_REVERSE)); - } - -#ifdef NOTYET - ip->instance = 0; -#endif - niids--; - if (niids > 0) - ip++; - else - ip = NULL; - } - - /* Anything to do? */ - if (rpmcliPackagesTotal <= 0) - break; - - tid = (time_t)thistid; - rpmlog(RPMLOG_NOTICE, - _("Rollback packages (+%d/-%d) to %-24.24s (0x%08x):\n"), - numAdded, numRemoved, ctime(&tid), thistid); - - rc = rpmtsCheck(ts); - ps = rpmtsProblems(ts); - if (rc != 0 && rpmpsNumProblems(ps) > 0) { - rpmlog(RPMLOG_ERR, _("Failed dependencies:\n")); - rpmpsPrint(NULL, ps); - ps = rpmpsFree(ps); - goto exit; - } - ps = rpmpsFree(ps); - - rc = rpmtsOrder(ts); - if (rc != 0) - goto exit; - - /* Drop added/available package indices and dependency sets. */ - rpmtsClean(ts); - - rc = rpmtsRun(ts, NULL, (ia->probFilter|RPMPROB_FILTER_OLDPACKAGE)); - ps = rpmtsProblems(ts); - if (rc > 0 && rpmpsNumProblems(ps) > 0) - rpmpsPrint(stderr, ps); - ps = rpmpsFree(ps); - if (rc) - goto exit; - - /* Clean up after successful rollback. */ - if (rtids && !rpmIsDebug()) { - int i; - rpmlog(RPMLOG_NOTICE, _("Cleaning up repackaged packages:\n")); - if (rtids->idt) - for (i = 0; i < rtids->nidt; i++) { - IDT rrp = rtids->idt + i; - if (rrp->val.u32 != thistid) - continue; - if (rrp->key) { /* XXX can't happen */ - rpmlog(RPMLOG_NOTICE, _("\tRemoving %s:\n"), rrp->key); - (void) unlink(rrp->key); /* XXX: Should check rc??? */ - } - } - } - - - } while (1); - -exit: - rtids = IDTXfree(rtids); - itids = IDTXfree(itids); - - rpmtsEmpty(ts); - (void) rpmtsSetFlags(ts, transFlags); - - return rc; -} |