Blame SOURCES/BZ-1506205-repotrack-add-repofrompath-opt.patch

b7ec20
commit c01c1bab3b3530e04d9cb13bcf03d6f1a95a7f33
b7ec20
Author: Michal Domonkos <mdomonko@redhat.com>
b7ec20
Date:   Fri Jun 22 22:39:30 2018 +0200
b7ec20
b7ec20
    repotrack: add --repofrompath option. BZ 1506205
b7ec20
    
b7ec20
    Code taken from repoquery.
b7ec20
b7ec20
diff --git a/docs/repotrack.1 b/docs/repotrack.1
b7ec20
index 6b46ed0..597b7a5 100644
b7ec20
--- a/docs/repotrack.1
b7ec20
+++ b/docs/repotrack.1
b7ec20
@@ -19,6 +19,10 @@ Act as if running the specified arch (default: current arch).
b7ec20
 .IP "\fB\-r REPOID, \-\-repoid=REPOID\fP"
b7ec20
 Specify repo ids to query, can be specified multiple times (default is
b7ec20
 all enabled).
b7ec20
+.IP "\fB\-\-repofrompath=<repoid>,<path/url>\fP"
b7ec20
+Specify repoid & paths of additional repositories - unique repoid and complete
b7ec20
+path required, can be specified multiple times.
b7ec20
+Example: --repofrompath=myrepo,/path/to/repo
b7ec20
 .IP "\fB\-t, \-\-tempcache\fP"
b7ec20
 Use a temp dir for storing/accessing yum-cache.
b7ec20
 .IP "\fB\-p DESTDIR, \-\-download_path=DESTDIR\fP"
b7ec20
diff --git a/repotrack.py b/repotrack.py
b7ec20
index 8dd8b9c..79b761f 100755
b7ec20
--- a/repotrack.py
b7ec20
+++ b/repotrack.py
b7ec20
@@ -87,6 +87,10 @@ def parseArgs():
b7ec20
         help='check as if running the specified arch (default: current arch)')
b7ec20
     parser.add_option("-r", "--repoid", default=[], action='append',
b7ec20
         help="specify repo ids to query, can be specified multiple times (default is all enabled)")
b7ec20
+    parser.add_option("--repofrompath", action="append",
b7ec20
+        help="specify repoid & paths of additional repositories - unique repoid "
b7ec20
+             "and complete path required, can be specified multiple times. "
b7ec20
+             "Example: --repofrompath=myrepo,/path/to/repo")
b7ec20
     parser.add_option("-t", "--tempcache", default=False, action="store_true", 
b7ec20
         help="Use a temp dir for storing/accessing yum-cache")
b7ec20
     parser.add_option("-p", "--download_path", dest='destdir', 
b7ec20
@@ -157,8 +161,33 @@ def main():
b7ec20
             repo.enable()
b7ec20
             my._getSacks(archlist=archlist, thisrepo=repo.id)
b7ec20
 
b7ec20
-    my.doRepoSetup()    
b7ec20
-    my._getSacks(archlist=archlist)
b7ec20
+    if opts.repofrompath:
b7ec20
+        for repo in opts.repofrompath:
b7ec20
+            tmp = tuple(repo.split(','))
b7ec20
+            if len(tmp) != 2:
b7ec20
+                my.logger.error("Error: Bad repofrompath argument: %s" %repo)
b7ec20
+                continue
b7ec20
+            repoid, repopath = tmp
b7ec20
+            if repopath and repopath[0] == '/':
b7ec20
+                baseurl = 'file://' + repopath
b7ec20
+            else:
b7ec20
+                baseurl = repopath
b7ec20
+            try:
b7ec20
+                my.add_enable_repo(repoid, baseurls=[baseurl],
b7ec20
+                                   basecachedir=my.conf.cachedir,
b7ec20
+                                   timestamp_check=False)
b7ec20
+            except yum.Errors.DuplicateRepoError, e:
b7ec20
+                my.logger.error(e)
b7ec20
+                sys.exit(1)
b7ec20
+            if not opts.quiet:
b7ec20
+                my.logger.info("Added %s repo from %s" % (repoid, repopath))
b7ec20
+
b7ec20
+    try:
b7ec20
+        my.doRepoSetup()
b7ec20
+        my._getSacks(archlist=archlist)
b7ec20
+    except yum.Errors.RepoError, e:
b7ec20
+        my.logger.error(e)
b7ec20
+        sys.exit(1)
b7ec20
     
b7ec20
     unprocessed_pkgs = {}
b7ec20
     final_pkgs = {}