- Use a kickstart file as input now (for cdsize and package manifest)
- Turn pkglist into a pre-parsed package dictionary - Arrange config setting logically - Error out on usage if no config file passed
This commit is contained in:
parent
cfdfdbbabe
commit
cc68ffa5d8
@ -1,3 +1,9 @@
|
||||
* Sat Aug 25 2007 Jesse Keating <jkeating@redhat.com>
|
||||
- Use a kickstart file as input now (for cdsize and package manifest)
|
||||
- Turn pkglist into a pre-parsed package dictionary
|
||||
- Arrange config setting logically
|
||||
- Error out on usage if no config file passed
|
||||
|
||||
* Fri Aug 24 2007 Jesse Keating <jkeating@redhat.com>
|
||||
- Remove a lot of configurable items and hard set them
|
||||
- Move some items to cli flags only (part of moving to pykickstart)
|
||||
|
68
pungi
68
pungi
@ -16,6 +16,8 @@ import os
|
||||
import pypungi.gather
|
||||
import pypungi.pungi
|
||||
import yum
|
||||
import pykickstart.parser
|
||||
import pykickstart.version
|
||||
|
||||
from ConfigParser import SafeConfigParser
|
||||
|
||||
@ -27,35 +29,30 @@ def main():
|
||||
sourcedir = "source"
|
||||
debugdir = "debug"
|
||||
isodir = "iso"
|
||||
cdsize = "685.0"
|
||||
cdsize = "4608.0"
|
||||
relnotefilere = "eula.txt fedora.css GPL README-BURNING-ISOS-en_US.txt RELEASE-NOTES-en_US.html ^RPM-GPG"
|
||||
relnotedirre = "images stylesheet-images"
|
||||
relnotepkgs = "fedora-release fedora-release-notes"
|
||||
|
||||
(opts, args) = get_arguments()
|
||||
|
||||
# Set up the kickstart parser and pass in the kickstart file we were handed
|
||||
ksparser = pykickstart.parser.KickstartParser(pykickstart.version.makeVersion())
|
||||
ksparser.readKickstart(opts.config)
|
||||
|
||||
config = SafeConfigParser()
|
||||
config.read(opts.config)
|
||||
|
||||
if "default" not in config.sections():
|
||||
print ("Check that the file %s exists and that it has a 'default' section" % opts.config)
|
||||
sys.exit(1)
|
||||
# add some sections here before setting stuff.
|
||||
|
||||
# hard coded non-options
|
||||
config.set('default', 'osdir', osdir)
|
||||
|
||||
config.set('default', 'sourcedir', sourcedir)
|
||||
|
||||
config.set('default', 'debugdir', debugdir)
|
||||
|
||||
config.set('default', 'isodir', isodir)
|
||||
|
||||
config.set('default', 'cdsize', cdsize)
|
||||
|
||||
config.set('default', 'relnotefilere', relnotefilere)
|
||||
|
||||
config.set('default', 'relnotedirre', relnotedirre)
|
||||
|
||||
config.set('default', 'relnotepkgs', relnotepkgs)
|
||||
config.set('default', 'product_path', 'Packages')
|
||||
|
||||
# set configs from cli options
|
||||
config.set('default', 'name', opts.name)
|
||||
@ -66,12 +63,24 @@ def main():
|
||||
config.set('default', 'discs', opts.discs)
|
||||
|
||||
# set some other defaults
|
||||
config.set('default', 'product_path', 'Packages')
|
||||
|
||||
config.set('default', 'iso_basename', config.get('default', 'name'))
|
||||
|
||||
pkglist = get_packagelist(config.get('default', 'manifest'))
|
||||
config.set('default', 'cdsize', cdsize)
|
||||
for part in ksparser.handler.partition.partitions:
|
||||
if part.mountpoint == 'iso':
|
||||
config.set('default', 'cdsize', part.size)
|
||||
|
||||
# Build up a package dict.
|
||||
pkgdict = {'groups': [], 'packages': [], 'excludes': [])
|
||||
for group in ksparser.handler.packages.groupList:
|
||||
if group.include == 1:
|
||||
pkgdict['groups'].append(group.name)
|
||||
|
||||
pkgdict['packages'].extend(ksparser.handler.packages.packageList)
|
||||
|
||||
pkgdict['excludes'].extend(ksparser.handler.packages.excludedList)
|
||||
|
||||
# Set up our directories
|
||||
if not os.path.exists(config.get('default', 'destdir')):
|
||||
try:
|
||||
os.makedirs(config.get('default', 'destdir'))
|
||||
@ -91,7 +100,7 @@ def main():
|
||||
# Actually do work.
|
||||
if not config.get('default', 'arch') == 'source':
|
||||
if opts.do_all or opts.do_gather:
|
||||
mygather = pypungi.gather.Gather(config, pkglist)
|
||||
mygather = pypungi.gather.Gather(config, pkgdict)
|
||||
mygather.getPackageObjects()
|
||||
mygather.downloadPackages()
|
||||
mygather.makeCompsFile()
|
||||
@ -162,8 +171,8 @@ if __name__ == '__main__':
|
||||
parser.add_option("--nosource", action="store_true", dest="nosource",
|
||||
help='the flavor of your distribution spin (optional)')
|
||||
|
||||
parser.add_option("-c", "--conf", default='/etc/pungi/pungi.conf', dest="config",
|
||||
help='Config file to use')
|
||||
parser.add_option("-c", "--config", dest="config",
|
||||
help='Path to kickstart config file')
|
||||
parser.add_option("--all-stages", action="store_true", default=True, dest="do_all",
|
||||
help="Enable ALL stages")
|
||||
parser.add_option("-G", action="store_true", default=False, dest="do_gather",
|
||||
@ -181,24 +190,13 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
(opts, args) = parser.parse_args()
|
||||
if opts.do_gather or opts.do_createrepo or opts.do_buildinstall or opts.do_packageorder or opts.do_splittree or opts.do_createiso:
|
||||
opts.do_all = False
|
||||
if len(sys.argv) < 2:
|
||||
|
||||
if not '-c' in sys.argv or not '--config' in sys.argv:
|
||||
parser.print_help()
|
||||
sys.exit(0)
|
||||
|
||||
if opts.do_gather or opts.do_createrepo or opts.do_buildinstall or opts.do_packageorder or opts.do_splittree or opts.do_createiso:
|
||||
opts.do_all = False
|
||||
return (opts, args)
|
||||
|
||||
def get_packagelist(manifest):
|
||||
# Get the list of packages from the manifest file
|
||||
try:
|
||||
manifestfile = open(manifest, 'r')
|
||||
|
||||
except IOError:
|
||||
print >> sys.stderr, "pungi: No such file:\'%s\'" % manifest
|
||||
sys.exit(1)
|
||||
|
||||
pkglist = manifestfile.readlines()
|
||||
manifestfile.close()
|
||||
return pkglist
|
||||
|
||||
main()
|
||||
|
@ -47,7 +47,7 @@ class PungiYum(yum.YumBase):
|
||||
pass
|
||||
|
||||
class Gather(pypungi.PungiBase):
|
||||
def __init__(self, config, pkglist):
|
||||
def __init__(self, config, pkgdict):
|
||||
pypungi.PungiBase.__init__(self, config)
|
||||
|
||||
# Set our own logging name space
|
||||
@ -60,7 +60,7 @@ class Gather(pypungi.PungiBase):
|
||||
console.setLevel(logging.INFO)
|
||||
self.logger.addHandler(console)
|
||||
|
||||
self.pkglist = pkglist
|
||||
self.pkgdict = pkgdict
|
||||
self.config.cachedir = os.path.join(self.workdir, 'yumcache')
|
||||
self.polist = []
|
||||
self.srpmlist = []
|
||||
@ -209,38 +209,16 @@ class Gather(pypungi.PungiBase):
|
||||
searchlist = [] # The list of package names/globs to search for
|
||||
matchdict = {} # A dict of objects to names
|
||||
|
||||
grouplist = []
|
||||
excludelist = []
|
||||
addlist = []
|
||||
|
||||
# Cycle through the package list and pull out the groups
|
||||
for line in self.pkglist:
|
||||
line = line.strip()
|
||||
if line.startswith('#'):
|
||||
self.logger.debug('Skipping comment: %s' % line)
|
||||
continue
|
||||
if line.startswith('@'):
|
||||
self.logger.info('Adding group: %s' % line)
|
||||
grouplist.append(line.strip('@'))
|
||||
continue
|
||||
if line.startswith('-'):
|
||||
self.logger.info('Adding exclude: %s' % line)
|
||||
excludelist.append(line.strip('-'))
|
||||
continue
|
||||
else:
|
||||
self.logger.info('Adding package: %s' % line)
|
||||
addlist.append(line)
|
||||
|
||||
# First remove the excludes
|
||||
self.ayum.conf.exclude.extend(excludelist)
|
||||
self.ayum.conf.exclude.extend(self.pkgdict['excludes'])
|
||||
self.ayum.excludePackages()
|
||||
|
||||
# Get a list of packages from groups
|
||||
for group in grouplist:
|
||||
for group in self.pkgdict['groups']:
|
||||
searchlist.extend(self.getPackagesFromGroup(group))
|
||||
|
||||
# Add the adds
|
||||
searchlist.extend(addlist)
|
||||
searchlist.extend(self.pkgdict['packages'])
|
||||
|
||||
# Make the search list unique
|
||||
searchlist = yum.misc.unique(searchlist)
|
||||
|
Loading…
Reference in New Issue
Block a user