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.
|
|
|
|
|
|
|
|
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
|
2006-10-17 06:08:10 +00:00
|
|
|
|
|
|
|
class Pungi:
|
2006-11-17 23:01:10 +00:00
|
|
|
def __init__(self, config):
|
|
|
|
self.config = config
|
2006-10-17 06:08:10 +00:00
|
|
|
self.prodpath = 'Fedora' # Probably should be defined elsewhere
|
2006-11-17 23:01:10 +00:00
|
|
|
self.topdir = os.path.join(self.config.get('default', 'destdir'),
|
|
|
|
self.config.get('default', 'version'),
|
|
|
|
self.config.get('default', 'arch'),
|
|
|
|
'os')
|
2006-12-12 04:23:05 +00:00
|
|
|
self.workdir = os.path.join(self.config.get('default', 'destdir'),
|
|
|
|
'work',
|
|
|
|
self.config.get('default', 'arch'))
|
|
|
|
self.common_files = []
|
|
|
|
|
2006-10-17 06:08:10 +00:00
|
|
|
|
|
|
|
def doBuildinstall(self):
|
2006-11-07 05:23:14 +00:00
|
|
|
# buildinstall looks for a comps file in base/ for now, copy it into place
|
2006-11-20 14:52:27 +00:00
|
|
|
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.config.get('default', 'product_path'), 'base', 'comps.xml'))
|
|
|
|
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)
|
2006-10-17 06:08:10 +00:00
|
|
|
os.system('/usr/lib/anaconda-runtime/buildinstall %s' % args)
|
|
|
|
|
|
|
|
def doPackageorder(self):
|
2006-11-17 23:01:10 +00:00
|
|
|
os.system('/usr/lib/anaconda-runtime/pkgorder %s %s %s > %s' % (self.topdir, self.config.get('default', 'arch'),
|
2006-11-20 14:52:27 +00:00
|
|
|
self.config.get('default', 'product_path'), os.path.join(self.config.get('default', 'destdir'),
|
|
|
|
'pkgorder-%s' % self.config.get('default', 'arch'))))
|
2006-10-17 06:08:10 +00:00
|
|
|
|
2006-12-12 04:23:05 +00:00
|
|
|
def doGetRelnotes(self):
|
|
|
|
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')))
|
|
|
|
|
|
|
|
for pkg in pkgs:
|
|
|
|
pkgname = pkg.rsplit('-', 2)[0]
|
|
|
|
for relnoterpm in relnoterpms:
|
|
|
|
if pkgname == relnoterpm:
|
|
|
|
output = os.system("pushd %s; rpm2cpio %s |cpio -imud; popd" %
|
|
|
|
(docsdir,
|
|
|
|
os.path.join(self.topdir, self.config.get('default', 'product_path'), pkg)))
|
|
|
|
|
|
|
|
# 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)):
|
|
|
|
print "Copying release note file %s" % filename
|
|
|
|
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):
|
|
|
|
for dir in dirname:
|
|
|
|
for regex in dirres:
|
|
|
|
if regex.match(dir) and not os.path.exists(os.path.join(self.topdir, dir)):
|
|
|
|
print "Copying release note dir %s" % dir
|
|
|
|
shutil.copytree(os.path.join(dirpath, dir), os.path.join(self.topdir, dir))
|
|
|
|
|
|
|
|
|
2006-10-31 15:27:36 +00:00
|
|
|
def doSplittree(self):
|
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')
|
|
|
|
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'))
|
2006-11-17 23:01:10 +00:00
|
|
|
timber.package_order_file = os.path.join(self.config.get('default', 'destdir'), '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 =
|
|
|
|
|
|
|
|
output = timber.main()
|
|
|
|
for line in output:
|
|
|
|
print line
|
2006-10-17 06:08:10 +00:00
|
|
|
|
2006-12-10 01:48:08 +00:00
|
|
|
def doSplitSRPMs(self):
|
|
|
|
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'))
|
|
|
|
timber.dist_dir = os.path.join(self.config.get('default', 'destdir'),
|
|
|
|
self.config.get('default', 'version'),
|
|
|
|
'source', 'SRPM')
|
|
|
|
timber.src_dir = os.path.join(self.config.get('default', 'destdir'), self.config.get('default', 'version'), 'source', 'SRPMS')
|
|
|
|
#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)
|
|
|
|
|
|
|
|
timber.splitSRPMS()
|
|
|
|
for line in timber.logfile:
|
|
|
|
print line
|
|
|
|
|
2006-11-01 22:33:53 +00:00
|
|
|
def doCreateSplitrepo(self):
|
2006-11-07 17:26:32 +00:00
|
|
|
discinfo = open('%s-disc1/.discinfo' % self.topdir, 'r').readlines()
|
2006-11-01 22:48:59 +00:00
|
|
|
mediaid = discinfo[0].rstrip('\n')
|
2006-11-06 21:15:25 +00:00
|
|
|
args = '-g %s --baseurl=media://%s --outputdir=%s-disc1 --basedir=%s-disc1 --split %s-disc?' % \
|
2006-11-07 17:26:32 +00:00
|
|
|
(os.path.join(self.topdir, 'repodata', 'comps.xml'), mediaid, self.topdir, self.topdir, self.topdir)
|
2006-11-01 22:33:53 +00:00
|
|
|
os.system('/usr/bin/createrepo %s' % args)
|
|
|
|
|
2006-11-07 21:52:56 +00:00
|
|
|
def doCreateIsos(self):
|
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
|
2006-11-07 21:52:56 +00:00
|
|
|
mkisofsargs = '-v -U -J -R -T -V' # common mkisofs flags
|
|
|
|
bootargs = ''
|
2006-12-04 20:47:50 +00:00
|
|
|
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'
|
2006-12-12 17:21:28 +00:00
|
|
|
ppcbootargs = '-part -hfs -r -l -sysid PPC -hfs-bless "./ppc/mac" -map %s -magic %s -no-desktop -allow-multidot -chrp-boot' % (os.path.join(anaruntime, 'mapping'), os.path.join(anaruntime, 'magic'))
|
2006-11-17 23:01:10 +00:00
|
|
|
isodir = os.path.join(self.config.get('default', 'destdir'), self.config.get('default', 'version'),
|
2006-11-20 14:52:27 +00:00
|
|
|
self.config.get('default', 'arch'), self.config.get('default', 'isodir'))
|
2006-11-07 21:52:56 +00:00
|
|
|
os.makedirs(isodir)
|
2006-11-17 23:01:10 +00:00
|
|
|
for disc in range(1, self.config.getint('default', 'discs') + 1): # cycle through the CD isos
|
2006-11-20 14:52:27 +00:00
|
|
|
volname = '"%s %s %s Disc %s"' % (self.config.get('default', 'product_name'), self.config.get('default', 'version'),
|
2006-11-17 23:01:10 +00:00
|
|
|
self.config.get('default', 'arch'), disc) # hacky :/
|
2006-11-20 14:52:27 +00:00
|
|
|
isoname = '%s-%s-%s-disc%s.iso' % (self.config.get('default', 'iso_basename'), self.config.get('default', 'version'),
|
2006-11-17 23:01:10 +00:00
|
|
|
self.config.get('default', 'arch'), disc)
|
2006-11-07 21:52:56 +00:00
|
|
|
if disc == 1: # if this is the first disc, we want to set boot flags
|
2006-11-17 23:01:10 +00:00
|
|
|
if self.config.get('default', 'arch') == 'i386' or self.config.get('default', 'arch') == 'x86_64':
|
2006-12-04 20:47:50 +00:00
|
|
|
bootargs = x86bootargs
|
|
|
|
elif self.config.get('default', 'arch') == 'ia64':
|
|
|
|
bootargs = ia64bootargs
|
2006-11-17 23:01:10 +00:00
|
|
|
elif self.config.get('default', 'arch') == 'ppc':
|
2006-12-04 20:47:50 +00:00
|
|
|
bootargs = ppcbootargs
|
2006-11-08 04:11:44 +00:00
|
|
|
else:
|
|
|
|
bootargs = '' # clear out any existing bootargs
|
|
|
|
|
2006-11-07 21:52:56 +00:00
|
|
|
os.system('mkisofs %s %s %s -o %s/%s %s' % (mkisofsargs,
|
|
|
|
volname,
|
|
|
|
bootargs,
|
|
|
|
isodir,
|
|
|
|
isoname,
|
|
|
|
os.path.join('%s-disc%s' % (self.topdir, disc))))
|
|
|
|
os.system('cd %s; sha1sum %s >> SHA1SUM' % (isodir, isoname))
|
2006-12-10 01:48:08 +00:00
|
|
|
# implant md5 for mediacheck on all but source arches
|
|
|
|
if not self.config.get('default', 'arch') == 'source':
|
|
|
|
os.system('/usr/lib/anaconda-runtime/implantisomd5 %s' % os.path.join(isodir, isoname))
|
2006-11-07 21:52:56 +00:00
|
|
|
|
2006-12-10 01:48:08 +00:00
|
|
|
# We've asked for more than one disc, and we're not srpms, so make a DVD image
|
|
|
|
if self.config.getint('default', 'discs') > 1 and not self.config.get('default', 'arch') == 'source':
|
2006-11-08 23:34:20 +00:00
|
|
|
# backup the main .discinfo to use a split one. This is an ugly hack :/
|
|
|
|
content = open(discinfofile, 'r').readlines()
|
2006-11-17 23:01:10 +00:00
|
|
|
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'
|
2006-11-08 23:34:20 +00:00
|
|
|
open(discinfofile, 'w').writelines(content)
|
|
|
|
|
|
|
|
|
2006-11-08 04:11:44 +00:00
|
|
|
# move the main repodata out of the way to use the split repodata
|
2006-11-17 23:01:10 +00:00
|
|
|
shutil.move(os.path.join(self.topdir, 'repodata'), os.path.join(self.config.get('default', 'destdir'),
|
|
|
|
'repodata-%s' % self.config.get('default', 'arch')))
|
2006-12-13 04:01:33 +00:00
|
|
|
shutil.copytree('%s-disc1/repodata' % self.topdir, os.path.join(self.topdir, 'repodata'))
|
2006-11-08 04:11:44 +00:00
|
|
|
|
2006-11-20 14:52:27 +00:00
|
|
|
volname = '"%s %s %s DVD"' % (self.config.get('default', 'product_name'), self.config.get('default', 'version'),
|
|
|
|
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'))
|
2006-11-17 23:01:10 +00:00
|
|
|
if self.config.get('default', 'arch') == 'i386' or self.config.get('default', 'arch') == 'x86_64':
|
2006-12-04 20:47:50 +00:00
|
|
|
bootargs = x86bootargs
|
2006-12-10 01:48:08 +00:00
|
|
|
elif self.config.get('default', 'arch') == 'ia64':
|
2006-12-04 20:47:50 +00:00
|
|
|
bootargs = ia64bootargs
|
2006-11-17 23:01:10 +00:00
|
|
|
elif self.config.get('default', 'arch') == 'ppc':
|
2006-12-04 20:47:50 +00:00
|
|
|
bootargs = ppcbootargs
|
2006-12-10 01:48:08 +00:00
|
|
|
else:
|
|
|
|
bootargs = '' # clear out any existing bootargs
|
2006-11-08 04:11:44 +00:00
|
|
|
|
|
|
|
os.system('mkisofs %s %s %s -o %s/%s %s' % (mkisofsargs,
|
|
|
|
volname,
|
|
|
|
bootargs,
|
|
|
|
isodir,
|
|
|
|
isoname,
|
2006-11-28 12:56:40 +00:00
|
|
|
self.topdir))
|
2006-11-08 04:11:44 +00:00
|
|
|
os.system('cd %s; sha1sum %s >> SHA1SUM' % (isodir, isoname))
|
2006-12-08 15:57:23 +00:00
|
|
|
os.system('/usr/lib/anaconda-runtime/implantisomd5 %s' % os.path.join(isodir, isoname))
|
2006-11-08 04:11:44 +00:00
|
|
|
|
2006-11-17 23:01:10 +00:00
|
|
|
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
|
|
|
|
2006-12-13 04:01:33 +00:00
|
|
|
shutil.rmtree(os.path.join(self.topdir, 'repodata')) # remove our copied repodata
|
2006-11-17 23:01:10 +00:00
|
|
|
shutil.move(os.path.join(self.config.get('default', 'destdir'),
|
|
|
|
'repodata-%s' % self.config.get('default', 'arch')), os.path.join(self.topdir, 'repodata'))
|