Merge lp:~mbp/launchpad/800295-delete-buildd-again into lp:launchpad

Proposed by Martin Pool
Status: Merged
Approved by: Martin Pool
Approved revision: no longer in the source branch.
Merged at revision: 14344
Proposed branch: lp:~mbp/launchpad/800295-delete-buildd-again
Merge into: lp:launchpad
Diff against target: 9033 lines (+18/-8598)
63 files modified
.bzrignore (+0/-8)
buildout.cfg (+4/-2)
lib/canonical/buildd/Makefile (+0/-19)
lib/canonical/buildd/README (+0/-47)
lib/canonical/buildd/__init__.py (+0/-5)
lib/canonical/buildd/binarypackage.py (+0/-133)
lib/canonical/buildd/buildd-config.py (+0/-54)
lib/canonical/buildd/buildd-slave-example.conf (+0/-25)
lib/canonical/buildd/buildd-slave.tac (+0/-55)
lib/canonical/buildd/buildrecipe (+0/-220)
lib/canonical/buildd/check-implicit-pointer-functions (+0/-118)
lib/canonical/buildd/debian.py (+0/-239)
lib/canonical/buildd/debian/changelog (+0/-698)
lib/canonical/buildd/debian/compat (+0/-1)
lib/canonical/buildd/debian/control (+0/-17)
lib/canonical/buildd/debian/launchpad-buildd.cron.daily (+0/-10)
lib/canonical/buildd/debian/launchpad-buildd.examples (+0/-1)
lib/canonical/buildd/debian/launchpad-buildd.init (+0/-98)
lib/canonical/buildd/debian/postinst (+0/-101)
lib/canonical/buildd/debian/rules (+0/-96)
lib/canonical/buildd/debian/source/format (+0/-1)
lib/canonical/buildd/debian/upgrade-config (+0/-122)
lib/canonical/buildd/generate-translation-templates (+0/-66)
lib/canonical/buildd/mount-chroot (+0/-25)
lib/canonical/buildd/override-sources-list (+0/-31)
lib/canonical/buildd/pottery/generate_translation_templates.py (+0/-114)
lib/canonical/buildd/pottery/intltool.py (+0/-342)
lib/canonical/buildd/remove-build (+0/-25)
lib/canonical/buildd/sbuild (+0/-3658)
lib/canonical/buildd/sbuild-package (+0/-92)
lib/canonical/buildd/sbuild.conf (+0/-155)
lib/canonical/buildd/sbuildrc (+0/-32)
lib/canonical/buildd/scan-for-processes (+0/-43)
lib/canonical/buildd/slave.py (+0/-686)
lib/canonical/buildd/sourcepackagerecipe.py (+0/-144)
lib/canonical/buildd/template-buildd-slave.conf (+0/-32)
lib/canonical/buildd/test_buildd_generatetranslationtemplates (+0/-33)
lib/canonical/buildd/test_buildd_recipe (+0/-48)
lib/canonical/buildd/tests/__init__.py (+0/-4)
lib/canonical/buildd/tests/buildd-slave-test.conf (+0/-27)
lib/canonical/buildd/tests/buildlog (+0/-23)
lib/canonical/buildd/tests/buildlog.long (+0/-82)
lib/canonical/buildd/tests/harness.py (+0/-139)
lib/canonical/buildd/tests/test_1.diff (+0/-17)
lib/canonical/buildd/tests/test_2.diff (+0/-32)
lib/canonical/buildd/tests/test_buildd_slave.py (+0/-198)
lib/canonical/buildd/tests/test_check_implicit_pointer_functions.py (+0/-43)
lib/canonical/buildd/tests/test_harness.py (+0/-10)
lib/canonical/buildd/tests/test_translationtemplatesbuildmanager.py (+0/-173)
lib/canonical/buildd/translationtemplates.py (+0/-99)
lib/canonical/buildd/umount-chroot (+0/-40)
lib/canonical/buildd/unpack-chroot (+0/-52)
lib/canonical/buildd/update-debian-chroot (+0/-45)
lib/canonical/launchpad/daemons/readyservice.py (+0/-6)
lib/lp/buildmaster/model/builder.py (+2/-3)
lib/lp/buildmaster/tests/mock_slaves.py (+1/-1)
lib/lp/buildmaster/tests/test_builder.py (+2/-1)
lib/lp/buildmaster/tests/test_manager.py (+2/-1)
lib/lp/testing/factory.py (+0/-1)
lib/lp/translations/tests/test_generate_translation_templates.py (+5/-2)
lib/lp/translations/tests/test_pottery_detect_intltool.py (+1/-1)
scripts/rosetta/pottery-generate-intltool.py (+1/-1)
utilities/snakefood/lp-sfood-packages (+0/-1)
To merge this branch: bzr merge lp:~mbp/launchpad/800295-delete-buildd-again
Reviewer Review Type Date Requested Status
Launchpad code reviewers Pending
Review via email: mp+82836@code.launchpad.net

Commit message

[no-qa] [r=mbp] delete canonical.buildd, now it has moved to launchpad-buildd

Description of the change

Try again to delete canonical.buildd, now that the dependencies are in place.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2011-11-17 19:41:24 +0000
+++ .bzrignore 2011-11-20 23:45:00 +0000
@@ -63,14 +63,6 @@
63twistd.pid63twistd.pid
64lib/canonical/launchpad/apidoc64lib/canonical/launchpad/apidoc
65*.prof65*.prof
66lib/canonical/launchpad-buildd_*.dsc
67lib/canonical/launchpad-buildd_*.tar.gz
68lib/canonical/launchpad-buildd_*_all.deb
69lib/canonical/launchpad-buildd_*.changes
70lib/canonical/launchpad-buildd_*_source.build
71lib/canonical/launchpad-buildd_*_source.changes
72lib/canonical/buildd/debian/*
73lib/canonical/buildd/launchpad-files/*
74.project66.project
75.pydevproject67.pydevproject
76librarian.log68librarian.log
7769
=== modified file 'buildout.cfg'
--- buildout.cfg 2011-11-17 19:41:24 +0000
+++ buildout.cfg 2011-11-20 23:45:00 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4[buildout]4[buildout]
@@ -57,7 +57,9 @@
57 zc.zservertracelog57 zc.zservertracelog
58# XXX gary 2009-5-12 bug 375751:58# XXX gary 2009-5-12 bug 375751:
59# Make mailman built and installed in a more normal way.59# Make mailman built and installed in a more normal way.
60extra-paths = ${buildout:directory}/lib/mailman60extra-paths =
61 ${buildout:directory}/lib/mailman
62 /usr/lib/launchpad-buildd
61include-site-packages = true63include-site-packages = true
62allowed-eggs-from-site-packages =64allowed-eggs-from-site-packages =
63interpreter = py65interpreter = py
6466
=== removed directory 'lib/canonical/buildd'
=== removed file 'lib/canonical/buildd/Makefile'
--- lib/canonical/buildd/Makefile 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/Makefile 1970-01-01 00:00:00 +0000
@@ -1,19 +0,0 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4all: deb
5
6src: clean
7 dpkg-buildpackage -rfakeroot -uc -us -S
8
9deb: clean
10 dpkg-buildpackage -rfakeroot -uc -us
11
12clean:
13 fakeroot debian/rules clean
14 rm -f ../launchpad-buildd*tar.gz
15 rm -f ../launchpad-buildd*dsc
16 rm -f ../launchpad-buildd*deb
17 rm -f ../launchpad-buildd*changes
18
19.PHONY: all clean deb
200
=== removed file 'lib/canonical/buildd/README'
--- lib/canonical/buildd/README 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/README 1970-01-01 00:00:00 +0000
@@ -1,47 +0,0 @@
1In order to build the package you need dpkg-dev and fakeroot
2
3To build the package do:
4
5cd ..../lib/canonical/buildd
6debian/rules package
7dpkg-buildpackage -rfakeroot -b
8
9It will "fail" because the package built in the "wrong" place. Don't
10worry about that.
11
12To clean up, do:
13
14fakeroot debian/rules clean
15rm launchpad-buildd*deb
16rm ../launchpad-buildd*changes
17
18-----------------------------------------------------------------------
19
20How to use the chroot tool:
21
22buildd-slave-chroot-tool --intervene <chroot tarball>
23
24...will unpack the chroot tarball, mount up the proc etc filesystems
25in it and chroot into it.
26
27When you leave the chroot, it will ask you if you want to repack the
28tarball. If you answer yes then it will repack it, if you answer no,
29then it will merely clean up and exit.
30
31If you wish to build a new chroot then first copy the example.chroot
32file from /usr/share/doc/launchpad-buildd/ and edit it to your
33requirements.
34
35Next run buildd-slave-chroot-tool --generate config.filename
36
37You must have sudo capability and ideally you would run this as the
38buildd user on a machine with launchpad-buildd installed.
39
40Once you have completed the chroot building, you will be left with a
41file named chroot-<distro>-<distrorelease>-<arch>.tar.bz2 which should
42be uploaded to the librarian from a machine with librarian access and
43then marked as the chroot for the given pocket.
44
45You should retain the configuration file so that we know how the
46chroot was built in case we need to rebuild it at a later date.
47
480
=== removed file 'lib/canonical/buildd/__init__.py'
--- lib/canonical/buildd/__init__.py 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/__init__.py 1970-01-01 00:00:00 +0000
@@ -1,5 +0,0 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4from canonical.buildd.slave import XMLRPCBuildDSlave
5from canonical.buildd.debian import DebianBuildManager
60
=== removed file 'lib/canonical/buildd/binarypackage.py'
--- lib/canonical/buildd/binarypackage.py 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/binarypackage.py 1970-01-01 00:00:00 +0000
@@ -1,133 +0,0 @@
1# Copyright 2009, 2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4
5import re
6
7from canonical.buildd.debian import DebianBuildManager, DebianBuildState
8
9
10class SBuildExitCodes:
11 """SBUILD process result codes."""
12 OK = 0
13 DEPFAIL = 1
14 GIVENBACK = 2
15 PACKAGEFAIL = 3
16 BUILDERFAIL = 4
17
18
19class BuildLogRegexes:
20 """Build log regexes for performing actions based on regexes, and extracting dependencies for auto dep-waits"""
21 GIVENBACK = [
22 ("^E: There are problems and -y was used without --force-yes"),
23 ]
24 DEPFAIL = [
25 ("(?P<pk>[\-+.\w]+)\(inst [^ ]+ ! >> wanted (?P<v>[\-.+\w:~]+)\)","\g<pk> (>> \g<v>)"),
26 ("(?P<pk>[\-+.\w]+)\(inst [^ ]+ ! >?= wanted (?P<v>[\-.+\w:~]+)\)","\g<pk> (>= \g<v>)"),
27 ("(?s)^E: Couldn't find package (?P<pk>[\-+.\w]+)(?!.*^E: Couldn't find package)","\g<pk>"),
28 ("(?s)^E: Package '?(?P<pk>[\-+.\w]+)'? has no installation candidate(?!.*^E: Package)","\g<pk>"),
29 ("(?s)^E: Unable to locate package (?P<pk>[\-+.\w]+)(?!.*^E: Unable to locate package)", "\g<pk>"),
30 ]
31
32
33class BinaryPackageBuildState(DebianBuildState):
34 SBUILD = "SBUILD"
35
36
37class BinaryPackageBuildManager(DebianBuildManager):
38 """Handle buildd building for a debian style binary package build"""
39
40 initial_build_state = BinaryPackageBuildState.SBUILD
41
42 def __init__(self, slave, buildid):
43 DebianBuildManager.__init__(self, slave, buildid)
44 self._sbuildpath = slave._config.get("binarypackagemanager", "sbuildpath")
45 self._sbuildargs = slave._config.get("binarypackagemanager",
46 "sbuildargs").split(" ")
47
48 def initiate(self, files, chroot, extra_args):
49 """Initiate a build with a given set of files and chroot."""
50
51 self._dscfile = None
52 for f in files:
53 if f.endswith(".dsc"):
54 self._dscfile = f
55 if self._dscfile is None:
56 raise ValueError, files
57
58 self.archive_purpose = extra_args.get('archive_purpose')
59 self.suite = extra_args.get('suite')
60 self.component = extra_args['ogrecomponent']
61 self.arch_indep = extra_args.get('arch_indep', False)
62 self.build_debug_symbols = extra_args.get('build_debug_symbols', False)
63
64 super(BinaryPackageBuildManager, self).initiate(
65 files, chroot, extra_args)
66
67 def doRunBuild(self):
68 """Run the sbuild process to build the package."""
69 args = ["sbuild-package", self._buildid, self.arch_tag]
70 if self.suite:
71 args.extend([self.suite])
72 args.extend(self._sbuildargs)
73 args.extend(["--dist=" + self.suite])
74 else:
75 args.extend(['autobuild'])
76 args.extend(self._sbuildargs)
77 args.extend(["--dist=autobuild"])
78 if self.arch_indep:
79 args.extend(["-A"])
80 if self.archive_purpose:
81 args.extend(["--purpose=" + self.archive_purpose])
82 if self.build_debug_symbols:
83 args.extend(["--build-debug-symbols"])
84 args.extend(["--architecture=" + self.arch_tag])
85 args.extend(["--comp=" + self.component])
86 args.extend([self._dscfile])
87 self.runSubProcess( self._sbuildpath, args )
88
89 def iterate_SBUILD(self, success):
90 """Finished the sbuild run."""
91 tmpLog = self.getTmpLogContents()
92 if success != SBuildExitCodes.OK:
93 if (success == SBuildExitCodes.DEPFAIL or
94 success == SBuildExitCodes.PACKAGEFAIL):
95 for rx in BuildLogRegexes.GIVENBACK:
96 mo = re.search(rx, tmpLog, re.M)
97 if mo:
98 success = SBuildExitCodes.GIVENBACK
99
100 if success == SBuildExitCodes.DEPFAIL:
101 for rx, dep in BuildLogRegexes.DEPFAIL:
102 mo = re.search(rx, tmpLog, re.M)
103 if mo:
104 if not self.alreadyfailed:
105 print("Returning build status: DEPFAIL")
106 print("Dependencies: " + mo.expand(dep))
107 self._slave.depFail(mo.expand(dep))
108 success = SBuildExitCodes.DEPFAIL
109 break
110 else:
111 success = SBuildExitCodes.PACKAGEFAIL
112
113 if success == SBuildExitCodes.GIVENBACK:
114 if not self.alreadyfailed:
115 print("Returning build status: GIVENBACK")
116 self._slave.giveBack()
117 elif success == SBuildExitCodes.PACKAGEFAIL:
118 if not self.alreadyfailed:
119 print("Returning build status: PACKAGEFAIL")
120 self._slave.buildFail()
121 elif success >= SBuildExitCodes.BUILDERFAIL:
122 # anything else is assumed to be a buildd failure
123 if not self.alreadyfailed:
124 print("Returning build status: BUILDERFAIL")
125 self._slave.builderFail()
126 self.alreadyfailed = True
127 self._state = DebianBuildState.REAP
128 self.doReapProcesses()
129 else:
130 print("Returning build status: OK")
131 self.gatherResults()
132 self._state = DebianBuildState.REAP
133 self.doReapProcesses()
1340
=== removed file 'lib/canonical/buildd/buildd-config.py'
--- lib/canonical/buildd/buildd-config.py 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/buildd-config.py 1970-01-01 00:00:00 +0000
@@ -1,54 +0,0 @@
1#!/usr/bin/python
2#
3# Copyright 2009 Canonical Ltd. This software is licensed under the
4# GNU Affero General Public License version 3 (see the file LICENSE).
5
6import os
7
8archtag = os.popen("dpkg --print-architecture").read().strip()
9
10from optparse import OptionParser
11
12parser = OptionParser()
13parser.add_option("-n", "--name", dest="NAME",
14 help="the name for this buildd",
15 metavar="NAME",
16 default="default")
17
18parser.add_option("-H", "--host", dest="BINDHOST",
19 help="the IP/host this buildd binds to",
20 metavar="HOSTNAME",
21 default="localhost")
22
23parser.add_option("-p", "--port", dest="BINDPORT",
24 help="the port this buildd binds to",
25 metavar="PORT",
26 default="8221")
27
28parser.add_option("-a", "--arch", dest="ARCHTAG",
29 help="the arch tag this buildd claims",
30 metavar="ARCHTAG",
31 default=archtag)
32
33parser.add_option("-t", "--template", dest="TEMPLATE",
34 help="the template file to use",
35 metavar="FILE",
36 default="/usr/share/launchpad-buildd/template-buildd-slave.conf")
37
38(options, args) = parser.parse_args()
39
40template = open(options.TEMPLATE, "r").read()
41
42replacements = {
43 "@NAME@": options.NAME,
44 "@BINDHOST@": options.BINDHOST,
45 "@ARCHTAG@": options.ARCHTAG,
46 "@BINDPORT@": options.BINDPORT,
47 }
48
49for replacement_key in replacements:
50 template = template.replace(replacement_key,
51 replacements[replacement_key])
52
53print template
54
550
=== removed file 'lib/canonical/buildd/buildd-slave-example.conf'
--- lib/canonical/buildd/buildd-slave-example.conf 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/buildd-slave-example.conf 1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4# Example buildd slave configuration
5# This should be refactored into a nice central configuration format when
6# such a beast becomes available
7
8[slave]
9architecturetag = i386
10filecache = /home/buildd/filecache
11bindhost = localhost
12bindport = 8221
13
14[allmanagers]
15unpackpath = /home/buildd/slavebin/unpack-chroot
16cleanpath = /home/buildd/slavebin/remove-build
17mountpath = /home/buildd/slavebin/mount-chroot
18umountpath = /home/buildd/slavebin/umount-chroot
19
20[debianmanager]
21sbuildpath = /home/buildd/slavebin/sbuild-package
22sbuildargs = -dautobuild --nolog --batch -A
23updatepath = /home/buildd/slavebin/update-debian-chroot
24processscanpath = /home/buildd/slavebin/scan-for-processes
25ogrepath = /home/buildd/slavebin/apply-ogre-model
260
=== removed file 'lib/canonical/buildd/buildd-slave.tac'
--- lib/canonical/buildd/buildd-slave.tac 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/buildd-slave.tac 1970-01-01 00:00:00 +0000
@@ -1,55 +0,0 @@
1# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4# CAUTION: The only modules in the Launchpad tree that this is permitted to
5# depend on are canonical.buildd, since buildds are deployed by copying that
6# directory only. (See also bug=800295.)
7
8# Buildd Slave implementation
9# XXX: dsilvers: 2005/01/21: Currently everything logged in the slave gets
10# passed through to the twistd log too. this could get dangerous/big
11
12from twisted.application import service, strports
13from canonical.buildd import XMLRPCBuildDSlave
14from canonical.buildd.binarypackage import BinaryPackageBuildManager
15from canonical.buildd.sourcepackagerecipe import (
16 SourcePackageRecipeBuildManager)
17from canonical.buildd.translationtemplates import (
18 TranslationTemplatesBuildManager)
19
20from twisted.web import server, resource, static
21from ConfigParser import SafeConfigParser
22
23import os
24
25conffile = os.environ.get('BUILDD_SLAVE_CONFIG', 'buildd-slave-example.conf')
26
27conf = SafeConfigParser()
28conf.read(conffile)
29slave = XMLRPCBuildDSlave(conf)
30
31# 'debian' is the old name. It remains here for compatibility.
32slave.registerBuilder(BinaryPackageBuildManager, "debian")
33slave.registerBuilder(BinaryPackageBuildManager, "binarypackage")
34slave.registerBuilder(SourcePackageRecipeBuildManager, "sourcepackagerecipe")
35slave.registerBuilder(
36 TranslationTemplatesBuildManager, 'translation-templates')
37
38application = service.Application('BuildDSlave')
39builddslaveService = service.IServiceCollection(application)
40
41root = resource.Resource()
42root.putChild('rpc', slave)
43root.putChild('filecache', static.File(conf.get('slave', 'filecache')))
44slavesite = server.Site(root)
45
46strports.service(slave.slave._config.get("slave","bindport"),
47 slavesite).setServiceParent(builddslaveService)
48
49# You can interact with a running slave like this:
50# (assuming the slave is on localhost:8221)
51#
52# python
53# import xmlrpclib
54# s = xmlrpclib.ServerProxy("http://localhost:8221/rpc")
55# s.echo("Hello World")
560
=== removed file 'lib/canonical/buildd/buildrecipe'
--- lib/canonical/buildd/buildrecipe 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/buildrecipe 1970-01-01 00:00:00 +0000
@@ -1,220 +0,0 @@
1#! /usr/bin/env python -u
2# Copyright 2010, 2011 Canonical Ltd. This software is licensed under the
3# GNU Affero General Public License version 3 (see the file LICENSE).
4
5"""A script that builds a package from a recipe and a chroot."""
6
7__metaclass__ = type
8
9
10import os
11import os.path
12import pwd
13from resource import RLIMIT_AS, setrlimit
14import socket
15from subprocess import (
16 Popen,
17 call,
18 )
19import sys
20
21
22RETCODE_SUCCESS = 0
23RETCODE_FAILURE_INSTALL = 200
24RETCODE_FAILURE_BUILD_TREE = 201
25RETCODE_FAILURE_INSTALL_BUILD_DEPS = 202
26RETCODE_FAILURE_BUILD_SOURCE_PACKAGE = 203
27
28
29class NotVirtualized(Exception):
30 """Exception raised when not running in a virtualized environment."""
31
32 def __init__(self):
33 Exception.__init__(self, 'Not running under Xen.')
34
35
36def call_report_rusage(args):
37 """Run a subprocess.
38
39 Report that it was run, and the resources used, and complain if it fails.
40
41 :return: The process wait status.
42 """
43 print 'RUN %r' % args
44 proc = Popen(args)
45 pid, status, rusage = os.wait4(proc.pid, 0)
46 print(rusage)
47 return status
48
49
50class RecipeBuilder:
51 """Builds a package from a recipe."""
52
53 def __init__(self, build_id, author_name, author_email,
54 suite, distroseries_name, component, archive_purpose):
55 """Constructor.
56
57 :param build_id: The id of the build (a str).
58 :param author_name: The name of the author (a str).
59 :param author_email: The email address of the author (a str).
60 :param suite: The suite the package should be built for (a str).
61 """
62 self.build_id = build_id
63 self.author_name = author_name.decode('utf-8')
64 self.author_email = author_email
65 self.archive_purpose = archive_purpose
66 self.component = component
67 self.distroseries_name = distroseries_name
68 self.suite = suite
69 self.base_branch = None
70 self.chroot_path = get_build_path(build_id, 'chroot-autobuild')
71 self.work_dir_relative = os.environ['HOME'] + '/work'
72 self.work_dir = os.path.join(self.chroot_path,
73 self.work_dir_relative[1:])
74 self.tree_path = os.path.join(self.work_dir, 'tree')
75 self.username = pwd.getpwuid(os.getuid())[0]
76
77 def install(self):
78 """Install all the requirements for building recipes.
79
80 :return: A retcode from apt.
81 """
82 # XXX: AaronBentley 2010-07-07 bug=602463: pbuilder uses aptitude but
83 # does not depend on it.
84 return self.chroot([
85 'apt-get', 'install', '-y', 'pbuilder', 'aptitude'])
86
87 def buildTree(self):
88 """Build the recipe into a source tree.
89
90 As a side-effect, sets self.source_dir_relative.
91 :return: a retcode from `bzr dailydeb`.
92 """
93 try:
94 ensure_virtualized()
95 except NotVirtualized, e:
96 sys.stderr.write('Aborting on failed virtualization check:\n')
97 sys.stderr.write(str(e))
98 return 1
99 assert not os.path.exists(self.tree_path)
100 recipe_path = os.path.join(self.work_dir, 'recipe')
101 manifest_path = os.path.join(self.tree_path, 'manifest')
102 recipe_file = open(recipe_path, 'rb')
103 try:
104 recipe = recipe_file.read()
105 finally:
106 recipe_file.close()
107 # As of bzr 2.2, a defined identity is needed. In this case, we're
108 # using buildd@<hostname>.
109 hostname = socket.gethostname()
110 bzr_email = 'buildd@%s' % hostname
111
112 print 'Bazaar versions:'
113 check_call(['bzr', 'version'])
114 check_call(['bzr', 'plugins'])
115
116 print 'Building recipe:'
117 print recipe
118 sys.stdout.flush()
119 env = {
120 'DEBEMAIL': self.author_email,
121 'DEBFULLNAME': self.author_name.encode('utf-8'),
122 'BZR_EMAIL': bzr_email}
123 retcode = call_report_rusage([
124 'bzr', 'dailydeb', '--safe', '--no-build', recipe_path,
125 self.tree_path, '--manifest', manifest_path,
126 '--allow-fallback-to-native', '--append-version',
127 '~%s1' % self.distroseries_name], env=env)
128 if retcode != 0:
129 return retcode
130 (source,) = [name for name in os.listdir(self.tree_path)
131 if name != 'manifest']
132 self.source_dir_relative = os.path.join(
133 self.work_dir_relative, 'tree', source)
134 return retcode
135
136 def getPackageName(self):
137 source_dir = os.path.join(
138 self.chroot_path, self.source_dir_relative.lstrip('/'))
139 changelog = os.path.join(source_dir, 'debian/changelog')
140 return open(changelog, 'r').readline().split(' ')[0]
141
142 def installBuildDeps(self):
143 """Install the build-depends of the source tree."""
144 package = self.getPackageName()
145 currently_building_path = os.path.join(
146 self.chroot_path, 'CurrentlyBuilding')
147 currently_building_contents = (
148 'Package: %s\n'
149 'Suite: %s\n'
150 'Component: %s\n'
151 'Purpose: %s\n'
152 'Build-Debug-Symbols: no\n' %
153 (package, self.suite, self.component, self.archive_purpose))
154 currently_building = open(currently_building_path, 'w')
155 currently_building.write(currently_building_contents)
156 currently_building.close()
157 return self.chroot(['sh', '-c', 'cd %s &&'
158 '/usr/lib/pbuilder/pbuilder-satisfydepends'
159 % self.source_dir_relative])
160
161 def chroot(self, args, echo=False):
162 """Run a command in the chroot.
163
164 :param args: the command and arguments to run.
165 :return: the status code.
166 """
167 if echo:
168 print "Running in chroot: %s" % ' '.join(
169 "'%s'" % arg for arg in args)
170 sys.stdout.flush()
171 return call([
172 '/usr/bin/sudo', '/usr/sbin/chroot', self.chroot_path] + args)
173
174 def buildSourcePackage(self):
175 """Build the source package.
176
177 :return: a retcode from dpkg-buildpackage.
178 """
179 retcode = self.chroot([
180 'su', '-c', 'cd %s && /usr/bin/dpkg-buildpackage -i -I -us -uc -S'
181 % self.source_dir_relative, self.username])
182 for filename in os.listdir(self.tree_path):
183 path = os.path.join(self.tree_path, filename)
184 if os.path.isfile(path):
185 os.rename(path, get_build_path(self.build_id, filename))
186 return retcode
187
188
189def get_build_path(build_id, *extra):
190 """Generate a path within the build directory.
191
192 :param build_id: the build id to use.
193 :param extra: the extra path segments within the build directory.
194 :return: the generated path.
195 """
196 return os.path.join(
197 os.environ["HOME"], "build-" + build_id, *extra)
198
199
200def ensure_virtualized():
201 """Raise an exception if not running in a virtualized environment.
202
203 Raises if not running under Xen.
204 """
205 if not os.path.isdir('/proc/xen') or os.path.exists('/proc/xen/xsd_kva'):
206 raise NotVirtualized()
207
208
209if __name__ == '__main__':
210 setrlimit(RLIMIT_AS, (1000000000, -1))
211 builder = RecipeBuilder(*sys.argv[1:])
212 if builder.buildTree() != 0:
213 sys.exit(RETCODE_FAILURE_BUILD_TREE)
214 if builder.install() != 0:
215 sys.exit(RETCODE_FAILURE_INSTALL)
216 if builder.installBuildDeps() != 0:
217 sys.exit(RETCODE_FAILURE_INSTALL_BUILD_DEPS)
218 if builder.buildSourcePackage() != 0:
219 sys.exit(RETCODE_FAILURE_BUILD_SOURCE_PACKAGE)
220 sys.exit(RETCODE_SUCCESS)
2210
=== removed file 'lib/canonical/buildd/check-implicit-pointer-functions'
--- lib/canonical/buildd/check-implicit-pointer-functions 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/check-implicit-pointer-functions 1970-01-01 00:00:00 +0000
@@ -1,118 +0,0 @@
1#!/usr/bin/env python
2
3#
4# Copyright (c) 2004 Hewlett-Packard Development Company, L.P.
5# David Mosberger <davidm@hpl.hp.com>
6# Copyright 2010 Canonical Ltd.
7#
8# Permission is hereby granted, free of charge, to any person
9# obtaining a copy of this software and associated documentation
10# files (the "Software"), to deal in the Software without
11# restriction, including without limitation the rights to use,
12# copy, modify, merge, publish, distribute, sublicense, and/or sell
13# copies of the Software, and to permit persons to whom the
14# Software is furnished to do so, subject to the following
15# conditions:
16#
17# The above copyright notice and this permission notice shall be
18# included in all copies or substantial portions of the Software.
19#
20# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27# OTHER DEALINGS IN THE SOFTWARE.
28
29# Scan standard input for GCC warning messages that are likely to
30# source of real 64-bit problems. In particular, see whether there
31# are any implicitly declared functions whose return values are later
32# interpreted as pointers. Those are almost guaranteed to cause
33# crashes.
34#
35import re
36import sys
37
38implicit_pattern = re.compile(
39 "([^:]*):(\d+):(\d+:)? warning: implicit declaration "
40 "of function [`']([^']*)'")
41pointer_pattern = re.compile(
42 "([^:]*):(\d+):(\d+:)? warning: "
43 + "("
44 + "(assignment"
45 + "|initialization"
46 + "|return"
47 + "|passing arg \d+ of `[^']*'"
48 + "|passing arg \d+ of pointer to function"
49 + ") makes pointer from integer without a cast"
50 + "|"
51 + "cast to pointer from integer of different size)")
52
53def main():
54 last_implicit_filename = ""
55 last_implicit_linenum = -1
56 last_implicit_func = ""
57
58 errlist = ""
59
60 in_line = False
61 warn_only = False
62
63 for arg in sys.argv[1:]:
64 if arg == '--inline':
65 in_line = True
66 elif arg == '--warnonly':
67 warn_only = True
68
69 rv = 0
70 while True:
71 line = sys.stdin.readline()
72 if in_line:
73 sys.stdout.write(line)
74 sys.stdout.flush()
75 if line == '':
76 break
77 m = implicit_pattern.match(line)
78 if m:
79 last_implicit_filename = m.group(1)
80 last_implicit_linenum = int(m.group(2))
81 last_implicit_func = m.group(4)
82 else:
83 m = pointer_pattern.match(line)
84 if m:
85 pointer_filename = m.group(1)
86 pointer_linenum = int(m.group(2))
87 if (last_implicit_filename == pointer_filename
88 and last_implicit_linenum == pointer_linenum):
89 err = "Function `%s' implicitly converted to pointer at " \
90 "%s:%d" % (last_implicit_func, last_implicit_filename,
91 last_implicit_linenum)
92 errlist += err+"\n"
93 print err
94 if not warn_only:
95 rv = 3
96
97 if len(errlist):
98 if in_line:
99 print errlist
100 print """
101
102Our automated build log filter detected the problem(s) above that will
103likely cause your package to segfault on architectures where the size of
104a pointer is greater than the size of an integer, such as ia64 and amd64.
105
106This is often due to a missing function prototype definition.
107
108Since use of implicitly converted pointers is always fatal to the application
109on ia64, they are errors. Please correct them for your next upload.
110
111More information can be found at:
112http://wiki.debian.org/ImplicitPointerConversions
113
114 """
115 sys.exit(rv)
116
117if __name__ == '__main__':
118 main()
1190
=== removed symlink 'lib/canonical/buildd/check_implicit_pointer_functions.py'
=== target was u'check-implicit-pointer-functions'
=== removed directory 'lib/canonical/buildd/debian'
=== removed file 'lib/canonical/buildd/debian.py'
--- lib/canonical/buildd/debian.py 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/debian.py 1970-01-01 00:00:00 +0000
@@ -1,239 +0,0 @@
1# Copyright 2009, 2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4# Authors: Daniel Silverstone <daniel.silverstone@canonical.com>
5# and Adam Conrad <adam.conrad@canonical.com>
6
7# Buildd Slave sbuild manager implementation
8
9__metaclass__ = type
10
11import os
12
13from canonical.buildd.slave import (
14 BuildManager,
15 )
16
17
18class DebianBuildState:
19 """States for the DebianBuildManager."""
20 INIT = "INIT"
21 UNPACK = "UNPACK"
22 MOUNT = "MOUNT"
23 SOURCES = "SOURCES"
24 UPDATE = "UPDATE"
25 REAP = "REAP"
26 UMOUNT = "UMOUNT"
27 CLEANUP = "CLEANUP"
28
29
30class DebianBuildManager(BuildManager):
31 """Base behaviour for Debian chrooted builds."""
32
33 def __init__(self, slave, buildid):
34 BuildManager.__init__(self, slave, buildid)
35 self._updatepath = slave._config.get("debianmanager", "updatepath")
36 self._scanpath = slave._config.get("debianmanager", "processscanpath")
37 self._sourcespath = slave._config.get("debianmanager", "sourcespath")
38 self._cachepath = slave._config.get("slave","filecache")
39 self._state = DebianBuildState.INIT
40 slave.emptyLog()
41 self.alreadyfailed = False
42
43 @property
44 def initial_build_state(self):
45 raise NotImplementedError()
46
47 def initiate(self, files, chroot, extra_args):
48 """Initiate a build with a given set of files and chroot."""
49
50 self.arch_tag = extra_args.get('arch_tag', self._slave.getArch())
51 self.sources_list = extra_args.get('archives')
52
53 BuildManager.initiate(self, files, chroot, extra_args)
54
55 def doSourcesList(self):
56 """Override apt/sources.list.
57
58 Mainly used for PPA builds.
59 """
60 args = ["override-sources-list", self._buildid]
61 args.extend(self.sources_list)
62 self.runSubProcess(self._sourcespath, args)
63
64 def doUpdateChroot(self):
65 """Perform the chroot upgrade."""
66 self.runSubProcess(
67 self._updatepath,
68 ["update-debian-chroot", self._buildid, self.arch_tag])
69
70 def doRunBuild(self):
71 """Run the main build process.
72
73 Subclasses must override this.
74 """
75 raise NotImplementedError()
76
77 def doReapProcesses(self):
78 """Reap any processes left lying around in the chroot."""
79 self.runSubProcess( self._scanpath, [self._scanpath, self._buildid] )
80
81 @staticmethod
82 def _parseChangesFile(linesIter):
83 """A generator that iterates over files listed in a changes file.
84
85 :param linesIter: an iterable of lines in a changes file.
86 """
87 seenfiles = False
88 for line in linesIter:
89 if line.endswith("\n"):
90 line = line[:-1]
91 if not seenfiles and line.startswith("Files:"):
92 seenfiles = True
93 elif seenfiles:
94 if not line.startswith(' '):
95 break
96 filename = line.split(' ')[-1]
97 yield filename
98
99 def getChangesFilename(self):
100 changes = self._dscfile[:-4] + "_" + self.arch_tag + ".changes"
101 return get_build_path(self._buildid, changes)
102
103 def gatherResults(self):
104 """Gather the results of the build and add them to the file cache.
105
106 The primary file we care about is the .changes file. We key from there.
107 """
108 path = self.getChangesFilename()
109 name = os.path.basename(path)
110 chfile = open(path, "r")
111 self._slave.waitingfiles[name] = self._slave.storeFile(chfile.read())
112 chfile.seek(0)
113 seenfiles = False
114
115 for fn in self._parseChangesFile(chfile):
116 self._slave.addWaitingFile(get_build_path(self._buildid, fn))
117
118 chfile.close()
119
120 def iterate(self, success):
121 # When a Twisted ProcessControl class is killed by SIGTERM,
122 # which we call 'build process aborted', 'None' is returned as
123 # exit_code.
124 print ("Iterating with success flag %s against stage %s"
125 % (success, self._state))
126 func = getattr(self, "iterate_" + self._state, None)
127 if func is None:
128 raise ValueError, "Unknown internal state " + self._state
129 func(success)
130
131 def iterate_INIT(self, success):
132 """Just finished initializing the build."""
133 if success != 0:
134 if not self.alreadyfailed:
135 # The init failed, can't fathom why that would be...
136 self._slave.builderFail()
137 self.alreadyfailed = True
138 self._state = DebianBuildState.CLEANUP
139 self.doCleanup()
140 else:
141 self._state = DebianBuildState.UNPACK
142 self.doUnpack()
143
144 def iterate_UNPACK(self, success):
145 """Just finished unpacking the tarball."""
146 if success != 0:
147 if not self.alreadyfailed:
148 # The unpack failed for some reason...
149 self._slave.chrootFail()
150 self.alreadyfailed = True
151 self._state = DebianBuildState.CLEANUP
152 self.doCleanup()
153 else:
154 self._state = DebianBuildState.MOUNT
155 self.doMounting()
156
157 def iterate_MOUNT(self, success):
158 """Just finished doing the mounts."""
159 if success != 0:
160 if not self.alreadyfailed:
161 self._slave.chrootFail()
162 self.alreadyfailed = True
163 self._state = DebianBuildState.UMOUNT
164 self.doUnmounting()
165 else:
166 if self.sources_list is not None:
167 self._state = DebianBuildState.SOURCES
168 self.doSourcesList()
169 else:
170 self._state = DebianBuildState.UPDATE
171 self.doUpdateChroot()
172
173 def getTmpLogContents(self):
174 try:
175 tmpLogHandle = open(os.path.join(self._cachepath, "buildlog"))
176 return tmpLogHandle.read()
177 finally:
178 tmpLogHandle.close()
179
180 def iterate_SOURCES(self, success):
181 """Just finished overwriting sources.list."""
182 if success != 0:
183 if not self.alreadyfailed:
184 self._slave.chrootFail()
185 self.alreadyfailed = True
186 self._state = DebianBuildState.REAP
187 self.doReapProcesses()
188 else:
189 self._state = DebianBuildState.UPDATE
190 self.doUpdateChroot()
191
192 def iterate_UPDATE(self, success):
193 """Just finished updating the chroot."""
194 if success != 0:
195 if not self.alreadyfailed:
196 self._slave.chrootFail()
197 self.alreadyfailed = True
198 self._state = DebianBuildState.REAP
199 self.doReapProcesses()
200 else:
201 self._state = self.initial_build_state
202 self.doRunBuild()
203
204 def iterate_REAP(self, success):
205 """Finished reaping processes; ignore error returns."""
206 self._state = DebianBuildState.UMOUNT
207 self.doUnmounting()
208
209 def iterate_UMOUNT(self, success):
210 """Just finished doing the unmounting."""
211 if success != 0:
212 if not self.alreadyfailed:
213 self._slave.builderFail()
214 self.alreadyfailed = True
215 self._state = DebianBuildState.CLEANUP
216 self.doCleanup()
217
218 def iterate_CLEANUP(self, success):
219 """Just finished the cleanup."""
220 if success != 0:
221 if not self.alreadyfailed:
222 self._slave.builderFail()
223 self.alreadyfailed = True
224 else:
225 # Successful clean
226 if not self.alreadyfailed:
227 self._slave.buildOK()
228 self._slave.buildComplete()
229
230
231def get_build_path(build_id, *extra):
232 """Generate a path within the build directory.
233
234 :param build_id: the build id to use.
235 :param extra: the extra path segments within the build directory.
236 :return: the generated path.
237 """
238 return os.path.join(
239 os.environ["HOME"], "build-" + build_id, *extra)
2400
=== removed file 'lib/canonical/buildd/debian/changelog'
--- lib/canonical/buildd/debian/changelog 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/debian/changelog 1970-01-01 00:00:00 +0000
@@ -1,698 +0,0 @@
1launchpad-buildd (82) hardy-cat; urgency=low
2
3 * Cut out readyservice from the buildds. LP: #800295
4 * buildrecipe shows the bzr and bzr-builder versions. LP: #884092
5 * buildrecipe shows bzr rusage. LP: 884997
6
7 -- Martin Pool <mbp@canonical.com> Thu, 03 Nov 2011 17:11:25 +1100
8
9launchpad-buildd (81) hardy-cat; urgency=low
10
11 * generate-translation-templates: switch to Python 2.7.
12
13 -- Danilo Å egan <danilo@canonical.com> Mon, 17 Oct 2011 14:46:13 +0200
14
15launchpad-buildd (80) hardy-cat; urgency=low
16
17 * binfmt-support demonstrated umount ordering issues for us. LP: #851934
18
19 -- LaMont Jones <lamont@canonical.com> Mon, 19 Sep 2011 04:56:58 -0600
20
21launchpad-buildd (79) hardy-cat; urgency=low
22
23 * Fix sudoers.d/buildd permissions
24
25 -- LaMont Jones <lamont@canonical.com> Fri, 19 Aug 2011 07:31:54 -0600
26
27launchpad-buildd (78) hardy-cat; urgency=low
28
29 * Correctly update sudoers files when needed. LP: #742881
30
31 -- LaMont Jones <lamont@canonical.com> Wed, 06 Apr 2011 22:20:17 -0600
32
33launchpad-buildd (77) hardy-cat; urgency=low
34
35 * Add back in ultimate-backstop umask() correction.
36
37 -- LaMont Jones <lamont@canonical.com> Wed, 06 Apr 2011 13:34:05 -0600
38
39launchpad-buildd (76) hardy-cat; urgency=low
40
41 [ various ]
42 * ProjectGroup.products sort order and remove Author: comments.
43 * Fix some tests to not print stuff
44 * Make buildd pointer check regexes work on natty
45 * merge before rollout + text conflict patch by wgrant
46
47 -- LaMont Jones <lamont@canonical.com> Tue, 15 Mar 2011 16:59:36 -0600
48
49launchpad-buildd (74) hardy-cat; urgency=low
50
51 [ Aaron Bentley]
52 * Memory-limit recipe builds. LP#676657
53
54 [ LaMont Jones]
55 * mount a tmpfs on /dev/shm in build chroots. LP#671441
56
57 [Michael Bienia]
58 * Update regexes used for DEPWAIT. LP#615286
59
60 -- LaMont Jones <lamont@canonical.com> Tue, 23 Nov 2010 06:17:57 -0700
61
62launchpad-buildd (73) hardy-cat; urgency=low
63
64 * Revert to revision 70
65
66 -- LaMont Jones <lamont@canonical.com> Thu, 28 Oct 2010 12:53:45 -0600
67
68launchpad-buildd (72) hardy-cat; urgency=low
69
70 * break out readyservice.py from tachandler.py. LP#663828
71
72 -- LaMont Jones <lamont@canonical.com> Wed, 20 Oct 2010 13:03:23 -0600
73
74launchpad-buildd (71) hardy-cat; urgency=low
75
76 * Detect ppa hosts for build recipes. LP#662664
77 * Better recipe builds. LP#599100, 627119, 479705
78
79 -- LaMont Jones <lamont@canonical.com> Tue, 19 Oct 2010 13:48:33 -0600
80
81launchpad-buildd (70) hardy-cat; urgency=low
82
83 [ LaMont Jones ]
84 * Restore the rest of version 68.
85
86 [ James Westby ]
87 * buildrecipe: Specify BZR_EMAIL via sudo so that the called command
88 sees the environment variable.
89 * buildrecipe: call sudo -i -u instead of sudo -iu so that it works with
90 older versions of sudo.
91 * buildrecipe: flush stdout before calling another command so that
92 the build log has the output correctly interleaved.
93
94 [ William Grant ]
95 * correct arch_tag arguments.
96
97 -- LaMont Jones <lamont@canonical.com> Fri, 20 Aug 2010 13:27:55 -0600
98
99launchpad-buildd (69) hardy-cat; urgency=low
100
101 * REVERT all of version 68 except for BZR_EMAIL LP#617072
102 (Not reflected in bzr.)
103
104 -- LaMont Jones <lamont@canonical.com> Tue, 17 Aug 2010 10:40:03 -0600
105
106launchpad-buildd (68) hardy-cat; urgency=low
107
108 [ William Grant ]
109 * Take an 'arch_tag' argument, so the master can override the slave
110 architecture.
111
112 [ Jelmer Vernooij ]
113
114 * Explicitly use source format 1.0.
115 * Add LSB information to init script.
116 * Use debhelper >= 5 (available in dapper, not yet deprecated in
117 maverick).
118 * Fix spelling in description.
119 * Install example buildd configuration.
120
121 [ Paul Hummer ]
122 * Provide BZR_EMAIL for bzr 2.2 in the buildds LP#617072
123
124 -- LaMont Jones <lamont@canonical.com> Mon, 16 Aug 2010 13:25:09 -0600
125
126launchpad-buildd (67) hardy-cat; urgency=low
127
128 * Force aptitude installation for recipe builds on maverick
129
130 -- LaMont Jones <lamont@canonical.com> Fri, 23 Jul 2010 14:22:23 -0600
131
132launchpad-buildd (66) hardy-cat; urgency=low
133
134 * handle [linux-any] build-dependencies. LP#604981
135
136 -- LaMont Jones <lamont@canonical.com> Mon, 19 Jul 2010 12:13:31 -0600
137
138launchpad-buildd (65) hardy-cat; urgency=low
139
140 * Drop preinst check, since human time does not scale across a large
141 rollout. soyuz just needs to deal with upgrades mid-build better.
142
143 -- LaMont Jones <lamont@canonical.com> Thu, 08 Jul 2010 05:04:02 -0600
144
145launchpad-buildd (64) hardy-cat; urgency=low
146
147 * Pottery now strips quotes from variables.
148
149 -- Jeroen Vermeulen <jtv@canonical.com> Wed, 30 Jun 2010 12:50:59 +0200
150
151launchpad-buildd (63) hardy-cat; urgency=low
152
153 * Drop apply-ogre-model, since override-sources-list replaced it three years
154 ago. Also clean up extra_args parsing a bit.
155
156 -- William Grant <wgrant@ubuntu.com> Sat, 12 Jun 2010 11:33:11 +1000
157
158launchpad-buildd (62) hardy-cat; urgency=low
159
160 * Make the buildds cope with not having a sourcepackagename LP#587109
161
162 -- LaMont Jones <lamont@canonical.com> Tue, 08 Jun 2010 13:02:31 -0600
163
164launchpad-buildd (61) hardy-cat; urgency=high
165
166 [ William Grant ]
167 * Fixed translation templates slave to return files properly. LP#549422
168
169 [ Danilo Segan ]
170 * Added more output to generate-translation-templates. LP#580345
171
172 [ Henning Eggers ]
173 * Improved output of build xmplrpc call, not returning None now. LP#581746
174 * Added apache2 dependency. LP#557634
175 * Added preinst script to prevent installation when a build is running.
176 LP#557347
177
178 [ LaMont Jones ]
179 * preinst needs to detect a stale buildlog as well.
180
181 -- LaMont Jones <lamont@canonical.com> Fri, 21 May 2010 05:52:53 -0600
182
183launchpad-buildd (60) lucid-cat; urgency=low
184
185 * Depends: lsb-release, which is ubuntu-minimal, but not essential.
186
187 -- LaMont Jones <lamont@ubuntu.com> Thu, 01 Apr 2010 08:54:48 -0600
188
189launchpad-buildd (59) lucid-cat; urgency=low
190
191 [ Henning Eggers ]
192 * Added translation template generation code (pottery).
193
194 [ LaMont Jones ]
195 * set umask for twisted where supported
196
197 -- LaMont Jones <lamont@canonical.com> Wed, 31 Mar 2010 10:38:15 -0600
198
199launchpad-buildd (58~1) karmic; urgency=low
200
201 * Misc fixes to match APIs.
202
203 -- Aaron Bentley <aaron@aaronbentley.com> Fri, 15 Jan 2010 10:03:07 +1300
204
205launchpad-buildd (58~0) karmic; urgency=low
206
207 * Include buildrecipe.py.
208
209 -- Aaron Bentley <aaron@aaronbentley.com> Wed, 13 Jan 2010 17:06:59 +1300
210
211launchpad-buildd (57) hardy-cat; urgency=low
212
213 * Split the sbuild wrapper from DebianBuildManager into a new
214 BinaryPackageBuildManager, and point the 'debian' builder at that
215 instead.
216
217 -- William Grant <wgrant@ubuntu.com> Tue, 12 Jan 2010 09:22:50 +1300
218
219launchpad-buildd (56) hardy-cat; urgency=low
220
221 * only error out on implicit-function-pointers check on lucid or later,
222 non-32-bit architectures. Warnings elsewhere. LP#504078
223 * drop use of ccache and /var/cache/apt/archives, since we don't use one,
224 and the other is just plain silly.
225
226 -- LaMont Jones <lamont@canonical.com> Mon, 11 Jan 2010 13:12:49 -0700
227
228launchpad-buildd (54) hardy-cat; urgency=low
229
230 [ William Grant ]
231 * debian.py: Tell sbuild to build debug symbols if the
232 build_debug_symbols argument is True.
233 * sbuild: Set "Build-Debug-Symbols: yes" in CurrentlyBuilding if
234 we have been told to build debug symbols.
235
236 [ LaMont Jones ]
237 * do not ignore SIGHUP in builds - it breaks test suites. LP#453460
238 * create filecache-default/ccache directories in init.d as well as postinst
239 * sbuild: run dpkg-source inside the chroot. LP#476036
240 * sbuild: change the regexp for dpkg-source extraction to handle both karmic and pre-karmic dpkg. LP#476036
241 * use --print-architecture instead of --print-installation-architecture
242 * mount-chroot: copy hosts et al into chroot. LP#447919
243 * provide and call check-implicit-function-pointers.
244
245 -- LaMont Jones <lamont@canonical.com> Mon, 14 Dec 2009 12:00:10 -0700
246
247launchpad-buildd (52) dapper-cat; urgency=low
248
249 * Depends: apt-transport-https
250
251 -- LaMont Jones <lamont@canonical.com> Fri, 09 Oct 2009 11:00:50 -0600
252
253launchpad-buildd (50) dapper-cat; urgency=low
254
255 * sbuild: Change all invocations of apt and dpkg to occur inside
256 the build chroot, rather than happening outside the chroot with
257 a bunch of flags to operate on data files in the chroot. This
258 should clear up issues we see with mismatched host toolchains.
259 * sbuild: Revert the above in the case of "apt-get source" which
260 doesn't require any fancy features in the chroot and, frankly,
261 is much easier to manage if it's executed externally.
262 * scan-for-processes: Bring in a change from production to make
263 sure that we follow symlinks in our search for process roots.
264 * sbuild-package: Output NR_PROCESSORS in the build logs, for
265 sightly easier debugging of possible parallel build bugs.
266 * update-debian-chroot: Stop using chapt-get, and instead chroot
267 into the build chroot and call the native apt-get there.
268 * update-debian-chroot: Cargo-cult the linux32 magic from the
269 sbuild wrapper to set our personality on chroot upgrades.
270 * mount-chroot: Mount sys in the chroot too. While it shouldn't
271 be, strictly-speaking, required for anything, it's nice to have.
272 * chapt-get, slave_chroot_tool.py: Delete both as obsolete cruft.
273
274 -- Adam Conrad <adconrad@ubuntu.com> Fri, 24 Jul 2009 07:21:30 -0600
275
276launchpad-buildd (49) dapper-cat; urgency=low
277
278 * sbuild.conf: bump default automake from automake1.8 to automake1.9
279
280 -- Adam Conrad <adconrad@ubuntu.com> Fri, 12 Sep 2008 08:54:24 -0600
281
282launchpad-buildd (48) dapper-cat; urgency=low
283
284 * sbuild-package: If we're an amd64 host system, but being used
285 to build i386 or lpia, use linux32 to pretend to be i686.
286
287 -- Adam Conrad <adconrad@ubuntu.com> Fri, 12 Sep 2008 08:12:34 -0600
288
289launchpad-buildd (47) dapper-cat; urgency=low
290
291 * slave.py: If the logfile doesn't currently exist on disk when
292 getLogTail() goes looking for it (which is a possible race with
293 the new sanitisation code), just return an empty string.
294
295 -- Adam Conrad <adconrad@ubuntu.com> Mon, 02 Jun 2008 13:09:55 -0600
296
297launchpad-buildd (46) dapper-cat; urgency=low
298
299 * slave.py: Accept a separate username and password to the
300 ensurePresent() call which, if present, are used to install
301 an auth handler to cope with basic http auth with the http
302 server when fetching files.
303 * slave.py: Ensure that build logs are sanitized so that any
304 user:password@ parts in URLs are removed.
305
306 -- Julian Edwards <julian.edwards@canonical.com> Tue, 29 Apr 2008 14:25:00 +0100
307
308launchpad-buildd (45) dapper-cat; urgency=low
309
310 * slave.py: Stop setting BuilderStatus.WAITING in each failure
311 method, as this gives us a race where the builddmaster might
312 dispatch another build to us before we're done cleaning up.
313 * slave.py: Don't set BuildStatus.OK in buildComplete(), this is
314 now a generic "the build has ended, succesfully or not" method.
315 * slave.py: Define a new buildOK() method that sets BuildStatus.OK.
316 * debian.py: When done cleaning, if the build isn't already marked
317 as failed, call buildOK, then call buildComplete unconditionally.
318 * The above changes should resolve https://launchpad.net/bugs/179466
319
320 -- Adam Conrad <adconrad@ubuntu.com> Tue, 08 Apr 2008 14:12:07 -0600
321
322launchpad-buildd (44) dapper-cat; urgency=low
323
324 * slave.py: Redefine "private" _unpackChroot() as "public" doUnpack(),
325 so we can use it from the build iteration control process.
326 * slave.py: Make the initiate method set a _chroottarfile private
327 variable for use by doUnpack(), rather than calling _unpackChroot().
328 * slave.py: Trigger the forked buildd process with an echo statement.
329 * debian.py: Add the INIT state to the DebianBuildState class.
330 * debian.py: Start the build process at INIT state instead of UNPACK.
331 * debian.py: Add iterate_INIT(), which just checks success of the
332 initial variable sanitisation checks, then hands off to doUnpack().
333 * debian.py: Adjust the failure return calls of the UNPACK and MOUNT
334 methods to chrootFail() instead of builderFail(), for correctness.
335 * The above changes should resolve https://launchpad.net/bugs/211974
336
337 -- Adam Conrad <adconrad@ubuntu.com> Mon, 07 Apr 2008 13:53:20 -0600
338
339launchpad-buildd (43) dapper-cat; urgency=low
340
341 * unpack-chroot: Move the ntpdate calls below the bunzip/exec bit,
342 so we don't run ntpdate twice when unzipping tarballs, which
343 happens on every single build on Xen hosts (like the PPA hosts).
344 * debian/control: We use adduser in postinst, depending on it helps.
345 * debian/control: Set myself as the Maintainer, since I'm in here.
346 * debian/control: Change our section from "misc" to "admin".
347 * sbuild{,-package}: Pass DEB_BUILD_OPTIONS="parallel=N" to dpkg.
348
349 -- Adam Conrad <adconrad@ubuntu.com> Thu, 24 Jan 2008 15:39:20 -0700
350
351launchpad-buildd (42) dapper-cat; urgency=low
352
353 * sbuild: using "eq" to evaluate strings instead of "==" is ever
354 so slightly less retarded (fixed the launchpad bug #184565)
355
356 -- Adam Conrad <adconrad@ubuntu.com> Tue, 22 Jan 2008 16:21:54 -0700
357
358launchpad-buildd (41) dapper-cat; urgency=low
359
360 * sbuild: If we've already marked a package as "installed" with a
361 valid version, don't overwrite that version with PROVIDED.
362
363 -- Adam Conrad <adconrad@ubuntu.com> Thu, 17 Jan 2008 10:39:26 -0700
364
365launchpad-buildd (40) dapper-cat; urgency=low
366
367 * sbuild: Don't allow versioned build-deps to be satisfied by provided
368 packages, but force them to go through the "upgrade/downgrade" tests.
369 * sbuild: Do --info and --contents on _all.deb packages as well, if
370 we're building arch:all packages.
371 * sbuild: Don't process ENV_OVERRIDE anymore, we only had an override
372 for one thing anyway (LC_ALL), and this code caused bug #87077.
373 * sbuild-package: Call sbuild with LC_ALL=C explicitely, to compensate.
374 * Makefile: clean up the makefile a bit to DTRT (as I expect it).
375
376 -- Adam Conrad <adconrad@ubuntu.com> Tue, 15 Jan 2008 16:51:08 -0700
377
378launchpad-buildd (39) unstable; urgency=low
379
380 * If we're fed an archive_purpose argument from the builddmaster,
381 we pass --purpose=$archive_purpose to sbuild, and if we get suite
382 from the builddmaster, we pass --dist=$suite to sbuild.
383 * Mangle sbuild to write out Suite: and Purpose: stanzas to our
384 CurrentlyBuilding file, according to command-line input.
385 * Now that we're no longer always feeding -dautobuild to sbuild,
386 fix up sbuild to always look for the chroot at chroot-autobuild
387 instead of the Debian Way of using chroot-$suite.
388 * If the config file contains an ntphost stanza, use that with
389 ntpdate to sync the system's clock before we unpack the chroot.
390 * Mangle update-config to add an ntphost stanza to the default
391 config, and to 's/-dautobuild //' from the sbuild arguments.
392
393 -- Adam Conrad <adconrad@ubuntu.com> Thu, 20 Dec 2007 01:51:49 -0700
394
395launchpad-buildd (38) unstable; urgency=high
396
397 * unpack-chroot: set $PATH rather than hardcoding paths to binaries
398 since bzip2 moved from /usr/bin to /bin in edgy and didn't bother with
399 compatability symlinks.
400
401 -- James Troup <james.troup@canonical.com> Wed, 21 Nov 2007 17:08:36 +0000
402
403launchpad-buildd (37) dapper; urgency=high
404
405 * update-debian-chroot: Adam's LPIA support (i.e. overriding
406 architecture for chapt-get).
407 * debian/launchpad-buildd.cron.daily: fix run-on-line.
408 * debian/postinst: only create ~buildd/.sbuildrc if it doesn't exist.
409 This avoids the problem of upgrades of the launchpad-buildd package
410 resetting the architecture to i386 on lpia builders.
411
412 -- James Troup <james.troup@canonical.com> Wed, 14 Nov 2007 18:34:46 +0000
413
414launchpad-buildd (36) dapper; urgency=low
415
416 * changing override-sources to replace current sources.list with
417 the content sent by buildmaster instead of prepend. It will allow
418 us to cope more easily with SoyuzArchive implementation (PARTNER,
419 EMBARGOED, PPA)
420
421 -- Celso Providelo <cprov@canonical.com> Thu, 7 Aug 2007 14:10:26 -0300
422
423launchpad-buildd (35) unstable; urgency=low
424
425 * including previous code changes (32 & 33).
426
427 -- Celso Providelo <cprov@canonical.com> Thu, 23 May 2007 17:40:26 -0300
428
429launchpad-buildd (34) unstable; urgency=low
430
431 * add suport for overriding the chroot /etc/apt/sources.list with the
432 content of builddmaster build arguments 'archives'.
433
434 -- Celso Providelo <cprov@canonical.com> Thu, 17 May 2007 15:12:26 -0300
435
436launchpad-buildd (33) unstable; urgency=low
437
438 * Mangle sbuild further to allow us to publish Martin's debug debs (ddeb)
439 to public_html/ddebs/ until such a time as soyuz can do this natively.
440 * Fix the auto-dep-wait regexes to allow for versions with ~ in them.
441 * Make cron.daily clean out translations and ddebs more than 1 week old.
442
443 -- Adam Conrad <adconrad@ubuntu.com> Sat, 30 Sep 2006 17:25:25 +1000
444
445launchpad-buildd (32) unstable; urgency=low
446
447 * We need to create /var/run/launchpad-buildd in our init script in the
448 case (such as in current dapper) where /var/run is on a tmpfs.
449 * Our init script shouldn't exit non-zero on "stop" if already stopped.
450 * Remove exc_info argument from our call to self.log in slave.py, which
451 clearly doesn't support that argument, so stop producing tracebacks.
452 * Reset self.builddependencies in our clean routine, so the variable
453 doesn't get leaked to the next build, causing me SERIOUS confusion.
454 * Tidy up translation handling a bit more to deal with old chroots (where
455 pkgstriptranslations won't dpkg-distaddfile for us), and to chmod the
456 translation dirs after the build, so apache can actually get at them.
457 * Add --no_save to our command line to avoid useless -shutdown.tap files.
458 * Make sure umount-chroot doesn't fail, even if there's nothing to umount.
459 * Append to the cron.daily cleaning to also occasionally clean up the apt
460 cache and /home/buildd/filecache-default, so we don't run out of disk.
461
462 -- Adam Conrad <adconrad@ubuntu.com> Fri, 17 Mar 2006 19:39:05 +1100
463
464launchpad-buildd (31) unstable; urgency=low
465
466 * Cherry-pick patch from Ryan's sbuild that outputs dpkg --purge output
467 line-by-line, instead of as one big blob, to make output on the web
468 UI a little bit more friendly for people following along at home.
469 * Install a cron.daily script (eww) to purge old build logs for now until
470 I have the time to learn how twisted's native log rotation works.
471
472 -- Adam Conrad <adconrad@ubuntu.com> Wed, 15 Mar 2006 17:23:26 +1100
473
474launchpad-buildd (30) unstable; urgency=low
475
476 * Move our translation publishing mojo so it happens BEFORE we move
477 all the files from debian/files out of the chroot, instead of after.
478
479 -- Adam Conrad <adconrad@ubuntu.com> Wed, 8 Mar 2006 18:50:49 +1100
480
481launchpad-buildd (29) unstable; urgency=low
482
483 * Use dpkg --print-installation-architecture in our postinst instead
484 of --print-architecture to avoid spewing suprious error messages.
485 * Remove the check for log_dir, since we call sbuild with --nolog,
486 and stop creating $HOME/logs in the user setup part of postinst.
487
488 -- Adam Conrad <adconrad@ubuntu.com> Tue, 7 Mar 2006 19:13:56 +1100
489
490launchpad-buildd (28) unstable; urgency=low
491
492 * Modify the protocol method ensurepresent to return additional
493 information about the target files lookup procedure. It helps to
494 debug intermittent Librarian errors.
495
496 -- Celso Providelo <celso.providelo@canonical.com> Mon, 06 Mar 2006 16:42:00 -0300
497
498launchpad-buildd (27) unstable; urgency=low
499
500 * Update the slave chroot tool to use getent so it works on the production
501 buildds
502
503 -- Daniel Silverstone <daniel.silverstone@canonical.com> Mon, 20 Feb 2006 12:57:45 +0000
504
505launchpad-buildd (26) unstable; urgency=low
506
507 * Update buildd-slave code to allow for GIVENBACK status returns,
508 matching the states under which sbuild used to do --auto-give-back.
509 * Port over sanae's build log regex parsing to allow us to do:
510 - Automatic dep-wait handling, based on sbuild's logs of apt-get.
511 - Automatic give-backs for a few corner cases (like kernel bugs).
512 * Make sbuild stop dying if we have no sendmail installed, since we
513 don't really want it sending mail in the launchpad world anyway.
514 * Call sbuild and apt with "LANG=C", so we don't have to worry about
515 locales matching between the base system and the autobuild chroots.
516 * Clear up confusion in build states with 's/BUILDFAIL/PACKAGEFAIL/'
517
518 -- Adam Conrad <adconrad@ubuntu.com> Mon, 27 Feb 2006 14:00:08 +1100
519
520launchpad-buildd (25) unstable; urgency=low
521
522 * Update sbuild.conf to current yumminess.
523
524 -- Daniel Silverstone <daniel.silverstone@canonical.com> Fri, 3 Feb 2006 19:22:01 +0000
525
526launchpad-buildd (24) unstable; urgency=low
527
528 * Add /var/cache/apt/archives to the buildd chroots when mounting
529
530 -- Daniel Silverstone <daniel.silverstone@canonical.com> Fri, 3 Feb 2006 00:30:07 +0000
531
532launchpad-buildd (23) unstable; urgency=low
533
534 * And make apply-ogre-model use $SUDO, yay
535
536 -- Daniel Silverstone <daniel.silverstone@canonical.com> Fri, 27 Jan 2006 13:59:10 +0000
537
538launchpad-buildd (22) unstable; urgency=low
539
540 * Fix typo in apply-ogre-model (missing space)
541
542 -- Daniel Silverstone <daniel.silverstone@canonical.com> Fri, 27 Jan 2006 13:55:12 +0000
543
544launchpad-buildd (21) unstable; urgency=low
545
546 * Fix the .extend call for the --comp argument to pass it as one argument
547 instead of as - - c o m p = m a i n (which kinda doesn't work)
548
549 -- Daniel Silverstone <daniel.silverstone@canonical.com> Fri, 27 Jan 2006 13:45:34 +0000
550
551launchpad-buildd (20) unstable; urgency=low
552
553 * Update sbuild to the latest sbuild from adam.
554 * Make sure we pass --archive=ubuntu
555 * Make sure we pass --comp=<the component we're building for>
556
557 -- Daniel Silverstone <daniel.silverstone@canonical.com> Thu, 26 Jan 2006 17:20:49 +0000
558
559launchpad-buildd (19) unstable; urgency=low
560
561 * Add ogre support to the slave chroot tool
562 * Make sure the chroot tool ensures localhost in /etc/hosts in the chroot
563
564 -- Daniel Silverstone <daniel.silverstone@canonical.com> Wed, 25 Jan 2006 12:29:04 +0000
565
566launchpad-buildd (18) unstable; urgency=low
567
568 * Remove sbuildrc.tmp dangleberry in postinst
569 * Add linux32 to set of depends so that hppa, sparc and powerpc can build
570 * Make hppa, sparc, powerpc use linux32 to invoke the sbuild binary
571 * Add --resolve-deps to debootstrap invocation
572 * Make chroot tool use /bin/su - rather than /bin/sh for chrooting. shiny
573 (apparently)
574 * Add a bunch of deps infinity spotted.
575 * Make sure we chown the chroot tarball to the calling user after packing
576 it up.
577
578 -- Daniel Silverstone <daniel.silverstone@canonical.com> Wed, 9 Nov 2005 17:37:37 -0500
579
580launchpad-buildd (17) unstable; urgency=low
581
582 * Changed default UID/GID to match the ldap buildd UID/GID
583
584 -- Daniel Silverstone <daniel.silverstone@canonical.com> Wed, 9 Nov 2005 17:13:22 -0500
585
586launchpad-buildd (16) unstable; urgency=low
587
588 * Change the XMLRPC method 'ensure' to be 'ensurepresent'
589
590 -- Daniel Silverstone <daniel.silverstone@canonical.com> Wed, 5 Oct 2005 15:50:58 +0100
591
592launchpad-buildd (15) unstable; urgency=low
593
594 * Fix it so getting a logtail when less than 2k is available will work.
595 * Actually install apply-ogre-model
596 * Also spot arch_indep properly
597
598 -- Daniel Silverstone <daniel.silverstone@canonical.com> Mon, 3 Oct 2005 14:34:55 +0100
599
600launchpad-buildd (14) unstable; urgency=low
601
602 * Slight bug in slave.py meant missing .emptyLog() attribute. Fixed.
603
604 -- Daniel Silverstone <daniel.silverstone@canonical.com> Mon, 3 Oct 2005 14:21:16 +0100
605
606launchpad-buildd (13) unstable; urgency=low
607
608 * Fix a syntax error in the postinst
609 * Oh, and actually include the buildd config upgrader
610
611 -- Daniel Silverstone <daniel.silverstone@canonical.com> Mon, 3 Oct 2005 12:17:50 +0100
612
613launchpad-buildd (12) unstable; urgency=low
614
615 * Implement V1.0new protocol.
616 * Add in OGRE support
617 * Add in archindep support
618 * If upgrading from < v12, will remove -A from sbuildargs and add in
619 a default ogrepath to any buildd configs found in /etc/launchpad-buildd
620 * Prevent launchpad-buildd init from starting ~ files
621
622 -- Daniel Silverstone <daniel.silverstone@canonical.com> Sun, 2 Oct 2005 23:20:08 +0100
623
624launchpad-buildd (11) unstable; urgency=low
625
626 * Quieten down the slave scripts and make them prettier for the logs.
627 * make unpack-chroot uncompress the chroot and keep it uncompressed if
628 possible. This fixes bug#2699
629 * Make the slave run the process reaper run even if the build failed.
630
631 -- Daniel Silverstone <daniel.silverstone@canonical.com> Fri, 30 Sep 2005 00:24:45 +0100
632
633launchpad-buildd (10) unstable; urgency=low
634
635 * Make sure /etc/source-dependencies is present in the postinst.
636 (just need to be touched)
637
638 -- Daniel Silverstone <daniel.silverstone@canonical.com> Wed, 28 Sep 2005 22:02:26 +0100
639
640launchpad-buildd (9) unstable; urgency=low
641
642 * Implement /filecache/XXX urls in the slave to permit larger file transfer
643
644 -- Daniel Silverstone <daniel.silverstone@canonical.com> Tue, 27 Sep 2005 13:16:52 +0100
645
646launchpad-buildd (8) unstable; urgency=low
647
648 * spiv's crappy spawnFDs implementation needs an int not a file handle
649 and can't cope with converting one to the other :-(
650
651 -- Daniel Silverstone <daniel.silverstone@canonical.com> Tue, 27 Sep 2005 02:18:05 +0100
652
653launchpad-buildd (7) unstable; urgency=low
654
655 * Made sure the slave puts /dev/null on the subprocess stdin.
656
657 -- Daniel Silverstone <daniel.silverstone@canonical.com> Tue, 27 Sep 2005 01:52:50 +0100
658
659launchpad-buildd (6) unstable; urgency=low
660
661 * Removed slavechroot.py from installed set.
662
663 -- Daniel Silverstone <daniel.silverstone@canonical.com> Thu, 15 Sep 2005 11:39:25 +0100
664
665launchpad-buildd (5) unstable; urgency=low
666
667 * Add slave tool and example chroot configuration
668 * Added debootstrap and dpkg-dev to the dependencies
669
670 -- Daniel Silverstone <daniel.silverstone@canonical.com> Fri, 9 Sep 2005 16:38:22 +0100
671
672launchpad-buildd (4) unstable; urgency=low
673
674 * Add sbuild.conf which was previously missing
675 * Fix up abort protocol and various other bits in the slave
676
677 -- Daniel Silverstone <daniel.silverstone@canonical.com> Fri, 9 Sep 2005 14:24:31 +0100
678
679launchpad-buildd (3) unstable; urgency=low
680
681 * Modified postinst to make sure ccache and log dirs are created
682 even if the user already exists.
683
684 -- Daniel Silverstone <daniel.silverstone@canonical.com> Wed, 7 Sep 2005 15:50:36 +0100
685
686launchpad-buildd (2) unstable; urgency=low
687
688 * Fixes to postinst to make sure ccache and log dirs are created if missing.
689 * Added README to explain how to build the package.
690
691 -- Daniel Silverstone <daniel.silverstone@canonical.com> Thu, 1 Sep 2005 10:46:08 +0100
692
693launchpad-buildd (1) unstable; urgency=low
694
695 * Initial version
696
697 -- Daniel Silverstone <daniel.silverstone@canonical.com> Mon, 13 Jun 2005 11:08:38 +0100
698
6990
=== removed file 'lib/canonical/buildd/debian/compat'
--- lib/canonical/buildd/debian/compat 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/debian/compat 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
15
20
=== removed file 'lib/canonical/buildd/debian/control'
--- lib/canonical/buildd/debian/control 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/debian/control 1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
1Source: launchpad-buildd
2Section: admin
3Priority: extra
4Maintainer: Adam Conrad <adconrad@ubuntu.com>
5Standards-Version: 3.5.9
6Build-Depends-Indep: debhelper (>= 5)
7
8Package: launchpad-buildd
9Section: misc
10Architecture: all
11Depends: python-twisted-core, python-twisted-web, debootstrap, dpkg-dev, linux32, file, bzip2, sudo, ntpdate, adduser, apt-transport-https, lsb-release, apache2, bzr-builder (>=0.5), ${misc:Depends}
12Description: Launchpad buildd slave
13 This is the launchpad buildd slave package. It contains everything needed to
14 get a launchpad buildd going apart from the database manipulation required to
15 tell launchpad about the slave instance. If you are creating more than one
16 slave instance on the same computer, be sure to give them independent configs
17 and independent filecaches etc.
180
=== removed file 'lib/canonical/buildd/debian/launchpad-buildd.cron.daily'
--- lib/canonical/buildd/debian/launchpad-buildd.cron.daily 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/debian/launchpad-buildd.cron.daily 1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
1#!/bin/sh
2#
3# Copyright 2009 Canonical Ltd. This software is licensed under the
4# GNU Affero General Public License version 3 (see the file LICENSE).
5
6find /var/log/launchpad-buildd/ -mindepth 1 -mtime +2 -print0 | xargs -r -0 rm
7find /home/buildd/public_html/ddebs/ -maxdepth 1 -mindepth 1 -mtime +7 -print0 | xargs -r -0 rm -r
8find /home/buildd/public_html/translations/ -maxdepth 1 -mindepth 1 -mtime +7 -print0 | xargs -r -0 rm -r
9find /home/buildd/filecache-default/ -mindepth 1 -mtime +2 -print0 | xargs -r -0 rm
10[ `date +%w` = "1" ] && apt-get clean || true
110
=== removed file 'lib/canonical/buildd/debian/launchpad-buildd.examples'
--- lib/canonical/buildd/debian/launchpad-buildd.examples 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/debian/launchpad-buildd.examples 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1buildd-slave-example.conf
20
=== removed file 'lib/canonical/buildd/debian/launchpad-buildd.init'
--- lib/canonical/buildd/debian/launchpad-buildd.init 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/debian/launchpad-buildd.init 1970-01-01 00:00:00 +0000
@@ -1,98 +0,0 @@
1#!/bin/sh
2#
3# Copyright 2009 Canonical Ltd. This software is licensed under the
4# GNU Affero General Public License version 3 (see the file LICENSE).
5#
6# launchpad-buildd
7# This file is used to start and stop launchpad buildds
8
9### BEGIN INIT INFO
10# Provides: launchpad_buildd
11# Required-Start: $local_fs $network $syslog $time
12# Required-Stop: $local_fs $network $syslog $time
13# Default-Start: 2 3 4 5
14# Default-Stop: 0 1 6
15# X-Interactive: false
16# Short-Description: Start/stop launchpad buildds
17### END INIT INFO
18
19set -e
20
21PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
22DESC="launchpad build slaves"
23
24TACFILE="/usr/share/launchpad-buildd/buildd-slave.tac"
25
26PIDROOT="/var/run/launchpad-buildd"
27LOGROOT="/var/log/launchpad-buildd"
28CONFROOT="/etc/launchpad-buildd"
29
30# Gracefully exit if the package has been removed.
31test -e $TACFILE || exit 0
32
33#
34# Function that starts a buildd slave
35#
36d_start() {
37 CONF=$1
38 PIDFILE="$PIDROOT"/"$CONF".pid
39 LOGFILE="$LOGROOT"/"$CONF".log
40 # prior to karmic, twisted didn't support --umask, and defaulted it well.
41 # we need it to be 022, not 077.
42 case $(lsb_release -sc) in
43 [a-j]*) UMASK="";;
44 [k-z]*) UMASK="--umask 022";;
45 esac
46 su - buildd -c "BUILDD_SLAVE_CONFIG=$CONFROOT/$CONF PYTHONPATH=/usr/share/launchpad-buildd twistd --no_save --pidfile $PIDFILE --python $TACFILE --logfile $LOGFILE $UMASK"
47}
48
49#
50# Function that stops a buildd slave
51#
52d_stop() {
53 CONF=$1
54 PIDFILE="$PIDROOT"/"$CONF".pid
55 test -r $PIDFILE && kill -TERM $(cat $PIDFILE) || true
56}
57
58CONFS=$(cd $CONFROOT; ls|grep -v "^-"|grep -v "~$")
59
60case "$1" in
61 start)
62 echo -n "Starting $DESC:"
63 install -m 755 -o buildd -g buildd -d $PIDROOT
64
65 # Create any missing directories and chown them appropriately
66 install -d -o buildd -g buildd /home/buildd/filecache-default
67
68 for conf in $CONFS; do
69 echo -n " $conf"
70 d_start $conf
71 done
72 echo "."
73 ;;
74 stop)
75 echo -n "Stopping $DESC:"
76 for conf in $CONFS; do
77 echo -n " $conf"
78 d_stop $conf
79 done
80 echo "."
81 ;;
82 restart|force-reload)
83 #
84 # If the "reload" option is implemented, move the "force-reload"
85 # option to the "reload" entry above. If not, "force-reload" is
86 # just the same as "restart".
87 #
88 $0 stop
89 sleep 1
90 $0 start
91 ;;
92 *)
93 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
94 exit 1
95 ;;
96esac
97
98exit 0
990
=== removed file 'lib/canonical/buildd/debian/postinst'
--- lib/canonical/buildd/debian/postinst 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/debian/postinst 1970-01-01 00:00:00 +0000
@@ -1,101 +0,0 @@
1#!/bin/sh
2#
3# Copyright 2009 Canonical Ltd. This software is licensed under the
4# GNU Affero General Public License version 3 (see the file LICENSE).
5
6# Post install script
7
8set -e
9set -u
10
11USER=${BUILDD_USER:-buildd}
12BUILDDGID=${BUILDD_GID:-2501}
13BUILDDUID=${BUILDD_UID:-2001}
14
15make_buildd()
16{
17 buildd-genconfig --name=default --host=0.0.0.0 --port=8221 > \
18 /etc/launchpad-buildd/default
19 echo Default buildd created.
20}
21
22case "$1" in
23 configure)
24 getent group buildd >/dev/null 2>&1 ||
25 addgroup --gid $BUILDDGID buildd
26
27 getent passwd buildd >/dev/null 2>&1 ||
28 adduser --ingroup buildd --disabled-login --gecos 'Buildd user' \
29 --uid $BUILDDUID ${USER}
30
31 SUDO_VERSION=$(sudo -V | sed -n '/^Sudo version/s/.* //p')
32 if dpkg --compare-versions $SUDO_VERSION lt 1.7 ||
33 ! grep -q '^#includedir /etc/sudoers.d' /etc/sudoers; then
34 grep -q ^${USER} /etc/sudoers ||
35 echo "${USER} ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers
36 else
37 if ! sudo -l -U ${USER} | grep -q '(ALL) NOPASSWD: ALL' ||
38 ! sudo -l -U ${USER} | grep -q umask_override; then
39 cat << EOF >> /etc/sudoers.d/buildd
40Defaults:buildd umask_override
41Defaults>buildd umask_override
42
43${USER} ALL=(ALL) NOPASSWD: ALL
44%buildd ALL=(buildd) NOPASSWD: ALL, (root) NOPASSWD: /bin/su - buildd
45%lpbuildd ALL=(ALL) NOPASSWD: ALL
46EOF
47 fi
48 chmod 440 /etc/sudoers.d/buildd
49 chown root:root /etc/sudoers.d/buildd
50 fi
51
52 install -d -o${USER} -m0755 /home/${USER}
53
54 # Create ~buildd/.sbuildrc if needed
55 if [ ! -f /home/${USER}/.sbuildrc ]; then
56 cp /usr/share/launchpad-buildd/sbuildrc \
57 /home/${USER}/sbuildrc.tmp
58 cd /home/${USER}
59 sed -e's/@ARCHTAG@/'$(dpkg --print-architecture)'/g' \
60 -e's/@FQDN@/'$(hostname --fqdn)'/g' \
61 <sbuildrc.tmp > .sbuildrc
62 chown $USER:buildd .sbuildrc
63 chmod 0644 .sbuildrc
64 rm sbuildrc.tmp
65 fi
66
67 # Prepare a default buildd...
68 test -e /etc/launchpad-buildd/default || make_buildd
69
70 # Create any missing directories and chown them appropriately
71 test -d /home/${USER}/filecache-default || mkdir /home/${USER}/filecache-default
72 chown $USER:buildd /home/${USER}/filecache-default
73
74 chown $USER:buildd /var/log/launchpad-buildd /var/run/launchpad-buildd
75
76 # Check for the presence of the /etc/source-dependencies file
77 # which sbuild will rant about the absence of...
78 test -e /etc/source-dependencies || touch /etc/source-dependencies
79
80 # Now check if we're upgrading a previous version...
81 if [ "x$2" != "x" ]; then
82 for CONFIG in $(ls /etc/launchpad-buildd/* \
83 | grep -v "^-" | grep -v "~$"); do
84 /usr/share/launchpad-buildd/upgrade-config $2 $CONFIG
85 done
86 fi
87
88 ;;
89 abort-upgrade|abort-remove|abort-deconfigure)
90
91 ;;
92
93 *)
94 echo "postinst called with unknown argument \`$1'" >&2
95 exit 1
96 ;;
97esac
98
99#DEBHELPER#
100
101exit 0
1020
=== removed file 'lib/canonical/buildd/debian/rules'
--- lib/canonical/buildd/debian/rules 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/debian/rules 1970-01-01 00:00:00 +0000
@@ -1,96 +0,0 @@
1#!/usr/bin/make -f
2#
3# Copyright 2009, 2010 Canonical Ltd. This software is licensed under the
4# GNU Affero General Public License version 3 (see the file LICENSE).
5
6export DH_OPTIONS
7
8# This is an incomplete debian rules file for making the launchpad-buildd deb
9# Only ever invoke this as debian/rules package, which will build the source
10# package in the parent directory, after copying in the files that live above
11# this directory, so that the source package is valid.
12# after that, build the source package found in the parent directory.
13
14target = debian/launchpad-buildd
15topdir = ../../..
16
17buildd = $(topdir)/lib/canonical/buildd
18
19targetshare = $(target)/usr/share/launchpad-buildd
20pytarget = $(targetshare)/canonical/buildd
21
22pyfiles = debian.py slave.py binarypackage.py utils.py __init__.py \
23 sourcepackagerecipe.py translationtemplates.py
24slavebins = unpack-chroot mount-chroot update-debian-chroot sbuild-package \
25 scan-for-processes umount-chroot remove-build override-sources-list \
26 buildrecipe generate-translation-templates
27
28BUILDDUID=65500
29BUILDDGID=65500
30
31install: DH_OPTIONS=-plaunchpad-buildd
32install:
33 dh_testdir
34 dh_clean
35 dh_testroot
36 dh_installdirs usr/bin etc usr/share/launchpad-buildd/slavebin \
37 usr/share/launchpad-buildd/canonical/buildd \
38 var/run/launchpad-buildd var/log/launchpad-buildd \
39 etc/launchpad-buildd \
40 usr/share/launchpad-buildd/canonical/launchpad/daemons \
41 usr/share/doc/launchpad-buildd
42 dh_installexamples
43
44 # Do installs here
45 touch $(pytarget)/../launchpad/__init__.py
46 touch $(pytarget)/../launchpad/daemons/__init__.py
47 install -m644 buildd-slave.tac $(targetshare)/buildd-slave.tac
48 cp -r pottery $(pytarget)
49 for pyfile in $(pyfiles); do \
50 install -m644 ./$$pyfile $(pytarget)/$$pyfile; \
51 done
52 for slavebin in $(slavebins); do \
53 install -m755 ./$$slavebin $(targetshare)/slavebin/$$slavebin; \
54 done
55 install -m755 ./sbuild $(target)/usr/bin/sbuild
56 touch $(targetshare)/canonical/__init__.py
57 install -m644 template-buildd-slave.conf $(targetshare)/template-buildd-slave.conf
58 install -m755 buildd-config.py $(target)/usr/bin/buildd-genconfig
59 install -m644 sbuildrc $(targetshare)/sbuildrc
60 install -m644 sbuild.conf $(target)/etc/sbuild.conf
61 install -m755 debian/upgrade-config $(targetshare)/upgrade-config
62 install -m755 check-implicit-pointer-functions $(target)/usr/bin/check-implicit-pointer-functions
63 # Okay, that's installed all the slave-related files
64
65
66binary-arch:
67 @echo No arch-specific binaries to make
68
69binary-indep: DH_OPTIONS=-plaunchpad-buildd
70binary-indep: install
71 dh_installdocs
72 dh_installchangelogs
73 dh_installinit
74 dh_installcron
75 dh_strip
76 dh_compress
77 dh_fixperms
78 dh_installdeb
79 dh_gencontrol
80 dh_md5sums
81 dh_builddeb
82
83binary: binary-indep
84
85.PHONY: binary binary-indep binary-arch install clean build
86
87clean:
88 dh_clean
89
90prepare:
91
92package: prepare
93 debuild -uc -us -S
94
95build:
96 @echo Mmm builders
970
=== removed directory 'lib/canonical/buildd/debian/source'
=== removed file 'lib/canonical/buildd/debian/source/format'
--- lib/canonical/buildd/debian/source/format 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/debian/source/format 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
11.0
20
=== removed file 'lib/canonical/buildd/debian/upgrade-config'
--- lib/canonical/buildd/debian/upgrade-config 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/debian/upgrade-config 1970-01-01 00:00:00 +0000
@@ -1,122 +0,0 @@
1#!/usr/bin/python
2#
3# Copyright 2009, 2010 Canonical Ltd. This software is licensed under the
4# GNU Affero General Public License version 3 (see the file LICENSE).
5
6"""Upgrade a launchpad-buildd configuration file."""
7
8import sys
9import os
10import subprocess
11
12(old_version, conf_file) = sys.argv[1:]
13
14def upgrade_to_12():
15 print "Upgrading %s to version 12" % conf_file
16 subprocess.call(["mv", conf_file, conf_file+"-prev12~"])
17 in_file = open(conf_file+"-prev12~", "r")
18 out_file = open(conf_file, "w")
19 for line in in_file:
20 if line.startswith("[debianmanager]"):
21 line += "ogrepath = /usr/share/launchpad-buildd/slavebin/apply-ogre-model\n"
22 if line.startswith("sbuildargs"):
23 line = line.replace("-A", "")
24 out_file.write(line)
25 in_file.close()
26 out_file.close()
27
28def upgrade_to_34():
29 print "Upgrading %s to version 34" % conf_file
30 subprocess.call(["mv", conf_file, conf_file+"-prev34~"])
31 in_file = open(conf_file+"-prev34~", "r")
32 out_file = open(conf_file, "w")
33 for line in in_file:
34 if line.startswith("[debianmanager]"):
35 line += "sourcespath = /usr/share/launchpad-buildd/slavebin/override-sources-list\n"
36 out_file.write(line)
37 in_file.close()
38 out_file.close()
39
40def upgrade_to_39():
41 print "Upgrading %s to version 39" % conf_file
42 subprocess.call(["mv", conf_file, conf_file+"-prev39~"])
43 in_file = open(conf_file+"-prev39~", "r")
44 out_file = open(conf_file, "w")
45 for line in in_file:
46 if line.startswith("sbuildargs"):
47 line = line.replace("-dautobuild ","")
48 if line.startswith("[slave]"):
49 line += "ntphost = ntp.buildd\n"
50 out_file.write(line)
51 in_file.close()
52 out_file.close()
53
54def upgrade_to_57():
55 print "Upgrading %s to version 57" % conf_file
56 subprocess.call(["mv", conf_file, conf_file+"-prev57~"])
57 in_file = open(conf_file+"-prev57~", "r")
58 out_file = open(conf_file, "w")
59 # We want to move all the sbuild lines to a new
60 # 'binarypackagemanager' section at the end.
61 binarypackage_lines = []
62 for line in in_file:
63 if line.startswith("sbuild"):
64 binarypackage_lines.append(line)
65 else:
66 out_file.write(line)
67 out_file.write('[binarypackagemanager]\n')
68 for line in binarypackage_lines:
69 out_file.write(line)
70 in_file.close()
71 out_file.close()
72
73def upgrade_to_58():
74 print "Upgrading %s to version 58" % conf_file
75 subprocess.call(["mv", conf_file, conf_file+"-prev58~"])
76 in_file = open(conf_file+"-prev58~", "r")
77 out_file = open(conf_file, "w")
78 out_file.write(in_file.read())
79 out_file.write(
80 '\n[sourcepackagerecipemanager]\n'
81 'buildrecipepath = /usr/share/launchpad-buildd'
82 '/slavebin/buildrecipe\n')
83
84def upgrade_to_59():
85 print "Upgrading %s to version 59" % conf_file
86 subprocess.call(["mv", conf_file, conf_file+"-prev59~"])
87 in_file = open(conf_file+"-prev59~", "r")
88 out_file = open(conf_file, "w")
89 out_file.write(in_file.read())
90 out_file.write(
91 '\n[translationtemplatesmanager]\n'
92 'generatepath = /usr/share/launchpad-buildd/slavebin/generate-translation-templates\n'
93 'resultarchive = translation-templates.tar.gz\n')
94
95def upgrade_to_63():
96 print "Upgrading %s to version 63" % conf_file
97 subprocess.call(["mv", conf_file, conf_file+"-prev63~"])
98 in_file = open(conf_file+"-prev63~", "r")
99 out_file = open(conf_file, "w")
100 for line in in_file:
101 if not line.startswith('ogrepath'):
102 out_file.write(line)
103
104
105if __name__ == "__main__":
106 if old_version.find("~") > 0:
107 old_version = old_version[:old_version.find("~")]
108 if int(old_version) < 12:
109 upgrade_to_12()
110 if int(old_version) < 34:
111 upgrade_to_34()
112 if int(old_version) < 39:
113 upgrade_to_39()
114 if int(old_version) < 57:
115 upgrade_to_57()
116 if int(old_version) < 58:
117 upgrade_to_58()
118 if int(old_version) < 59:
119 upgrade_to_59()
120 if int(old_version) < 63:
121 upgrade_to_63()
122
1230
=== removed file 'lib/canonical/buildd/generate-translation-templates'
--- lib/canonical/buildd/generate-translation-templates 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/generate-translation-templates 1970-01-01 00:00:00 +0000
@@ -1,66 +0,0 @@
1#!/bin/sh
2#
3# Copyright 2010 Canonical Ltd. This software is licensed under the
4# GNU Affero General Public License version 3 (see the file LICENSE).
5
6# Buildd Slave tool to generate translation templates. Boiler plate code
7# copied from sbuild-package.
8
9# Expects build id as arg 1.
10# Expects branch url as arg 2.
11# Expects output tarball name as arg 3.
12
13# Must run as user with password-less sudo ability.
14
15exec 2>&1
16
17export LANG=C LC_ALL=C
18
19CHMOD=/bin/chmod
20CHROOT=/usr/sbin/chroot
21CP=/bin/cp
22INSTALL=/usr/bin/install
23MKDIR=/bin/mkdir
24SU=/bin/su
25SUDO=/usr/bin/sudo
26TOUCH=/usr/bin/touch
27
28BUILDID=$1
29BRANCH_URL=$2
30RESULT_NAME=$3
31
32BUILDD_HOME=/usr/share/launchpad-buildd
33SLAVEBIN=$BUILDD_HOME/slavebin
34BUILD_CHROOT="$HOME/build-$BUILDID/chroot-autobuild"
35USER=$(whoami)
36
37# Debug output.
38echo "Running as $USER for build $BUILDID on $BRANCH_URL."
39echo "Results expected in $RESULT_NAME."
40
41BUILDD_PACKAGE=canonical/buildd
42POTTERY=$BUILDD_PACKAGE/pottery
43# The script should be smarter about detecting the python version.
44PYMODULES=/usr/lib/pymodules/python2.7
45echo -n "Default Python in the chroot is: "
46$BUILD_CHROOT/usr/bin/python --version
47
48GENERATE_SCRIPT=$PYMODULES/$POTTERY/generate_translation_templates.py
49
50debug_exec() {
51 echo "Executing '$1'..."
52 $1 || echo "Got error $? from '$1'."
53}
54
55# Copy pottery files to chroot.
56debug_exec "$SUDO $MKDIR -vp $BUILD_CHROOT$PYMODULES/$BUILDD_PACKAGE"
57debug_exec "$SUDO $TOUCH $BUILD_CHROOT$PYMODULES/canonical/__init__.py"
58debug_exec "$SUDO $TOUCH $BUILD_CHROOT$PYMODULES/canonical/buildd/__init__.py"
59debug_exec "$SUDO $CP -vr $BUILDD_HOME/$POTTERY $BUILD_CHROOT$PYMODULES/$BUILDD_PACKAGE"
60debug_exec "$SUDO $CHMOD -v -R go+rX $BUILD_CHROOT$PYMODULES/canonical"
61debug_exec "$SUDO $CHMOD -v 755 $BUILD_CHROOT$GENERATE_SCRIPT"
62
63# Enter chroot, switch back to unprivileged user, execute the generate script.
64$SUDO $CHROOT $BUILD_CHROOT \
65 $SU - $USER \
66 -c "PYTHONPATH=$PYMODULES $GENERATE_SCRIPT $BRANCH_URL $RESULT_NAME"
670
=== removed directory 'lib/canonical/buildd/launchpad-files'
=== removed file 'lib/canonical/buildd/mount-chroot'
--- lib/canonical/buildd/mount-chroot 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/mount-chroot 1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
1#!/bin/sh
2#
3# Copyright 2009 Canonical Ltd. This software is licensed under the
4# GNU Affero General Public License version 3 (see the file LICENSE).
5
6# Buildd Slave tool to mount a chroot
7
8# Expects build id as arg 1, makes build-id to contain the build
9
10# Needs SUDO to be set to a sudo instance for passwordless access
11
12SUDO=/usr/bin/sudo
13BUILDID="$1"
14
15set -e
16
17exec 2>&1
18
19echo "Mounting chroot for build $BUILDID"
20
21$SUDO mount -t proc none "$HOME/build-$BUILDID/chroot-autobuild/proc"
22$SUDO mount -t devpts none "$HOME/build-$BUILDID/chroot-autobuild/dev/pts"
23$SUDO mount -t sysfs none "$HOME/build-$BUILDID/chroot-autobuild/sys"
24$SUDO mount -t tmpfs none "$HOME/build-$BUILDID/chroot-autobuild/dev/shm"
25$SUDO cp /etc/hosts /etc/hostname /etc/resolv.conf $HOME/build-$BUILDID/chroot-autobuild/etc/
260
=== removed file 'lib/canonical/buildd/override-sources-list'
--- lib/canonical/buildd/override-sources-list 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/override-sources-list 1970-01-01 00:00:00 +0000
@@ -1,31 +0,0 @@
1#!/bin/sh
2#
3# Copyright 2009 Canonical Ltd. This software is licensed under the
4# GNU Affero General Public License version 3 (see the file LICENSE).
5
6# Buildd Slave tool to override sources.list in the chroot with a list of
7# archives
8
9# Expects build id as arg 1
10# Expects sources.list lines as subsequent args
11
12# Needs SUDO to be set to a sudo instance for passwordless access
13
14set -e
15exec 2>&1
16
17SUDO=/usr/bin/sudo
18
19BUILDID="$1"
20shift
21
22cd $HOME
23cd "build-$BUILDID/chroot-autobuild/etc/apt"
24
25echo "Overriding sources.list in build-$BUILDID"
26
27$SUDO rm -f sources.list.new
28(for archive; do
29 echo "$archive"
30done) | $SUDO tee sources.list.new >/dev/null
31$SUDO mv sources.list.new sources.list
320
=== removed directory 'lib/canonical/buildd/pottery'
=== removed file 'lib/canonical/buildd/pottery/__init__.py'
=== removed file 'lib/canonical/buildd/pottery/generate_translation_templates.py'
--- lib/canonical/buildd/pottery/generate_translation_templates.py 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/pottery/generate_translation_templates.py 1970-01-01 00:00:00 +0000
@@ -1,114 +0,0 @@
1#! /usr/bin/python
2# Copyright 2010 Canonical Ltd. This software is licensed under the
3# GNU Affero General Public License version 3 (see the file LICENSE).
4
5__metaclass__ = type
6
7import os.path
8import sys
9import tarfile
10
11import logging
12
13from bzrlib.branch import Branch
14from bzrlib.export import export
15
16from canonical.buildd.pottery import intltool
17
18
19class GenerateTranslationTemplates:
20 """Script to generate translation templates from a branch."""
21
22 def __init__(self, branch_spec, result_name, work_dir, log_file=None):
23 """Prepare to generate templates for a branch.
24
25 :param branch_spec: Either a branch URL or the path of a local
26 branch. URLs are recognized by the occurrence of ':'. In
27 the case of a URL, this will make up a path for the branch
28 and check out the branch to there.
29 :param result_name: The name of the result tarball. Should end in
30 .tar.gz.
31 :param work_dir: The directory to work in. Must exist.
32 :param log_file: File-like object to log to. If None, defaults to
33 stderr.
34 """
35 self.work_dir = work_dir
36 self.branch_spec = branch_spec
37 self.result_name = result_name
38 self.logger = self._setupLogger(log_file)
39
40 def _setupLogger(self, log_file):
41 """Sets up and returns a logger."""
42 if log_file is None:
43 log_file = sys.stderr
44 logger = logging.getLogger("generate-templates")
45 logger.setLevel(logging.DEBUG)
46 ch = logging.StreamHandler(log_file)
47 ch.setLevel(logging.DEBUG)
48 logger.addHandler(ch)
49 return logger
50
51 def _getBranch(self):
52 """Set `self.branch_dir`, and check out branch if needed."""
53 if ':' in self.branch_spec:
54 # This is a branch URL. Check out the branch.
55 self.branch_dir = os.path.join(self.work_dir, 'source-tree')
56 self.logger.info("Getting remote branch %s..." % self.branch_spec)
57 self._checkout(self.branch_spec)
58 else:
59 # This is a local filesystem path. Use the branch in-place.
60 self.logger.info("Using local branch %s..." % self.branch_spec)
61 self.branch_dir = self.branch_spec
62
63 def _checkout(self, branch_url):
64 """Check out a source branch to generate from.
65
66 The branch is checked out to the location specified by
67 `self.branch_dir`.
68 """
69 self.logger.info("Opening branch %s..." % branch_url)
70 branch = Branch.open(branch_url)
71 self.logger.info("Getting branch revision tree...")
72 rev_tree = branch.basis_tree()
73 self.logger.info("Exporting branch to %s..." % self.branch_dir)
74 export(rev_tree, self.branch_dir)
75 self.logger.info("Exporting branch done.")
76
77 def _makeTarball(self, files):
78 """Put the given files into a tarball in the working directory."""
79 tarname = os.path.join(self.work_dir, self.result_name)
80 self.logger.info("Making tarball with templates in %s..." % tarname)
81 tarball = tarfile.open(tarname, 'w|gz')
82 files = [name for name in files if not name.endswith('/')]
83 for path in files:
84 full_path = os.path.join(self.branch_dir, path)
85 self.logger.info("Adding template %s..." % full_path)
86 tarball.add(full_path, path)
87 tarball.close()
88 self.logger.info("Tarball generated.")
89
90 def generate(self):
91 """Do It. Generate templates."""
92 self.logger.info("Generating templates for %s." % self.branch_spec)
93 self._getBranch()
94 pots = intltool.generate_pots(self.branch_dir)
95 self.logger.info("Generated %d templates." % len(pots))
96 if len(pots) > 0:
97 self._makeTarball(pots)
98 return 0
99
100
101if __name__ == '__main__':
102 if len(sys.argv) < 3:
103 print "Usage: %s branch resultname [workdir]" % sys.argv[0]
104 print " 'branch' is a branch URL or directory."
105 print " 'resultname' is the name of the result tarball."
106 print " 'workdir' is a directory, defaults to HOME."
107 sys.exit(1)
108 if len(sys.argv) == 4:
109 workdir = sys.argv[3]
110 else:
111 workdir = os.environ['HOME']
112 script = GenerateTranslationTemplates(
113 sys.argv[1], sys.argv[2], workdir)
114 sys.exit(script.generate())
1150
=== removed file 'lib/canonical/buildd/pottery/intltool.py'
--- lib/canonical/buildd/pottery/intltool.py 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/pottery/intltool.py 1970-01-01 00:00:00 +0000
@@ -1,342 +0,0 @@
1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4"""Functions to build PO templates on the build slave."""
5
6__metaclass__ = type
7__all__ = [
8 'check_potfiles_in',
9 'generate_pot',
10 'generate_pots',
11 'get_translation_domain',
12 'find_intltool_dirs',
13 'find_potfiles_in',
14 ]
15
16from contextlib import contextmanager
17import errno
18import os.path
19import re
20from subprocess import call
21
22
23def find_potfiles_in():
24 """Search the current directory and its subdirectories for POTFILES.in.
25
26 :returns: A list of names of directories that contain a file POTFILES.in.
27 """
28 result_dirs = []
29 for dirpath, dirnames, dirfiles in os.walk("."):
30 if "POTFILES.in" in dirfiles:
31 result_dirs.append(dirpath)
32 return result_dirs
33
34
35def check_potfiles_in(path):
36 """Check if the files listed in the POTFILES.in file exist.
37
38 Running 'intltool-update -m' will perform this check and also take a
39 possible POTFILES.skip into account. It stores details about 'missing'
40 (files that should be in POTFILES.in) and 'notexist'ing files (files
41 that are listed in POTFILES.in but don't exist) in files which are
42 named accordingly. These files are removed before the run.
43
44 We don't care about files missing from POTFILES.in but want to know if
45 all listed files exist. The presence of the 'notexist' file tells us
46 that.
47
48 :param path: The directory where POTFILES.in resides.
49 :returns: False if the directory does not exist, if an error occurred
50 when executing intltool-update or if files are missing from
51 POTFILES.in. True if all went fine and all files in POTFILES.in
52 actually exist.
53 """
54 current_path = os.getcwd()
55
56 try:
57 os.chdir(path)
58 except OSError, e:
59 # Abort nicely if the directory does not exist.
60 if e.errno == errno.ENOENT:
61 return False
62 raise
63 try:
64 # Remove stale files from a previous run of intltool-update -m.
65 for unlink_name in ['missing', 'notexist']:
66 try:
67 os.unlink(unlink_name)
68 except OSError, e:
69 # It's ok if the files are missing.
70 if e.errno != errno.ENOENT:
71 raise
72 devnull = open("/dev/null", "w")
73 returncode = call(
74 ["/usr/bin/intltool-update", "-m"],
75 stdout=devnull, stderr=devnull)
76 devnull.close()
77 finally:
78 os.chdir(current_path)
79
80 if returncode != 0:
81 # An error occurred when executing intltool-update.
82 return False
83
84 notexist = os.path.join(path, "notexist")
85 return not os.access(notexist, os.R_OK)
86
87
88def find_intltool_dirs():
89 """Search for directories with intltool structure.
90
91 The current directory and its subdiretories are searched. An 'intltool
92 structure' is a directory that contains a POFILES.in file and where all
93 files listed in that POTFILES.in do actually exist. The latter
94 condition makes sure that the file is not stale.
95
96 :returns: A list of directory names.
97 """
98 return sorted(filter(check_potfiles_in, find_potfiles_in()))
99
100
101def _get_AC_PACKAGE_NAME(config_file):
102 """Get the value of AC_PACKAGE_NAME from function parameters.
103
104 The value of AC_PACKAGE_NAME is either the first or the fourth
105 parameter of the AC_INIT call if it is called with at least two
106 parameters.
107 """
108 params = config_file.getFunctionParams("AC_INIT")
109 if params is None or len(params) < 2:
110 return None
111 if len(params) < 4:
112 return params[0]
113 else:
114 return params[3]
115
116
117def _try_substitution(config_files, varname, substitution):
118 """Try to find a substitution in the config files.
119
120 :returns: The completed substitution or None if none was found.
121 """
122 subst_value = None
123 if varname == substitution.name:
124 # Do not look for the same name in the current file.
125 config_files = config_files[:-1]
126 for config_file in reversed(config_files):
127 subst_value = config_file.getVariable(substitution.name)
128 if subst_value is not None:
129 # Substitution found.
130 break
131 else:
132 # No substitution found.
133 return None
134 return substitution.replace(subst_value)
135
136
137def get_translation_domain(dirname):
138 """Get the translation domain for this PO directory.
139
140 Imitates some of the behavior of intltool-update to find out which
141 translation domain the build environment provides. The domain is usually
142 defined in the GETTEXT_PACKAGE variable in one of the build files. Another
143 variant is DOMAIN in the Makevars file. This function goes through the
144 ordered list of these possible locations, top to bottom, and tries to
145 find a valid value. Since the same variable name may be defined in
146 multiple files (usually configure.ac and Makefile.in.in), it needs to
147 keep trying with the next file, until it finds the most specific
148 definition.
149
150 If the found value contains a substitution, either autoconf style (@...@)
151 or make style ($(...)), the search is continued in the same file and back
152 up the list of files, now searching for the substitution. Multiple
153 substitutions or multi-level substitutions are not supported.
154 """
155 locations = [
156 ('../configure.ac', 'GETTEXT_PACKAGE', True),
157 ('../configure.in', 'GETTEXT_PACKAGE', True),
158 ('Makefile.in.in', 'GETTEXT_PACKAGE', False),
159 ('Makevars', 'DOMAIN', False),
160 ]
161 value = None
162 substitution = None
163 config_files = []
164 for filename, varname, keep_trying in locations:
165 path = os.path.join(dirname, filename)
166 if not os.access(path, os.R_OK):
167 # Skip non-existent files.
168 continue
169 config_files.append(ConfigFile(path))
170 new_value = config_files[-1].getVariable(varname)
171 if new_value is not None:
172 value = new_value
173 if value == "AC_PACKAGE_NAME":
174 value = _get_AC_PACKAGE_NAME(config_files[-1])
175 else:
176 # Check if the value needs a substitution.
177 substitution = Substitution.get(value)
178 if substitution is not None:
179 # Try to substitute with value.
180 value = _try_substitution(
181 config_files, varname, substitution)
182 if value is None:
183 # No substitution found; the setup is broken.
184 break
185 if value is not None and not keep_trying:
186 # A value has been found.
187 break
188 return value
189
190
191@contextmanager
192def chdir(directory):
193 cwd = os.getcwd()
194 os.chdir(directory)
195 yield
196 os.chdir(cwd)
197
198
199def generate_pot(podir, domain):
200 """Generate one PO template using intltool.
201
202 Although 'intltool-update -p' can try to find out the translation domain
203 we trust our own code more on this one and simply specify the domain.
204 Also, the man page for 'intltool-update' states that the '-g' option
205 "has an additional effect: the name of current working directory is no
206 more limited to 'po' or 'po-*'." We don't want that limit either.
207
208 :param podir: The PO directory in which to build template.
209 :param domain: The translation domain to use as the name of the template.
210 If it is None or empty, 'messages.pot' will be used.
211 :return: True if generation succeeded.
212 """
213 if domain is None or domain.strip() == "":
214 domain = "messages"
215 with chdir(podir):
216 with open("/dev/null", "w") as devnull:
217 returncode = call(
218 ["/usr/bin/intltool-update", "-p", "-g", domain],
219 stdout=devnull, stderr=devnull)
220 return returncode == 0
221
222
223def generate_pots(package_dir='.'):
224 """Top-level function to generate all PO templates in a package."""
225 potpaths = []
226 with chdir(package_dir):
227 for podir in find_intltool_dirs():
228 domain = get_translation_domain(podir)
229 if generate_pot(podir, domain):
230 potpaths.append(os.path.join(podir, domain + ".pot"))
231 return potpaths
232
233
234class ConfigFile(object):
235 """Represent a config file and return variables defined in it."""
236
237 def __init__(self, file_or_name):
238 if isinstance(file_or_name, basestring):
239 conf_file = file(file_or_name)
240 else:
241 conf_file = file_or_name
242 self.content = conf_file.read()
243
244 def _stripQuotes(self, identifier):
245 """Strip surrounding quotes from `identifier`, if present.
246
247 :param identifier: a string, possibly surrounded by matching
248 'single,' "double," or [bracket] quotes.
249 :return: `identifier` but with the outer pair of matching quotes
250 removed, if they were there.
251 """
252 if len(identifier) < 2:
253 return identifier
254
255 quote_pairs = [
256 ('"', '"'),
257 ("'", "'"),
258 ("[", "]"),
259 ]
260 for (left, right) in quote_pairs:
261 if identifier.startswith(left) and identifier.endswith(right):
262 return identifier[1:-1]
263
264 return identifier
265
266 def getVariable(self, name):
267 """Search the file for a variable definition with this name."""
268 pattern = re.compile(
269 "^%s[ \t]*=[ \t]*([^\s]*)" % re.escape(name), re.M)
270 result = pattern.search(self.content)
271 if result is None:
272 return None
273 return self._stripQuotes(result.group(1))
274
275 def getFunctionParams(self, name):
276 """Search file for a function call with this name, return parameters.
277 """
278 pattern = re.compile("^%s\(([^)]*)\)" % re.escape(name), re.M)
279 result = pattern.search(self.content)
280 if result is None:
281 return None
282 else:
283 return [
284 self._stripQuotes(param.strip())
285 for param in result.group(1).split(',')
286 ]
287
288
289class Substitution(object):
290 """Find and replace substitutions.
291
292 Variable texts may contain other variables which should be substituted
293 for their value. These are either marked by surrounding @ signs (autoconf
294 style) or preceded by a $ sign with optional () (make style).
295
296 This class identifies a single such substitution in a variable text and
297 extract the name of the variable who's value is to be inserted. It also
298 facilitates the actual replacement so that caller does not have to worry
299 about the substitution style that is being used.
300 """
301
302 autoconf_pattern = re.compile("@([^@]+)@")
303 makefile_pattern = re.compile("\$\(?([^\s\)]+)\)?")
304
305 @staticmethod
306 def get(variabletext):
307 """Factory method.
308
309 Creates a Substitution instance and checks if it found a substitution.
310
311 :param variabletext: A variable value with possible substitution.
312 :returns: A Substitution object or None if no substitution was found.
313 """
314 subst = Substitution(variabletext)
315 if subst.name is not None:
316 return subst
317 return None
318
319 def _searchForPatterns(self):
320 """Search for all the available patterns in variable text."""
321 result = self.autoconf_pattern.search(self.text)
322 if result is None:
323 result = self.makefile_pattern.search(self.text)
324 return result
325
326 def __init__(self, variabletext):
327 """Extract substitution name from variable text."""
328 self.text = variabletext
329 self.replaced = False
330 result = self._searchForPatterns()
331 if result is None:
332 self._replacement = None
333 self.name = None
334 else:
335 self._replacement = result.group(0)
336 self.name = result.group(1)
337
338 def replace(self, value):
339 """Return a copy of the variable text with the substitution resolved.
340 """
341 self.replaced = True
342 return self.text.replace(self._replacement, value)
3430
=== removed file 'lib/canonical/buildd/remove-build'
--- lib/canonical/buildd/remove-build 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/remove-build 1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
1#!/bin/sh
2#
3# Copyright 2009 Canonical Ltd. This software is licensed under the
4# GNU Affero General Public License version 3 (see the file LICENSE).
5
6# Buildd Slave tool to remove an unmounted chroot
7
8# Expects build id as arg 1, makes build-id to contain the build
9
10# Needs RM to be set to a gnu rm instance
11# Needs SUDO to be set to a sudo instance for passwordless access
12
13RM=/bin/rm
14SUDO=/usr/bin/sudo
15BUILDID="$1"
16
17set -e
18
19exec 2>&1
20
21echo "Removing build $BUILDID"
22
23cd $HOME
24
25$SUDO $RM -rf "build-$BUILDID"
260
=== removed file 'lib/canonical/buildd/sbuild'
--- lib/canonical/buildd/sbuild 2011-11-17 22:06:34 +0000
+++ lib/canonical/buildd/sbuild 1970-01-01 00:00:00 +0000
@@ -1,3658 +0,0 @@
1#! /usr/bin/perl
2#
3# sbuild: build packages, obeying source dependencies
4# Copyright (C) 1998-2000 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
5#
6# This program is free software; you can redistribute it and/or
7# modify it under the terms of the GNU General Public License as
8# published by the Free Software Foundation; either version 2 of the
9# License, or (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful, but
12# WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14# General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19#
20# $Id: sbuild,v 1.170 2002/10/10 18:50:44 rnhodek Exp $
21#
22# $Log: sbuild,v $
23# Revision 1.170 2002/10/10 18:50:44 rnhodek
24# Security/accepted autobuilding patch by Ryan.
25#
26# Revision 1.169 2002/03/11 09:49:55 rnhodek
27# chroot_apt_options: don't just set Dir::Etc::sourcelist, but whole
28# Dir::Etc, to avoid new preferences.
29#
30# Revision 1.168 2002/02/07 09:12:25 rnhodek
31# Fixed sudo call for running scripts.
32#
33# Revision 1.167 2002/01/22 08:53:10 rnhodek
34# Use capitalized "Noninteractive" das DEBIAN_FRONTENT.
35#
36# Revision 1.166 2001/11/08 09:32:10 rnhodek
37# fetch_source_file: in case of apt, need to pass up a $dscfile with
38# epoch stripped.
39#
40# Revision 1.165 2001/11/07 18:04:31 rnhodek
41# Argl.. I should learn perl first :)
42#
43# Revision 1.164 2001/11/07 09:25:59 rnhodek
44# fetch_source_files: after apt-get, fix $dscfile not to contain epoch.
45#
46# Revision 1.163 2001/11/06 15:11:24 rnhodek
47# fetch_source_files: don't touch symlinks generated by apt-get.
48#
49# Revision 1.162 2001/11/06 12:29:22 rnhodek
50# New config var $use_FetchFile (default 0).
51# Integrated patches for using apt-get to download sources; modified so
52# that old code (using FetchFile.pm) still present.
53# run_apt: Fix parsing error of apt-output (\s matched ^M printed by
54# pre-configuring).
55#
56# Revision 1.161 2001/10/29 12:20:41 rnhodek
57# Added $fakeroot var.
58#
59# Revision 1.160 2001/10/29 08:27:53 rnhodek
60# Fix typo in message.
61#
62# Revision 1.159 2001/06/18 09:57:55 rnhodek
63# Use --database option when wanna_build_dbbase set in config.
64#
65# Revision 1.158 2001/06/01 09:54:36 rnhodek
66# Fix two typos.
67#
68# Revision 1.157 2001/05/31 08:08:08 rnhodek
69# Fixed thinko in conflicts checking (tnx James)
70#
71# Revision 1.156 2001/05/30 08:20:05 rnhodek
72# Use /var/lib/apt as Dir::State if exists (newer apt versions use that)
73# (tnx to Ryan Murray).
74#
75# Revision 1.155 2001/05/30 08:17:01 rnhodek
76# Print also architecture at start of log.
77#
78# Revision 1.154 2001/05/29 07:33:54 rnhodek
79# Also handle versioned Build-Conflicts.
80# (Tnx to David Schleef <ds@schleef.org>)
81#
82# Revision 1.153 2001/03/13 08:45:17 rnhodek
83# Run chmod -R on source tree only after unpacking.
84#
85# Revision 1.152 2001/02/19 09:23:24 rnhodek
86# Fix typo.
87#
88# Revision 1.151 2001/02/19 08:43:22 rnhodek
89# Fix wrong arch logic.
90#
91# Revision 1.150 2001/01/22 12:56:16 rnhodek
92# Fix handling of arch-restricted build-deps (tnx to Ryan Murray).
93#
94# Revision 1.149 2001/01/15 11:17:36 rnhodek
95# Fixed typo.
96#
97# Revision 1.148 2001/01/15 10:59:18 rnhodek
98# Shortcut when looking for non-dsc files: first try to fetch from same
99# dir as .dsc and FF_search only if that fails.
100#
101# Revision 1.147 2001/01/10 16:16:48 rnhodek
102# Move all built files from chroot dir, not only *.deb.
103#
104# Revision 1.146 2000/10/23 10:39:24 rnhodek
105# Before doing chmod on /etc/ld.so.conf, test if it exists at all.
106#
107# Revision 1.145 2000/10/19 09:08:35 rnhodek
108# A couple of little fixes from Ben.
109# Checks and assures that /etc/ld.so.conf is readable.
110# Support for local overrides with $conf::srcdep_over.
111#
112# Revision 1.144 2000/06/27 12:34:00 rnhodek
113# Implemented new 'prepre' and 'unpack' sections for special targets;
114# the first is a script run before package installation, and the latter
115# can list source packages that should be unpacked in the build dir.
116#
117# Revision 1.143 2000/06/20 14:39:59 rnhodek
118# Call apt-get with some options for relocating various files instead of
119# chrooting it; this avoids that the archive must be available in chroot
120# environment; same is true for dpkg and apt-cache calls.
121# If chrooted, call dpkg with the chroot dir as cwd to avoid "cannot get
122# current directory" errors; same for apt option DPkg::Run-Directory.
123#
124# Revision 1.142 2000/06/19 14:09:00 rnhodek
125# Fix syntax error.
126#
127# Revision 1.141 2000/06/19 14:05:38 rnhodek
128# Call buildd-addpkg with --chroot=DIR options for each dist that is >=
129# the one building for (to run apt-get update in the chroot
130# environments).
131#
132# Revision 1.140 2000/06/19 09:10:24 rnhodek
133# Obey new config var @ignore_watches_no_build_deps, i.e. don't flag
134# watches that are listed there if the package doesn't have build deps.
135# In check_watches(), strip $chroot_dir instead of $chroot_build_dir
136# from pathname.
137#
138# Revision 1.139 2000/06/13 10:54:43 rnhodek
139# Also execute special dependency scripts in chroot environment.
140#
141# Revision 1.138 2000/06/09 12:47:52 rnhodek
142# File .dsc filename for rbuilder (with URL).
143#
144# Revision 1.137 2000/06/09 09:15:21 rnhodek
145# Always install built package (if already) when building chroot; i.e.
146# the $system_level test is not necessary when chrooted.
147#
148# Revision 1.136 2000/06/09 08:20:52 rnhodek
149# Fixed su usage in sub build.
150#
151# Revision 1.135 2000/06/08 14:02:11 rnhodek
152# After changing to chroot dir, change back to be the normal user again
153# and start dpkg-buildpackage with -rsudo again; some packages require
154# that the build target is executed as non-root.
155#
156# Revision 1.134 2000/06/08 13:01:54 rnhodek
157# apt-cache calls need sudo, too, when using chroot.
158#
159# Revision 1.133 2000/06/08 09:13:31 rnhodek
160# Implemented chroot builds; there are a few new global variables
161# $main::chroot_*; major changes are in build, where the source tree is
162# unpacked somewhere else, dpkg-buildpackage called under chroot and
163# built packages are moved back again; also all apt-get and dpkg calls
164# are chroot-ed and /var/lib/dpkg/status is accessed from the chroot
165# environment; also watches are checked under the new root dir.
166#
167# Revision 1.132 2000/06/06 14:37:05 rnhodek
168# New option --source (-s): Also build source package, i.e. don't pass
169# -b or -B to dpkg-buildpackage.
170#
171# Revision 1.131 2000/05/30 15:41:34 rnhodek
172# Call buildd-addpkg with --dist option.
173# Install freshly built packages only if $conf::system_level >= $dist.
174#
175# Revision 1.130 2000/05/16 12:34:20 rnhodek
176# Insert a chmod -R go+rX on the build tree to make files readable; it
177# happens sometimes that files in a .orig.tar.gz have restrictive
178# permissions and this can be inconvenient.
179#
180# Revision 1.129 2000/03/01 14:43:34 rnhodek
181# Also match error message "dpkg: status database area is locked" from
182# apt and retry call later.
183#
184# Revision 1.128 2000/02/16 15:21:33 rnhodek
185# Fix a print message in merge_pkg_build_deps.
186#
187# Revision 1.127 2000/02/16 15:20:38 rnhodek
188# Print version number of sbuild in package log.
189#
190# Revision 1.126 2000/02/16 15:15:15 rnhodek
191# Fix regexp for finding !needs-no-XXX packages.
192# Move !needs-no-XXX from central deps to $main::additional_deps so that
193# they can be found by prepare_watches later.
194#
195# Revision 1.125 2000/02/15 14:40:35 rnhodek
196# Remove forgotten debugging code.
197#
198# Revision 1.124 2000/02/15 11:12:43 rnhodek
199# Expand virtual packages in package build dependencies for comparing
200# with central deps.
201#
202# Revision 1.123 2000/02/11 11:17:07 rnhodek
203# Do not activate watches for packages XXX if a negative dependency
204# needs-no-XXX exists (used to be just a comment, now really processed
205# by sbuild.)
206# Also do not activate watches for dependencies of pkg build deps.
207#
208# Revision 1.122 2000/02/09 15:57:25 rnhodek
209# In merge_pkg_build_deps, do not show warnings about missing
210# !this-package-does-not-exist or !needs-no-xxx dependencies.
211#
212# Revision 1.121 2000/02/04 14:04:18 rnhodek
213# Use --no-down-propagation.
214#
215# Revision 1.120 2000/02/01 12:05:56 rnhodek
216# In binNMU mode, a '_' was missing in the job name.
217#
218# Revision 1.119 2000/01/28 14:54:43 rnhodek
219# Accept abbrevs for distribution options (-ds, -df, -du) here, too.
220# New option --make-binNMU=entry.
221# New binNMU hack to modify debian/changelog; it will add a new entry
222# for the NMU version.
223# New helper function binNMU_version to generate a new version number.
224#
225# Revision 1.118 2000/01/13 14:32:30 rnhodek
226# For compiling on slink systems, pass the --force-confold option to
227# dpkg only for versions < 1.4.1.18 (that don't understand it yet).
228#
229# Revision 1.117 1999/12/17 13:49:50 rnhodek
230# Improved output about missing central deps: build-essential (act.
231# policy) and dependencies of pkg build deps are filtered out and
232# printed separately.
233# New functions cmp_dep_lists, read_build_essential,
234# expand_dependencies, and get_dependencies for the above.
235#
236# Revision 1.116 1999/12/17 11:04:43 rnhodek
237# When pkg build-deps were read from debian/sbuild-build-deps, a wrong
238# package name was used.
239#
240# Revision 1.115 1999/12/09 09:54:42 rnhodek
241# Again fixed a fatal typo...
242#
243# Revision 1.114 1999/12/08 12:33:16 rnhodek
244# merge_pkg_build_deps: Fix printing of overrides.
245#
246# Revision 1.113 1999/12/08 12:25:34 rnhodek
247# Special dependencies are implicitly overrides, i.e. are added to the
248# package-provided build deps.
249#
250# Revision 1.112 1999/12/08 11:31:38 rnhodek
251# get_dpkg_status: don't reset $res{$pkg}->{Installed} to 0 if $pkg is
252# provided.
253#
254# Revision 1.111 1999/12/08 10:37:33 rnhodek
255# Change parsing of .dsc file so that multi-line build dependencies are
256# allowed.
257# Make warning about missing central deps a bit bigger.
258#
259# Revision 1.110 1999/12/06 15:00:33 rnhodek
260# Fix comparison with old deps (must copy them, not only the reference).
261#
262# Revision 1.109 1999/12/06 08:35:53 rnhodek
263# Fixed typo.
264#
265# Revision 1.108 1999/12/03 09:58:16 rnhodek
266# If a pkg has its own build deps, compare them with the central ones
267# and report missing ones.
268#
269# Revision 1.107 1999/11/30 13:54:38 rnhodek
270# Print a message if build deps from the .dsc are used (to avoid confusion).
271# If a pkg has build deps, store them in debian/.sbuild-build-deps to
272# have them available when rebuilding later (no .dsc anymore); also
273# check for this file and read deps from it if building without a .dsc
274# in unpacked source.
275#
276# Revision 1.106 1999/11/15 12:30:15 rnhodek
277# merge_pkg_build_deps: added missing if $main::debug.
278#
279# Revision 1.105 1999/11/03 14:56:32 rnhodek
280# When running apt, set env var DEBIAN_FRONTEND to noninteractive to
281# stop debconf from asking questions or complaining that /dev/tty can't
282# be opened.
283#
284# Revision 1.104 1999/11/02 16:43:51 rnhodek
285# check_inst_packages: also upgrade dependencies of src-deps (if they're
286# already installed); some -dev packages fail to correctly require an
287# identical versioned shlib pkg, so in some cases only the -dev pkg was
288# installed.
289#
290# Revision 1.103 1999/11/02 15:45:43 rnhodek
291# build: Use epoch-stripped version number for the .changes file.
292# check_inst_packages: forgot a if $main::debug.
293#
294# Revision 1.102 1999/10/29 13:07:49 rnhodek
295# New option --stats-dir=DIR; if used, a "1" is appended to
296# DIR/give-back each time a package is given back.
297#
298# Revision 1.101 1999/10/29 12:32:24 rnhodek
299# If using an already unpacked source tree, check (with
300# dpkg-parsechangelog) if it's really the requested version.
301# Make apt-get run dpkg with --force-confold, as the </dev/null trick
302# doesn't work anymore with dpkg >= 1.4.1.18.
303#
304# Revision 1.100 1999/10/25 12:12:21 rnhodek
305# check_inst_packages: Add packages to @deps_inst only if they're not
306# already to be installed.
307#
308# Revision 1.99 1999/10/22 09:01:36 rnhodek
309# Minor changes to output of check_inst_packages.
310#
311# Revision 1.98 1999/10/21 14:21:57 rnhodek
312# Oops... call check_inst_packages only if build was successful.
313#
314# Revision 1.97 1999/10/21 11:46:50 rnhodek
315# Deleted RCS logs for < 1.50.
316# New option --store-built-packages.
317# Fix package name parsing: \w also matches '_' which is unwanted;
318# replace by a-zA-Z.
319# Read reverse sourcedeps of $main::store_built_packages.
320# New sub check_inst_packages.
321#
322# Revision 1.96 1999/09/27 11:18:10 rnhodek
323# Added a missing PLOG.
324#
325# Revision 1.95 1999/09/15 09:10:25 rnhodek
326# Additionally print a warning if a special dep has a version relation.
327#
328# Revision 1.94 1999/09/15 09:08:12 rnhodek
329# Changed parsing of dependencies a bit so that special deps can have
330# arch restrictions, too.
331#
332# Revision 1.93 1999/08/30 09:44:35 rnhodek
333# get_dpkg_status: don't exit too early if a pkg isn't in the arg list,
334# as it might be provided only.
335#
336# Revision 1.92 1999/08/27 13:32:04 rnhodek
337# --auto-give-back has a new optional argument, the user and hostname
338# where to call wanna-build (like $conf::sshcmd); this is needed that
339# sbuild can do give-backs when there's no local wanna-build.
340#
341# Revision 1.91 1999/08/23 12:53:02 rnhodek
342# Support for alternatives.
343# Support for [ARCH1 !ARCH2] arch restriction on dependencies.
344# Parses only src-deps which are needed for packages to be built.
345# Reads Build-{Depends,Conflicts}{,-Indep}: fields from .dsc if present;
346# those override the central src-deps, except those marked as override
347# (& prefix).
348# Implemented abbrevs as kind of macros in src-deps.
349# New option --add-depends (-a).
350# New option --arch-all (-A).
351#
352# Revision 1.90 1999/08/11 15:28:11 rnhodek
353# Insert missing wait call in run_script to get correct return value.
354#
355# Revision 1.89 1999/08/10 14:01:49 rnhodek
356# Virtual packages as dependencies didn't work really yet -- the
357# consistency check didn't see them (dpkg --status doesn't know them)
358# and thus aborted the build; solution: get_dpkg_status now directly
359# reads the status file (which should be a bit faster, too) and extracts
360# Provides: fields of all installed packages and considers those virtual
361# packages installed, too.
362# Print "Source-dependencies not satisfied" message to package log, not
363# to sbuild log.
364# Same in run_apt for virtual package handling.
365# Fix stdout/stderr redirecting when running scripts.
366#
367# Revision 1.88 1999/07/13 07:23:55 rnhodek
368# Use GDBM for time/space databases, as perl-5.004 seems not to contain
369# DB_File anymore.
370#
371# Revision 1.87 1999/06/21 12:52:00 rnhodek
372# Seems apt has a new error message if a cached Packages file isn't
373# up-to-date anymore -- recognize this msg, too, and reun apt-get update.
374#
375# Revision 1.86 1999/06/09 15:05:38 rnhodek
376# Fix loop in apply_patches.
377# Don't fail due to failed patch if a global patch.
378# Global patches are no syntax error when parsing src-deps...
379#
380# Revision 1.85 1999/06/04 09:47:02 rnhodek
381# Add support for global patches, which will be tried on any package;
382# their names in source-dependencies start with "**".
383#
384# Revision 1.84 1999/06/04 08:17:17 rnhodek
385# When calling wanna-build --give-back, don't forget the --dist argument!
386# Added support for virtual packages as source dependencies: apt-get tells us
387# which alternatives are possible, and one of these is selected either by
388# %conf::alternatives or by random.
389#
390# Revision 1.83 1999/06/02 09:07:47 rnhodek
391# With --batch, write each finished job to SBUILD-FINISHED; buildd can pick up
392# this file if sbuild crashes and needs not rebuild already done stuff. The file
393# is removed on normal exit and if sbuild dumps to REDO during a shutdown.
394#
395# Revision 1.82 1999/06/02 08:47:39 rnhodek
396# Remove as many die's as possible -- the bad exit status can cause
397# buildd to retry all packages of an sbuild run; better let this one
398# package fail.
399# Make sure that after build() we're in the correct directory: some
400# chdir()s were missing; also don't chdir("..") because this can be
401# wrong if we followed a symlink, use $main::cwd instead.
402# If the package directory already exists as a symlink, abort the build.
403#
404# Revision 1.81 1999/05/31 12:59:41 rnhodek
405# Run du after build under sudo, to avoid error messages about
406# unreadable dirs.
407#
408# Revision 1.80 1999/05/27 13:28:04 rnhodek
409# Oops, missed an epoch fix (when constructing the .changes file name).
410#
411# Revision 1.79 1999/05/26 11:34:11 rnhodek
412# Ignore epochs for fetching files.
413#
414# Revision 1.78 1999/05/26 09:48:23 rnhodek
415# If dpkg-source fails, remove .tmp-nest dir.
416#
417# Revision 1.77 1999/05/05 07:56:51 rnhodek
418# Need to empty %main::this_watches before filling it for a new package;
419# otherwise we have some spurious reports :-)
420#
421# Revision 1.76 1999/05/04 14:51:40 rnhodek
422# Some more minor stuff for avg-build-space: Reset global
423# $main::this_space to 0 before each build to avoid using the figure of
424# the previous package in case of errors; don't write a 0 value into the
425# database.
426#
427# Revision 1.75 1999/05/04 14:43:01 rnhodek
428# Fix parsing of a single dependency: package name never should contain
429# a '('.
430#
431# Revision 1.74 1999/05/04 14:29:51 rnhodek
432# Determine how much space is required for a build (final build dir +
433# generated .debs) after dpkg-buildpackage is finished; display figure
434# in package log and also store it in $conf::avg_space_db (analogous to
435# avg_time_db).
436#
437# Revision 1.73 1999/05/03 12:53:25 rnhodek
438# After unpacking src dir, run "chmod -R g-s ." on it; some
439# .orig.tar.gz's are packed with the setgid bit, which causes the debian
440# dir and all subdirs to be created setgid, too, and later dpkg-deb
441# --build complains about this.
442#
443# Revision 1.72 1999/04/22 14:16:25 rnhodek
444# Don't kill tee process if verbose but --nolog set -- $pkg_tee_pid
445# undefined then!
446#
447# Revision 1.71 1999/04/21 14:54:10 rnhodek
448# Implemented watches if certain binaries have been used during a build
449# without a source dependency.
450#
451# Revision 1.70 1999/03/12 10:29:32 rnhodek
452# New option --force-depends (-f) to override src-deps of a package.
453#
454
455BEGIN {
456 ($main::HOME = $ENV{'HOME'})
457 or die "HOME not defined in environment!\n";
458 push( @INC, "$main::HOME/lib" );
459}
460
461chomp( $main::HOSTNAME = `hostname` );
462
463package conf;
464$HOME = $main::HOME;
465# defaults:
466@dist_parts = qw(main contrib non-free);
467$source_dependencies = "/etc/source-dependencies";
468$mailprog = "/usr/sbin/sendmail";
469$dpkg = "/usr/bin/dpkg";
470$sudo = "/usr/bin/sudo";
471$su = "/bin/su";
472$fakeroot = "/usr/bin/fakeroot";
473$apt_get = "/usr/bin/apt-get";
474$apt_cache = "/usr/bin/apt-cache";
475$dpkg_source = "/usr/bin/dpkg-source";
476$build_env_cmnd = "";
477$pgp_options = "-us -uc";
478$log_dir = "$main::HOME/logs";
479$mailto = "";
480$purge_build_directory = "successful";
481@toolchain_regex = ( 'binutils$', 'gcc-[\d.]+$', 'g\+\+-[\d.]+$', 'libstdc\+\+', 'libc[\d.]+-dev$', 'linux-kernel-headers$', 'dpkg-dev$', 'make$' );
482$stalled_pkg_timeout = 90; # minutes
483$srcdep_lock_wait = 1; # minutes
484%individual_stalled_pkg_timeout = ();
485$path = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/usr/games";
486# read conf files
487require "/etc/sbuild.conf" if -r "/etc/sbuild.conf";
488require "$HOME/.sbuildrc" if -r "$HOME/.sbuildrc";
489# some checks
490#die "mailprog binary $conf::mailprog does not exist or isn't executable\n"
491# if !-x $conf::mailprog;
492die "sudo binary $conf::sudo does not exist or isn't executable\n"
493 if !-x $conf::sudo;
494die "apt-get binary $conf::apt_get does not exist or isn't executable\n"
495 if !-x $conf::apt_get;
496die "apt-cache binary $conf::apt_cache does not exist or isn't executable\n"
497 if !-x $conf::apt_cache;
498die "dpkg-source binary $conf::dpkg_source does not exist or isn't executable\n"
499 if !-x $conf::dpkg_source;
500#die "$conf::log_dir is not a directory\n" if ! -d $conf::log_dir;
501die "$conf::srcdep_lock_dir is not a directory\n" if ! -d $conf::srcdep_lock_dir;
502die "conf::mailto not set\n" if !$conf::mailto;
503package main;
504
505use strict;
506use GDBM_File;
507use POSIX;
508use FileHandle;
509use Cwd;
510
511# avoid intermixing of stdout and stderr
512$| = 1;
513
514# We should not ignore HUP for our children - it breaks test suites.
515# in case the terminal disappears, the build should continue
516#$SIG{'HUP'} = 'IGNORE';
517
518$main::distribution = "";
519$main::distribution = $conf::default_distribution if $conf::default_distribution;
520
521chomp( $main::arch = `$conf::dpkg --print-architecture` );
522$main::username = (getpwuid($<))[0] || $ENV{'LOGNAME'} || $ENV{'USER'};
523$main::debug = 0;
524$main::verbose = 0;
525$main::batchmode = 0;
526$main::auto_giveback = 0;
527$main::nomail = 0;
528$main::build_arch_all = 0;
529$main::build_source = 0;
530$main::jobs_file = cwd() . "/build-progress";
531$main::max_lock_trys = 120;
532$main::lock_interval = 5;
533$main::cwd = cwd();
534$main::ilock_file = "$conf::srcdep_lock_dir/install";
535$main::srcdep_lock_cnt = 0;
536$main::chroot_dir = "";
537$main::chroot_build_dir = "";
538$main::chroot_apt_options = "";
539@main::toolchain_pkgs = ();
540$main::component="";
541$main::nr_processors = $ENV{'NR_PROCESSORS'} if $ENV{'NR_PROCESSORS'};
542
543umask(022);
544
545$main::new_dpkg = 0;
546check_dpkg_version();
547
548while( @ARGV && $ARGV[0] =~ /^-/ ) {
549 $_ = shift @ARGV;
550 if (/^-v$/ || /^--verbose$/) {
551 $main::verbose++;
552 }
553 elsif (/^-D$/ || /^--debug$/) {
554 $main::debug++;
555 }
556 elsif (/^-b$/ || /^--batch$/) {
557 $main::batchmode = 1;
558 }
559 elsif (/^-n$/ || /^--nolog$/) {
560 $main::nolog = 1;
561 }
562 elsif (/^-A$/ || /^--arch-all$/) {
563 $main::build_arch_all++;
564 }
565 elsif (/^-s$/ || /^--source$/) {
566 $main::build_source++;
567 $conf::purge_build_directory = "never";
568 }
569 elsif (/^--architecture=(.)/) {
570 $conf::arch=$1.$';
571 }
572 elsif (/^--archive=(.)/) {
573 $main::archive=$1.$';
574 }
575 elsif (/^--comp=(.)/) {
576 $main::component=$1.$';
577 }
578 elsif (/^--purpose=(.)/) {
579 $main::purpose=$1.$';
580 }
581 elsif (/^--build-debug-symbols$/) {
582 $main::build_debug_symbols = 1;
583 }
584 elsif (/^-d/ || /^--dist/) {
585 if (/^-d(.)/ || /^--dist=(.)/) {
586 $main::distribution = $1.$';
587 }
588 elsif (!@ARGV) {
589 die "$_ option missing argument\n";
590 }
591 else {
592 $main::distribution = shift @ARGV;
593 }
594 $main::distribution = "stable" if $main::distribution eq "s";
595 $main::distribution = "testing" if $main::distribution eq "t";
596 $main::distribution = "unstable" if $main::distribution eq "u";
597 }
598 elsif (/^-p/ || /^--purge/) {
599 if (/^-p(.)/ || /^--purge=(.)/) {
600 $conf::purge_build_directory = $1.$';
601 }
602 elsif (!@ARGV) {
603 die "$_ option missing argument\n";
604 }
605 else {
606 $conf::purge_build_directory = shift @ARGV;
607 }
608 die "Bad purge mode\n"
609 if !isin($conf::purge_build_directory, qw(always successful never));
610 }
611 elsif (/^-m/ || /^--maintainer/) {
612 if (/^-m(.)/ || /^--maintainer=(.)/) {
613 $conf::maintainer_name = $1.$';
614 }
615 elsif (!@ARGV) {
616 die "$_ option missing argument\n";
617 }
618 else {
619 $conf::maintainer_name = shift @ARGV;
620 }
621 }
622 elsif (/^-f/ || /^--force-depends/) {
623 if (/^-f(.)/ || /^--force-depends=(.)/) {
624 push( @main::manual_srcdeps, "f".$1.$' );
625 }
626 elsif (!@ARGV) {
627 die "$_ option missing argument\n";
628 }
629 else {
630 push( @main::manual_srcdeps, "f".(shift @ARGV) );
631 }
632 }
633 elsif (/^-a/ || /^--add-depends/) {
634 if (/^-a(.)/ || /^--add-depends=(.)/) {
635 push( @main::manual_srcdeps, "a".$1.$' );
636 }
637 elsif (!@ARGV) {
638 die "$_ option missing argument\n";
639 }
640 else {
641 push( @main::manual_srcdeps, "a".(shift @ARGV) );
642 }
643 }
644 elsif (/^--auto-give-back(=(.*))?$/) {
645 $main::auto_giveback = 1;
646 if ($2) {
647 my @parts = split( '@', $2 );
648 $main::auto_giveback_socket = "$main::HOME/build" if @parts > 3;
649 $main::auto_giveback_socket .= $parts[$#parts-3] if @parts > 3;
650 $main::auto_giveback_wb_user = $parts[$#parts-2] if @parts > 2;
651 $main::auto_giveback_user = $parts[$#parts-1] if @parts > 1;
652 $main::auto_giveback_host = $parts[$#parts];
653 }
654 }
655 elsif (/^--database=(.+)$/) {
656 $main::database = $1;
657 }
658 elsif (/^--stats-dir=(.+)$/) {
659 $main::stats_dir = $1;
660 }
661 elsif (/^--make-binNMU=(.+)$/) {
662 $main::binNMU = $1;
663 $main::binNMUver ||= 1;
664 }
665 elsif (/^--binNMU=(\d+)$/) {
666 $main::binNMUver = $1;
667 }
668 elsif (/^--use-snapshot$/) {
669 $main::useSNAP = 1;
670 $main::ld_library_path = "/usr/lib/gcc-snapshot/lib";
671 $conf::path = "/usr/lib/gcc-snapshot/bin:$conf::path";
672 }
673 else {
674 die "Unknown option: $_\n";
675 }
676}
677
678die "Need distribution\n" if $main::distribution eq "";
679
680$conf::mailto = $conf::mailto{$main::distribution}
681 if $conf::mailto{$main::distribution};
682
683$main::arch = $conf::arch if $conf::arch;
684
685# variables for scripts:
686open_log();
687$SIG{'INT'} = \&shutdown;
688$SIG{'TERM'} = \&shutdown;
689$SIG{'ALRM'} = \&shutdown;
690$SIG{'PIPE'} = \&shutdown;
691read_deps( map { m,(?:.*/)?([^_/]+)[^/]*, } @ARGV );
692if (-d "chroot-autobuild") {
693 $main::chroot_dir = "chroot-autobuild";
694 $main::chroot_build_dir = "$main::chroot_dir/build/$main::username/";
695 $conf::srcdep_lock_dir = "$main::chroot_dir/var/debbuild/srcdep-lock";
696 $main::ilock_file = "$conf::srcdep_lock_dir/install";
697 my $absroot = "$main::cwd/$main::chroot_dir";
698 $main::chroot_apt_options =
699 "-o APT::Architecture=$main::arch ".
700 "-o Dir::State=$absroot/var/".
701 (-d "$absroot/var/lib/apt" ? "lib":"state")."/apt ".
702 "-o Dir::State::status=$absroot/var/lib/dpkg/status ".
703 "-o Dir::Cache=$absroot/var/cache/apt ".
704 "-o Dir::Etc=$absroot/etc/apt ".
705 "-o DPkg::Options::=--root=$absroot ".
706 "-o DPkg::Options::=--force-architecture ".
707 "-o DPkg::Run-Directory=$absroot";
708 $main::chroot_apt_op = '$CHROOT_OPTIONS';
709}
710write_jobs_file();
711
712my( $pkgv, $pkg );
713foreach $pkgv (@ARGV) {
714 my $urlbase;
715
716
717 ($urlbase, $pkgv) = ($1, $3) if $pkgv =~ m,^(\w+://(\S+/)?)([^/]+)$,;
718 $pkgv =~ s/\.dsc$//;
719 next if !open_pkg_log( $pkgv );
720 (my $pkg = $pkgv) =~ s/_.*$//;
721 $main::pkg_start_time = time;
722 $main::this_space = 0;
723 $main::pkg_status = "failed"; # assume for now
724 $main::current_job = $main::binNMU_name || $pkgv;
725 $main::additional_deps = [];
726 write_jobs_file( "currently building" );
727 if (should_skip( $pkgv )) {
728 $main::pkg_status = "skipped";
729 goto cleanup_close;
730 }
731 my $dscfile = $pkgv.".dsc";
732 $main::pkg_fail_stage = "fetch-src";
733 my @files_to_rm = fetch_source_files( \$dscfile );
734 if (@files_to_rm && $files_to_rm[0] eq "ERROR") {
735 shift @files_to_rm;
736 goto cleanup_symlinks;
737 }
738
739 $main::pkg_fail_stage = "install-deps";
740 if (!install_deps( $pkg )) {
741 print PLOG "Source-dependencies not satisfied; skipping $pkg\n";
742 goto cleanup_packages;
743 }
744
745 my $dscbase = basename( $dscfile );
746 $main::pkg_status = "successful" if build( $dscbase, $pkgv );
747 chdir( $main::cwd );
748 write_jobs_file( $main::pkg_status );
749 append_to_FINISHED( $main::current_job );
750
751 cleanup_packages:
752 undo_specials();
753 uninstall_deps();
754 remove_srcdep_lock_file();
755 cleanup_symlinks:
756 remove_files( @files_to_rm );
757 cleanup_close:
758 analyze_fail_stage( $pkgv );
759 if( $main::pkg_status eq 'failed' ) {
760 $main::pkg_status = 'failed ' . $main::pkg_fail_stage;
761 }
762 write_jobs_file( $main::pkg_status );
763 close_pkg_log( $pkgv );
764 $main::current_job = "";
765 if ( $main::batchmode and (-f "$main::HOME/EXIT-DAEMON-PLEASE") ) {
766 main::shutdown("NONE (flag file exit)");
767 }
768}
769write_jobs_file();
770
771close_log();
772#unlink( $main::jobs_file ) if $main::batchmode;
773unlink( "SBUILD-FINISHED" ) if $main::batchmode;
774exit 0;
775
776sub fetch_source_files {
777 my $dscfile_ref = shift;
778 my $dscfile = $$dscfile_ref;
779 my ($dir, $dscbase, $files, @other_files, $dscarchs, @made);
780 my ($build_depends, $build_depends_indep, $build_conflicts,
781 $build_conflicts_indep);
782 local( *F );
783
784 $dscfile =~ m,^(.*)/([^/]+)$,;
785 ($dir, $dscbase) = ($1, $2);
786 my $urlbase;
787 $urlbase = $1 if $dscfile =~ m,^(\w+://(\S+/)?)([^/]+)$,;
788 (my $pkgv = $dscfile) =~ s,^(.*/)?([^/]+)\.dsc$,$2,;
789 my ($pkg, $version) = split /_/, $pkgv;
790 @main::have_dsc_build_deps = ();
791
792 if (-d $dscfile) {
793 if (-f "$dscfile/debian/.sbuild-build-deps") {
794 open( F, "<$dscfile/debian/.sbuild-build-deps" );
795 my $pkg;
796 while( <F> ) {
797 /^Package:\s*(.*)\s*$/i and $pkg = $1;
798 /^Build-Depends:\s*(.*)\s*$/i and $build_depends = $1;
799 /^Build-Depends-Indep:\s*(.*)\s*$/i and $build_depends_indep = $1;
800 /^Build-Conflicts:\s*(.*)\s*$/i and $build_conflicts = $1;
801 /^Build-Conflicts-Indep:\s*(.*)\s*$/i and $build_conflicts_indep = $1;
802 }
803 close( F );
804 if ($build_depends || $build_depends_indep || $build_conflicts ||
805 $build_conflicts_indep) {
806 merge_pkg_build_deps( $pkg, $build_depends,
807 $build_depends_indep, $build_conflicts,
808 $build_conflicts_indep );
809 }
810 }
811 return;
812 }
813
814 if ($dir ne ".") {
815 {
816 if (-f "${pkgv}.dsc") {
817 print PLOG "${pkgv}.dsc exists in cwd\n";
818 }
819 else {
820 my %entries;
821 my $retried = 0;
822
823 retry:
824 print PLOG "Checking available source versions...\n";
825 if (!open( PIPE, "$conf::sudo /usr/sbin/chroot ".
826 "$main::chroot_dir $conf::apt_cache ".
827 "-q showsrc $pkg 2>&1 </dev/null |" )) {
828 print PLOG "Can't open pipe to apt-cache: $!\n";
829 return ("ERROR");
830 }
831 { local($/) = "";
832 while( <PIPE> ) {
833 my $ver = $1 if /^Version:\s+(\S+)\s*$/mi;
834 my $tfile = $1 if /^Files:\s*\n((\s+.*\s*\n)+)/mi;
835 @{$entries{$ver}} = map { (split( /\s+/, $_ ))[3] }
836 split( "\n", $tfile );
837 }
838 }
839 close( PIPE );
840 if ($?) {
841 print PLOG "$conf::apt_cache failed\n";
842 return ("ERROR");
843 }
844
845 if (!defined($entries{$version})) {
846 if (!$retried) {
847 # try to update apt's cache if nothing found
848 system "$conf::sudo /usr/sbin/chroot ".
849 "$main::chroot_dir $conf::apt_get ".
850 "update >/dev/null";
851 $retried = 1;
852 goto retry;
853 }
854 print PLOG "Can't find source for $pkgv\n";
855 print PLOG "(only different version(s) ",
856 join( ", ", sort keys %entries), " found)\n"
857 if %entries;
858 return( "ERROR" );
859 }
860
861 print PLOG "Fetching source files...\n";
862 @made = @{$entries{$version}};
863 if (!open( PIPE, "$conf::apt_get $main::chroot_apt_options ".
864 "--only-source -q -d source $pkg=$version 2>&1 </dev/null |" )) {
865 print PLOG "Can't open pipe to $conf::apt_get: $!\n";
866 return ("ERROR", @made);
867 }
868 while( <PIPE> ) {
869 print PLOG $_;
870 }
871 close( PIPE );
872 if ($?) {
873 print PLOG "$conf::apt_get for sources failed\n";
874 return( "ERROR", @made );
875 }
876 # touch the downloaded files, otherwise buildd-watcher
877 # will complain that they're old :)
878 $$dscfile_ref = $dscfile = (grep { /\.dsc$/ } @made)[0];
879 }
880 }
881 }
882
883 if (!open( F, "<$dscfile" )) {
884 print PLOG "Can't open $dscfile: $!\n";
885 return( "ERROR", @made );
886 }
887 my $dsctext;
888 { local($/); $dsctext = <F>; }
889 close( F );
890
891 $dsctext =~ /^Build-Depends:\s*((.|\n\s+)*)\s*$/mi
892 and $build_depends = $1;
893 $dsctext =~ /^Build-Depends-Indep:\s*((.|\n\s+)*)\s*$/mi
894 and $build_depends_indep = $1;
895 $dsctext =~ /^Build-Conflicts:\s*((.|\n\s+)*)\s*$/mi
896 and $build_conflicts = $1;
897 $dsctext =~ /^Build-Conflicts-Indep:\s*((.|\n\s+)*)\s*$/mi
898 and $build_conflicts_indep = $1;
899 $build_depends =~ s/\n\s+/ /g if defined $build_depends;
900 $build_depends_indep =~ s/\n\s+/ /g if defined $build_depends_indep;
901 $build_conflicts =~ s/\n\s+/ /g if defined $build_conflicts;
902 $build_conflicts_indep =~ s/\n\s+/ /g if defined $build_conflicts_indep;
903
904 $dsctext =~ /^Architecture:\s*(.*)$/mi and $dscarchs = $1;
905
906 $dsctext =~ /^Files:\s*\n((\s+.*\s*\n)+)/mi and $files = $1;
907 @other_files = map { (split( /\s+/, $_ ))[3] } split( "\n", $files );
908
909 if (!$dscarchs) {
910 print PLOG "$dscbase has no Architecture: field -- skipping arch check!\n";
911 }
912 else {
913 my $valid_arch;
914 for my $a (split(/\s+/, $dscarchs)) {
915 if (system('dpkg-architecture', '-a' . $main::arch, '-i' . $a) eq 0) {
916 $valid_arch = 1;
917 last;
918 }
919 }
920 if ($dscarchs ne "any" && !($valid_arch) &&
921 !($dscarchs eq "all" && $main::build_arch_all) ) {
922 my $msg = "$dscbase: $main::arch not in arch list or does not match any arch ";
923 $msg .= "wildcards: $dscarchs -- skipping\n";
924 print PLOG $msg;
925 $main::pkg_fail_stage = "arch-check";
926 return( "ERROR", @made );
927 }
928 }
929 print "Arch check ok ($main::arch included in $dscarchs)\n"
930 if $main::debug;
931
932 if ($build_depends || $build_depends_indep || $build_conflicts ||
933 $build_conflicts_indep) {
934 @main::have_dsc_build_deps = ($build_depends, $build_depends_indep,
935 $build_conflicts,$build_conflicts_indep);
936 merge_pkg_build_deps( $pkg, $build_depends, $build_depends_indep,
937 $build_conflicts, $build_conflicts_indep );
938 }
939
940 return @made;
941}
942
943sub build {
944 my $dsc = shift;
945 my $pkgv = shift;
946 my( $dir, $rv, $changes );
947 my $do_apply_patches = 1;
948 local( *PIPE, *F, *F2 );
949
950 fixup_pkgv( \$pkgv );
951 print PLOG "-"x78, "\n";
952 # count build time from now, ignoring the installation of source deps
953 $main::pkg_start_time = time;
954 $main::this_space = 0;
955 $pkgv =~ /^([a-zA-Z\d.+-]+)_([a-zA-Z\d:.+~-]+)/;
956 my ($pkg, $version) = ($1,$2);
957 (my $sversion = $version) =~ s/^\d+://;
958 my $tmpunpackdir = $dsc;
959 $tmpunpackdir =~ s/-.*$/.orig.tmp-nest/;
960 $tmpunpackdir =~ s/_/-/;
961 $tmpunpackdir = "$main::chroot_build_dir$tmpunpackdir";
962
963 if (-d "$main::chroot_build_dir$dsc" && -l "$main::chroot_build_dir$dsc") {
964 # if the package dir already exists but is a symlink, complain
965 print PLOG "Cannot unpack source: a symlink to a directory with the\n",
966 "same name already exists.\n";
967 return 0;
968 }
969 if (! -d "$main::chroot_build_dir$dsc") {
970 $main::pkg_fail_stage = "unpack";
971 # dpkg-source refuses to remove the remanants of an
972 # aborted dpkg-source extraction, so we will if necessary.
973 if (-d $tmpunpackdir) {
974 system ("rm -fr $tmpunpackdir");
975 }
976 $main::sub_pid = open( PIPE, "-|" );
977 if (!defined $main::sub_pid) {
978 print PLOG "Can't spawn dpkg-source: $!\n";
979 return 0;
980 }
981 if ($main::sub_pid == 0) {
982 setpgrp( 0, $$ );
983 if ($main::chroot_build_dir && !chdir( $main::chroot_build_dir )) {
984 print PLOG "Couldn't cd to $main::chroot_build_dir: $!\n";
985 system ("rm -fr $tmpunpackdir") if -d $tmpunpackdir;
986 exit 1;
987 }
988
989 my @files;
990 push( @files, $dsc );
991 if (!open( F, "<$main::cwd/$dsc" )) {
992 print PLOG "Can't open $main::cwd/$dsc: $!\n";
993 return 0;
994 }
995 my $dsctext;
996 { local($/); $dsctext = <F>; }
997 close( F );
998 my $files;
999 $dsctext =~ /^Files:\s*\n((\s+.*\s*\n)+)/mi and $files = $1;
1000 push(@files, map { (split( /\s+/, $_ ))[3] } split( "\n", $files ));
1001
1002 my $file;
1003 foreach $file (@files) {
1004 system ("cp", "$main::cwd/$file", "$file");
1005 }
1006 exec "$conf::sudo", "/usr/sbin/chroot", "$main::cwd/$main::chroot_dir",
1007 "$conf::su", $main::username, "-s", "/bin/sh", "-c",
1008 "cd /build/$main::username && $conf::dpkg_source -sn -x $dsc 2>&1";
1009 unlink @files;
1010 }
1011 $main::sub_task = "dpkg-source";
1012
1013 while( <PIPE> ) {
1014 print PLOG $_;
1015 $dir = $1 if /^dpkg-source: (?:info: )?extracting \S+ in (\S+)/;
1016 $main::pkg_fail_stage = "unpack-check"
1017 if /^dpkg-source: error: file.*instead of expected/;
1018 }
1019 close( PIPE );
1020 undef $main::sub_pid;
1021 if ($?) {
1022 print PLOG "FAILED [dpkg-source died]\n";
1023
1024 system ("rm -fr $tmpunpackdir") if -d $tmpunpackdir;
1025 return 0;
1026 }
1027 if (!$dir) {
1028 print PLOG "Couldn't find directory of $dsc in dpkg-source output\n";
1029 system ("rm -fr $tmpunpackdir") if -d $tmpunpackdir;
1030 return 0;
1031 }
1032 $dir = "$main::chroot_build_dir$dir";
1033
1034 if (system( "chmod -R g-s,go+rX $dir" ) != 0) {
1035 print PLOG "chmod -R g-s,go+rX $dir failed.\n";
1036 return 0;
1037 }
1038
1039 if (@main::have_dsc_build_deps && !defined $main::build_source) {
1040 my ($d, $di, $c, $ci) = @main::have_dsc_build_deps;
1041 open( F, ">$dir/debian/.sbuild-build-deps" );
1042 print F "Package: $pkg\n";
1043 print F "Build-Depends: $d\n" if $d;
1044 print F "Build-Depends-Indep: $di\n" if $di;
1045 print F "Build-Conflicts: $c\n" if $c;
1046 print F "Build-Conflicts-Indep: $ci\n" if $ci;
1047 close( F );
1048 }
1049 }
1050 else {
1051 $dir = "$main::chroot_build_dir$dsc";
1052 $do_apply_patches = 0;
1053
1054 $main::pkg_fail_stage = "check-unpacked-version";
1055 # check if the unpacked tree is really the version we need
1056 $main::sub_pid = open( PIPE, "-|" );
1057 if (!defined $main::sub_pid) {
1058 print PLOG "Can't spawn dpkg-parsechangelog: $!\n";
1059 return 0;
1060 }
1061 if ($main::sub_pid == 0) {
1062 setpgrp( 0, $$ );
1063 chdir( $dir );
1064 exec "dpkg-parsechangelog 2>&1";
1065 }
1066 $main::sub_task = "dpkg-parsechangelog";
1067
1068 my $clog = "";
1069 while( <PIPE> ) {
1070 $clog .= $_;
1071 }
1072 close( PIPE );
1073 undef $main::sub_pid;
1074 if ($?) {
1075 print PLOG "FAILED [dpkg-parsechangelog died]\n";
1076 return 0;
1077 }
1078 if ($clog !~ /^Version:\s*(.+)\s*$/mi) {
1079 print PLOG "dpkg-parsechangelog didn't print Version:\n";
1080 return 0;
1081 }
1082 my $tree_version = $1;
1083 my $cmp_version = ($main::binNMU && -f "$dir/debian/.sbuild-binNMU-done") ?
1084 binNMU_version($version) : $version;
1085 if ($tree_version ne $cmp_version) {
1086 print PLOG "The unpacked source tree $dir is version ".
1087 "$tree_version, not wanted $cmp_version!\n";
1088 return 0;
1089 }
1090 }
1091
1092 if (!chdir( $dir )) {
1093 print PLOG "Couldn't cd to $dir: $!\n";
1094 system ("rm -fr $tmpunpackdir") if -d $tmpunpackdir;
1095 return 0;
1096 }
1097
1098 $main::pkg_fail_stage = "check-space";
1099 my $current_usage = `/usr/bin/du -s .`;
1100 $current_usage =~ /^(\d+)/;
1101 $current_usage = $1;
1102 if ($current_usage) {
1103 my $free = df( "." );
1104 if ($free < 2*$current_usage) {
1105 print PLOG "Disk space is propably not enough for building.\n".
1106 "(Source needs $current_usage KB, free are $free KB.)\n";
1107 print PLOG "Purging $dir\n";
1108 chdir( $main::cwd );
1109 system "$conf::sudo rm -rf $dir";
1110 return 0;
1111 }
1112 }
1113
1114 $main::pkg_fail_stage = "hack-binNMU";
1115 if ($main::binNMU && ! -f "debian/.sbuild-binNMU-done") {
1116 if (open( F, "<debian/changelog" )) {
1117 my($firstline, $text);
1118 $firstline = <F> while $firstline =~ /^$/;
1119 { local($/); undef $/; $text = <F>; }
1120 close( F );
1121 $firstline =~ /^(\S+)\s+\((\S+)\)\s+([^;]+)\s*;\s*urgency=(\S+)\s*$/;
1122 my ($name, $version, $dists, $urgent) = ($1, $2, $3, $4);
1123 my $NMUversion = binNMU_version($version);
1124 chomp( my $date = `822-date` );
1125 if (!open( F, ">debian/changelog" )) {
1126 print PLOG "Can't open debian/changelog for binNMU hack: $!\n";
1127 chdir( $main::cwd );
1128 return 0;
1129 }
1130 $dists = $main::distribution;
1131 print F "$name ($NMUversion) $dists; urgency=low\n\n";
1132 print F " * Binary-only non-maintainer upload for $main::arch; ",
1133 "no source changes.\n";
1134 print F " * ", join( " ", split( "\n", $main::binNMU )), "\n\n";
1135 print F " -- $conf::maintainer_name $date\n\n";
1136
1137 print F $firstline, $text;
1138 close( F );
1139 system "touch debian/.sbuild-binNMU-done";
1140 print PLOG "*** Created changelog entry for bin-NMU version $NMUversion\n";
1141 }
1142 else {
1143 print PLOG "Can't open debian/changelog -- no binNMU hack!\n";
1144 }
1145 }
1146
1147 if ($do_apply_patches) {
1148 if (!apply_patches( $pkg )) {
1149 chdir( $main::cwd );
1150 return 0;
1151 }
1152 }
1153
1154 if (-f "debian/files") {
1155 local( *FILES );
1156 my @lines;
1157 open( FILES, "<debian/files" );
1158 chomp( @lines = <FILES> );
1159 close( FILES );
1160 @lines = map { my $ind = 68-length($_);
1161 $ind = 0 if $ind < 0;
1162 "| $_".(" " x $ind)." |\n"; } @lines;
1163
1164 print PLOG <<"EOF";
1165
1166+----------------------------------------------------------------------+
1167| sbuild Warning: |
1168| --------------- |
1169| After unpacking, there exists a file debian/files with the contents: |
1170| |
1171EOF
1172 print PLOG @lines;
1173 print PLOG <<"EOF";
1174| |
1175| This should be reported as a bug. |
1176| The file has been removed to avoid dpkg-genchanges errors. |
1177+----------------------------------------------------------------------+
1178
1179EOF
1180 unlink "debian/files";
1181 }
1182
1183 open CURRENT, ">$main::cwd/$main::chroot_dir/CurrentlyBuilding" or die "$main::cwd/$main::chroot_dir/CurrentlyBuilding open failed";
1184 # Package: must be first
1185 print CURRENT "Package: $pkg\nComponent: $main::component\n";
1186 print CURRENT "Suite: $main::distribution\n" if $main::distribution;
1187 print CURRENT "Purpose: $main::purpose\n" if $main::purpose;
1188 print CURRENT "Build-Debug-Symbols: yes\n" if $main::build_debug_symbols;
1189 close CURRENT;
1190
1191 $main::build_start_time = time;
1192 $main::pkg_fail_stage = "build";
1193 $main::sub_pid = open( PIPE, "-|" );
1194 if (!defined $main::sub_pid) {
1195 print PLOG "Can't spawn dpkg-buildpackage: $!\n";
1196 chdir( $main::cwd );
1197 return 0;
1198 }
1199 if ($main::sub_pid == 0) {
1200 setpgrp( 0, $$ );
1201 my $binopt = $main::build_source ? "" :
1202 $main::build_arch_all ? "-b" : "-B";
1203 my $env_cmnd = $conf::build_env_cmnd;
1204 $env_cmnd = $conf::build_env_cmnd{$pkg} if $conf::build_env_cmnd{$pkg};
1205 if ($main::chroot_dir) {
1206 my $bdir = $dir;
1207 $bdir =~ s/^\Q$main::chroot_dir\E//;
1208 if (-f "$main::chroot_dir/etc/ld.so.conf" &&
1209 ! -r "$main::chroot_dir/etc/ld.so.conf") {
1210 system "$conf::sudo chmod a+r $main::chroot_dir/etc/ld.so.conf";
1211 print PLOG "ld.so.conf was not readable! Fixed.\n";
1212 }
1213 exec "$conf::sudo", "/usr/sbin/chroot", "$main::cwd/$main::chroot_dir",
1214 "$conf::su", $main::username, "-s", "/bin/sh", "-c",
1215 "cd $bdir && PATH=$conf::path ".
1216 (defined($main::nr_processors) ?
1217 "DEB_BUILD_OPTIONS=\"parallel=".$main::nr_processors."\" " : "").
1218 (defined($main::ld_library_path) ?
1219 "LD_LIBRARY_PATH=".$main::ld_library_path." " : "").
1220 "exec $env_cmnd dpkg-buildpackage $conf::pgp_options ".
1221 "$binopt -m'$conf::maintainer_name' -r$conf::fakeroot 2>&1";
1222 }
1223 else {
1224 if (-f "/etc/ld.so.conf" && ! -r "/etc/ld.so.conf") {
1225 system "$conf::sudo chmod a+r /etc/ld.so.conf";
1226 print PLOG "ld.so.conf was not readable! Fixed.\n";
1227 }
1228 exec "$env_cmnd dpkg-buildpackage $conf::pgp_options $binopt ".
1229 "-m'$conf::maintainer_name' -r$conf::fakeroot 2>&1";
1230 }
1231 }
1232 $main::sub_task = "dpkg-buildpackage";
1233
1234 # We must send the signal as root, because some subprocesses of
1235 # dpkg-buildpackage could run as root. So we have to use a shell
1236 # command to send the signal... but /bin/kill can't send to
1237 # process groups :-( So start another Perl :-)
1238 my $timeout = $conf::individual_stalled_pkg_timeout{$pkg} ||
1239 $conf::stalled_pkg_timeout;
1240 $timeout *= 60;
1241 my $timed_out = 0;
1242 my(@timeout_times, @timeout_sigs, $last_time);
1243 $SIG{'ALRM'} = sub {
1244 my $signal = ($timed_out > 0) ? 9 : 15;
1245 system "$conf::sudo perl -e 'kill( -$signal, $main::sub_pid )'";
1246 $timeout_times[$timed_out] = time - $last_time;
1247 $timeout_sigs[$timed_out] = $signal;
1248 $timed_out++;
1249 $timeout = 5*60; # only wait 5 minutes until next signal
1250 };
1251
1252 alarm( $timeout );
1253 while( <PIPE> ) {
1254 alarm( $timeout );
1255 $last_time = time;
1256 print PLOG $_;
1257 }
1258 close( PIPE );
1259 undef $main::sub_pid;
1260 alarm( 0 );
1261 $rv = $?;
1262
1263 my $i;
1264 for( $i = 0; $i < $timed_out; ++$i ) {
1265 print PLOG "Build killed with signal ", $timeout_sigs[$i],
1266 " after ", int($timeout_times[$i]/60),
1267 " minutes of inactivity\n";
1268 }
1269 $main::pkg_end_time = time;
1270 my $date = `date +%Y%m%d-%H%M`;
1271 print PLOG "*"x78, "\n";
1272 print PLOG "Build finished at $date";
1273 chdir( $main::cwd );
1274
1275 my @space_files = ("$dir");
1276 if (!$main::nolog and defined $conf::exit_hook and open TMP, '-|', "$conf::exit_hook <$main::pkg_logfile") {
1277 local $/ = undef;
1278 my $log = <TMP>;
1279 close TMP;
1280 $rv |= $?;
1281 print PLOG $log;
1282 }
1283 if ($rv) {
1284 print PLOG "FAILED [dpkg-buildpackage died]\n";
1285 }
1286 else {
1287 my $trans_oldfmt="$main::chroot_build_dir${pkg}_${version}_translations.tar.gz";
1288 my $trans_newfmt="$main::chroot_build_dir${pkg}_${version}_${main::arch}_translations.tar.gz";
1289 my $translations="";
1290 if (-r $trans_newfmt) {
1291 $translations = $trans_newfmt;
1292 } elsif (-r $trans_oldfmt) {
1293 $translations = $trans_oldfmt;
1294 }
1295 if ($translations) {
1296 print PLOG "Publishing $translations for rosetta.\n";
1297 my $date = strftime '%Y%m%d',gmtime;
1298 my $target = "$main::HOME/public_html/translations/$date/";
1299 system "mkdir -p $target";
1300 if (system("cp",$translations,$target) != 0) {
1301 print PLOG "ERROR: Could not move $translations to $target\n";
1302 } else {
1303 open TRANS, ">>$target/translations.txt";
1304 print TRANS "File: " . basename(${translations}) . "\n".
1305 "Distribution: ${main::archive}\n".
1306 "Release: ${main::distribution}\n".
1307 "Component: ${main::component}\n".
1308 "Source: ${pkg}\n".
1309 "Version: ${version}\n\n";
1310 close TRANS;
1311 system("chmod -R go+rX $main::HOME/public_html/translations");
1312 }
1313 }
1314
1315 my $ddebtar = "";
1316 my $ddebstring = "";
1317 if (-r glob("$main::chroot_build_dir/*.ddeb")) {
1318 my @ddeblist = glob("$main::chroot_build_dir/*.ddeb");
1319 $ddebtar="${pkg}_${version}_${main::arch}_ddebs.tar";
1320 while (@ddeblist) {
1321 $ddebstring .= basename(@ddeblist[0]) . " ";
1322 shift @ddeblist;
1323 }
1324 }
1325 if ($ddebstring) {
1326 print PLOG "Publishing debug debs.\n";
1327 my $date = strftime '%Y%m%d',gmtime;
1328 my $target = "$main::HOME/public_html/ddebs/$date/";
1329 system "mkdir -p $target";
1330 if (system("tar -C $main::chroot_build_dir -chf $target/$ddebtar $ddebstring") != 0) {
1331 print PLOG "ERROR: Could not create $ddebtar in $target\n";
1332 } else {
1333 open TRANS, ">>$target/ddebs.txt";
1334 print TRANS "File: " . basename(${ddebtar}) . "\n".
1335 "Distribution: ${main::archive}\n".
1336 "Release: ${main::distribution}\n".
1337 "Component: ${main::component}\n".
1338 "Source: ${pkg}\n".
1339 "Version: ${version}\n\n";
1340 close TRANS;
1341 system("chmod -R go+rX $main::HOME/public_html/ddebs");
1342 }
1343 }
1344
1345 if (-r "$dir/debian/files") {
1346 my @debs;
1347 my @files;
1348 open( F, "<$dir/debian/files" );
1349 while( <F> ) {
1350 my $f = (split( /\s+/, $_ ))[0];
1351 push( @files, "$main::chroot_build_dir$f" );
1352 if ($main::build_arch_all) {
1353 next if ($f !~ /$main::arch\.[\w\d.-]*$/ && $f !~ /all\.[\w\d.-]*$/);
1354 } else {
1355 next if ($f !~ /$main::arch\.[\w\d.-]*$/);
1356 }
1357 push( @debs, "$main::chroot_build_dir$f" );
1358 push( @space_files, $f );
1359 }
1360 close( F );
1361 my @debs2 = @debs;
1362 foreach (@debs) {
1363 print PLOG "\n$_:\n";
1364 if (!open( PIPE, "dpkg --info $_ 2>&1 |" )) {
1365 print PLOG "Can't spawn dpkg: $! -- can't dump infos\n";
1366 }
1367 else {
1368 print PLOG $_ while( <PIPE> );
1369 close( PIPE );
1370 }
1371 }
1372 foreach (@debs2) {
1373 print PLOG "\n$_:\n";
1374 if (!open( PIPE, "dpkg --contents $_ 2>&1 |" )) {
1375 print PLOG "Can't spawn dpkg: $! -- can't dump infos\n";
1376 }
1377 else {
1378 print PLOG $_ while( <PIPE> );
1379 close( PIPE );
1380 }
1381 }
1382 if ($main::chroot_build_dir) {
1383 foreach (@files) {
1384 system "mv", $_, "."
1385 and print PLOG "ERROR: Could not move $_ to .\n";
1386 }
1387 }
1388 }
1389
1390 if (-r $translations) {
1391 system("rm",$translations);
1392 }
1393
1394 $changes = "${pkg}_".
1395 ($main::binNMU ? binNMU_version($sversion) : $sversion).
1396 "_$main::arch.changes";
1397 if (-r "$main::chroot_build_dir$changes") {
1398 my(@do_dists, @saved_dists);
1399 print PLOG "\n$changes:\n";
1400 open( F, "<$main::chroot_build_dir$changes" );
1401 if (open( F2, ">$changes.new" )) {
1402 while( <F> ) {
1403 if (/^Distribution:\s*(.*)\s*$/) {
1404 print PLOG "Distribution: $main::distribution\n";
1405 print F2 "Distribution: $main::distribution\n";
1406 }
1407 else {
1408 print F2 $_;
1409 while (length $_ > 989)
1410 {
1411 my $index = rindex($_,' ',989);
1412 print PLOG substr ($_,0,$index) . "\n";
1413 $_ = ' ' . substr ($_,$index+1);
1414 }
1415 print PLOG $_;
1416 }
1417 }
1418 close( F2 );
1419 rename( "$changes.new", "$changes" )
1420 or print PLOG "$changes.new could not be renamed ".
1421 "to $changes: $!\n";
1422 unlink( "$main::chroot_build_dir$changes" )
1423 if $main::chroot_build_dir;
1424 }
1425 else {
1426 print PLOG "Cannot create $changes.new: $!\n";
1427 print PLOG "Distribution field may be wrong!!!\n";
1428 if ($main::chroot_build_dir) {
1429 system "mv", "$main::chroot_build_dir$changes", "."
1430 and print PLOG "ERROR: Could not move $_ to .\n";
1431 }
1432 }
1433 close( F );
1434 print PLOG "\n";
1435 }
1436 else {
1437 print PLOG "Can't find $changes -- can't dump infos\n";
1438 }
1439
1440 print PLOG "*"x78, "\n";
1441 print PLOG "Built successfully\n";
1442 }
1443
1444 check_watches();
1445 check_space( @space_files );
1446
1447 if ($conf::purge_build_directory eq "always" ||
1448 ($conf::purge_build_directory eq "successful" && $rv == 0)) {
1449 print PLOG "Purging $dir\n";
1450 system "$conf::sudo rm -rf $dir";
1451 }
1452
1453 print PLOG "-"x78, "\n";
1454 return $rv == 0 ? 1 : 0;
1455}
1456
1457sub apply_patches {
1458 my $pkg = shift;
1459 my $name;
1460
1461 $main::pkg_fail_stage = "apply-patch";
1462 foreach $name ((map { $_->{'Package'} } @{$main::deps{$pkg}}),
1463 @main::global_patches) {
1464 if ($name =~ /^\*/ && exists $main::specials{$name}->{'patch'}) {
1465 if (exists $main::specials{$name}->{'patchcond'}) {
1466 print "Testing condition for $name patch:\n"
1467 if $main::debug;
1468 if (run_script("+e",$main::specials{$name}->{'patchcond'})!=0){
1469 print PLOG "Condition for $name patch not true -- ",
1470 "not applying\n" if $name !~ /^\*\*/;
1471 next;
1472 }
1473 print PLOG "Condition for $name patch ok\n";
1474 }
1475 print PLOG "Applying $name patch\n";
1476 $main::sub_pid = open( PIPE, "|-" );
1477 if (!defined $main::sub_pid) {
1478 print PLOG "Can't spawn patch: $! -- can't patch\n";
1479 return 0;
1480 }
1481 if ($main::sub_pid == 0) {
1482 setpgrp( 0, $$ );
1483 open( STDOUT, ">&PLOG" );
1484 open( STDERR, ">&PLOG" );
1485 exec "patch --batch --quiet -p1 -E -N --no-backup-if-mismatch";
1486 }
1487 $main::sub_task = "patch";
1488
1489 print PIPE $main::specials{$name}->{'patch'};
1490 close( PIPE );
1491 undef $main::sub_pid;
1492 if ($name !~ /^\*\*/ && $?) {
1493 print PLOG "FAILED [patch died]\n";
1494 return 0;
1495 }
1496 }
1497 }
1498 return 1;
1499}
1500
1501sub analyze_fail_stage {
1502 my $pkgv = shift;
1503
1504 return if $main::pkg_status ne "failed";
1505 return if !$main::auto_giveback;
1506 if (isin( $main::pkg_fail_stage,
1507 qw(find-dsc fetch-src unpack-check check-space install-deps-env))) {
1508 $main::pkg_status = "given-back";
1509 print PLOG "Giving back package $pkgv after failure in ".
1510 "$main::pkg_fail_stage stage.\n";
1511 chdir( $main::cwd );
1512 my $cmd = "";
1513 $cmd = "ssh -l$main::auto_giveback_user $main::auto_giveback_host "
1514 if $main::auto_giveback_host;
1515 $cmd .= "-S $main::auto_giveback_socket "
1516 if ($main::auto_giveback_socket and -S "$main::auto_giveback_socket");
1517 $cmd .= "wanna-build --give-back --no-down-propagation ".
1518 "--dist=$main::distribution";
1519 $cmd .= " --database=$main::database" if $main::database;
1520 $cmd .= " --user=$main::auto_giveback_wb_user "
1521 if $main::auto_giveback_wb_user;
1522 $cmd .= " $pkgv";
1523 system $cmd;
1524 if ($?) {
1525 print PLOG "wanna-build failed with status $?\n";
1526 }
1527 else {
1528 add_givenback( $pkgv, time );
1529 if ($main::stats_dir) {
1530 local( *F );
1531 lock_file( "$main::stats_dir" );
1532 open( F, ">>$main::stats_dir/give-back" );
1533 print F "1\n";
1534 close( F );
1535 unlock_file( "$main::stats_dir" );
1536 }
1537 }
1538 }
1539}
1540
1541sub remove_files {
1542
1543 foreach (@_) {
1544 unlink $_;
1545 print "Removed $_\n" if $main::debug;
1546 }
1547}
1548
1549
1550sub install_deps {
1551 my $pkg = shift;
1552 my( @positive, @negative, @special, @instd, @rmvd );
1553
1554 if (!exists $main::deps{$pkg}) {
1555 prepare_watches( [] );
1556 return 1;
1557 }
1558
1559 my $dep = $main::deps{$pkg};
1560 if ($main::debug) {
1561 print "Source dependencies of $pkg: ", format_deps(@$dep), "\n";
1562 }
1563
1564 repeat:
1565 lock_file( "$main::ilock_file", 1 );
1566
1567 print "Filtering dependencies\n" if $main::debug;
1568 if (!filter_dependencies( $dep, \@positive, \@negative, \@special )) {
1569 print PLOG "Package installation not possible\n";
1570 unlock_file( "$main::ilock_file" );
1571 return 0;
1572 }
1573
1574 print PLOG "Checking for source dependency conflicts...\n";
1575 if (!run_apt( "-s", \@instd, \@rmvd, @positive )) {
1576 print PLOG "Test what should be installed failed.\n";
1577 unlock_file( "$main::ilock_file" );
1578 return 0;
1579 }
1580 # add negative deps as to be removed for checking srcdep conflicts
1581 push( @rmvd, @negative );
1582 my @confl;
1583 if (@confl = check_srcdep_conflicts( \@instd, \@rmvd, \@special )) {
1584 print PLOG "Waiting for job(s) @confl to finish\n";
1585
1586 unlock_file( "$main::ilock_file" );
1587 wait_for_srcdep_conflicts( @confl );
1588 goto repeat;
1589 }
1590
1591 write_srcdep_lock_file( $dep, \@special );
1592
1593 foreach my $sp (@special) {
1594 next if $sp !~ /^\*/ || !exists $main::specials{$sp}->{'prepre'};
1595 print PLOG "Running prepre script for $sp\n";
1596 if (run_script( "-e", $main::specials{$sp}->{'prepre'} ) != 0) {
1597 print PLOG "prepre script of special dependency $sp failed\n";
1598 unlock_file( "$main::ilock_file" );
1599 return 0;
1600 }
1601 }
1602
1603 print "Installing positive dependencies: @positive\n" if $main::debug;
1604 if (!run_apt( "-y", \@instd, \@rmvd, @positive )) {
1605 print PLOG "Package installation failed\n";
1606 # try to reinstall removed packages
1607 print PLOG "Trying to reinstall removed packages:\n";
1608 print "Reinstalling removed packages: @rmvd\n" if $main::debug;
1609 my (@instd2, @rmvd2);
1610 print PLOG "Failed to reinstall removed packages!\n"
1611 if !run_apt( "-y", \@instd2, \@rmvd2, @rmvd );
1612 print "Installed were: @instd2\n" if $main::debug;
1613 print "Removed were: @rmvd2\n" if $main::debug;
1614 # remove additional packages
1615 print PLOG "Trying to uninstall newly installed packages:\n";
1616 uninstall_debs( $main::chroot_dir ? "purge" : "remove", @instd );
1617 unlock_file( "$main::ilock_file" );
1618 return 0;
1619 }
1620 set_installed( @instd );
1621 set_removed( @rmvd );
1622
1623 print "Removing negative dependencies: @negative\n" if $main::debug;
1624 if (!uninstall_debs( $main::chroot_dir ? "purge" : "remove", @negative )) {
1625 print PLOG "Removal of packages failed\n";
1626 unlock_file( "$main::ilock_file" );
1627 return 0;
1628 }
1629 set_removed( @negative );
1630
1631 my $fail = check_dependencies( $dep );
1632 if ($fail) {
1633 print PLOG "After installing, the following source dependencies are ".
1634 "still unsatisfied:\n$fail\n";
1635 unlock_file( "$main::ilock_file" );
1636 return 0;
1637 }
1638
1639 foreach my $sp (@special) {
1640 next if $sp !~ /^\*/ ||
1641 (!exists $main::specials{$sp}->{'pre'} &&
1642 !exists $main::specials{$sp}->{'post'} &&
1643 !exists $main::specials{$sp}->{'unpack'});
1644 if (exists $main::specials{$sp}->{'unpack'}) {
1645 my $s = $main::specials{$sp}->{'unpack'};
1646 $s =~ s/^\s+//mg;
1647 $s =~ s/\s+$//mg;
1648 my @s = split( /\s+/, $s );
1649 my @rem;
1650 print PLOG "Unpacking special sources $sp: @s\n";
1651 if (!(@rem = unpack_special_source( @s ))) {
1652 print PLOG "unpacking of special dependency sources for $sp failed\n";
1653 unlock_file( "$main::ilock_file" );
1654 return 0;
1655 }
1656 $main::changes->{'unpacked'}->{$sp} = \@rem;
1657 }
1658 if (exists $main::specials{$sp}->{'pre'}) {
1659 print PLOG "Running pre script for $sp\n";
1660 $main::changes->{'specials'}->{$sp} = 1;
1661 if (run_script( "-e", $main::specials{$sp}->{'pre'} ) != 0) {
1662 print PLOG "pre script of special dependency $sp failed\n";
1663 unlock_file( "$main::ilock_file" );
1664 return 0;
1665 }
1666 }
1667 }
1668
1669 local (*F);
1670 if (open( F, "| $conf::sudo /usr/sbin/chroot $main::chroot_dir $conf::dpkg --set-selections")) {
1671 foreach my $tpkg (@instd) {
1672 print F $tpkg . " purge\n";
1673 }
1674 close( F );
1675 if ($?) {
1676 print PLOG "$conf::dpkg --set-selections failed";
1677 }
1678 }
1679
1680 unlock_file( "$main::ilock_file" );
1681
1682 prepare_watches( $dep, @instd );
1683 return 1;
1684}
1685
1686sub unpack_special_source {
1687 my @s = @_;
1688 my (@files, @dirs);
1689 local (*PIPE);
1690
1691 foreach my $s (@s) {
1692 my $dsc;
1693
1694 {
1695 if (!open( PIPE, "$conf::apt_get $main::chroot_apt_options ".
1696 "--only-source -q -d source $s 2>&1 </dev/null |" )) {
1697 print PLOG "Can't open pipe to apt-get: $!\n";
1698 goto failed;
1699 }
1700 while( <PIPE> ) {
1701 $dsc = "$1_$2.dsc" if /(\S+) (?:[^:]+:)?(\S+) \(dsc\)/;
1702 print PLOG $_;
1703 }
1704 close( PIPE );
1705 if ($?) {
1706 print PLOG "Apt-get of special unpack sources failed\n";
1707 goto failed;
1708 }
1709 push( @files, $dsc );
1710 if (!open( F, "<$dsc" )) {
1711 print PLOG "Can't open $dsc: $!\n";
1712 goto failed;
1713 }
1714 my $dsctext;
1715 { local($/); $dsctext = <F>; }
1716 close( F );
1717 my $files;
1718 $dsctext =~ /^Files:\s*\n((\s+.*\s*\n)+)/mi and $files = $1;
1719 push(@files, map { (split( /\s+/, $_ ))[3] } split( "\n", $files ));
1720 }
1721
1722 my $pid = open( PIPE, "-|" );
1723 if (!defined $pid) {
1724 print PLOG "Can't spawn dpkg-source: $! -- special unpack failed\n";
1725 goto failed;
1726 }
1727 if ($pid == 0) {
1728 setpgrp( 0, $$ );
1729 if ($main::chroot_build_dir && !chdir( $main::chroot_build_dir )) {
1730 print PLOG "Couldn't cd to $main::chroot_build_dir: $! -- special unpack failed\n";
1731 exit 1;
1732 }
1733 exec "$conf::dpkg_source -sn -x $main::cwd/$dsc 2>&1";
1734 }
1735 my $dir;
1736 while( <PIPE> ) {
1737 print PLOG $_;
1738 $dir = $1 if /^dpkg-source: (?:info: )?extracting \S+ in (\S+)/;
1739 }
1740 close( PIPE );
1741 if ($?) {
1742 print PLOG "dpkg-source failure -- special unpack failed\n";
1743 goto failed;
1744 }
1745 push( @dirs, "$main::chroot_build_dir$dir" );
1746 unlink( @files );
1747 }
1748
1749 return @dirs;
1750
1751 failed:
1752 unlink( @files );
1753 system( "rm", "-rf", @dirs );
1754 return ();
1755}
1756
1757sub wait_for_srcdep_conflicts {
1758 my @confl = @_;
1759
1760 for(;;) {
1761 sleep( $conf::srcdep_lock_wait*60 );
1762 my $allgone = 1;
1763 for (@confl) {
1764 /^(\d+)-(\d+)$/;
1765 my $pid = $1;
1766 if (-f "$conf::srcdep_lock_dir/$_") {
1767 if (kill( 0, $pid ) == 0 && $! == ESRCH) {
1768 print PLOG "Ignoring stale src-dep lock $_\n";
1769 unlink( "$conf::srcdep_lock_dir/$_" ) or
1770 print PLOG "Cannot remove $conf::srcdep_lock_dir/$_: $!\n";
1771 }
1772 else {
1773 $allgone = 0;
1774 last;
1775 }
1776 }
1777 }
1778 last if $allgone;
1779 }
1780}
1781
1782sub uninstall_deps {
1783 my( @pkgs, @instd, @rmvd );
1784
1785 lock_file( "$main::ilock_file", 1 );
1786
1787 @pkgs = keys %{$main::changes->{'removed'}};
1788 print "Reinstalling removed packages: @pkgs\n" if $main::debug;
1789 print PLOG "Failed to reinstall removed packages!\n"
1790 if !run_apt( "-y", \@instd, \@rmvd, @pkgs );
1791 print "Installed were: @instd\n" if $main::debug;
1792 print "Removed were: @rmvd\n" if $main::debug;
1793 unset_removed( @instd );
1794 unset_installed( @rmvd );
1795
1796 @pkgs = keys %{$main::changes->{'installed'}};
1797 print "Removing installed packages: @pkgs\n" if $main::debug;
1798 print PLOG "Failed to remove installed packages!\n"
1799 if !uninstall_debs( "purge", @pkgs );
1800 unset_installed( @pkgs );
1801
1802 unlock_file( "$main::ilock_file" );
1803}
1804
1805sub uninstall_debs {
1806 my $mode = shift;
1807 local (*PIPE);
1808
1809 return 1 if !@_;
1810 print "Uninstalling packages: @_\n" if $main::debug;
1811 print PLOG " $conf::sudo dpkg --$mode @_\n";
1812 repeat:
1813 my $output;
1814 if (!open( PIPE, "$conf::sudo /usr/sbin/chroot $main::chroot_dir $conf::dpkg --$mode @_ 2>&1 </dev/null |")) {
1815 print PLOG "Can't open pipe to dpkg: $!\n";
1816 return 0;
1817 }
1818 while ( <PIPE> ) {
1819 $output .= $_;
1820 print PLOG $_;
1821 }
1822 close( PIPE );
1823
1824 if ($output =~ /status database area is locked/mi) {
1825 print PLOG "Another dpkg is running -- retrying later\n";
1826 $output = "";
1827 sleep( 2*60 );
1828 goto repeat;
1829 }
1830 print PLOG "dpkg run to remove packages (@_) failed!\n" if $?;
1831 return $? == 0;
1832}
1833
1834sub undo_specials {
1835 my $sp;
1836
1837 print "Running post scripts of special dependencies:\n" if $main::debug;
1838 foreach $sp (keys %{$main::changes->{'specials'}}) {
1839 print PLOG "Running post script for $sp\n";
1840 if (run_script( "-e", $main::specials{$sp}->{'post'} ) != 0) {
1841 print PLOG "post script of special dependency $sp failed\n";
1842 }
1843 delete $main::changes->{'specials'}->{$sp};
1844 }
1845 foreach $sp (keys %{$main::changes->{'unpacked'}}) {
1846 my @dirs = @{$main::changes->{'unpacked'}->{$sp}};
1847 print PLOG "Removing special unpacked sources for $sp: @dirs\n";
1848 system "rm", "-rf", @dirs;
1849 delete $main::changes->{'unpacked'}->{$sp};
1850 }
1851}
1852
1853
1854sub run_apt {
1855 my $mode = shift;
1856 my $inst_ret = shift;
1857 my $rem_ret = shift;
1858 my @to_install = @_;
1859 my( $msgs, $status, $pkgs, $rpkgs );
1860 local (*PIPE);
1861 local (%ENV) = %ENV; # make local environment
1862 # hardwire frontend for debconf to non-interactive
1863 $ENV{'DEBIAN_FRONTEND'} = "noninteractive";
1864
1865 @$inst_ret = ();
1866 @$rem_ret = ();
1867 return 1 if !@to_install;
1868 repeat:
1869 print PLOG " $conf::sudo $conf::apt_get --purge $main::chroot_apt_op -q $mode install @to_install\n"
1870 if $mode ne "-s";
1871 $msgs = "";
1872 # redirection of stdin from /dev/null so that conffile question are
1873 # treated as if RETURN was pressed.
1874 # dpkg since 1.4.1.18 issues an error on the conffile question if it reads
1875 # EOF -- hardwire the new --force-confold option to avoid the questions.
1876 if (!open( PIPE, "$conf::sudo /usr/sbin/chroot ".
1877 "$main::chroot_dir $conf::apt_get --purge ".
1878 ($main::new_dpkg ? "-o DPkg::Options::=--force-confold " : "").
1879 "-q $mode install @to_install 2>&1 </dev/null |" )) {
1880 print PLOG "Can't open pipe to apt-get: $!\n";
1881 return 0;
1882 }
1883 while( <PIPE> ) {
1884 $msgs .= $_;
1885 print PLOG $_ if $mode ne "-s" || $main::debug;
1886 }
1887 close( PIPE );
1888 $status = $?;
1889
1890 if ($status != 0 && $msgs =~ /^E: Packages file \S+ (has changed|is out of sync)/mi) {
1891 print PLOG "$conf::sudo $conf::apt_get $main::chroot_apt_op -q update\n";
1892 if (!open( PIPE, "$conf::sudo /usr/sbin/chroot $main::chroot_dir $conf::apt_get -q update 2>&1 |" )) {
1893 print PLOG "Can't open pipe to apt-get: $!\n";
1894 return 0;
1895 }
1896 $msgs = "";
1897 while( <PIPE> ) {
1898 $msgs .= $_;
1899 print PLOG $_;
1900 }
1901 close( PIPE );
1902 print PLOG "apt-get update failed\n" if $?;
1903 $msgs = "";
1904 goto repeat;
1905 }
1906
1907 if ($status != 0 && $msgs =~ /^Package (\S+) is a virtual package provided by:\n((^\s.*\n)*)/mi) {
1908 my $to_replace = $1;
1909 my @providers;
1910 foreach (split( "\n", $2 )) {
1911 s/^\s*//;
1912 push( @providers, (split( /\s+/, $_ ))[0] );
1913 }
1914 print PLOG "$to_replace is a virtual package provided by: @providers\n";
1915 my $selected;
1916 if (@providers == 1) {
1917 $selected = $providers[0];
1918 print PLOG "Using $selected (only possibility)\n";
1919 }
1920 elsif (exists $conf::alternatives{$to_replace}) {
1921 $selected = $conf::alternatives{$to_replace};
1922 print PLOG "Using $selected (selected in sbuildrc)\n";
1923 }
1924 else {
1925 $selected = $providers[0];
1926 print PLOG "Using $selected (no default, using first one)\n";
1927 }
1928
1929 @to_install = grep { $_ ne $to_replace } @to_install;
1930 push( @to_install, $selected );
1931
1932 goto repeat;
1933 }
1934
1935 if ($status != 0 && ($msgs =~ /^E: Could( not get lock|n.t lock)/mi ||
1936 $msgs =~ /^dpkg: status database area is locked/mi)) {
1937 print PLOG "Another apt-get or dpkg is running -- retrying later\n";
1938 sleep( 2*60 );
1939 goto repeat;
1940 }
1941
1942 # check for errors that are probably caused by something broken in
1943 # the build environment, and give back the packages.
1944 if ($status != 0 && $mode ne "-s" &&
1945 (($msgs =~ /^E: dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem./mi) ||
1946 ($msgs =~ /^dpkg: parse error, in file `\/.+\/var\/lib\/dpkg\/(?:available|status)' near line/mi) ||
1947 ($msgs =~ /^E: Unmet dependencies. Try 'apt-get -f install' with no packages \(or specify a solution\)\./mi))) {
1948 print PLOG "Build environment unusable, giving back\n";
1949 $main::pkg_fail_stage = "install-deps-env";
1950 }
1951
1952 if ($status != 0 && $mode ne "-s" &&
1953 (($msgs =~ /^E: Unable to fetch some archives, maybe run apt-get update or try with/mi))) {
1954 print PLOG "Unable to fetch build-depends\n";
1955 $main::pkg_fail_stage = "install-deps-env";
1956 }
1957
1958 $pkgs = $rpkgs = "";
1959 if ($msgs =~ /NEW packages will be installed:\n((^[ ].*\n)*)/mi) {
1960 ($pkgs = $1) =~ s/^[ ]*((.|\n)*)\s*$/$1/m;
1961 $pkgs =~ s/\*//g;
1962 }
1963 if ($msgs =~ /packages will be REMOVED:\n((^[ ].*\n)*)/mi) {
1964 ($rpkgs = $1) =~ s/^[ ]*((.|\n)*)\s*$/$1/m;
1965 $rpkgs =~ s/\*//g;
1966 }
1967 @$inst_ret = split( /\s+/, $pkgs );
1968 @$rem_ret = split( /\s+/, $rpkgs );
1969
1970 print PLOG "apt-get failed.\n" if $status && $mode ne "-s";
1971 return $mode eq "-s" || $status == 0;
1972}
1973
1974sub filter_dependencies {
1975 my $dependencies = shift;
1976 my $pos_list = shift;
1977 my $neg_list = shift;
1978 my $special_list = shift;
1979 my($dep, $d, $name, %names);
1980
1981 print PLOG "Checking for already installed source dependencies...\n";
1982
1983 @$pos_list = @$neg_list = @$special_list = ();
1984 foreach $d (@$dependencies) {
1985 my $name = $d->{'Package'};
1986 $names{$name} = 1 if $name !~ /^\*/;
1987 foreach (@{$d->{'Alternatives'}}) {
1988 my $name = $_->{'Package'};
1989 $names{$name} = 1 if $name !~ /^\*/;
1990 }
1991 }
1992 my $status = get_dpkg_status( keys %names );
1993
1994 foreach $dep (@$dependencies) {
1995 $name = $dep->{'Package'};
1996 next if !$name;
1997 if ($name =~ /^\*/) {
1998 my $doit = 1;
1999 if (exists $main::specials{$name}->{'condition'}) {
2000 print "Testing condition for special dependency $name:\n"
2001 if $main::debug;
2002 if (run_script("+e",$main::specials{$name}->{'condition'})!=0){
2003 print "Condition false -> not running scripts\n"
2004 if $main::debug;
2005 $doit = 0;
2006 }
2007 }
2008 push( @$special_list, $name ) if $doit;
2009 next;
2010 }
2011 my $stat = $status->{$name};
2012 if ($dep->{'Neg'}) {
2013 if ($stat->{'Installed'}) {
2014 my ($rel, $vers) = ($dep->{'Rel'}, $dep->{'Version'});
2015 my $ivers = $stat->{'Version'};
2016 if (!$rel || version_cmp( $ivers, $rel, $vers )){
2017 print "$name: neg dep, installed, not versioned or ",
2018 "version relation satisfied --> remove\n" if $main::debug;
2019 print PLOG "$name: installed (negative dependency)";
2020 print PLOG " (bad version $ivers $rel $vers)"
2021 if $rel;
2022 print PLOG "\n";
2023 push( @$neg_list, $name );
2024 }
2025 else {
2026 print PLOG "$name: installed (negative dependency)",
2027 "(but version ok $ivers $rel $vers)\n";
2028 }
2029 }
2030 else {
2031 print "$name: neg dep, not installed\n" if $main::debug;
2032 print PLOG "$name: already deinstalled\n";
2033 }
2034 next;
2035 }
2036
2037 my $is_satisfied = 0;
2038 my $installable = "";
2039 my $upgradeable = "";
2040 my $downgradeable = "";
2041 foreach $d ($dep, @{$dep->{'Alternatives'}}) {
2042 my ($name, $rel, $vers) =
2043 ($d->{'Package'}, $d->{'Rel'}, $d->{'Version'});
2044 my $stat = $status->{$name};
2045 if (!$stat->{'Installed'}) {
2046 print "$name: pos dep, not installed\n" if $main::debug;
2047 print PLOG "$name: missing\n";
2048 my $exists = package_exists($name);
2049 print PLOG "$name: does not exist\n" if not $exists;
2050 $installable = $name if !$installable and $exists;
2051 next;
2052 }
2053 my $ivers = $stat->{'Version'};
2054 if (!$rel || version_cmp( $ivers, $rel, $vers )) {
2055 print "$name: pos dep, installed, no versioned dep or ",
2056 "version ok\n" if $main::debug;
2057 print PLOG "$name: already installed ($ivers";
2058 print PLOG " $rel $vers is satisfied"
2059 if $rel;
2060 print PLOG ")\n";
2061 $is_satisfied = 1;
2062 last;
2063 }
2064 print "$name: vers dep, installed $ivers ! $rel $vers\n"
2065 if $main::debug;
2066 print PLOG "$name: non-matching version installed ",
2067 "($ivers ! $rel $vers)\n";
2068 if ($rel =~ /^</ ||
2069 ($rel eq '=' && version_cmp($ivers, '>>', $vers))) {
2070 print "$name: would be a downgrade!\n" if $main::debug;
2071 print PLOG "$name: would have to downgrade!\n";
2072 $downgradeable = $name if !$downgradeable;
2073 }
2074 else {
2075 $upgradeable = $name if !$upgradeable;
2076 }
2077 }
2078 if (!$is_satisfied) {
2079 if ($upgradeable) {
2080 print "using $upgradeable for upgrade\n" if $main::debug;
2081 push( @$pos_list, $upgradeable );
2082 }
2083 elsif ($installable) {
2084 print "using $installable for install\n" if $main::debug;
2085 push( @$pos_list, $installable );
2086 }
2087 elsif ($downgradeable) {
2088 print PLOG "To satisfy this dependency the package(s) would ",
2089 "have\n",
2090 "to be downgraded; this is not implemented.\n";
2091 return 0;
2092 }
2093 else {
2094 # None of the build-deps exist. Return the
2095 # first one so that we get a useful dep-wait.
2096 $installable = $dep->{'Package'};
2097 print "using $installable for install (does not exist)\n" if $main::debug;
2098 push( @$pos_list, $installable );
2099 }
2100 }
2101 }
2102
2103 return 1;
2104}
2105
2106sub check_dependencies {
2107 my $dependencies = shift;
2108 my $fail = "";
2109 my($dep, $d, $name, %names);
2110
2111 print PLOG "Checking correctness of source dependencies...\n";
2112
2113 foreach $d (@$dependencies) {
2114 my $name = $d->{'Package'};
2115 $names{$name} = 1 if $name !~ /^\*/;
2116 foreach (@{$d->{'Alternatives'}}) {
2117 my $name = $_->{'Package'};
2118 $names{$name} = 1 if $name !~ /^\*/;
2119 }
2120 }
2121 foreach $name (@main::toolchain_pkgs) {
2122 $names{$name} = 1;
2123 }
2124 my $status = get_dpkg_status( keys %names );
2125
2126 foreach $dep (@$dependencies) {
2127 $name = $dep->{'Package'};
2128 next if $name =~ /^\*/;
2129 my $stat = $status->{$name};
2130 if ($dep->{'Neg'}) {
2131 if ($stat->{'Installed'}) {
2132 if (!$dep->{'Rel'}) {
2133 $fail .= "$name(still installed) ";
2134 }
2135 elsif (version_cmp($stat->{'Version'}, $dep->{'Rel'},
2136 $dep->{'Version'})) {
2137 $fail .= "$name(inst $stat->{'Version'} $dep->{'Rel'} ".
2138 "conflicted $dep->{'Version'})\n";
2139 }
2140 }
2141 }
2142 else {
2143 my $is_satisfied = 0;
2144 my $f = "";
2145 foreach $d ($dep, @{$dep->{'Alternatives'}}) {
2146 my $name = $d->{'Package'};
2147 my $stat = $status->{$name};
2148 if (!$stat->{'Installed'}) {
2149 $f =~ s/ $/\|/ if $f;
2150 $f .= "$name(missing) ";
2151 }
2152 elsif ($d->{'Rel'} &&
2153 !version_cmp( $stat->{'Version'}, $d->{'Rel'},
2154 $d->{'Version'} )) {
2155 $f =~ s/ $/\|/ if $f;
The diff has been truncated for viewing.