multilib_yum: Remove main() function

Nothing is calling this file as an executable, so there is no reason to
have logic for parsing arguments.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2017-06-22 16:32:35 +02:00
parent 01026858f7
commit 69a6046bf8
1 changed files with 0 additions and 115 deletions

View File

@ -268,118 +268,3 @@ def po_is_multilib(po, methods):
if method.select(po):
return method_name
return None
def do_multilib(yum_arch, methods, repos, tmpdir, logfile):
import os
import yum
import rpm
import logging
archlist = yum.rpmUtils.arch.getArchList(yum_arch)
yumbase = yum.YumBase()
yumbase.preconf.init_plugins = False
yumbase.preconf.root = tmpdir
# order matters!
# must run doConfigSetup() before touching yumbase.conf
yumbase.doConfigSetup(fn="/dev/null")
yumbase.conf.cache = False
yumbase.conf.cachedir = tmpdir
yumbase.conf.exactarch = True
yumbase.conf.gpgcheck = False
yumbase.conf.logfile = logfile
yumbase.conf.plugins = False
yumbase.conf.reposdir = []
yumbase.verbose_logger.setLevel(logging.ERROR)
yumbase.doRepoSetup()
yumbase.doTsSetup()
yumbase.doRpmDBSetup()
yumbase.ts.pushVSFlags((rpm._RPMVSF_NOSIGNATURES|rpm._RPMVSF_NODIGESTS))
for repo in yumbase.repos.findRepos("*"):
repo.disable()
for i, baseurl in enumerate(repos):
repo_id = "multilib-%s" % i
if "://" not in baseurl:
baseurl = "file://" + os.path.abspath(baseurl)
yumbase.add_enable_repo(repo_id, baseurls=[baseurl])
yumbase.doSackSetup(archlist=archlist)
yumbase.doSackFilelistPopulate()
method_kwargs = {}
result = []
for po in sorted(yumbase.pkgSack):
method = po_is_multilib(po, methods)
if method:
nvra = "%s-%s-%s.%s.rpm" % (po.name, po.version, po.release, po.arch)
result.append((nvra, method))
return result
def main():
import optparse
import shutil
import tempfile
class MyOptionParser(optparse.OptionParser):
def print_help(self, *args, **kwargs):
optparse.OptionParser.print_help(self, *args, **kwargs)
print
print "Available multilib methods:"
for key, value in sorted(METHOD_MAP.items()):
default = (key in DEFAULT_METHODS) and " (default)" or ""
print " %-10s %s%s" % (key, value.__doc__ or "", default)
parser = MyOptionParser("usage: %prog [options]")
parser.add_option(
"--arch",
)
parser.add_option(
"--method",
action="append",
default=DEFAULT_METHODS,
help="multilib method",
)
parser.add_option(
"--repo",
dest="repos",
action="append",
help="path or url to yum repo; can be specified multiple times",
)
parser.add_option("--tmpdir")
parser.add_option("--logfile", action="store")
opts, args = parser.parse_args()
if args:
parser.error("no arguments expected")
if not opts.repos:
parser.error("provide at least one repo")
for method_name in opts.method:
if method_name not in METHOD_MAP:
parser.error("unknown method: %s" % method_name)
print opts.method
tmpdir = opts.tmpdir
if not opts.tmpdir:
tmpdir = tempfile.mkdtemp(prefix="multilib_")
init()
nvra_list = do_multilib(opts.arch, opts.method, opts.repos, tmpdir, opts.logfile)
for nvra, method in nvra_list:
print "MULTILIB(%s): %s" % (method, nvra)
if not opts.tmpdir:
shutil.rmtree(tmpdir)
if __name__ == "__main__":
main()