2006-10-24 01:46:30 +00:00
|
|
|
#!/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
|
2006-10-24 13:44:11 +00:00
|
|
|
# the Free Software Foundation; version 2 of the License.
|
2006-10-24 01:46:30 +00:00
|
|
|
#
|
|
|
|
# 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
|
2008-06-12 15:24:54 +00:00
|
|
|
import pypungi
|
2007-09-12 18:36:28 +00:00
|
|
|
import pypungi.config
|
2013-01-15 13:05:04 +00:00
|
|
|
import pypungi.ks
|
2007-12-03 16:40:41 +00:00
|
|
|
import subprocess
|
2006-10-24 01:46:30 +00:00
|
|
|
|
|
|
|
def main():
|
2007-08-26 23:48:49 +00:00
|
|
|
|
2007-12-03 03:24:11 +00:00
|
|
|
config = pypungi.config.Config()
|
|
|
|
|
|
|
|
(opts, args) = get_arguments(config)
|
|
|
|
|
2007-11-30 20:41:58 +00:00
|
|
|
# You must be this high to ride if you're going to do root tasks
|
|
|
|
if os.geteuid () != 0 and (opts.do_all or opts.do_buildinstall):
|
2007-08-27 18:21:14 +00:00
|
|
|
print >> sys.stderr, "You must run pungi as root"
|
2007-08-26 23:48:49 +00:00
|
|
|
return 1
|
2007-12-03 16:40:41 +00:00
|
|
|
|
|
|
|
if opts.do_all or opts.do_buildinstall:
|
|
|
|
try:
|
2007-12-04 14:31:40 +00:00
|
|
|
selinux = subprocess.Popen('/usr/sbin/getenforce',
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=open('/dev/null', 'w')).communicate()[0].strip('\n')
|
2007-12-03 16:40:41 +00:00
|
|
|
if selinux == 'Enforcing':
|
|
|
|
print >> sys.stdout, "WARNING: SELinux is enforcing. This may lead to a compose with selinux disabled."
|
|
|
|
print >> sys.stdout, "Consider running with setenforce 0."
|
|
|
|
except:
|
|
|
|
pass
|
2007-08-26 23:48:49 +00:00
|
|
|
|
2007-08-25 12:56:16 +00:00
|
|
|
# Set up the kickstart parser and pass in the kickstart file we were handed
|
2013-01-15 13:05:04 +00:00
|
|
|
ksparser = pypungi.ks.get_ksparser(ks_path=opts.config)
|
2007-08-25 12:56:16 +00:00
|
|
|
|
2007-08-30 20:56:08 +00:00
|
|
|
if opts.sourceisos:
|
2008-12-04 23:44:34 +00:00
|
|
|
config.set('pungi', 'arch', 'source')
|
2006-12-12 04:23:05 +00:00
|
|
|
|
2007-08-25 12:56:16 +00:00
|
|
|
for part in ksparser.handler.partition.partitions:
|
|
|
|
if part.mountpoint == 'iso':
|
2008-12-04 23:44:34 +00:00
|
|
|
config.set('pungi', 'cdsize', str(part.size))
|
2007-12-02 19:31:26 +00:00
|
|
|
|
2008-12-04 23:44:34 +00:00
|
|
|
config.set('pungi', 'force', str(opts.force))
|
2007-08-25 12:56:16 +00:00
|
|
|
|
|
|
|
# Set up our directories
|
2008-12-04 23:44:34 +00:00
|
|
|
if not os.path.exists(config.get('pungi', 'destdir')):
|
2006-10-24 01:46:30 +00:00
|
|
|
try:
|
2008-12-04 23:44:34 +00:00
|
|
|
os.makedirs(config.get('pungi', 'destdir'))
|
2006-10-24 01:46:30 +00:00
|
|
|
except OSError, e:
|
2008-12-04 23:44:34 +00:00
|
|
|
print >> sys.stderr, "Error: Cannot create destination dir %s" % config.get('pungi', 'destdir')
|
2006-10-24 01:46:30 +00:00
|
|
|
sys.exit(1)
|
2007-12-02 19:31:26 +00:00
|
|
|
else:
|
|
|
|
print >> sys.stdout, "Warning: Reusing existing destination directory."
|
2006-10-24 01:46:30 +00:00
|
|
|
|
2008-12-04 23:44:34 +00:00
|
|
|
cachedir = config.get('pungi', 'cachedir')
|
2006-11-17 23:01:10 +00:00
|
|
|
|
|
|
|
if not os.path.exists(cachedir):
|
2006-10-24 01:46:30 +00:00
|
|
|
try:
|
2006-11-17 23:01:10 +00:00
|
|
|
os.makedirs(cachedir)
|
2006-10-24 01:46:30 +00:00
|
|
|
except OSError, e:
|
2006-11-17 23:01:10 +00:00
|
|
|
print >> sys.stderr, "Error: Cannot create cache dir %s" % cachedir
|
2006-10-24 01:46:30 +00:00
|
|
|
sys.exit(1)
|
|
|
|
|
2008-07-08 21:53:25 +00:00
|
|
|
# Set debuginfo flag
|
|
|
|
if opts.nodebuginfo:
|
2008-12-04 23:44:34 +00:00
|
|
|
config.set('pungi', 'debuginfo', "False")
|
2013-06-20 10:18:13 +00:00
|
|
|
if opts.greedy:
|
|
|
|
config.set('pungi', 'greedy', opts.greedy)
|
|
|
|
else:
|
|
|
|
# XXX: compatibility
|
|
|
|
if opts.nogreedy:
|
|
|
|
config.set('pungi', 'greedy', "none")
|
|
|
|
else:
|
|
|
|
config.set('pungi', 'greedy', "all")
|
2013-01-21 08:53:32 +00:00
|
|
|
config.set('pungi', 'resolve_deps', str(bool(opts.resolve_deps)))
|
2011-05-16 22:59:23 +00:00
|
|
|
if opts.isfinal:
|
|
|
|
config.set('pungi', 'isfinal', "True")
|
2012-02-09 15:12:55 +00:00
|
|
|
if opts.nohash:
|
|
|
|
config.set('pungi', 'nohash', "True")
|
2011-11-01 15:21:58 +00:00
|
|
|
if opts.full_archlist:
|
|
|
|
config.set('pungi', 'full_archlist', "True")
|
2011-11-01 18:08:15 +00:00
|
|
|
if opts.arch:
|
|
|
|
config.set('pungi', 'arch', opts.arch)
|
2012-11-26 07:32:01 +00:00
|
|
|
if opts.multilib:
|
|
|
|
config.set('pungi', 'multilib', " ".join(opts.multilib))
|
2012-10-25 12:47:19 +00:00
|
|
|
if opts.lookaside_repos:
|
|
|
|
config.set('pungi', 'lookaside_repos', " ".join(opts.lookaside_repos))
|
2012-12-18 12:38:26 +00:00
|
|
|
config.set("pungi", "fulltree", str(bool(opts.fulltree)))
|
|
|
|
config.set("pungi", "selfhosting", str(bool(opts.selfhosting)))
|
|
|
|
config.set("pungi", "nosource", str(bool(opts.nosource)))
|
|
|
|
config.set("pungi", "nodebuginfo", str(bool(opts.nodebuginfo)))
|
2008-07-08 21:53:25 +00:00
|
|
|
|
2006-12-10 01:48:08 +00:00
|
|
|
# Actually do work.
|
2008-06-12 13:06:19 +00:00
|
|
|
mypungi = pypungi.Pungi(config, ksparser)
|
|
|
|
|
2014-04-01 19:56:29 +00:00
|
|
|
with mypungi.yumlock:
|
|
|
|
if not opts.sourceisos:
|
|
|
|
if opts.do_all or opts.do_gather or opts.do_buildinstall:
|
|
|
|
mypungi._inityum() # initialize the yum object for things that need it
|
|
|
|
if opts.do_all or opts.do_gather:
|
|
|
|
mypungi.gather()
|
2011-08-18 10:29:10 +00:00
|
|
|
if opts.nodownload:
|
2014-04-01 19:56:29 +00:00
|
|
|
for line in mypungi.list_packages():
|
2013-06-21 11:53:10 +00:00
|
|
|
flags_str = ",".join(line["flags"])
|
|
|
|
if flags_str:
|
|
|
|
flags_str = "(%s)" % flags_str
|
2014-04-01 19:56:29 +00:00
|
|
|
sys.stdout.write("RPM%s: %s\n" % (flags_str, line["path"]))
|
2011-08-18 10:29:10 +00:00
|
|
|
sys.stdout.flush()
|
|
|
|
else:
|
2014-04-01 19:56:29 +00:00
|
|
|
mypungi.downloadPackages()
|
|
|
|
mypungi.makeCompsFile()
|
|
|
|
if not opts.nodebuginfo:
|
|
|
|
mypungi.getDebuginfoList()
|
|
|
|
if opts.nodownload:
|
|
|
|
for line in mypungi.list_debuginfo():
|
|
|
|
flags_str = ",".join(line["flags"])
|
|
|
|
if flags_str:
|
|
|
|
flags_str = "(%s)" % flags_str
|
|
|
|
sys.stdout.write("DEBUGINFO%s: %s\n" % (flags_str, line["path"]))
|
|
|
|
sys.stdout.flush()
|
|
|
|
else:
|
|
|
|
mypungi.downloadDebuginfo()
|
|
|
|
if not opts.nosource:
|
|
|
|
if opts.nodownload:
|
|
|
|
for line in mypungi.list_srpms():
|
|
|
|
flags_str = ",".join(line["flags"])
|
|
|
|
if flags_str:
|
|
|
|
flags_str = "(%s)" % flags_str
|
|
|
|
sys.stdout.write("SRPM%s: %s\n" % (flags_str, line["path"]))
|
|
|
|
sys.stdout.flush()
|
|
|
|
else:
|
|
|
|
mypungi.downloadSRPMs()
|
|
|
|
|
|
|
|
print "RPM size: %s MiB" % (mypungi.size_packages() / 1024 ** 2)
|
|
|
|
if not opts.nodebuginfo:
|
|
|
|
print "DEBUGINFO size: %s MiB" % (mypungi.size_debuginfo() / 1024 ** 2)
|
|
|
|
if not opts.nosource:
|
|
|
|
print "SRPM size: %s MiB" % (mypungi.size_srpms() / 1024 ** 2)
|
|
|
|
|
|
|
|
# Furthermore (but without the yumlock...)
|
|
|
|
if not opts.sourceisos:
|
2007-07-28 14:59:14 +00:00
|
|
|
if opts.do_all or opts.do_createrepo:
|
2011-11-01 07:51:28 +00:00
|
|
|
mypungi.doCreaterepo()
|
2007-07-28 14:59:14 +00:00
|
|
|
|
2007-02-12 22:07:37 +00:00
|
|
|
if opts.do_all or opts.do_buildinstall:
|
2011-10-31 11:10:22 +00:00
|
|
|
if not opts.norelnotes:
|
|
|
|
mypungi.doGetRelnotes()
|
2011-11-01 07:51:28 +00:00
|
|
|
mypungi.doBuildinstall()
|
2007-02-12 22:07:37 +00:00
|
|
|
|
|
|
|
if opts.do_all or opts.do_createiso:
|
2011-11-01 07:51:28 +00:00
|
|
|
mypungi.doCreateIsos()
|
2006-12-10 01:48:08 +00:00
|
|
|
|
|
|
|
# Do things slightly different for src.
|
2007-08-30 20:56:08 +00:00
|
|
|
if opts.sourceisos:
|
2006-12-10 01:48:08 +00:00
|
|
|
# we already have all the content gathered
|
2008-12-04 23:44:34 +00:00
|
|
|
mypungi.topdir = os.path.join(config.get('pungi', 'destdir'),
|
|
|
|
config.get('pungi', 'version'),
|
|
|
|
config.get('pungi', 'flavor'),
|
2008-04-17 02:22:14 +00:00
|
|
|
'source', 'SRPMS')
|
|
|
|
mypungi.doCreaterepo(comps=False)
|
2007-02-12 22:51:36 +00:00
|
|
|
if opts.do_all or opts.do_createiso:
|
2011-02-22 00:28:39 +00:00
|
|
|
mypungi.doCreateIsos()
|
2006-10-24 01:46:30 +00:00
|
|
|
|
2007-08-15 23:19:13 +00:00
|
|
|
print "All done!"
|
|
|
|
|
2006-10-24 01:46:30 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
from optparse import OptionParser
|
|
|
|
import sys
|
2007-08-24 13:13:53 +00:00
|
|
|
import time
|
|
|
|
|
|
|
|
today = time.strftime('%Y%m%d', time.localtime())
|
2006-10-24 01:46:30 +00:00
|
|
|
|
2007-09-12 18:36:28 +00:00
|
|
|
def get_arguments(config):
|
2014-04-29 21:29:34 +00:00
|
|
|
parser = OptionParser("%prog [--help] [options]", version="%prog 3.04")
|
2007-08-24 13:13:53 +00:00
|
|
|
|
2007-09-12 18:36:28 +00:00
|
|
|
def set_config(option, opt_str, value, parser, config):
|
2008-12-04 23:44:34 +00:00
|
|
|
config.set('pungi', option.dest, value)
|
2008-10-03 18:35:50 +00:00
|
|
|
# When setting name, also set the iso_basename.
|
|
|
|
if option.dest == 'name':
|
2008-12-04 23:44:34 +00:00
|
|
|
config.set('pungi', 'iso_basename', value)
|
2007-09-12 18:36:28 +00:00
|
|
|
|
2007-08-24 13:13:53 +00:00
|
|
|
# Pulled in from config file to be cli options as part of pykickstart conversion
|
2007-09-12 18:36:28 +00:00
|
|
|
parser.add_option("--name", dest="name", type="string",
|
|
|
|
action="callback", callback=set_config, callback_args=(config, ),
|
2007-08-24 13:13:53 +00:00
|
|
|
help='the name for your distribution (defaults to "Fedora")')
|
2007-09-12 18:36:28 +00:00
|
|
|
parser.add_option("--ver", dest="version", type="string",
|
|
|
|
action="callback", callback=set_config, callback_args=(config, ),
|
2007-08-24 13:13:53 +00:00
|
|
|
help='the version of your distribution (defaults to datestamp)')
|
2007-09-12 18:36:28 +00:00
|
|
|
parser.add_option("--flavor", dest="flavor", type="string",
|
|
|
|
action="callback", callback=set_config, callback_args=(config, ),
|
2007-08-24 13:13:53 +00:00
|
|
|
help='the flavor of your distribution spin (optional)')
|
2007-09-12 18:36:28 +00:00
|
|
|
parser.add_option("--destdir", dest="destdir", type="string",
|
|
|
|
action="callback", callback=set_config, callback_args=(config, ),
|
2007-02-12 22:51:36 +00:00
|
|
|
help='destination directory (defaults to current directory)')
|
2007-09-12 18:36:28 +00:00
|
|
|
parser.add_option("--cachedir", dest="cachedir", type="string",
|
|
|
|
action="callback", callback=set_config, callback_args=(config, ),
|
2007-08-26 23:44:38 +00:00
|
|
|
help='package cache directory (defaults to /var/cache/pungi)')
|
2007-09-12 18:36:28 +00:00
|
|
|
parser.add_option("--bugurl", dest="bugurl", type="string",
|
|
|
|
action="callback", callback=set_config, callback_args=(config, ),
|
2007-08-24 13:13:53 +00:00
|
|
|
help='the url for your bug system (defaults to http://bugzilla.redhat.com)')
|
2009-04-03 19:53:55 +00:00
|
|
|
parser.add_option("--selfhosting", action="store_true", dest="selfhosting",
|
|
|
|
help='build a self-hosting tree by following build dependencies (optional)')
|
2009-04-03 19:53:59 +00:00
|
|
|
parser.add_option("--fulltree", action="store_true", dest="fulltree",
|
|
|
|
help='build a tree that includes all packages built from corresponding source rpms (optional)')
|
2007-08-24 13:13:53 +00:00
|
|
|
parser.add_option("--nosource", action="store_true", dest="nosource",
|
2007-08-27 20:59:31 +00:00
|
|
|
help='disable gathering of source packages (optional)')
|
2008-07-08 21:53:25 +00:00
|
|
|
parser.add_option("--nodebuginfo", action="store_true", dest="nodebuginfo",
|
|
|
|
help='disable gathering of debuginfo packages (optional)')
|
2011-08-18 10:29:10 +00:00
|
|
|
parser.add_option("--nodownload", action="store_true", dest="nodownload",
|
|
|
|
help='disable downloading of packages. instead, print the package URLs (optional)')
|
2011-10-31 11:10:22 +00:00
|
|
|
parser.add_option("--norelnotes", action="store_true", dest="norelnotes",
|
2013-06-20 10:18:13 +00:00
|
|
|
help='disable gathering of release notes (optional); DEPRECATED')
|
2011-02-10 20:30:02 +00:00
|
|
|
parser.add_option("--nogreedy", action="store_true", dest="nogreedy",
|
|
|
|
help='disable pulling of all providers of package dependencies (optional)')
|
2013-01-21 08:53:32 +00:00
|
|
|
parser.add_option("--nodeps", action="store_false", dest="resolve_deps", default=True,
|
|
|
|
help='disable resolving dependencies')
|
2007-08-26 18:08:27 +00:00
|
|
|
parser.add_option("--sourceisos", default=False, action="store_true", dest="sourceisos",
|
|
|
|
help='Create the source isos (other arch runs must be done)')
|
2007-12-02 19:31:26 +00:00
|
|
|
parser.add_option("--force", default=False, action="store_true",
|
|
|
|
help='Force reuse of an existing destination directory (will overwrite files)')
|
2011-05-16 22:59:23 +00:00
|
|
|
parser.add_option("--isfinal", default=False, action="store_true",
|
|
|
|
help='Specify this is a GA tree, which causes betanag to be turned off during install')
|
2012-02-09 15:12:55 +00:00
|
|
|
parser.add_option("--nohash", default=False, action="store_true",
|
|
|
|
help='disable hashing the Packages trees')
|
2011-11-01 15:21:58 +00:00
|
|
|
parser.add_option("--full-archlist", action="store_true",
|
|
|
|
help='Use the full arch list for x86_64 (include i686, i386, etc.)')
|
2011-11-01 18:08:15 +00:00
|
|
|
parser.add_option("--arch",
|
|
|
|
help='Override default (uname based) arch')
|
2013-06-20 10:18:13 +00:00
|
|
|
parser.add_option("--greedy", metavar="METHOD",
|
|
|
|
help='Greedy method; none, all, build')
|
2012-11-26 07:32:01 +00:00
|
|
|
parser.add_option("--multilib", action="append", metavar="METHOD",
|
|
|
|
help='Multilib method; can be specified multiple times; recommended: devel, runtime')
|
2012-10-25 12:47:19 +00:00
|
|
|
parser.add_option("--lookaside-repo", action="append", dest="lookaside_repos", metavar="NAME",
|
|
|
|
help='Specify lookaside repo name(s) (packages will used for depsolving but not be included in the output)')
|
2007-08-24 13:13:53 +00:00
|
|
|
|
2007-08-25 12:56:16 +00:00
|
|
|
parser.add_option("-c", "--config", dest="config",
|
|
|
|
help='Path to kickstart config file')
|
2007-02-12 22:51:36 +00:00
|
|
|
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")
|
2007-07-28 14:59:14 +00:00
|
|
|
parser.add_option("-C", action="store_true", default=False, dest="do_createrepo",
|
|
|
|
help="Flag to enable processing the Createrepo stage")
|
2007-02-16 18:38:27 +00:00
|
|
|
parser.add_option("-B", action="store_true", default=False, dest="do_buildinstall",
|
|
|
|
help="Flag to enable processing the BuildInstall stage")
|
2007-02-12 22:51:36 +00:00
|
|
|
parser.add_option("-I", action="store_true", default=False, dest="do_createiso",
|
|
|
|
help="Flag to enable processing the CreateISO stage")
|
2006-10-24 01:46:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
(opts, args) = parser.parse_args()
|
2011-11-01 18:12:24 +00:00
|
|
|
|
2007-11-20 22:29:18 +00:00
|
|
|
if not opts.config:
|
2011-11-01 18:12:24 +00:00
|
|
|
parser.error("Please specify a config file")
|
|
|
|
|
2008-12-04 23:44:34 +00:00
|
|
|
if not config.get('pungi', 'flavor').isalnum() and not config.get('pungi', 'flavor') == '':
|
2011-11-01 18:12:24 +00:00
|
|
|
parser.error("Flavor must be alphanumeric")
|
2006-10-24 01:46:30 +00:00
|
|
|
|
2007-11-28 22:10:02 +00:00
|
|
|
if opts.do_gather or opts.do_createrepo or opts.do_buildinstall or opts.do_createiso:
|
2007-08-25 12:56:16 +00:00
|
|
|
opts.do_all = False
|
2011-11-01 18:08:15 +00:00
|
|
|
|
|
|
|
if opts.arch and (opts.do_all or opts.do_buildinstall):
|
2011-11-01 18:12:24 +00:00
|
|
|
parser.error("Cannot override arch while the BuildInstall stage is enabled")
|
2011-11-01 18:08:15 +00:00
|
|
|
|
2007-08-25 12:56:16 +00:00
|
|
|
return (opts, args)
|
2006-10-24 01:46:30 +00:00
|
|
|
|
|
|
|
main()
|