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-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-10-24 02:30:05 +00:00
|
|
|
self.topdir = os.path.join(self.opts.destdir, self.opts.arch)
|
|
|
|
self.basedir = os.path.join(self.topdir, self.prodpath, 'base') # Probably should be defined elsewhere
|
2006-10-17 06:08:10 +00:00
|
|
|
os.mkdir(self.basedir)
|
2006-10-24 02:18:02 +00:00
|
|
|
shutil.copy(self.opts.comps, os.path.join(self.basedir, 'comps.xml'))
|
2006-10-17 06:08:10 +00:00
|
|
|
|
|
|
|
# def doCreateSplitrepo(self):
|
|
|
|
# for disc in seq
|
|
|
|
# os.system('/usr/bin/createrepo -g %s --baseurl=media://%s --split %s' % (self.opts.comps, self.prodpath, 'Fedora-%s' % self.opts.version, os.path.join)
|
|
|
|
|
|
|
|
def doBuildinstall(self):
|
2006-10-24 02:30:05 +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-10-31 15:27:36 +00:00
|
|
|
os.system('/usr/lib/anaconda-runtime/pkgorder %s %s %s > %s' % (self.topdir, self.opts.arch, self.prodpath, os.path.join(self.basedir, 'pkgorder')))
|
2006-10-17 06:08:10 +00:00
|
|
|
|
2006-10-31 15:27:36 +00:00
|
|
|
def doSplittree(self):
|
|
|
|
args = '--release-string="%s" --arch=%s --total-discs=%s --bin-discs=%s --src-discs=0 --pkgorderfile=%s --distdir=%s --srcdir=%s --productpath=%s' % ('Fedora %s' % self.opts.version, self.opts.arch, self.opts.discs, self.opts.discs, os.path.join(self.basedir, 'pkgorder'), self.topdir, os.path.join(self.opts.destdir, 'source', 'SRPMS'), self.prodpath)
|
|
|
|
print args # DEBUG
|
|
|
|
os.system('/usr/lib/anaconda-runtime/splittree.py %s' % args)
|
2006-10-17 06:08:10 +00:00
|
|
|
|
|
|
|
def main():
|
|
|
|
# This is used for testing the module
|
|
|
|
(opts, args) = get_arguments()
|
|
|
|
|
2006-10-24 02:43:41 +00:00
|
|
|
if not os.path.exists(opts.destdir):
|
|
|
|
print >> sys.stderr, "Error: Cannot read top dir %s" % opts.destdir
|
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-10-17 06:08:10 +00:00
|
|
|
#myPungi.doCreateSplitrepo()
|
|
|
|
|
|
|
|
|
|
|
|
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()
|