[yum-cvs] 2 commits - yum-complete-transaction.py
Seth Vidal
skvidal at linux.duke.edu
Mon Dec 10 15:05:54 UTC 2007
yum-complete-transaction.py | 124 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 124 insertions(+)
New commits:
commit 3fa2335a14eea161085c51df8bd44d8cab4c344a
Merge: a1970fa... a5515fc...
Author: Seth Vidal <skvidal at fedoraproject.org>
Date: Mon Dec 10 10:05:00 2007 -0500
Merge branch 'master' of ssh://login.linux.duke.edu/home/groups/yum/git/yum-utils
* 'master' of ssh://login.linux.duke.edu/home/groups/yum/git/yum-utils:
Fix unreferenced variable in repoclosure.py
updated ChangeLog
bumped yum-utils version to 1.1.9
bumped yum-utils version to 1.1.9
commit a1970fa51c36fc37df556253a52bb298bd2a79ea
Author: Seth Vidal <skvidal at fedoraproject.org>
Date: Mon Dec 10 10:04:30 2007 -0500
implement yum-util to clean up unfinished/aborted transactions using
transaction-done/transaction-all files.
diff --git a/yum-complete-transaction.py b/yum-complete-transaction.py
new file mode 100755
index 0000000..e035697
--- /dev/null
+++ b/yum-complete-transaction.py
@@ -0,0 +1,124 @@
+#!/usr/bin/python -tt
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+import sys
+sys.path.insert(0,'/usr/share/yum-cli')
+
+import yum
+from yum.misc import getCacheDir
+import yum.misc
+
+from cli import *
+from utils import YumUtilBase
+
+from urlparse import urljoin
+from urlgrabber.progress import TextMeter
+
+
+class YumCompleteTransaction(YumUtilBase):
+ NAME = 'yum-complete-transactions'
+ VERSION = '1.0'
+ USAGE = '"usage: yum-complete-transaction [options] package1 [package2] [package..]'
+
+ def __init__(self):
+ YumUtilBase.__init__(self,
+ YumCompleteTransaction.NAME,
+ YumCompleteTransaction.VERSION,
+ YumCompleteTransaction.USAGE)
+ self.logger = logging.getLogger("yum.verbose.cli.yumcompletets")
+ self.main()
+
+ def clean_up_ts_files(self, timestamp, path):
+
+ # clean up the transactions
+ tsdone = '%s/transaction-done.%s' % (path, timestamp)
+ tsall = '%s/transaction-all.%s' % (path, timestamp)
+ os.unlink(tsdone)
+ os.unlink(tsall)
+
+ def main(self):
+ # Add util commandline options to the yum-cli ones
+ parser = self.getOptionParser()
+ # Parse the commandline option and setup the basics.
+ try:
+ opts = self.doUtilConfigSetup()
+ except yum.Errors.RepoError, e:
+ self.logger.error("Cannot handle specific enablerepo/disablerepo options.")
+ sys.exit(50)
+
+ # Check if there is anything to do.
+# if len(self.cmds) < 1:
+# parser.print_help()
+# sys.exit(0)
+
+ if self.conf.uid != 0:
+ self.logger.error("Error: You must be root to finish transactions")
+ sys.exit(1)
+
+ # Setup yum (Ts, RPM db, Repo & Sack)
+ self.doUtilYumSetup()
+ # Do the real action
+ # get the list of transactions remaining
+ # list the number of them
+ # take the most recent one
+ # populate the ts
+ # run it
+ times = yum.misc.find_unfinished_transactions(self.conf.persistdir)
+ if not times:
+ print "No unfinished transactions left."
+ sys.exit()
+
+ print "There are %d outstanding transactions to complete. Finishing the most recent one" % len(times)
+
+ timestamp = times[-1]
+ remaining = yum.misc.find_ts_remaining(timestamp, yumlibpath=self.conf.persistdir)
+ print "The remaining transaction had %d elements left to run" % len(remaining)
+ for (action, pkgspec) in remaining:
+ if action == 'install':
+ try:
+ self.install(pattern=pkgspec)
+ except yum.Errors.InstallError, e:
+ pass
+
+ if action == 'erase':
+ (e, m, u) = self.rpmdb.matchPackageNames([pkgspec])
+ for pkg in e:
+ self.remove(po=pkg)
+
+
+
+ self.buildTransaction()
+ if len(self.tsInfo) < 1:
+ print 'Nothing in the unfinished transaction to cleanup.'
+ print "Cleaning up completed transaction file"
+ self.clean_up_ts_files(timestamp, self.conf.persistdir)
+ sys.exit()
+
+ else:
+ if self.doTransaction():
+ print "Cleaning up completed transaction file"
+ self.clean_up_ts_files(timestamp, self.conf.persistdir)
+ sys.exit()
+
+
+
+
+
+
+if __name__ == '__main__':
+ util = YumCompleteTransaction()
+
+
More information about the Yum-cvs-commits
mailing list