Enable the ability to pull down and make isos of srpms.
This commit is contained in:
parent
78dd15b5e2
commit
f376824c84
32
pungi
32
pungi
@ -71,17 +71,31 @@ def main():
|
|||||||
print >> sys.stderr, "Error: Cannot create cache dir %s" % cachedir
|
print >> sys.stderr, "Error: Cannot create cache dir %s" % cachedir
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
mygather = pypungi.gather.Gather(config, pkglist)
|
# Actually do work.
|
||||||
mygather.getPackageObjects()
|
if not config.get('default', 'arch') == 'source':
|
||||||
mygather.downloadPackages()
|
mygather = pypungi.gather.Gather(config, pkglist)
|
||||||
|
mygather.getPackageObjects()
|
||||||
|
mygather.downloadPackages()
|
||||||
|
if config.getboolean('default', 'getsource'):
|
||||||
|
mygather.getSRPMList()
|
||||||
|
mygather.downloadSRPMs()
|
||||||
|
|
||||||
mypungi = pypungi.pungi.Pungi(config)
|
mypungi = pypungi.pungi.Pungi(config)
|
||||||
mypungi.doBuildinstall()
|
mypungi.doBuildinstall()
|
||||||
mypungi.doPackageorder()
|
mypungi.doPackageorder()
|
||||||
mypungi.doSplittree()
|
mypungi.doSplittree()
|
||||||
mypungi.doCreateSplitrepo()
|
mypungi.doCreateSplitrepo()
|
||||||
mypungi.doCreateIsos()
|
mypungi.doCreateIsos()
|
||||||
|
|
||||||
|
# Do things slightly different for src.
|
||||||
|
if config.get('default', 'arch') == 'source':
|
||||||
|
# we already have all the content gathered
|
||||||
|
mypungi = pypungi.pungi.Pungi(config)
|
||||||
|
mypungi.topdir = os.path.join(config.get('default', 'destdir'),
|
||||||
|
config.get('default', 'version'),
|
||||||
|
'source', 'SRPM')
|
||||||
|
mypungi.doSplitSRPMs()
|
||||||
|
mypungi.doCreateIsos()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
import yum
|
import yum
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
import sys
|
||||||
|
|
||||||
class Gather(yum.YumBase):
|
class Gather(yum.YumBase):
|
||||||
def __init__(self, config, pkglist):
|
def __init__(self, config, pkglist):
|
||||||
@ -33,6 +34,7 @@ class Gather(yum.YumBase):
|
|||||||
self.config = config
|
self.config = config
|
||||||
self.pkglist = pkglist
|
self.pkglist = pkglist
|
||||||
self.polist = []
|
self.polist = []
|
||||||
|
self.srpmlist = []
|
||||||
|
|
||||||
def getPackageDeps(self, po):
|
def getPackageDeps(self, po):
|
||||||
"""Return the dependencies for a given package, as well
|
"""Return the dependencies for a given package, as well
|
||||||
@ -97,6 +99,18 @@ class Gather(yum.YumBase):
|
|||||||
|
|
||||||
self.polist = final_pkgobjs.keys()
|
self.polist = final_pkgobjs.keys()
|
||||||
|
|
||||||
|
def getSRPMList(self):
|
||||||
|
"""Cycle through the list of package objects and
|
||||||
|
find the sourcerpm for them. Requires yum still
|
||||||
|
configured and a list of package objects"""
|
||||||
|
|
||||||
|
|
||||||
|
for po in self.polist:
|
||||||
|
srpm = po.returnSimple('sourcerpm').rsplit('-', 2)[0]
|
||||||
|
if not srpm in self.srpmlist:
|
||||||
|
self.srpmlist.append(srpm)
|
||||||
|
|
||||||
|
|
||||||
def downloadPackages(self):
|
def downloadPackages(self):
|
||||||
"""Cycle through the list of package objects and
|
"""Cycle through the list of package objects and
|
||||||
download them from their respective repos."""
|
download them from their respective repos."""
|
||||||
@ -144,6 +158,73 @@ class Gather(yum.YumBase):
|
|||||||
os.link(local, os.path.join(pkgdir, os.path.basename(remote)))
|
os.link(local, os.path.join(pkgdir, os.path.basename(remote)))
|
||||||
|
|
||||||
|
|
||||||
|
def downloadSRPMs(self):
|
||||||
|
"""Cycle through the list of srpms and
|
||||||
|
find the package objects for them, Then download them."""
|
||||||
|
|
||||||
|
|
||||||
|
srpmpolist = []
|
||||||
|
|
||||||
|
# Work around for yum bug
|
||||||
|
for sack in self.pkgSack.sacks.values():
|
||||||
|
sack.excludes = {}
|
||||||
|
|
||||||
|
self.pkgSack.excludes = {}
|
||||||
|
|
||||||
|
# We need to reset the yum object
|
||||||
|
self.pkgSack = None
|
||||||
|
|
||||||
|
# Setup the sack with just src arch
|
||||||
|
self.doSackSetup(archlist=['src'])
|
||||||
|
|
||||||
|
for srpm in self.srpmlist:
|
||||||
|
try:
|
||||||
|
matches = self.pkgSack.searchNevra(name=srpm)
|
||||||
|
mysack = yum.packageSack.ListPackageSack(matches)
|
||||||
|
srpmpo = mysack.returnNewestByNameArch()[0]
|
||||||
|
if not srpmpo in srpmpolist:
|
||||||
|
srpmpolist.append(srpmpo)
|
||||||
|
except IndexError:
|
||||||
|
print >> sys.stderr, "Error: Cannot find a source rpm for %s" % srpm
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
# do the downloads
|
||||||
|
pkgdir = os.path.join(self.config.get('default', 'destdir'), self.config.get('default', 'version'),
|
||||||
|
'source', 'SRPMS')
|
||||||
|
|
||||||
|
if not os.path.exists(pkgdir):
|
||||||
|
os.makedirs(pkgdir)
|
||||||
|
|
||||||
|
for pkg in srpmpolist:
|
||||||
|
repo = self.repos.getRepo(pkg.repoid)
|
||||||
|
remote = pkg.returnSimple('relativepath')
|
||||||
|
local = os.path.basename(remote)
|
||||||
|
local = os.path.join(self.config.get('default', 'cachedir'), local)
|
||||||
|
if os.path.exists(local) and str(os.path.getsize(local)) == pkg.returnSimple('packagesize'):
|
||||||
|
|
||||||
|
if not self.config.has_option('default', 'quiet'):
|
||||||
|
self.logger.info("%s already exists and appears to be complete" % local)
|
||||||
|
if os.path.exists(os.path.join(pkgdir, os.path.basename(remote))) and str(os.path.getsize(os.path.join(pkgdir, os.path.basename(remote)))) == pkg.returnSimple('packagesize'):
|
||||||
|
if not self.config.has_option('default', 'quiet'):
|
||||||
|
self.logger.info("%s already exists in tree and appears to be complete" % local)
|
||||||
|
else:
|
||||||
|
os.link(local, os.path.join(pkgdir, os.path.basename(remote)))
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Disable cache otherwise things won't download
|
||||||
|
repo.cache = 0
|
||||||
|
if not self.config.has_option('default', 'quiet'):
|
||||||
|
self.logger.info('Downloading %s' % os.path.basename(remote))
|
||||||
|
pkg.localpath = local # Hack: to set the localpath to what we want.
|
||||||
|
|
||||||
|
# do a little dance for file:// repos...
|
||||||
|
path = repo.getPackage(pkg)
|
||||||
|
if not os.path.exists(local) or not os.path.samefile(path, local):
|
||||||
|
shutil.copy2(path, local)
|
||||||
|
|
||||||
|
os.link(local, os.path.join(pkgdir, os.path.basename(remote)))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# This is used for testing the module
|
# This is used for testing the module
|
||||||
(opts, args) = get_arguments()
|
(opts, args) = get_arguments()
|
||||||
|
@ -59,6 +59,34 @@ class Pungi:
|
|||||||
for line in output:
|
for line in output:
|
||||||
print line
|
print line
|
||||||
|
|
||||||
|
def doSplitSRPMs(self):
|
||||||
|
timber = splittree.Timber()
|
||||||
|
timber.arch = self.config.get('default', 'arch')
|
||||||
|
#timber.total_discs = self.config.getint('default', 'discs')
|
||||||
|
#timber.bin_discs = self.config.getint('default', 'discs')
|
||||||
|
timber.src_discs = self.config.getint('default', 'discs')
|
||||||
|
#timber.release_str = '%s %s' % (self.config.get('default', 'product_name'), self.config.get('default', 'version'))
|
||||||
|
#timber.package_order_file = os.path.join(self.config.get('default', 'destdir'), 'pkgorder-%s' % self.config.get('default', 'arch'))
|
||||||
|
timber.dist_dir = os.path.join(self.config.get('default', 'destdir'),
|
||||||
|
self.config.get('default', 'version'),
|
||||||
|
'source', 'SRPM')
|
||||||
|
timber.src_dir = os.path.join(self.config.get('default', 'destdir'), self.config.get('default', 'version'), 'source', 'SRPMS')
|
||||||
|
#timber.product_path = self.config.get('default', 'product_path')
|
||||||
|
#timber.reserve_size =
|
||||||
|
# Set this ourselves, for creating our dirs ourselves
|
||||||
|
timber.src_list = range(1, timber.src_discs + 1)
|
||||||
|
|
||||||
|
# this is stolen from splittree.py in anaconda-runtime. Blame them if its ugly (:
|
||||||
|
for i in range(timber.src_list[0], timber.src_list[-1] + 1):
|
||||||
|
os.makedirs("%s-disc%d/SRPMS" % (timber.dist_dir, i))
|
||||||
|
timber.linkFiles(timber.dist_dir,
|
||||||
|
"%s-disc%d" %(timber.dist_dir, i),
|
||||||
|
timber.common_files)
|
||||||
|
|
||||||
|
timber.splitSRPMS()
|
||||||
|
for line in timber.logfile:
|
||||||
|
print line
|
||||||
|
|
||||||
def doCreateSplitrepo(self):
|
def doCreateSplitrepo(self):
|
||||||
discinfo = open('%s-disc1/.discinfo' % self.topdir, 'r').readlines()
|
discinfo = open('%s-disc1/.discinfo' % self.topdir, 'r').readlines()
|
||||||
mediaid = discinfo[0].rstrip('\n')
|
mediaid = discinfo[0].rstrip('\n')
|
||||||
@ -98,9 +126,12 @@ class Pungi:
|
|||||||
isoname,
|
isoname,
|
||||||
os.path.join('%s-disc%s' % (self.topdir, disc))))
|
os.path.join('%s-disc%s' % (self.topdir, disc))))
|
||||||
os.system('cd %s; sha1sum %s >> SHA1SUM' % (isodir, isoname))
|
os.system('cd %s; sha1sum %s >> SHA1SUM' % (isodir, isoname))
|
||||||
os.system('/usr/lib/anaconda-runtime/implantisomd5 %s' % os.path.join(isodir, isoname))
|
# implant md5 for mediacheck on all but source arches
|
||||||
|
if not self.config.get('default', 'arch') == 'source':
|
||||||
|
os.system('/usr/lib/anaconda-runtime/implantisomd5 %s' % os.path.join(isodir, isoname))
|
||||||
|
|
||||||
if self.config.getint('default', 'discs') > 1: # We've asked for more than one disc, make a DVD image
|
# We've asked for more than one disc, and we're not srpms, so make a DVD image
|
||||||
|
if self.config.getint('default', 'discs') > 1 and not self.config.get('default', 'arch') == 'source':
|
||||||
# backup the main .discinfo to use a split one. This is an ugly hack :/
|
# backup the main .discinfo to use a split one. This is an ugly hack :/
|
||||||
content = open(discinfofile, 'r').readlines()
|
content = open(discinfofile, 'r').readlines()
|
||||||
shutil.move(discinfofile, os.path.join(self.config.get('default', 'destdir'),
|
shutil.move(discinfofile, os.path.join(self.config.get('default', 'destdir'),
|
||||||
@ -120,10 +151,12 @@ class Pungi:
|
|||||||
self.config.get('default', 'arch'))
|
self.config.get('default', 'arch'))
|
||||||
if self.config.get('default', 'arch') == 'i386' or self.config.get('default', 'arch') == 'x86_64':
|
if self.config.get('default', 'arch') == 'i386' or self.config.get('default', 'arch') == 'x86_64':
|
||||||
bootargs = x86bootargs
|
bootargs = x86bootargs
|
||||||
if self.config.get('default', 'arch') == 'ia64':
|
elif self.config.get('default', 'arch') == 'ia64':
|
||||||
bootargs = ia64bootargs
|
bootargs = ia64bootargs
|
||||||
elif self.config.get('default', 'arch') == 'ppc':
|
elif self.config.get('default', 'arch') == 'ppc':
|
||||||
bootargs = ppcbootargs
|
bootargs = ppcbootargs
|
||||||
|
else:
|
||||||
|
bootargs = '' # clear out any existing bootargs
|
||||||
|
|
||||||
os.system('mkisofs %s %s %s -o %s/%s %s' % (mkisofsargs,
|
os.system('mkisofs %s %s %s -o %s/%s %s' % (mkisofsargs,
|
||||||
volname,
|
volname,
|
||||||
|
Loading…
Reference in New Issue
Block a user