comparison 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
comparison
equal deleted inserted replaced
169:261b75d7b972 170:bfcb2bbf9a52
12 contains the pbuilder settings. Also, this script assumes that there is 12 contains the pbuilder settings. Also, this script assumes that there is
13 only one pbuilder setting for all packagers. 13 only one pbuilder setting for all packagers.
14 """ 14 """
15 15
16 import sys 16 import sys
17 import os
18 from optparse import OptionParser
19 17
20 import treepkgcmd 18 import treepkgcmd
21 from treepkg.options import create_parser 19 from treepkg.options import create_parser
22 from treepkg.packager import create_package_track, PackagerGroup 20 from treepkg.packager import create_package_track, PackagerGroup
23 from treepkg.readconfig import read_config 21 from treepkg.readconfig import read_config
24 from treepkg.util import ensure_directory, writefile
25 from treepkg.run import call
26 from treepkg.cmdexpand import cmdexpand
27
28
29 pbuilderrc_template = '''\
30 # This file was automatically generated by initpbuilder.py.
31 # for the possible settings see "man pbuilderrc"
32
33 BASETGZ=%(basedir)s/base.tgz
34 BUILDPLACE=%(builddir)s
35 USEPROC=yes
36 USEDEVPTS=yes
37 BUILDRESULT=%(resultdir)s
38 DISTRIBUTION=%(distribution)s
39 APTCACHE=%(basedir)s/aptcache
40 APTCACHEHARDLINK=yes
41 REMOVEPACKAGES=lilo
42 MIRRORSITE="%(mirrorsite)s"
43 OTHERMIRROR="%(othermirror)s"
44 BINDMOUNTS="%(extra-pkgdir)s"
45 PKGNAME_LOGFILE=yes
46 '''
47
48
49 def init_pbuilder(pbuilderrc, distribution, mirrorsite, extramirrors, root_cmd):
50 if not os.path.isabs(pbuilderrc):
51 print >>sys.stderr, "pbuilderrc must be an absolute filename"
52 sys.exit(1)
53
54 if os.path.exists(pbuilderrc):
55 print >>sys.stderr, "pbuilderrc %r already exists." % pbuilderrc
56 sys.exit(1)
57
58 basedir = os.path.dirname(pbuilderrc)
59 replacements = dict(basedir=basedir,
60 distribution=distribution,
61 mirrorsite=mirrorsite)
62
63 # create the pbuilder directories. basedir is created implicitly by
64 # creating its subdirectories.
65 for subdir in ["base", "build", "result", "aptcache", "extra-pkg"]:
66 directory = os.path.join(basedir, subdir)
67 replacements[subdir + "dir"] = directory
68 print "creating directory:", repr(directory)
69 ensure_directory(directory)
70
71 # build OTHERMIRROR value. We always include the extra-pkg dir.
72 othermirror = "deb file://%(extra-pkgdir)s ./" % replacements
73 if extramirrors:
74 othermirror += " | " + extramirrors
75 replacements["othermirror"] = othermirror
76
77 # create the pbuilderrcfile
78 print "creating pbuilderrc:", repr(pbuilderrc)
79 writefile(pbuilderrc, pbuilderrc_template % replacements)
80
81 # turn the extra-pkg directory into a proper deb archive
82 print "turning the extra-pkg dir into a debian archive"
83 extra_pkgdir = replacements["extra-pkgdir"]
84 call(cmdexpand("apt-ftparchive packages ."),
85 stdout=open(os.path.join(extra_pkgdir, "Packages"), "w"),
86 cwd=extra_pkgdir)
87
88 # create the base.tgz chroot
89 print "running pbuilder create"
90 call(cmdexpand("@root_cmd pbuilder create --configfile $pbuilderrc",
91 **locals()))
92 22
93 23
94 def parse_commandline(): 24 def parse_commandline():
95 parser = create_parser() 25 parser = create_parser()
96 parser.set_defaults(distribution="etch") 26 parser.set_defaults(distribution="etch")
116 treepkg_opts, packager_opts = read_config(options.config_file) 46 treepkg_opts, packager_opts = read_config(options.config_file)
117 group = PackagerGroup([create_package_track(**opts) 47 group = PackagerGroup([create_package_track(**opts)
118 for opts in packager_opts], 48 for opts in packager_opts],
119 **treepkg_opts) 49 **treepkg_opts)
120 track = group.get_package_tracks()[0] 50 track = group.get_package_tracks()[0]
121 init_pbuilder(track.pbuilderrc, 51 track.builder.init_pbuilder(distribution=options.distribution,
122 distribution=options.distribution, 52 mirrorsite=options.mirrorsite,
123 mirrorsite=options.mirrorsite, 53 extramirrors=options.othermirror)
124 extramirrors=options.othermirror,
125 root_cmd=track.root_cmd)
126 54
127 main() 55 main()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)