Add --nodownload option to print packages instead of downloading them.

This allows other tools to use Pungi for depsolving and process
packages in their own way.
This commit is contained in:
Daniel Mach 2011-08-18 12:29:10 +02:00 committed by Dennis Gilmore
parent 9cf7418cd5
commit 249efe1d75
2 changed files with 36 additions and 3 deletions

View File

@ -110,13 +110,28 @@ def main():
mypungi.completePackageSet() mypungi.completePackageSet()
if plen == len(mypungi.srpmpolist): if plen == len(mypungi.srpmpolist):
break break
mypungi.downloadPackages() if opts.nodownload:
for line in mypungi.listPackages():
sys.stdout.write("RPM: %s\n" % line)
sys.stdout.flush()
else:
mypungi.downloadPackages()
mypungi.makeCompsFile() mypungi.makeCompsFile()
if not opts.nodebuginfo: if not opts.nodebuginfo:
mypungi.getDebuginfoList() mypungi.getDebuginfoList()
mypungi.downloadDebuginfo() if opts.nodownload:
for line in mypungi.listDebuginfo():
sys.stdout.write("DEBUGINFO: %s\n" % line)
sys.stdout.flush()
else:
mypungi.downloadDebuginfo()
if not opts.nosource: if not opts.nosource:
mypungi.downloadSRPMs() if opts.nodownload:
for line in mypungi.listSRPMs():
sys.stdout.write("SRPM: %s\n" % line)
sys.stdout.flush()
else:
mypungi.downloadSRPMs()
if opts.do_all or opts.do_createrepo: if opts.do_all or opts.do_createrepo:
mypungi.doCreaterepo() mypungi.doCreaterepo()
@ -184,6 +199,8 @@ if __name__ == '__main__':
help='disable gathering of source packages (optional)') help='disable gathering of source packages (optional)')
parser.add_option("--nodebuginfo", action="store_true", dest="nodebuginfo", parser.add_option("--nodebuginfo", action="store_true", dest="nodebuginfo",
help='disable gathering of debuginfo packages (optional)') help='disable gathering of debuginfo packages (optional)')
parser.add_option("--nodownload", action="store_true", dest="nodownload",
help='disable downloading of packages. instead, print the package URLs (optional)')
parser.add_option("--nogreedy", action="store_true", dest="nogreedy", parser.add_option("--nogreedy", action="store_true", dest="nogreedy",
help='disable pulling of all providers of package dependencies (optional)') help='disable pulling of all providers of package dependencies (optional)')
parser.add_option("--sourceisos", default=False, action="store_true", dest="sourceisos", parser.add_option("--sourceisos", default=False, action="store_true", dest="sourceisos",

View File

@ -728,6 +728,22 @@ class Pungi(pypungi.PungiBase):
self._downloadPackageList(self.debuginfolist, os.path.join(self.config.get('pungi', 'arch'), self._downloadPackageList(self.debuginfolist, os.path.join(self.config.get('pungi', 'arch'),
'debug')) 'debug'))
def _listPackages(self, polist):
"""Cycle through the list of packages and return their paths."""
return [ os.path.join(pkg.basepath or "", pkg.relativepath) for pkg in polist ]
def listPackages(self):
"""Cycle through the list of RPMs and return their paths."""
return self._listPackages(self.polist)
def listSRPMs(self):
"""Cycle through the list of SRPMs and return their paths."""
return self._listPackages(self.srpmpolist)
def listDebuginfo(self):
"""Cycle through the list of DEBUGINFO RPMs and return their paths."""
return self._listPackages(self.debuginfolist)
def writeinfo(self, line): def writeinfo(self, line):
"""Append a line to the infofile in self.infofile""" """Append a line to the infofile in self.infofile"""