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

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