support downloading non-rpm archives via download-build --type
This commit is contained in:
parent
b35c6ae75b
commit
2f2a7d0379
1 changed files with 50 additions and 22 deletions
72
cli/koji
72
cli/koji
|
|
@ -5230,9 +5230,12 @@ def anon_handle_download_build(options, session, args):
|
|||
parser = OptionParser(usage=usage)
|
||||
parser.add_option("--arch", dest="arches", metavar="ARCH", action="append", default=[],
|
||||
help=_("Only download packages for this arch (may be used multiple times)"))
|
||||
parser.add_option("--type", help=_("Download archives of the given type, rather than rpms"))
|
||||
parser.add_option("--latestfrom", dest="latestfrom", help=_("Download the latest build from this tag"))
|
||||
parser.add_option("--debuginfo", action="store_true", help=_("Also download -debuginfo rpms"))
|
||||
parser.add_option("--key", help=_("Download rpms signed with the given key"))
|
||||
parser.add_option("--topurl", metavar="URL",
|
||||
help=_("URL under which Koji files are accessible"))
|
||||
parser.add_option("-q", "--quiet", action="store_true", help=_("Do not display progress meter"),
|
||||
default=options.quiet)
|
||||
(suboptions, args) = parser.parse_args(args)
|
||||
|
|
@ -5270,36 +5273,61 @@ def anon_handle_download_build(options, session, args):
|
|||
print "No such build: %s" % build
|
||||
return 1
|
||||
|
||||
arches = suboptions.arches
|
||||
if len(arches) == 0:
|
||||
arches = None
|
||||
rpms = session.listRPMs(buildID=info['id'], arches=arches)
|
||||
if not rpms:
|
||||
if arches:
|
||||
print "No %s packages available for %s" % (" or ".join(arches), koji.buildLabel(info))
|
||||
urls = []
|
||||
if suboptions.type:
|
||||
archives = session.listArchives(buildID=info['id'], type=suboptions.type)
|
||||
if not archives:
|
||||
print "No %s archives available for %s" % (suboptions.type, koji.buildLabel(info))
|
||||
return 1
|
||||
if suboptions.type == 'maven':
|
||||
if not suboptions.topurl:
|
||||
print "You must specify --topurl to download Maven archives"
|
||||
return 1
|
||||
maven_pi = koji.PathInfo(topdir=suboptions.topurl)
|
||||
maven_info = session.getMavenBuild(info['id'], strict=True)
|
||||
for archive in archives:
|
||||
urls.append((maven_pi.mavenbuild(info, maven_info) + '/' + archive['filename'], archive['filename']))
|
||||
elif suboptions.type == 'win':
|
||||
for archive in archives:
|
||||
url = '%s/%s/%s/%s/win/%s' % (options.pkgurl, info['name'], info['version'], info['release'],
|
||||
koji.pathinfo.winfile(archive))
|
||||
urls.append((url, koji.pathinfo.winfile(archive)))
|
||||
else:
|
||||
print "No packages available for %s" % koji.buildLabel(info)
|
||||
return 1
|
||||
# can't happen
|
||||
assert False
|
||||
else:
|
||||
arches = suboptions.arches
|
||||
if len(arches) == 0:
|
||||
arches = None
|
||||
rpms = session.listRPMs(buildID=info['id'], arches=arches)
|
||||
if not rpms:
|
||||
if arches:
|
||||
print "No %s packages available for %s" % (" or ".join(arches), koji.buildLabel(info))
|
||||
else:
|
||||
print "No packages available for %s" % koji.buildLabel(info)
|
||||
return 1
|
||||
for rpm in rpms:
|
||||
if not suboptions.debuginfo and koji.is_debuginfo(rpm['name']):
|
||||
continue
|
||||
if suboptions.key:
|
||||
fname = koji.pathinfo.signed(rpm, suboptions.key)
|
||||
else:
|
||||
fname = koji.pathinfo.rpm(rpm)
|
||||
url = '%s/%s/%s/%s/%s' % (options.pkgurl, info['name'], info['version'], info['release'],
|
||||
fname)
|
||||
urls.append((url, os.path.basename(fname)))
|
||||
|
||||
if suboptions.quiet:
|
||||
pg = None
|
||||
else:
|
||||
pg = progress.TextMeter()
|
||||
|
||||
for rpm in rpms:
|
||||
if not suboptions.debuginfo and koji.is_debuginfo(rpm['name']):
|
||||
continue
|
||||
for url, relpath in urls:
|
||||
file = grabber.urlopen(url, progress_obj=pg, text=relpath)
|
||||
|
||||
if suboptions.key:
|
||||
fname = koji.pathinfo.signed(rpm, suboptions.key)
|
||||
else:
|
||||
fname = koji.pathinfo.rpm(rpm)
|
||||
|
||||
url = "%s/%s/%s/%s/%s" % (options.pkgurl, info['package_name'], info['version'], info['release'], fname)
|
||||
|
||||
file = grabber.urlopen(url, progress_obj = pg, text = "%s.%s" % (rpm['name'], rpm['arch']))
|
||||
|
||||
out = os.open(os.path.basename(fname), os.O_WRONLY|os.O_CREAT|os.O_TRUNC, 0666)
|
||||
if '/' in relpath:
|
||||
koji.ensuredir(os.path.dirname(relpath))
|
||||
out = os.open(relpath, os.O_WRONLY|os.O_CREAT|os.O_TRUNC, 0666)
|
||||
try:
|
||||
while 1:
|
||||
buf = file.read(4096)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue