[yum-commits] 2 commits - Makefile yum-debug-restore.py yum-utils.spec
James Antill
james at osuosl.org
Tue Mar 31 05:27:13 UTC 2009
Makefile | 2
yum-debug-restore.py | 210 +++++++++++++++++++++++++++++++++++++++++++++++++++
yum-utils.spec | 7 -
3 files changed, 215 insertions(+), 4 deletions(-)
New commits:
commit 2c7909bd3cde0c0c65e0fc1bd9efff2538219b7b
Author: James Antill <james at and.org>
Date: Tue Mar 31 01:22:02 2009 -0400
Add a "simple" version of yum-debug-restore
diff --git a/Makefile b/Makefile
index 9509cbc..7ae6710 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
SUBDIRS = docs
PKGNAME = yum-utils
-UTILS = package-cleanup debuginfo-install repoclosure repomanage repoquery repo-graph repo-rss yumdownloader yum-builddep repotrack reposync repodiff yum-debug-dump verifytree yum-groups-manager find-repos-of-install
+UTILS = package-cleanup debuginfo-install repoclosure repomanage repoquery repo-graph repo-rss yumdownloader yum-builddep repotrack reposync repodiff yum-debug-dump yum-debug-restore verifytree yum-groups-manager find-repos-of-install
UTILSROOT = yum-complete-transaction
VERSION=$(shell awk '/Version:/ { print $$2 }' ${PKGNAME}.spec)
RELEASE=$(shell awk -F%: '/Release:/ { print $$2 }' ${PKGNAME}.spec ')
diff --git a/yum-debug-restore.py b/yum-debug-restore.py
new file mode 100755
index 0000000..e501dce
--- /dev/null
+++ b/yum-debug-restore.py
@@ -0,0 +1,210 @@
+#!/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.
+## (c) 2008 Red Hat. Written by skvidal at fedoraproject.org
+## james at fedoraproject.org
+
+import os
+import sys
+import gzip
+import tempfile
+
+from optparse import OptionParser
+
+import yum
+import rpmUtils.miscutils
+
+sections = ['%%%%SYSTEM INFO\n', '%%%%YUM INFO\n',
+ '%%%%RPMDB PROBLEMS\n', '%%%%RPMDB\n',
+ '%%%%REPOS\n']
+
+def cmd_line():
+ parser = OptionParser()
+ parser.set_usage("yum-debug-restore [options]")
+ parser.add_option("-C", "--cache", action="store_true",
+ help="run from cache only")
+ parser.add_option("-c", dest="conffile", help="config file location")
+ parser.add_option("--enablerepo", action="append", dest="enablerepos",
+ help="specify additional repoids to query, can be specified multiple times")
+ parser.add_option("--disablerepo", action="append", dest="disablerepos",
+ help="specify repoids to disable, can be specified multiple times")
+ parser.add_option("-y", dest="assumeyes", action="store_true",
+ help="answer yes for all questions")
+ parser.add_option("--skip-broken", action="store_true",
+ help="skip packages with depsolving problems")
+
+ parser.add_option("--output", action="store_true",
+ help="output the yum shell commands")
+ parser.add_option("--shell",
+ help="output the yum shell commands to a file")
+
+ parser.add_option("--install-latest", action="store_true",
+ help="install the latest instead of specific versions")
+
+ parser.add_option("--filter-types",
+ help="Limit to: install, remove, update, downgrade")
+
+ (opts, args) = parser.parse_args()
+ if not args:
+ parser.usage()
+ return (opts, args)
+
+class OtherRpmDB:
+
+ def __init__(self, fn):
+ self.pkgtups = []
+
+ if fn.endswith(".gz"):
+ fo = gzip.GzipFile(fn)
+ else:
+ fo = open(fn)
+
+ if fo.readline() != 'yum-debug-dump version 1\n':
+ print >>sys.stderr, "Bad yum debug file:", fn
+ sys.exit(1)
+
+ skip = sections[:-1]
+ for line in fo:
+ if skip: # Header stuff
+ if line == skip[0]:
+ skip.pop(0)
+ continue
+
+ if not line or line[0] != ' ':
+ break
+
+ pkgtup = rpmUtils.miscutils.splitFilename(line.strip())
+ n,v,r,e,a = pkgtup # grrr...
+ pkgtup = (n,a,e,v,r)
+ self.pkgtups.append(pkgtup)
+
+def naevr2str(n,a,e,v,r):
+ if e in (None, '', '0'):
+ return "%s-%s-%s.%s" % (n,v,r,a)
+ return "%s-%s:%s-%s.%s" % (n,e,v,r,a)
+def pkgtup2str(pkgtup):
+ n,a,e,v,r = pkgtup
+ return naevr2str(n,a,e,v,r)
+
+def pkg_data2list(yb, opkgtups, opkgmaps, install_latest):
+ ret = []
+ npkgtups = set()
+ npkgmaps = {}
+ for po in sorted(yb.rpmdb.returnPackages()):
+ if False: pass
+ elif (po.name, po.arch) not in opkgmaps:
+ ret.append(("remove", str(po)))
+ elif po.pkgtup not in opkgtups:
+ n,a,e,v,r = opkgmaps[(po.name, po.arch)]
+ pinstEVR = yum.packages.PackageEVR(e, v, r)
+ if po.EVR < pinstEVR:
+ ret.append(("upgrade", naevr2str(n,a,e,v,r)))
+ else:
+ ret.append(("downgrade", naevr2str(n,a,e,v,r)))
+ npkgtups.add(po.pkgtup)
+ npkgmaps[(po.name, po.arch)] = po
+
+ for name, arch in sorted(opkgmaps):
+ if (name, arch) in npkgmaps:
+ continue
+ if install_latest:
+ ret.append(("install", "%s.%s" % (name, arch)))
+ else:
+ ret.append(("install", pkgtup2str(opkgmaps[(name, arch)])))
+ return ret
+
+def main():
+ (opts, args) = cmd_line()
+ yb = yum.YumBase()
+ yb.preconf.init_plugins = True
+ if opts.conffile:
+ yb.preconf.fn = opts.conffile
+
+ yb.conf
+ if opts.cache:
+ yb.conf.cache = True
+
+ if opts.disablerepos:
+ for repo_match in opts.disablerepos:
+ for repo in yb.repos.findRepos(repo_match):
+ repo.disable()
+
+ if opts.enablerepos:
+ for repo_match in opts.enablerepos:
+ for repo in yb.repos.findRepos(repo_match):
+ repo.enable()
+
+ xtra_args = []
+ if opts.skip_broken:
+ xtra_args.append('--skip-broken')
+
+ if opts.assumeyes:
+ xtra_args.append('-y')
+
+ fn = args[0]
+ print "Reading from: %s" % fn
+ orpmdb = OtherRpmDB(fn)
+
+ opkgmaps = {}
+ for pkgtup in orpmdb.pkgtups:
+ opkgmaps[(pkgtup[0], pkgtup[1])] = pkgtup
+
+ if opts.output:
+ fo = sys.stdout
+ elif opts.shell:
+ try:
+ fo = open(opts.shell, "wb")
+ except OSError, e:
+ print >>sys.stderr, "open(%s): %s" % (opts.shell, e)
+ sys.exit(1)
+ else:
+ fo = tempfile.NamedTemporaryFile()
+
+ fT = None
+ if opts.filter_types:
+ fT = set(opts.filter_types.replace(",", " ").split())
+
+ counts = {}
+ for T, pkg in pkg_data2list(yb, set(orpmdb.pkgtups), opkgmaps,
+ opts.install_latest):
+ if fT is not None and T not in fT:
+ continue
+ counts[T] = counts.get(T, 0) + 1
+ print >>fo, "%-9s %s" % (T, pkg)
+
+ if opts.output:
+ sys.exit(0)
+
+ print >>fo, "run"
+ fo.flush()
+
+ if opts.shell:
+ if counts:
+ print "Statistics:"
+ for T in sorted(counts):
+ print " %9s %6u" % (T, counts[T])
+ print "Done"
+ sys.exit(0)
+
+ # Want to do the transaction, hacky method
+ if xtra_args:
+ os.system("yum shell %s %s" % (" ".join(xtra_args), fo.name))
+ else:
+ os.system("yum shell %s" % fo.name)
+
+if __name__ == "__main__":
+ main()
+
+
diff --git a/yum-utils.spec b/yum-utils.spec
index eef2bfc..15f3ed7 100644
--- a/yum-utils.spec
+++ b/yum-utils.spec
@@ -8,7 +8,7 @@ Source: http://yum.baseurl.org/download/yum-utils/%{name}-%{version}.tar.gz
URL: http://yum.baseurl.org/download/yum-utils/
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
-Requires: python >= 2.4 , yum >= 3.2.22
+Requires: python >= 2.4 , yum >= 3.2.23
%description
yum-utils is a collection of utilities and examples for the yum package
@@ -16,7 +16,7 @@ manager. It includes utilities by different authors that make yum easier and
more powerful to use. These tools include: debuginfo-install, package-cleanup,
repoclosure, repodiff, repo-graph, repomanage, repoquery, repo-rss, reposync,
repotrack, verifytree, yum-builddep, yum-complete-transaction, yumdownloader,
-yum-debug-dump and yum-groups-manager.
+yum-debug-dump, yum-debug-restore and yum-groups-manager.
%package -n yum-updateonboot
Summary: Run yum update on system boot
@@ -435,6 +435,7 @@ fi
%{_bindir}/yum-builddep
%{_bindir}/yum-debug-dump
%{_bindir}/yum-groups-manager
+%{_bindir}/yum-debug-restore
%{_sbindir}/yum-complete-transaction
%{_mandir}/man1/yum-utils.1.*
%{_mandir}/man1/debuginfo-install.1.*
commit 67800273aae043f9e563551adaeeb554463f36cd
Author: James Antill <james at and.org>
Date: Mon Mar 30 23:41:58 2009 -0400
Put the require for changelog in the right place
diff --git a/yum-utils.spec b/yum-utils.spec
index dab35a3..eef2bfc 100644
--- a/yum-utils.spec
+++ b/yum-utils.spec
@@ -8,8 +8,7 @@ Source: http://yum.baseurl.org/download/yum-utils/%{name}-%{version}.tar.gz
URL: http://yum.baseurl.org/download/yum-utils/
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
-# changelog requires new update_md.UpdateMetadata() API in 3.2.23
-Requires: python >= 2.4 , yum >= 3.2.23
+Requires: python >= 2.4 , yum >= 3.2.22
%description
yum-utils is a collection of utilities and examples for the yum package
@@ -37,7 +36,8 @@ Group: System Environment/Base
Provides: yum-changelog = %{version}-%{release}
Obsoletes: yum-changelog < 1.1.20-0
Conflicts: yum-changelog < 1.1.20-0
-Requires: yum >= 3.2.19
+# changelog requires new update_md.UpdateMetadata() API in 3.2.23
+Requires: yum >= 3.2.23
Requires: python-dateutil
%description -n yum-plugin-changelog
More information about the Yum-commits
mailing list