c88e50ee5e
Add source repo to kickstart file End %packages section with %end per new pykickstart api
209 lines
8.3 KiB
Python
Executable File
209 lines
8.3 KiB
Python
Executable File
#!/usr/bin/python -tt
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; version 2 of the License.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Library General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, write to the Free Software
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
import os
|
|
import pypungi.gather
|
|
import pypungi.pungi
|
|
import yum
|
|
import pykickstart.parser
|
|
import pykickstart.version
|
|
|
|
from ConfigParser import SafeConfigParser
|
|
|
|
def main():
|
|
|
|
# You must be this high to ride.
|
|
if os.geteuid () != 0:
|
|
print >> sys.stderr, "You must run pungi as root"
|
|
return 1
|
|
|
|
# Set some default variables, can be overrided in config file
|
|
|
|
# Turn this into a dict someday, to iterate over when setting defaults
|
|
osdir = "os"
|
|
sourcedir = "source"
|
|
debugdir = "debug"
|
|
isodir = "iso"
|
|
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.add_section('default')
|
|
|
|
# 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', 'relnotefilere', relnotefilere)
|
|
config.set('default', 'relnotedirre', relnotedirre)
|
|
config.set('default', 'relnotepkgs', relnotepkgs)
|
|
config.set('default', 'product_path', 'Packages')
|
|
config.set('default', 'cachedir', '/var/cache/pungi')
|
|
config.set('default', 'arch', yum.rpmUtils.arch.getBaseArch())
|
|
|
|
# set configs from cli options
|
|
config.set('default', 'name', opts.name)
|
|
config.set('default', 'version', opts.ver)
|
|
config.set('default', 'flavor', opts.flavor)
|
|
config.set('default', 'destdir', opts.destdir)
|
|
config.set('default', 'cachedir', opts.cachedir)
|
|
config.set('default', 'bugurl', opts.bugurl)
|
|
config.set('default', 'discs', opts.discs)
|
|
if opts.sourceisos:
|
|
config.set('default', 'arch', 'source')
|
|
|
|
# set some other defaults
|
|
config.set('default', 'iso_basename', config.get('default', 'name'))
|
|
|
|
config.set('default', 'cdsize', cdsize)
|
|
for part in ksparser.handler.partition.partitions:
|
|
if part.mountpoint == 'iso':
|
|
config.set('default', 'cdsize', part.size)
|
|
|
|
# Set up our directories
|
|
if not os.path.exists(config.get('default', 'destdir')):
|
|
try:
|
|
os.makedirs(config.get('default', 'destdir'))
|
|
except OSError, e:
|
|
print >> sys.stderr, "Error: Cannot create destination dir %s" % config.get('default', 'destdir')
|
|
sys.exit(1)
|
|
|
|
cachedir = config.get('default', 'cachedir')
|
|
|
|
if not os.path.exists(cachedir):
|
|
try:
|
|
os.makedirs(cachedir)
|
|
except OSError, e:
|
|
print >> sys.stderr, "Error: Cannot create cache dir %s" % cachedir
|
|
sys.exit(1)
|
|
|
|
# Actually do work.
|
|
if not opts.sourceisos:
|
|
if opts.do_all or opts.do_gather:
|
|
mygather = pypungi.gather.Gather(config, ksparser)
|
|
mygather.getPackageObjects()
|
|
mygather.downloadPackages()
|
|
mygather.makeCompsFile()
|
|
if not opts.nosource:
|
|
mygather.getSRPMList()
|
|
mygather.downloadSRPMs()
|
|
|
|
del mygather
|
|
|
|
mypungi = pypungi.pungi.Pungi(config)
|
|
|
|
if opts.do_all or opts.do_createrepo:
|
|
mypungi.doCreaterepo()
|
|
|
|
if opts.do_all or opts.do_buildinstall:
|
|
mypungi.doBuildinstall()
|
|
mypungi.doGetRelnotes()
|
|
|
|
if opts.do_all or opts.do_packageorder:
|
|
mypungi.doPackageorder()
|
|
|
|
if opts.do_all or opts.do_splittree:
|
|
mypungi.doSplittree()
|
|
|
|
if opts.do_all or opts.do_createiso:
|
|
mypungi.doCreateSplitrepo()
|
|
mypungi.doCreateIsos()
|
|
|
|
# Do things slightly different for src.
|
|
if opts.sourceisos:
|
|
# 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'),
|
|
config.get('default', 'flavor'),
|
|
'source', 'SRPM')
|
|
if opts.do_all or opts.do_splittree:
|
|
mypungi.doSplitSRPMs()
|
|
|
|
if opts.do_all or opts.do_createiso:
|
|
mypungi.doCreateIsos()
|
|
|
|
print "All done!"
|
|
|
|
if __name__ == '__main__':
|
|
from optparse import OptionParser
|
|
import sys
|
|
import time
|
|
|
|
today = time.strftime('%Y%m%d', time.localtime())
|
|
|
|
def get_arguments():
|
|
parser = OptionParser(version="%prog 1.0.2")
|
|
|
|
# Pulled in from config file to be cli options as part of pykickstart conversion
|
|
parser.add_option("--name", default="Fedora", dest="name",
|
|
help='the name for your distribution (defaults to "Fedora")')
|
|
parser.add_option("--ver", default=today, dest="ver",
|
|
help='the version of your distribution (defaults to datestamp)')
|
|
parser.add_option("--flavor", default="", dest="flavor",
|
|
help='the flavor of your distribution spin (optional)')
|
|
parser.add_option("--destdir", default=".", dest="destdir",
|
|
help='destination directory (defaults to current directory)')
|
|
parser.add_option("--cachedir", default="/var/cache/pungi", dest="cachedir",
|
|
help='package cache directory (defaults to /var/cache/pungi)')
|
|
parser.add_option("--bugurl", default="http://bugzilla.redhat.com", dest="bugurl",
|
|
help='the url for your bug system (defaults to http://bugzilla.redhat.com)')
|
|
parser.add_option("--discs", default='1', dest="discs",
|
|
help='the number of discs you want to create (defaults to 1)')
|
|
parser.add_option("--nosource", action="store_true", dest="nosource",
|
|
help='disable gathering of source packages (optional)')
|
|
parser.add_option("--sourceisos", default=False, action="store_true", dest="sourceisos",
|
|
help='Create the source isos (other arch runs must be done)')
|
|
|
|
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",
|
|
help="Flag to enable processing the Gather stage")
|
|
parser.add_option("-C", action="store_true", default=False, dest="do_createrepo",
|
|
help="Flag to enable processing the Createrepo stage")
|
|
parser.add_option("-B", action="store_true", default=False, dest="do_buildinstall",
|
|
help="Flag to enable processing the BuildInstall stage")
|
|
parser.add_option("-P", action="store_true", default=False, dest="do_packageorder",
|
|
help="Flag to enable processing the Package Order stage")
|
|
parser.add_option("-S", action="store_true", default=False, dest="do_splittree",
|
|
help="Flag to enable processing the SplitTree stage")
|
|
parser.add_option("-I", action="store_true", default=False, dest="do_createiso",
|
|
help="Flag to enable processing the CreateISO stage")
|
|
|
|
|
|
(opts, args) = parser.parse_args()
|
|
|
|
#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)
|
|
|
|
main()
|