Mercurial > treepkg
diff bin/initpbuilder.py @ 170:bfcb2bbf9a52
Move the pbuilder initialization code from bin/initpbuilder.py to
treepkg/builder.py to make it work again and add some tests.
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Mon, 23 Jun 2008 13:21:08 +0000 |
parents | b4226070371f |
children | 1fcdffbeb9de |
line wrap: on
line diff
--- a/bin/initpbuilder.py Fri Jun 20 15:51:24 2008 +0000 +++ b/bin/initpbuilder.py Mon Jun 23 13:21:08 2008 +0000 @@ -14,81 +14,11 @@ """ import sys -import os -from optparse import OptionParser import treepkgcmd from treepkg.options import create_parser from treepkg.packager import create_package_track, PackagerGroup from treepkg.readconfig import read_config -from treepkg.util import ensure_directory, writefile -from treepkg.run import call -from treepkg.cmdexpand import cmdexpand - - -pbuilderrc_template = '''\ -# This file was automatically generated by initpbuilder.py. -# for the possible settings see "man pbuilderrc" - -BASETGZ=%(basedir)s/base.tgz -BUILDPLACE=%(builddir)s -USEPROC=yes -USEDEVPTS=yes -BUILDRESULT=%(resultdir)s -DISTRIBUTION=%(distribution)s -APTCACHE=%(basedir)s/aptcache -APTCACHEHARDLINK=yes -REMOVEPACKAGES=lilo -MIRRORSITE="%(mirrorsite)s" -OTHERMIRROR="%(othermirror)s" -BINDMOUNTS="%(extra-pkgdir)s" -PKGNAME_LOGFILE=yes -''' - - -def init_pbuilder(pbuilderrc, distribution, mirrorsite, extramirrors, root_cmd): - if not os.path.isabs(pbuilderrc): - print >>sys.stderr, "pbuilderrc must be an absolute filename" - sys.exit(1) - - if os.path.exists(pbuilderrc): - print >>sys.stderr, "pbuilderrc %r already exists." % pbuilderrc - sys.exit(1) - - basedir = os.path.dirname(pbuilderrc) - replacements = dict(basedir=basedir, - distribution=distribution, - mirrorsite=mirrorsite) - - # create the pbuilder directories. basedir is created implicitly by - # creating its subdirectories. - for subdir in ["base", "build", "result", "aptcache", "extra-pkg"]: - directory = os.path.join(basedir, subdir) - replacements[subdir + "dir"] = directory - print "creating directory:", repr(directory) - ensure_directory(directory) - - # build OTHERMIRROR value. We always include the extra-pkg dir. - othermirror = "deb file://%(extra-pkgdir)s ./" % replacements - if extramirrors: - othermirror += " | " + extramirrors - replacements["othermirror"] = othermirror - - # create the pbuilderrcfile - print "creating pbuilderrc:", repr(pbuilderrc) - writefile(pbuilderrc, pbuilderrc_template % replacements) - - # turn the extra-pkg directory into a proper deb archive - print "turning the extra-pkg dir into a debian archive" - extra_pkgdir = replacements["extra-pkgdir"] - call(cmdexpand("apt-ftparchive packages ."), - stdout=open(os.path.join(extra_pkgdir, "Packages"), "w"), - cwd=extra_pkgdir) - - # create the base.tgz chroot - print "running pbuilder create" - call(cmdexpand("@root_cmd pbuilder create --configfile $pbuilderrc", - **locals())) def parse_commandline(): @@ -118,10 +48,8 @@ for opts in packager_opts], **treepkg_opts) track = group.get_package_tracks()[0] - init_pbuilder(track.pbuilderrc, - distribution=options.distribution, - mirrorsite=options.mirrorsite, - extramirrors=options.othermirror, - root_cmd=track.root_cmd) + track.builder.init_pbuilder(distribution=options.distribution, + mirrorsite=options.mirrorsite, + extramirrors=options.othermirror) main()