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