Add some default config options

Make use of them in various files
This commit is contained in:
jkeating@dhcp83-49.boston.redhat.com 2006-11-20 09:52:27 -05:00 committed by Jesse Keating
parent a426fcc6e5
commit f188205cf9
3 changed files with 45 additions and 13 deletions

26
pungi
View File

@ -20,11 +20,37 @@ import yum
from ConfigParser import SafeConfigParser from ConfigParser import SafeConfigParser
def main(): def main():
# Set some default variables, can be overrided in config file
osdir = "os"
sourcedir = "source"
debugdir = "debug"
isodir = "iso"
(opts, args) = get_arguments() (opts, args) = get_arguments()
config = SafeConfigParser() config = SafeConfigParser()
config.read(opts.config) config.read(opts.config)
if not config.has_option('default', 'osdir'):
config.set('default', 'osdir', osdir)
if not config.has_option('default', 'sourcedir'):
config.set('default', 'sourcedir', sourcedir)
if not config.has_option('default', 'debugdir'):
config.set('default', 'debugdir', debugdir)
if not config.has_option('default', 'isodir'):
config.set('default', 'isodir', isodir)
# set some other defaults
if not config.has_option('default', 'product_path'):
config.set('default', 'product_path', config.get('default', 'product_name'))
if not config.has_option('default', 'iso_basename'):
config.set('default', 'iso_basename', config.get('default', 'product_name'))
pkglist = get_packagelist(config.get('default', 'comps')) pkglist = get_packagelist(config.get('default', 'comps'))
destdir = config.get('default', 'destdir') destdir = config.get('default', 'destdir')

View File

@ -109,7 +109,8 @@ class Gather(yum.YumBase):
# Package location within destdir, name subject to change/config # Package location within destdir, name subject to change/config
pkgdir = os.path.join(self.config.get('default', 'destdir'), self.config.get('default', 'version'), pkgdir = os.path.join(self.config.get('default', 'destdir'), self.config.get('default', 'version'),
self.config.get('default', 'arch'), 'os', 'Fedora') self.config.get('default', 'arch'), self.config.get('default', 'osdir'),
self.config.get('default', 'product_path'))
if not os.path.exists(pkgdir): if not os.path.exists(pkgdir):
os.makedirs(pkgdir) os.makedirs(pkgdir)

View File

@ -29,15 +29,18 @@ class Pungi:
def doBuildinstall(self): def doBuildinstall(self):
# buildinstall looks for a comps file in base/ for now, copy it into place # buildinstall looks for a comps file in base/ for now, copy it into place
os.makedirs(os.path.join(self.topdir, self.prodpath, 'base')) os.makedirs(os.path.join(self.topdir, self.config.get('default', 'product_path'), 'base'))
shutil.copy(self.config.get('default', 'comps'), os.path.join(self.topdir, self.prodpath, 'base', 'comps.xml')) shutil.copy(self.config.get('default', 'comps'), os.path.join(self.topdir,
args = '--product "Fedora" --version %s --release "%s" --prodpath %s %s' % (self.config.get('default', 'version'), self.config.get('default', 'product_path'), 'base', 'comps.xml'))
'Fedora %s' % self.config.get('default', 'version'), self.prodpath, self.topdir) args = '--product "%s" --version %s --release "%s" --prodpath %s %s' % (self.config.get('default', 'product_name'),
self.config.get('default', 'version'), '%s %s' % (self.config.get('default', 'product_name'),
self.config.get('default', 'version')), self.config.get('default', 'product_path'), self.topdir)
os.system('/usr/lib/anaconda-runtime/buildinstall %s' % args) os.system('/usr/lib/anaconda-runtime/buildinstall %s' % args)
def doPackageorder(self): def doPackageorder(self):
os.system('/usr/lib/anaconda-runtime/pkgorder %s %s %s > %s' % (self.topdir, self.config.get('default', 'arch'), os.system('/usr/lib/anaconda-runtime/pkgorder %s %s %s > %s' % (self.topdir, self.config.get('default', 'arch'),
self.prodpath, os.path.join(self.config.get('default', 'destdir'), 'pkgorder-%s' % self.config.get('default', 'arch')))) self.config.get('default', 'product_path'), os.path.join(self.config.get('default', 'destdir'),
'pkgorder-%s' % self.config.get('default', 'arch'))))
def doSplittree(self): def doSplittree(self):
timber = splittree.Timber() timber = splittree.Timber()
@ -45,11 +48,11 @@ class Pungi:
timber.total_discs = self.config.getint('default', 'discs') timber.total_discs = self.config.getint('default', 'discs')
timber.bin_discs = self.config.getint('default', 'discs') timber.bin_discs = self.config.getint('default', 'discs')
timber.src_discs = 0 timber.src_discs = 0
timber.release_str = 'Fedora %s' % self.config.get('default', 'version') 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.package_order_file = os.path.join(self.config.get('default', 'destdir'), 'pkgorder-%s' % self.config.get('default', 'arch'))
timber.dist_dir = self.topdir timber.dist_dir = self.topdir
timber.src_dir = os.path.join(self.config.get('default', 'destdir'), self.config.get('default', 'version'), 'source', 'SRPMS') timber.src_dir = os.path.join(self.config.get('default', 'destdir'), self.config.get('default', 'version'), 'source', 'SRPMS')
timber.product_path = self.prodpath timber.product_path = self.config.get('default', 'product_path')
#timber.reserve_size = #timber.reserve_size =
output = timber.main() output = timber.main()
@ -68,12 +71,12 @@ class Pungi:
mkisofsargs = '-v -U -J -R -T -V' # common mkisofs flags mkisofsargs = '-v -U -J -R -T -V' # common mkisofs flags
bootargs = '' bootargs = ''
isodir = os.path.join(self.config.get('default', 'destdir'), self.config.get('default', 'version'), isodir = os.path.join(self.config.get('default', 'destdir'), self.config.get('default', 'version'),
self.config.get('default', 'arch'), 'iso') self.config.get('default', 'arch'), self.config.get('default', 'isodir'))
os.makedirs(isodir) os.makedirs(isodir)
for disc in range(1, self.config.getint('default', 'discs') + 1): # cycle through the CD isos for disc in range(1, self.config.getint('default', 'discs') + 1): # cycle through the CD isos
volname = '"%s %s %s Disc %s"' % ('Fedora', self.config.get('default', 'version'), volname = '"%s %s %s Disc %s"' % (self.config.get('default', 'product_name'), self.config.get('default', 'version'),
self.config.get('default', 'arch'), disc) # hacky :/ self.config.get('default', 'arch'), disc) # hacky :/
isoname = 'Fedora-%s-%s-disc%s.iso' % (self.config.get('default', 'version'), isoname = '%s-%s-%s-disc%s.iso' % (self.config.get('default', 'iso_basename'), self.config.get('default', 'version'),
self.config.get('default', 'arch'), disc) self.config.get('default', 'arch'), disc)
if disc == 1: # if this is the first disc, we want to set boot flags if disc == 1: # if this is the first disc, we want to set boot flags
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':
@ -106,8 +109,10 @@ class Pungi:
'repodata-%s' % self.config.get('default', 'arch'))) 'repodata-%s' % self.config.get('default', 'arch')))
os.symlink('%s-disc1/repodata' % self.topdir, os.path.join(self.topdir, 'repodata')) os.symlink('%s-disc1/repodata' % self.topdir, os.path.join(self.topdir, 'repodata'))
volname = '"%s %s %s DVD"' % ('Fedora', self.config.get('default', 'version'), self.config.get('default', 'arch')) volname = '"%s %s %s DVD"' % (self.config.get('default', 'product_name'), self.config.get('default', 'version'),
isoname = 'Fedora-%s-%s-DVD.iso' % (self.config.get('default', 'version'), self.config.get('default', 'arch')) self.config.get('default', 'arch'))
isoname = '%s-%s-%s-DVD.iso' % (self.config.get('default', 'iso_basename'), self.config.get('default', 'version'),
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 = '-b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table' bootargs = '-b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table'
elif self.config.get('default', 'arch') == 'ppc': elif self.config.get('default', 'arch') == 'ppc':