2006-10-17 06:08:10 +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-17 06:08:10 +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.
|
|
|
|
|
2007-03-07 19:42:33 +00:00
|
|
|
import subprocess
|
2007-02-14 22:33:07 +00:00
|
|
|
import logging
|
2006-10-17 06:08:10 +00:00
|
|
|
import os
|
2006-11-06 21:15:25 +00:00
|
|
|
import sys
|
2007-01-08 19:46:45 +00:00
|
|
|
sys.path.append('/usr/lib/anaconda-runtime')
|
2006-11-06 21:15:25 +00:00
|
|
|
import splittree
|
2006-10-24 02:16:07 +00:00
|
|
|
import shutil
|
2006-12-12 04:23:05 +00:00
|
|
|
import re
|
2007-08-15 23:19:13 +00:00
|
|
|
import pypungi
|
2006-10-17 06:08:10 +00:00
|
|
|
|
2007-08-15 23:19:13 +00:00
|
|
|
class Pungi(pypungi.PungiBase):
|
2006-11-17 23:01:10 +00:00
|
|
|
def __init__(self, config):
|
2007-08-15 23:19:13 +00:00
|
|
|
pypungi.PungiBase.__init__(self, config)
|
|
|
|
|
|
|
|
self.logger = logging.getLogger('Pungi.Pungi')
|
|
|
|
|
2006-10-17 06:08:10 +00:00
|
|
|
self.prodpath = 'Fedora' # Probably should be defined elsewhere
|
2007-02-13 18:23:00 +00:00
|
|
|
self.destdir = self.config.get('default', 'destdir')
|
|
|
|
self.archdir = os.path.join(self.destdir,
|
2007-01-17 15:54:09 +00:00
|
|
|
self.config.get('default', 'version'),
|
2007-01-25 04:42:40 +00:00
|
|
|
self.config.get('default', 'flavor'),
|
2007-01-17 15:54:09 +00:00
|
|
|
self.config.get('default', 'arch'))
|
|
|
|
|
|
|
|
self.topdir = os.path.join(self.archdir, 'os')
|
2007-02-03 21:19:41 +00:00
|
|
|
self.isodir = os.path.join(self.archdir, self.config.get('default','isodir'))
|
|
|
|
|
2007-08-15 23:19:13 +00:00
|
|
|
self.workdir = os.path.join(self.config.get('default', 'destdir'),
|
2006-12-12 04:23:05 +00:00
|
|
|
'work',
|
2007-01-25 04:42:40 +00:00
|
|
|
self.config.get('default', 'flavor'),
|
2006-12-12 04:23:05 +00:00
|
|
|
self.config.get('default', 'arch'))
|
2007-01-25 04:42:40 +00:00
|
|
|
|
|
|
|
if not os.path.exists(self.workdir):
|
|
|
|
os.makedirs(self.workdir)
|
|
|
|
|
2006-12-12 04:23:05 +00:00
|
|
|
self.common_files = []
|
2007-02-13 22:20:01 +00:00
|
|
|
self.infofile = os.path.join(self.config.get('default', 'destdir'),
|
2007-02-09 21:13:52 +00:00
|
|
|
'.composeinfo')
|
2006-12-12 04:23:05 +00:00
|
|
|
|
2007-02-13 22:20:01 +00:00
|
|
|
def writeinfo(self, line):
|
|
|
|
"""Append a line to the infofile in self.infofile"""
|
2007-02-15 19:17:39 +00:00
|
|
|
|
|
|
|
|
2007-02-13 22:20:01 +00:00
|
|
|
f=open(self.infofile, "a+")
|
|
|
|
f.write(line.strip() + "\n")
|
2007-02-09 21:13:52 +00:00
|
|
|
f.close()
|
|
|
|
|
2007-02-13 22:20:01 +00:00
|
|
|
def mkrelative(self, subfile):
|
|
|
|
"""Return the relative path for 'subfile' underneath 'self.destdir'."""
|
2007-02-15 19:17:39 +00:00
|
|
|
|
|
|
|
|
2007-02-13 18:23:00 +00:00
|
|
|
if subfile.startswith(self.destdir):
|
2007-02-13 22:20:01 +00:00
|
|
|
return subfile.replace(self.destdir + os.path.sep, '')
|
2006-10-17 06:08:10 +00:00
|
|
|
|
2007-03-08 15:58:13 +00:00
|
|
|
def _doRunCommand(self, command, rundir='/tmp', output=subprocess.PIPE, error=subprocess.PIPE):
|
|
|
|
"""Run a command and log the output. Error out if we get something on stderr"""
|
|
|
|
|
|
|
|
|
2007-08-15 23:19:13 +00:00
|
|
|
self.logger.info("Running %s" % ' '.join(command))
|
2007-03-08 15:58:13 +00:00
|
|
|
|
2007-06-11 18:59:18 +00:00
|
|
|
p1 = subprocess.Popen(command, cwd=rundir, stdout=output, stderr=error, universal_newlines=True)
|
2007-03-14 02:16:39 +00:00
|
|
|
(out, err) = p1.communicate()
|
2007-07-20 20:59:09 +00:00
|
|
|
|
2007-08-15 23:19:13 +00:00
|
|
|
self.logger.debug(out)
|
2007-07-20 20:59:09 +00:00
|
|
|
|
2007-03-14 02:16:39 +00:00
|
|
|
if p1.returncode != 0:
|
2007-08-15 23:19:13 +00:00
|
|
|
self.logger.error("Got an error from %s" % command[0])
|
|
|
|
self.logger.error(err)
|
2007-07-28 15:02:20 +00:00
|
|
|
raise OSError, "Got an error from %s: %s" % (command[0], err)
|
2007-03-08 15:58:13 +00:00
|
|
|
|
2007-07-28 14:59:14 +00:00
|
|
|
def doCreaterepo(self):
|
|
|
|
"""Run createrepo to generate repodata in the tree."""
|
2007-02-15 19:17:39 +00:00
|
|
|
|
|
|
|
|
2007-07-28 14:59:14 +00:00
|
|
|
# setup the createrepo call
|
2007-03-07 22:53:53 +00:00
|
|
|
createrepo = ['/usr/bin/createrepo']
|
|
|
|
createrepo.append('--database')
|
|
|
|
|
|
|
|
createrepo.append('--groupfile')
|
|
|
|
createrepo.append(self.config.get('default', 'comps'))
|
|
|
|
|
|
|
|
createrepo.append(self.topdir)
|
|
|
|
|
|
|
|
# run the command
|
2007-03-08 15:58:13 +00:00
|
|
|
self._doRunCommand(createrepo, rundir=self.topdir)
|
2007-03-07 19:42:33 +00:00
|
|
|
|
2007-07-28 14:59:14 +00:00
|
|
|
def doBuildinstall(self):
|
|
|
|
"""Run anaconda-runtime's buildinstall on the tree."""
|
|
|
|
|
|
|
|
|
2007-03-07 19:42:33 +00:00
|
|
|
# setup the buildinstall call
|
|
|
|
buildinstall = ['/usr/lib/anaconda-runtime/buildinstall']
|
|
|
|
#buildinstall.append('TMPDIR=%s' % self.workdir) # TMPDIR broken in buildinstall
|
|
|
|
|
|
|
|
buildinstall.append('--product')
|
|
|
|
buildinstall.append(self.config.get('default', 'product_name'))
|
|
|
|
|
2007-03-22 18:01:26 +00:00
|
|
|
if not self.config.get('default', 'flavor') == "":
|
|
|
|
buildinstall.append('--variant')
|
|
|
|
buildinstall.append(self.config.get('default', 'flavor'))
|
|
|
|
|
2007-03-07 19:42:33 +00:00
|
|
|
buildinstall.append('--version')
|
|
|
|
buildinstall.append(self.config.get('default', 'version'))
|
|
|
|
|
|
|
|
buildinstall.append('--release')
|
2007-07-20 18:40:32 +00:00
|
|
|
buildinstall.append('%s %s' % (self.config.get('default', 'product_name'), self.config.get('default', 'version')))
|
2007-03-07 19:42:33 +00:00
|
|
|
|
|
|
|
buildinstall.append('--prodpath')
|
|
|
|
buildinstall.append(self.config.get('default', 'product_path'))
|
|
|
|
|
2007-02-03 20:53:47 +00:00
|
|
|
if self.config.has_option('default', 'bugurl'):
|
2007-03-07 19:42:33 +00:00
|
|
|
buildinstall.append('--bugurl')
|
|
|
|
buildinstall.append(self.config.get('default', 'bugurl'))
|
|
|
|
|
|
|
|
buildinstall.append(self.topdir)
|
|
|
|
|
|
|
|
# run the command
|
2007-03-08 15:58:13 +00:00
|
|
|
self._doRunCommand(buildinstall)
|
2007-03-07 19:42:33 +00:00
|
|
|
|
|
|
|
# write out the tree data for snake
|
2007-02-13 18:23:00 +00:00
|
|
|
self.writeinfo('tree: %s' % self.mkrelative(self.topdir))
|
2006-10-17 06:08:10 +00:00
|
|
|
|
|
|
|
def doPackageorder(self):
|
2007-02-15 19:17:39 +00:00
|
|
|
"""Run anaconda-runtime's pkgorder on the tree, used for splitting media."""
|
|
|
|
|
|
|
|
|
2007-03-14 21:57:09 +00:00
|
|
|
# non-op for only one disc
|
|
|
|
if self.config.getint('default', 'discs') == 1:
|
|
|
|
return
|
|
|
|
|
2007-03-07 19:42:33 +00:00
|
|
|
pkgorderfile = open(os.path.join(self.workdir, 'pkgorder-%s' % self.config.get('default', 'arch')), 'w')
|
|
|
|
# setup the command
|
|
|
|
pkgorder = ['/usr/lib/anaconda-runtime/pkgorder']
|
|
|
|
#pkgorder.append('TMPDIR=%s' % self.workdir)
|
|
|
|
pkgorder.append(self.topdir)
|
|
|
|
pkgorder.append(self.config.get('default', 'arch'))
|
|
|
|
pkgorder.append(self.config.get('default', 'product_path'))
|
|
|
|
|
|
|
|
# run the command
|
2007-03-08 15:58:13 +00:00
|
|
|
self._doRunCommand(pkgorder, output=pkgorderfile)
|
2007-03-07 19:42:33 +00:00
|
|
|
pkgorderfile.close()
|
2006-10-17 06:08:10 +00:00
|
|
|
|
2006-12-12 04:23:05 +00:00
|
|
|
def doGetRelnotes(self):
|
2007-02-15 19:17:39 +00:00
|
|
|
"""Get extra files from packages in the tree to put in the topdir of
|
|
|
|
the tree."""
|
|
|
|
|
|
|
|
|
2006-12-12 04:23:05 +00:00
|
|
|
docsdir = os.path.join(self.workdir, 'docs')
|
|
|
|
relnoterpms = self.config.get('default', 'relnotepkgs').split()
|
|
|
|
|
|
|
|
fileres = []
|
|
|
|
for pattern in self.config.get('default', 'relnotefilere').split():
|
|
|
|
fileres.append(re.compile(pattern))
|
|
|
|
|
|
|
|
dirres = []
|
|
|
|
for pattern in self.config.get('default', 'relnotedirre').split():
|
|
|
|
dirres.append(re.compile(pattern))
|
|
|
|
|
|
|
|
os.makedirs(docsdir)
|
|
|
|
|
|
|
|
# Expload the packages we list as relnote packages
|
|
|
|
pkgs = os.listdir(os.path.join(self.topdir, self.config.get('default', 'product_path')))
|
|
|
|
|
2007-03-07 19:42:33 +00:00
|
|
|
rpm2cpio = ['/usr/bin/rpm2cpio']
|
|
|
|
cpio = ['cpio', '-imud']
|
|
|
|
|
2006-12-12 04:23:05 +00:00
|
|
|
for pkg in pkgs:
|
|
|
|
pkgname = pkg.rsplit('-', 2)[0]
|
|
|
|
for relnoterpm in relnoterpms:
|
|
|
|
if pkgname == relnoterpm:
|
2007-03-07 19:42:33 +00:00
|
|
|
extraargs = [os.path.join(self.topdir, self.config.get('default', 'product_path'), pkg)]
|
2007-03-14 00:36:48 +00:00
|
|
|
try:
|
|
|
|
p1 = subprocess.Popen(rpm2cpio + extraargs, cwd=docsdir, stdout=subprocess.PIPE)
|
|
|
|
(out, err) = subprocess.Popen(cpio, cwd=docsdir, stdin=p1.stdout, stdout=subprocess.PIPE,
|
2007-06-11 18:59:18 +00:00
|
|
|
stderr=subprocess.PIPE, universal_newlines=True).communicate()
|
2007-03-14 00:36:48 +00:00
|
|
|
except:
|
2007-08-15 23:19:13 +00:00
|
|
|
self.logger.error("Got an error from rpm2cpio")
|
|
|
|
self.logger.error(err)
|
2007-03-14 00:36:48 +00:00
|
|
|
raise
|
|
|
|
|
2007-08-15 23:19:13 +00:00
|
|
|
self.logger.debug(out)
|
2007-03-14 00:36:48 +00:00
|
|
|
|
2006-12-12 04:23:05 +00:00
|
|
|
# Walk the tree for our files
|
|
|
|
for dirpath, dirname, filelist in os.walk(docsdir):
|
|
|
|
for filename in filelist:
|
|
|
|
for regex in fileres:
|
|
|
|
if regex.match(filename) and not os.path.exists(os.path.join(self.topdir, filename)):
|
2007-08-15 23:19:13 +00:00
|
|
|
self.logger.info("Copying release note file %s" % filename)
|
2006-12-12 04:23:05 +00:00
|
|
|
shutil.copy(os.path.join(dirpath, filename), os.path.join(self.topdir, filename))
|
|
|
|
self.common_files.append(filename)
|
|
|
|
|
|
|
|
# Walk the tree for our dirs
|
|
|
|
for dirpath, dirname, filelist in os.walk(docsdir):
|
2007-03-07 19:42:33 +00:00
|
|
|
for directory in dirname:
|
2006-12-12 04:23:05 +00:00
|
|
|
for regex in dirres:
|
2007-03-07 19:42:33 +00:00
|
|
|
if regex.match(directory) and not os.path.exists(os.path.join(self.topdir, directory)):
|
2007-08-15 23:19:13 +00:00
|
|
|
self.logger.info("Copying release note dir %s" % directory)
|
2007-03-07 19:42:33 +00:00
|
|
|
shutil.copytree(os.path.join(dirpath, directory), os.path.join(self.topdir, directory))
|
2006-12-12 04:23:05 +00:00
|
|
|
|
|
|
|
|
2006-10-31 15:27:36 +00:00
|
|
|
def doSplittree(self):
|
2007-02-15 19:17:39 +00:00
|
|
|
"""Use anaconda-runtime's splittree to split the tree into appropriate
|
|
|
|
sized chunks."""
|
|
|
|
|
|
|
|
|
2007-03-14 21:57:09 +00:00
|
|
|
# non-op for only one disc
|
|
|
|
if self.config.getint('default', 'discs') == 1:
|
|
|
|
return
|
|
|
|
|
2006-11-06 21:15:25 +00:00
|
|
|
timber = splittree.Timber()
|
2006-11-17 23:01:10 +00:00
|
|
|
timber.arch = self.config.get('default', 'arch')
|
2007-05-25 18:28:38 +00:00
|
|
|
timber.target_size = self.config.getfloat('default', 'cdsize') * 1024 * 1024
|
2006-11-17 23:01:10 +00:00
|
|
|
timber.total_discs = self.config.getint('default', 'discs')
|
|
|
|
timber.bin_discs = self.config.getint('default', 'discs')
|
2006-11-06 21:15:25 +00:00
|
|
|
timber.src_discs = 0
|
2006-11-20 14:52:27 +00:00
|
|
|
timber.release_str = '%s %s' % (self.config.get('default', 'product_name'), self.config.get('default', 'version'))
|
2007-01-25 04:42:40 +00:00
|
|
|
timber.package_order_file = os.path.join(self.workdir, 'pkgorder-%s' % self.config.get('default', 'arch'))
|
2006-11-06 21:15:25 +00:00
|
|
|
timber.dist_dir = self.topdir
|
2006-11-17 23:01:10 +00:00
|
|
|
timber.src_dir = os.path.join(self.config.get('default', 'destdir'), self.config.get('default', 'version'), 'source', 'SRPMS')
|
2006-11-20 14:52:27 +00:00
|
|
|
timber.product_path = self.config.get('default', 'product_path')
|
2006-12-12 04:23:05 +00:00
|
|
|
timber.common_files = self.common_files
|
2006-11-06 21:15:25 +00:00
|
|
|
#timber.reserve_size =
|
|
|
|
|
2007-08-15 23:19:13 +00:00
|
|
|
self.logger.info("Running splittree.")
|
|
|
|
|
2006-11-06 21:15:25 +00:00
|
|
|
output = timber.main()
|
2007-08-15 23:19:13 +00:00
|
|
|
self.logger.debug("Output from splittree: %s" % '\n'.join(output))
|
2006-10-17 06:08:10 +00:00
|
|
|
|
2006-12-10 01:48:08 +00:00
|
|
|
def doSplitSRPMs(self):
|
2007-02-15 19:17:39 +00:00
|
|
|
"""Use anaconda-runtime's splittree to split the srpms into appropriate
|
|
|
|
sized chunks."""
|
|
|
|
|
2007-03-26 14:39:46 +00:00
|
|
|
# non-op for only one disc
|
|
|
|
if self.config.getint('default', 'discs') == 1:
|
|
|
|
return
|
|
|
|
|
2006-12-10 01:48:08 +00:00
|
|
|
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'))
|
2007-01-25 04:42:40 +00:00
|
|
|
timber.dist_dir = os.path.join(self.config.get('default', 'destdir'),
|
|
|
|
self.config.get('default', 'version'),
|
|
|
|
self.config.get('default', 'flavor'),
|
2006-12-10 01:48:08 +00:00
|
|
|
'source', 'SRPM')
|
2007-01-25 04:42:40 +00:00
|
|
|
timber.src_dir = os.path.join(self.config.get('default', 'destdir'),
|
|
|
|
self.config.get('default', 'version'),
|
|
|
|
self.config.get('default', 'flavor'),
|
|
|
|
'source', 'SRPMS')
|
2006-12-10 01:48:08 +00:00
|
|
|
#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)
|
|
|
|
|
2007-08-15 23:19:13 +00:00
|
|
|
self.logger.info("Splitting SRPMs")
|
2006-12-10 01:48:08 +00:00
|
|
|
timber.splitSRPMS()
|
2007-08-15 23:19:13 +00:00
|
|
|
self.logger.info("splitSRPMS complete")
|
2006-12-10 01:48:08 +00:00
|
|
|
|
2006-11-01 22:33:53 +00:00
|
|
|
def doCreateSplitrepo(self):
|
2007-02-15 19:17:39 +00:00
|
|
|
"""Create the split metadata for the isos"""
|
|
|
|
|
|
|
|
|
2007-03-14 21:57:09 +00:00
|
|
|
if self.config.getint('default', 'discs') > 1:
|
|
|
|
discinfo = open('%s-disc1/.discinfo' % self.topdir, 'r').readlines()
|
|
|
|
else:
|
|
|
|
discinfo = open(os.path.join(self.topdir, '.discinfo'), 'r').readlines()
|
2006-11-01 22:48:59 +00:00
|
|
|
mediaid = discinfo[0].rstrip('\n')
|
2007-03-07 19:42:33 +00:00
|
|
|
|
|
|
|
# set up the process
|
|
|
|
createrepo = ['/usr/bin/createrepo']
|
|
|
|
createrepo.append('--database')
|
|
|
|
|
|
|
|
createrepo.append('--groupfile')
|
2007-03-08 02:33:45 +00:00
|
|
|
createrepo.append(self.config.get('default', 'comps'))
|
2007-03-07 19:42:33 +00:00
|
|
|
|
|
|
|
createrepo.append('--baseurl')
|
|
|
|
createrepo.append('media://%s' % mediaid)
|
|
|
|
|
|
|
|
createrepo.append('--outputdir')
|
2007-03-14 21:57:09 +00:00
|
|
|
if self.config.getint('default', 'discs') == 1:
|
|
|
|
os.makedirs('%s-disc1' % self.topdir)
|
2007-03-07 19:42:33 +00:00
|
|
|
createrepo.append('%s-disc1' % self.topdir)
|
|
|
|
|
|
|
|
createrepo.append('--basedir')
|
2007-03-14 21:57:09 +00:00
|
|
|
if self.config.getint('default', 'discs') == 1:
|
|
|
|
createrepo.append(self.topdir)
|
|
|
|
createrepo.append(self.topdir)
|
|
|
|
else:
|
|
|
|
createrepo.append('%s-disc1' % self.topdir)
|
2007-03-07 19:42:33 +00:00
|
|
|
|
2007-03-14 21:57:09 +00:00
|
|
|
if self.config.getint('default', 'discs') > 1:
|
|
|
|
createrepo.append('--split')
|
2007-03-07 19:42:33 +00:00
|
|
|
|
2007-03-14 21:57:09 +00:00
|
|
|
for disc in range(1, self.config.getint('default', 'discs') + 1):
|
|
|
|
createrepo.append('%s-disc%s' % (self.topdir, disc))
|
2007-03-07 19:42:33 +00:00
|
|
|
|
|
|
|
# run the command
|
2007-03-08 15:58:13 +00:00
|
|
|
self._doRunCommand(createrepo)
|
2006-11-01 22:33:53 +00:00
|
|
|
|
2006-11-07 21:52:56 +00:00
|
|
|
def doCreateIsos(self):
|
2007-02-15 19:17:39 +00:00
|
|
|
"""Create isos from the various split directories."""
|
|
|
|
|
|
|
|
|
2007-03-07 19:42:33 +00:00
|
|
|
isolist=[]
|
2006-12-12 17:21:28 +00:00
|
|
|
anaruntime = '/usr/lib/anaconda-runtime/boot'
|
2006-11-08 23:34:20 +00:00
|
|
|
discinfofile = os.path.join(self.topdir, '.discinfo') # we use this a fair amount
|
2007-03-07 19:42:33 +00:00
|
|
|
|
2007-02-03 21:19:41 +00:00
|
|
|
os.makedirs(self.isodir)
|
2007-03-07 19:42:33 +00:00
|
|
|
|
|
|
|
# setup the base command
|
|
|
|
mkisofs = ['/usr/bin/mkisofs']
|
|
|
|
mkisofs.extend(['-v', '-U', '-J', '-R', '-T']) # common mkisofs flags
|
|
|
|
|
|
|
|
x86bootargs = ['-b', 'isolinux/isolinux.bin', '-c', 'isolinux/boot.cat',
|
|
|
|
'-no-emul-boot', '-boot-load-size', '4', '-boot-info-table']
|
|
|
|
|
|
|
|
ia64bootargs = ['-b', 'images/boot.img', '-no-emul-boot']
|
|
|
|
|
|
|
|
ppcbootargs = ['-part', '-hfs', '-r', '-l', '-sysid', 'PPC', '-no-desktop', '-allow-multidot', '-chrp-boot']
|
|
|
|
|
|
|
|
ppcbootargs.append('-map')
|
|
|
|
ppcbootargs.append(os.path.join(anaruntime, 'mapping'))
|
|
|
|
|
|
|
|
ppcbootargs.append('-magic')
|
|
|
|
ppcbootargs.append(os.path.join(anaruntime, 'magic'))
|
|
|
|
|
|
|
|
ppcbootargs.append('-hfs-bless') # must be last
|
|
|
|
|
2007-05-15 17:06:34 +00:00
|
|
|
sparcbootargs = ['-G', '/boot/isofs.b', '-B', '...', '-s', '/boot/silo.conf', '-sparc-label', '"sparc"']
|
|
|
|
|
2007-03-14 21:57:09 +00:00
|
|
|
if self.config.getint('default', 'discs') > 1:
|
|
|
|
for disc in range(1, self.config.getint('default', 'discs') + 1): # cycle through the CD isos
|
|
|
|
isoname = '%s-%s-%s-disc%s.iso' % (self.config.get('default', 'iso_basename'), self.config.get('default', 'version'),
|
|
|
|
self.config.get('default', 'arch'), disc)
|
|
|
|
isofile = os.path.join(self.isodir, isoname)
|
2007-03-07 19:42:33 +00:00
|
|
|
|
2007-03-14 21:57:09 +00:00
|
|
|
extraargs = []
|
2007-03-07 19:42:33 +00:00
|
|
|
|
2007-03-14 21:57:09 +00:00
|
|
|
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':
|
|
|
|
extraargs.extend(x86bootargs)
|
|
|
|
elif self.config.get('default', 'arch') == 'ia64':
|
|
|
|
extraargs.extend(ia64bootargs)
|
|
|
|
elif self.config.get('default', 'arch') == 'ppc':
|
|
|
|
extraargs.extend(ppcbootargs)
|
|
|
|
extraargs.append(os.path.join('%s-disc%s' % (self.topdir, disc), "ppc/mac"))
|
2007-05-15 17:06:34 +00:00
|
|
|
elif self.config.get('default', 'arch') == 'sparc':
|
|
|
|
extraargs.extend(sparcbootargs)
|
2007-03-07 19:42:33 +00:00
|
|
|
|
2007-03-14 21:57:09 +00:00
|
|
|
extraargs.append('-V')
|
2007-05-15 15:37:37 +00:00
|
|
|
extraargs.append('%s %s %s Disc %s' % (self.config.get('default', 'product_name'),
|
2007-03-14 21:57:09 +00:00
|
|
|
self.config.get('default', 'version'), self.config.get('default', 'arch'), disc))
|
2007-03-07 19:42:33 +00:00
|
|
|
|
2007-03-14 21:57:09 +00:00
|
|
|
extraargs.append('-o')
|
|
|
|
extraargs.append(isofile)
|
2007-03-07 19:42:33 +00:00
|
|
|
|
2007-03-14 21:57:09 +00:00
|
|
|
extraargs.append(os.path.join('%s-disc%s' % (self.topdir, disc)))
|
2007-03-07 19:42:33 +00:00
|
|
|
|
2007-03-14 21:57:09 +00:00
|
|
|
# run the command
|
|
|
|
self._doRunCommand(mkisofs + extraargs)
|
2006-11-08 04:11:44 +00:00
|
|
|
|
2007-03-14 21:57:09 +00:00
|
|
|
# implant md5 for mediacheck on all but source arches
|
|
|
|
if not self.config.get('default', 'arch') == 'source':
|
|
|
|
self._doRunCommand(['/usr/lib/anaconda-runtime/implantisomd5', isofile])
|
2007-03-07 19:42:33 +00:00
|
|
|
|
2007-03-14 21:57:09 +00:00
|
|
|
# shove the sha1sum into a file
|
|
|
|
sha1file = open(os.path.join(self.isodir, 'SHA1SUM'), 'a')
|
|
|
|
self._doRunCommand(['/usr/bin/sha1sum', isoname], rundir=self.isodir, output=sha1file)
|
|
|
|
sha1file.close()
|
2007-03-07 19:42:33 +00:00
|
|
|
|
2007-03-14 21:57:09 +00:00
|
|
|
# keep track of the CD images we've written
|
|
|
|
isolist.append(self.mkrelative(isofile))
|
2007-03-07 19:42:33 +00:00
|
|
|
|
2007-03-14 21:57:09 +00:00
|
|
|
# Write out a line describing the CD set
|
|
|
|
self.writeinfo('cdset: %s' % ' '.join(isolist))
|
2006-11-07 21:52:56 +00:00
|
|
|
|
2007-02-09 21:13:52 +00:00
|
|
|
isolist=[]
|
2007-03-26 14:39:46 +00:00
|
|
|
# We've asked for one or more discs, so make a DVD image
|
|
|
|
if self.config.getint('default', 'discs') >= 1:
|
2007-03-07 19:42:33 +00:00
|
|
|
isoname = '%s-%s-%s-DVD.iso' % (self.config.get('default', 'iso_basename'), self.config.get('default', 'version'),
|
|
|
|
self.config.get('default', 'arch'))
|
|
|
|
isofile = os.path.join(self.isodir, isoname)
|
|
|
|
|
2007-03-26 14:39:46 +00:00
|
|
|
if not self.config.get('default', 'arch') == 'source':
|
|
|
|
# backup the main .discinfo to use a split one. This is an ugly hack :/
|
|
|
|
content = open(discinfofile, 'r').readlines()
|
|
|
|
shutil.move(discinfofile, os.path.join(self.config.get('default', 'destdir'),
|
|
|
|
'.discinfo-%s' % self.config.get('default', 'arch')))
|
|
|
|
content[content.index('ALL\n')] = ','.join([str(x) for x in range(1, self.config.getint('default', 'discs') + 1)]) + '\n'
|
|
|
|
open(discinfofile, 'w').writelines(content)
|
2006-11-08 23:34:20 +00:00
|
|
|
|
2007-03-26 14:39:46 +00:00
|
|
|
# move the main repodata out of the way to use the split repodata
|
|
|
|
shutil.move(os.path.join(self.topdir, 'repodata'), os.path.join(self.config.get('default', 'destdir'),
|
|
|
|
'repodata-%s' % self.config.get('default', 'arch')))
|
|
|
|
shutil.copytree('%s-disc1/repodata' % self.topdir, os.path.join(self.topdir, 'repodata'))
|
2006-11-08 04:11:44 +00:00
|
|
|
|
2007-03-07 19:42:33 +00:00
|
|
|
# setup the extra mkisofs args
|
|
|
|
extraargs = []
|
|
|
|
|
2006-11-17 23:01:10 +00:00
|
|
|
if self.config.get('default', 'arch') == 'i386' or self.config.get('default', 'arch') == 'x86_64':
|
2007-03-07 19:42:33 +00:00
|
|
|
extraargs.extend(x86bootargs)
|
2006-12-10 01:48:08 +00:00
|
|
|
elif self.config.get('default', 'arch') == 'ia64':
|
2007-03-07 19:42:33 +00:00
|
|
|
extraargs.extend(ia64bootargs)
|
2006-11-17 23:01:10 +00:00
|
|
|
elif self.config.get('default', 'arch') == 'ppc':
|
2007-03-07 19:42:33 +00:00
|
|
|
extraargs.extend(ppcbootargs)
|
2007-03-14 21:57:09 +00:00
|
|
|
if self.config.getint('default', 'discs') == 1:
|
|
|
|
extraargs.append(os.path.join(self.topdir, "ppc/mac")) # this may work for both cases.. test
|
|
|
|
else:
|
|
|
|
extraargs.append(os.path.join('%s-disc%s' % (self.topdir, disc), "ppc/mac"))
|
2007-05-15 17:06:34 +00:00
|
|
|
elif self.config.get('default', 'arch') == 'sparc':
|
|
|
|
extraargs.extend(sparcbootargs)
|
2007-03-07 19:42:33 +00:00
|
|
|
|
|
|
|
extraargs.append('-V')
|
2007-05-15 15:37:37 +00:00
|
|
|
extraargs.append('%s %s %s DVD' % (self.config.get('default', 'product_name'),
|
2007-03-07 19:42:33 +00:00
|
|
|
self.config.get('default', 'version'), self.config.get('default', 'arch')))
|
|
|
|
|
|
|
|
extraargs.append('-o')
|
|
|
|
extraargs.append(isofile)
|
2006-11-08 04:11:44 +00:00
|
|
|
|
2007-03-26 14:39:46 +00:00
|
|
|
if not self.config.get('default', 'arch') == 'source':
|
|
|
|
extraargs.append(self.topdir)
|
|
|
|
else:
|
|
|
|
extraargs.append(os.path.join(self.archdir, 'SRPMS'))
|
2007-03-07 19:42:33 +00:00
|
|
|
|
|
|
|
# run the command
|
2007-03-08 15:58:13 +00:00
|
|
|
self._doRunCommand(mkisofs + extraargs)
|
2007-03-07 19:42:33 +00:00
|
|
|
|
|
|
|
# implant md5 for mediacheck on all but source arches
|
2007-03-26 14:39:46 +00:00
|
|
|
if not self.config.get('default', 'arch') == 'source':
|
|
|
|
self._doRunCommand(['/usr/lib/anaconda-runtime/implantisomd5', isofile])
|
2006-11-08 04:11:44 +00:00
|
|
|
|
2007-03-07 19:42:33 +00:00
|
|
|
# shove the sha1sum into a file
|
|
|
|
sha1file = open(os.path.join(self.isodir, 'SHA1SUM'), 'a')
|
2007-03-08 15:58:13 +00:00
|
|
|
self._doRunCommand(['/usr/bin/sha1sum', isoname], rundir=self.isodir, output=sha1file)
|
2007-03-07 19:42:33 +00:00
|
|
|
sha1file.close()
|
|
|
|
|
|
|
|
# return the .discinfo file
|
2007-03-26 14:39:46 +00:00
|
|
|
if not self.config.get('default', 'arch') == 'source':
|
|
|
|
shutil.move(os.path.join(self.config.get('default', 'destdir'), '.discinfo-%s' % self.config.get('default', 'arch')), discinfofile)
|
2006-11-08 23:34:20 +00:00
|
|
|
|
2007-03-26 14:39:46 +00:00
|
|
|
shutil.rmtree(os.path.join(self.topdir, 'repodata')) # remove our copied repodata
|
|
|
|
shutil.move(os.path.join(self.config.get('default', 'destdir'),
|
|
|
|
'repodata-%s' % self.config.get('default', 'arch')), os.path.join(self.topdir, 'repodata'))
|
2007-03-07 19:42:33 +00:00
|
|
|
|
2007-02-09 21:13:52 +00:00
|
|
|
# keep track of the DVD images we've written
|
2007-02-13 18:23:00 +00:00
|
|
|
isolist.append(self.mkrelative(isofile))
|
2007-02-09 21:13:52 +00:00
|
|
|
|
|
|
|
# Write out a line describing the DVD set
|
2007-02-13 18:23:00 +00:00
|
|
|
self.writeinfo('dvdset: %s' % ' '.join(isolist))
|
2007-01-17 03:59:02 +00:00
|
|
|
|
|
|
|
# Now make rescue images
|
2007-03-26 14:39:46 +00:00
|
|
|
if not self.config.get('default', 'arch') == 'source' and \
|
2007-03-22 21:48:41 +00:00
|
|
|
os.path.exists('/usr/lib/anaconda-runtime/mk-rescueimage.%s' % self.config.get('default', 'arch')):
|
2007-03-07 19:42:33 +00:00
|
|
|
isoname = '%s-%s-%s-rescuecd.iso' % (self.config.get('default', 'iso_basename'),
|
|
|
|
self.config.get('default', 'version'), self.config.get('default', 'arch'))
|
|
|
|
isofile = os.path.join(self.isodir, isoname)
|
|
|
|
|
|
|
|
# make the rescue tree
|
|
|
|
rescue = ['/usr/lib/anaconda-runtime/mk-rescueimage.%s' % self.config.get('default', 'arch')]
|
|
|
|
rescue.append(self.topdir)
|
|
|
|
rescue.append(self.workdir)
|
|
|
|
rescue.append(self.config.get('default', 'iso_basename'))
|
|
|
|
rescue.append(self.config.get('default', 'product_path'))
|
|
|
|
|
|
|
|
# run the command
|
2007-03-08 15:58:13 +00:00
|
|
|
self._doRunCommand(rescue)
|
2007-01-29 20:20:49 +00:00
|
|
|
|
|
|
|
# write the iso
|
2007-03-07 19:42:33 +00:00
|
|
|
extraargs = []
|
|
|
|
|
2007-01-29 20:20:49 +00:00
|
|
|
if self.config.get('default', 'arch') == 'i386' or self.config.get('default', 'arch') == 'x86_64':
|
2007-03-07 19:42:33 +00:00
|
|
|
extraargs.extend(x86bootargs)
|
2007-01-29 20:20:49 +00:00
|
|
|
elif self.config.get('default', 'arch') == 'ia64':
|
2007-03-07 19:42:33 +00:00
|
|
|
extraargs.extend(ia64bootargs)
|
2007-01-29 20:20:49 +00:00
|
|
|
elif self.config.get('default', 'arch') == 'ppc':
|
2007-03-07 19:42:33 +00:00
|
|
|
extraargs.extend(ppcbootargs)
|
|
|
|
extraargs.append(os.path.join(self.workdir, "%s-rescueimage" % self.config.get('default', 'arch'), "ppc/mac"))
|
2007-05-15 17:06:34 +00:00
|
|
|
elif self.config.get('default', 'arch') == 'sparc':
|
|
|
|
extraargs.extend(sparcbootargs)
|
2007-01-29 20:20:49 +00:00
|
|
|
|
2007-03-07 19:42:33 +00:00
|
|
|
extraargs.append('-V')
|
2007-05-15 15:37:37 +00:00
|
|
|
extraargs.append('%s %s %s Rescue' % (self.config.get('default', 'product_name'),
|
2007-03-07 19:42:33 +00:00
|
|
|
self.config.get('default', 'version'), self.config.get('default', 'arch')))
|
2007-01-29 20:20:49 +00:00
|
|
|
|
2007-03-07 19:42:33 +00:00
|
|
|
extraargs.append('-o')
|
|
|
|
extraargs.append(isofile)
|
|
|
|
|
|
|
|
extraargs.append(os.path.join(self.workdir, "%s-rescueimage" % self.config.get('default', 'arch')))
|
|
|
|
|
|
|
|
# run the command
|
2007-03-08 15:58:13 +00:00
|
|
|
self._doRunCommand(mkisofs + extraargs)
|
2007-03-07 19:42:33 +00:00
|
|
|
|
|
|
|
# shove the sha1sum into a file
|
|
|
|
sha1file = open(os.path.join(self.isodir, 'SHA1SUM'), 'a')
|
2007-03-08 15:58:13 +00:00
|
|
|
self._doRunCommand(['/usr/bin/sha1sum', isoname], rundir=self.isodir, output=sha1file)
|
2007-03-07 19:42:33 +00:00
|
|
|
sha1file.close()
|
2007-01-17 03:59:02 +00:00
|
|
|
|
2007-01-17 15:54:09 +00:00
|
|
|
# Do some clean up
|
|
|
|
dirs = os.listdir(self.archdir)
|
|
|
|
|
2007-03-07 19:42:33 +00:00
|
|
|
for directory in dirs:
|
|
|
|
if directory.startswith('os-disc') or directory.startswith('SRPM-disc'):
|
|
|
|
shutil.move(os.path.join(self.archdir, directory), os.path.join(self.workdir, directory))
|
2007-02-15 19:17:39 +00:00
|
|
|
|
2007-08-15 23:19:13 +00:00
|
|
|
self.logger.info("CreateIsos is done.")
|