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
|
2006-11-08 21:34:59 +00:00
|
|
|
#sys.path.append('/usr/lib/anaconda-runtime') # use our patched splittree for now
|
2006-11-06 21:15:25 +00:00
|
|
|
import splittree
|
2006-10-24 02:16:07 +00:00
|
|
|
import shutil
|
2006-10-17 06:08:10 +00:00
|
|
|
|
|
|
|
class Pungi:
|
|
|
|
def __init__(self, opts):
|
|
|
|
self.opts = opts
|
|
|
|
self.prodpath = 'Fedora' # Probably should be defined elsewhere
|
2006-11-07 05:23:14 +00:00
|
|
|
self.topdir = os.path.join(self.opts.destdir, self.opts.version, self.opts.arch, 'os')
|
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
|
|
|
|
os.makedirs(os.path.join(self.topdir, self.prodpath, 'base'))
|
|
|
|
shutil.copy(self.opts.comps, os.path.join(self.topdir, self.prodpath, 'base', 'comps.xml'))
|
2006-11-01 21:29:17 +00:00
|
|
|
args = '--product "Fedora" --version %s --release "%s" --prodpath %s %s' % (self.opts.version,
|
|
|
|
'Fedora %s' % self.opts.version, self.prodpath, self.topdir)
|
2006-10-17 06:08:10 +00:00
|
|
|
os.system('/usr/lib/anaconda-runtime/buildinstall %s' % args)
|
|
|
|
|
|
|
|
def doPackageorder(self):
|
2006-11-07 05:23:14 +00:00
|
|
|
os.system('/usr/lib/anaconda-runtime/pkgorder %s %s %s > %s' % (self.topdir,
|
|
|
|
self.opts.arch,
|
|
|
|
self.prodpath,
|
|
|
|
os.path.join(self.opts.destdir, 'pkgorder-%s' % self.opts.arch)))
|
2006-10-17 06:08:10 +00:00
|
|
|
|
2006-10-31 15:27:36 +00:00
|
|
|
def doSplittree(self):
|
2006-11-06 21:15:25 +00:00
|
|
|
timber = splittree.Timber()
|
|
|
|
timber.arch = self.opts.arch
|
|
|
|
timber.total_discs = self.opts.discs
|
|
|
|
timber.bin_discs = self.opts.discs
|
|
|
|
timber.src_discs = 0
|
|
|
|
timber.release_str = 'Fedora %s' % self.opts.version
|
2006-11-07 05:23:14 +00:00
|
|
|
timber.package_order_file = os.path.join(self.opts.destdir, 'pkgorder-%s' % self.opts.arch)
|
2006-11-06 21:15:25 +00:00
|
|
|
timber.dist_dir = self.topdir
|
2006-11-07 05:23:14 +00:00
|
|
|
timber.src_dir = os.path.join(self.opts.destdir, self.opts.version, 'source', 'SRPMS')
|
2006-11-06 21:15:25 +00:00
|
|
|
timber.product_path = self.prodpath
|
|
|
|
#timber.reserve_size =
|
|
|
|
|
|
|
|
output = timber.main()
|
|
|
|
for line in output:
|
|
|
|
print line
|
2006-10-17 06:08:10 +00:00
|
|
|
|
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-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 = ''
|
|
|
|
isodir = os.path.join(self.opts.destdir, self.opts.version, self.opts.arch, 'iso')
|
|
|
|
os.makedirs(isodir)
|
|
|
|
for disc in range(1, self.opts.discs + 1): # cycle through the CD isos
|
|
|
|
volname = '"%s %s %s Disc %s"' % ('Fedora', self.opts.version, self.opts.arch, disc) # hacky :/
|
|
|
|
isoname = 'Fedora-%s-%s-disc%s.iso' % (self.opts.version, self.opts.arch, disc)
|
|
|
|
if disc == 1: # if this is the first disc, we want to set boot flags
|
|
|
|
if self.opts.arch == 'i386' or self.opts.arch == 'x86_64':
|
|
|
|
bootargs = '-b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table'
|
|
|
|
elif self.opts.arch == 'ppc':
|
|
|
|
# Boy, it would be nice if somebody who understood ppc helped out here...
|
|
|
|
bootargs = ''
|
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-11-08 04:11:44 +00:00
|
|
|
if self.opts.discs > 1: # We've asked for more than one disc, make a DVD image
|
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()
|
|
|
|
shutil.move(discinfofile, os.path.join(self.opts.destdir, '.discinfo-%s' % self.opts.arch))
|
|
|
|
content[content.index('ALL\n')] = ','.join([str(x) for x in range(1, self.opts.discs + 1)]) + '\n'
|
|
|
|
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
|
|
|
|
shutil.move(os.path.join(self.topdir, 'repodata'), os.path.join(self.opts.destdir, 'repodata-%s' % self.opts.arch))
|
|
|
|
os.symlink('%s-disc1/repodata' % self.topdir, os.path.join(self.topdir, 'repodata'))
|
|
|
|
|
|
|
|
volname = '"%s %s %s DVD"' % ('Fedora', self.opts.version, self.opts.arch)
|
|
|
|
isoname = 'Fedora-%s-%s-DVD.iso' % (self.opts.version, self.opts.arch)
|
|
|
|
if self.opts.arch == 'i386' or self.opts.arch == 'x86_64':
|
|
|
|
bootargs = '-b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table'
|
|
|
|
elif self.opts.arch == 'ppc':
|
|
|
|
# Boy, it would be nice if somebody who understood ppc helped out here...
|
|
|
|
bootargs = ''
|
|
|
|
|
|
|
|
os.system('mkisofs %s %s %s -o %s/%s %s' % (mkisofsargs,
|
|
|
|
volname,
|
|
|
|
bootargs,
|
|
|
|
isodir,
|
|
|
|
isoname,
|
|
|
|
os.path.join('%s-disc1' % self.topdir)))
|
|
|
|
os.system('cd %s; sha1sum %s >> SHA1SUM' % (isodir, isoname))
|
|
|
|
|
2006-11-08 23:34:20 +00:00
|
|
|
shutil.move(os.path.join(self.opts.destdir, '.discinfo-%s' % self.opts.arch), discinfofile)
|
|
|
|
|
2006-11-08 04:11:44 +00:00
|
|
|
os.unlink(os.path.join(self.topdir, 'repodata')) # remove our temp symlink and move the orig repodata back
|
|
|
|
shutil.move(os.path.join(self.opts.destdir, 'repodata-%s' % self.opts.arch), os.path.join(self.topdir, 'repodata'))
|
|
|
|
|
|
|
|
|
2006-10-17 06:08:10 +00:00
|
|
|
def main():
|
|
|
|
# This is used for testing the module
|
|
|
|
(opts, args) = get_arguments()
|
|
|
|
|
2006-11-07 05:23:14 +00:00
|
|
|
if not os.path.exists(os.path.join(opts.destdir, opts.version, 'os')):
|
|
|
|
print >> sys.stderr, "Error: Cannot read top dir %s" % os.path.join(opts.destdir, opts.version, 'os')
|
2006-10-17 06:08:10 +00:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
myPungi = Pungi(opts)
|
|
|
|
myPungi.doBuildinstall()
|
|
|
|
myPungi.doPackageorder()
|
2006-10-31 15:27:36 +00:00
|
|
|
myPungi.doSplittree()
|
2006-11-01 22:33:53 +00:00
|
|
|
myPungi.doCreateSplitrepo()
|
2006-11-07 21:52:56 +00:00
|
|
|
myPungi.doCreateIsos()
|
2006-10-17 06:08:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
from optparse import OptionParser
|
|
|
|
import sys
|
|
|
|
|
|
|
|
def get_arguments():
|
|
|
|
# hack job for now, I'm sure this could be better for our uses
|
|
|
|
usage = "usage: %s [options]" % sys.argv[0]
|
|
|
|
parser = OptionParser(usage=usage)
|
2006-10-24 02:43:41 +00:00
|
|
|
parser.add_option("--destdir", default=".", dest="destdir",
|
2006-10-17 06:08:10 +00:00
|
|
|
help='Directory that contains the package set')
|
|
|
|
parser.add_option("--comps", default="comps.xml", dest="comps",
|
|
|
|
help='comps file to use')
|
|
|
|
parser.add_option("--arch", default="i386", dest="arch",
|
|
|
|
help='Base arch to use')
|
|
|
|
parser.add_option("--version", default="test", dest="version",
|
|
|
|
help='Version of the spin')
|
2006-10-31 15:27:36 +00:00
|
|
|
parser.add_option("--discs", default="5", dest="discs",
|
|
|
|
help='Number of discs to spin')
|
2006-10-17 06:08:10 +00:00
|
|
|
parser.add_option("-q", "--quiet", default=False, action="store_true",
|
|
|
|
help="Output as little as possible")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(opts, args) = parser.parse_args()
|
|
|
|
#if len(opts) < 1:
|
|
|
|
# parser.print_help()
|
|
|
|
# sys.exit(0)
|
|
|
|
return (opts, args)
|
|
|
|
|
|
|
|
main()
|