[yum-commits] 2 commits - find-repos-of-install.py Makefile yum-utils.spec

skvidal at osuosl.org skvidal at osuosl.org
Wed Dec 10 20:56:01 UTC 2008


 Makefile                 |    2 
 find-repos-of-install.py |  114 +++++++++++++++++++++++++++++++++++++++++++++++
 yum-utils.spec           |    4 +
 3 files changed, 119 insertions(+), 1 deletion(-)

New commits:
commit bc825ce7767b1430c4d5acb5327c4a2fcb3a6001
Merge: 3ecfce6... 6bbb5f0...
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Wed Dec 10 15:55:33 2008 -0500

    Merge branch 'master' of ssh://yum.baseurl.org/srv/projects/yum/git/yum-utils
    
    * 'master' of ssh://yum.baseurl.org/srv/projects/yum/git/yum-utils:
      Fixup the security documentation for --bugfix etc.
      Allow list-security to specify bugfix/enhancement/recommended/etc.

commit 3ecfce6fec91b1ae2bbcbd0e8c0d5a1590fbf68a
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Wed Dec 10 15:45:56 2008 -0500

    add find-repos-of-install

diff --git a/Makefile b/Makefile
index 1034e17..12b5c81 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
+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
 UTILSROOT = yum-complete-transaction 
 VERSION=$(shell awk '/Version:/ { print $$2 }' ${PKGNAME}.spec)
 RELEASE=$(shell awk -F%: '/Release:/ { print $$2 }' ${PKGNAME}.spec ')
diff --git a/find-repos-of-install.py b/find-repos-of-install.py
new file mode 100644
index 0000000..b3bad60
--- /dev/null
+++ b/find-repos-of-install.py
@@ -0,0 +1,114 @@
+#!/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.
+# copyright 2008 red hat, inc
+
+import sys
+import os
+import os.path
+
+from optparse import OptionParser
+
+import yum
+
+my = yum.YumBase()
+my.conf.showdupesfromrepos = 1
+
+if True:
+    parser = OptionParser(version = "find-repos-of-installed version 0.1")
+
+    parser.add_option("--repoid", action="append",
+                      help="specify repoids to query, can be specified multiple times (default is all enabled)")
+
+    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("--repofrompath", action="append",
+                      help="specify repoid & paths of additional repositories - unique repoid and complete path required, can be specified multiple times. Example. --repofrompath=myrepo,/path/to/repo")
+
+    parser.add_option("-C", "--cache", action="store_true",
+                      help="run from cache only")
+    parser.add_option("--tempcache", action="store_true",
+                      help="use private cache (default when used as non-root)")
+
+
+    (opts, regexs) = parser.parse_args()
+
+    if os.geteuid() != 0 or opts.tempcache:
+        cachedir = yum.misc.getCacheDir()
+        if cachedir is None:
+            my.logger.error("Error: Could not make cachedir, exiting")
+            sys.exit(50)
+        my.repos.setCacheDir(cachedir)
+        my.conf.cache = 0 # yum set cache=1, if uid != 0
+
+
+    if opts.cache:
+        my.conf.cache = True
+        if not opts.quiet:
+            my.logger.info('Running from cache, results might be incomplete.')
+
+    if opts.repofrompath:
+        # setup the fake repos
+        for repo in opts.repofrompath:
+            repoid,repopath = tuple(repo.split(','))
+            if repopath[0] == '/':
+                baseurl = 'file://' + repopath
+            else:
+                baseurl = repopath
+                
+            repopath = os.path.normpath(repopath)
+            newrepo = yum.yumRepo.YumRepository(repoid)
+            newrepo.name = repopath
+            newrepo.baseurl = baseurl
+            newrepo.basecachedir = my.conf.cachedir
+            newrepo.metadata_expire = 0
+            newrepo.timestamp_check = False
+            my.repos.add(newrepo)
+            my.repos.enableRepo(newrepo.id)
+            my.logger.info( "Added %s repo from %s" % (repoid,repopath))
+
+    if opts.repoid:
+        for repo in my.repos.findRepos('*'):
+            if repo.id not in opts.repoid:
+                repo.disable()
+            else:
+                repo.enable()
+    if opts.disablerepos:
+        for repo_match in opts.disablerepos:
+            for repo in my.repos.findRepos(repo_match):
+                repo.disable()
+
+    if opts.enablerepos:    
+            for repo_match in opts.enablerepos:
+                for repo in my.repos.findRepos(repo_match):
+                    repo.enable()
+
+
+
+if len(sys.argv) > 1:
+    pkgs = my.rpmdb.returnPackages(patterns=sys.argv[1:], ignore_case=True)
+else:
+    pkgs = my.rpmdb
+
+for ipkg in sorted(pkgs):
+    apkgs = my.pkgSack.searchPkgTuple(ipkg.pkgtup)
+    if len(apkgs) < 1:
+        print "Error: %s not found in any repository" % ipkg
+    else:
+        apkg = apkgs[0]
+        print '%s from repo %s' % (ipkg, apkg.repoid)
+        
+    
diff --git a/yum-utils.spec b/yum-utils.spec
index 3657889..6e60ff9 100644
--- a/yum-utils.spec
+++ b/yum-utils.spec
@@ -366,6 +366,7 @@ fi
 %doc COPYING
 %doc plugins/README
 %{_bindir}/debuginfo-install
+%{_bindir}/find-repos-of-install
 %{_bindir}/package-cleanup
 %{_bindir}/repoclosure
 %{_bindir}/repodiff
@@ -546,6 +547,9 @@ fi
 
 
 %changelog
+* Wed Dec 10 2008 Seth Vidal <skvidal at fedoraproject.org>
+- add find-repos-of-install from James' stash of misc stuff
+
 * Wed Oct 29 2008 Tim Lauridsen <timlau at fedoraproject.org>
 - mark as 1.1.18
 


More information about the Yum-commits mailing list