chiark / gitweb /
adt-run: Fix for 678359, thanks to Martin Pitt
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 8 Jul 2012 18:27:04 +0000 (19:27 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 8 Jul 2012 18:27:04 +0000 (19:27 +0100)
debian/changelog
debian/control
runner/adt-run

index 4f23960f472906512f2a9d7782ebd33f536248c5..924b6f758bba03b63931cbc311a4f7a78b12891e 100644 (file)
@@ -1,3 +1,11 @@
+autopkgtest (2.2.3~~iwj) unstable; urgency=medium
+
+  [ Martin Pitt ]
+  * Make `@' in tests' Depends work even if we're not building the
+    source tree.  Closes: #678359.  This is an important bugfix.
+
+ -- Ian Jackson <ijackson@chiark.greenend.org.uk>  Sun, 08 Jul 2012 19:26:23 +0100
+
 autopkgtest (2.2.2) unstable; urgency=low
 
   [ Martin Pitt ]
index 548f25aa4f725bd32a473a4c0826ec88e4d71741..2ef2353fe79afb2416578485ecee0596c9bfacce 100644 (file)
@@ -10,7 +10,7 @@ Vcs-Browser: http://anonscm.debian.org/gitweb/?p=autopkgtest/autopkgtest.git
 
 Package: autopkgtest
 Architecture: all
-Depends: python (>= 2.6)
+Depends: python (>= 2.6), debhelper
 Conflicts: autodebtest (<< 0.5.3)
 Replaces: autodebtest (<< 0.5.3)
 Recommends: apt-utils, pbuilder
index 1efa756fa4ca36a9916e4ab422edc7cc260ef443..0e30bd93d15334eae8b488dc157ec576dc18697c 100755 (executable)
@@ -1090,7 +1090,7 @@ def run_tests(stanzas, tree):
                        report('*', 'SKIP package has metadata but no tests')
                        errorcode |= 8
                for t in tests:
-                       t.prepare()
+                       t.prepare(tree)
                        t.run(tree)
                        if 'breaks-testbed' in t.restriction_names:
                                testbed.needs_reset()
@@ -1116,7 +1116,7 @@ class Test:
        global errorcode
        errorcode |= 4
        report(t.what, 'FAIL ' + m)
- def prepare(t):
+ def prepare(t, tree):
        t._debug('preparing')
        dn = []
        for d in t.depends:
@@ -1125,7 +1125,7 @@ class Test:
                        t._debug('  literal dependency '+d)
                        dn.append(d)
                else:
-                       for (pkg,bin) in t.act.binaries:
+                       for pkg in packages_from_source(t.act, tree):
                                dp = d.replace('@',pkg)
                                t._debug('  synthesised dependency '+dp)
                                dn.append(dp)
@@ -1205,19 +1205,11 @@ class Test:
 
        t._debug('----------------------------------------]')
 
-def read_control(act, tree, control_override):
+def read_stanzas(af):
        stanzas = [ ]
 
-       if control_override is not None:
-               control_af = control_override
-               testbed.blame('arg:'+control_override.spec)
-       else:
-               if act.missing_tests_control:
-                       return ()
-               control_af = RelativeInputFile(act.what+'-testcontrol',
-                       tree, 'debian/tests/control')
        try:
-               control = open(control_af.read(), 'r')
+               control = open(af.read(), 'r')
        except (IOError,OSError), oe:
                if oe[0] != errno.ENOENT: raise
                return []
@@ -1261,6 +1253,21 @@ def read_control(act, tree, control_override):
                hcurrent.append((lno, l))
        end_stanza(stz)
 
+        return stanzas
+
+def read_control(act, tree, control_override):
+
+       if control_override is not None:
+               control_af = control_override
+               testbed.blame('arg:'+control_override.spec)
+       else:
+               if act.missing_tests_control:
+                       return ()
+               control_af = RelativeInputFile(act.what+'-testcontrol',
+                       tree, 'debian/tests/control')
+
+        stanzas = read_stanzas(control_af)
+
        def testbadctrl(stz, lno, m):
                report_badctrl(lno, m)
                stz[' errs'] += 1
@@ -1346,6 +1353,29 @@ def determine_package(act):
                act.pkg = m.groups()[0]
        if not act.pkg: badpkg('no good Package: line in control file')
 
+def packages_from_source(act, tree):
+    (rc, output) = subprocess_cooked(['dh_listpackages'],
+            stdout=subprocess.PIPE, cwd=tree.read(True))
+    if rc: badpkg('failed to parse packages built from source, code %d' % rc)
+
+    # filter out empty lines
+    packages = [p for p in output.split() if p] 
+
+    # filter out udebs
+    control_af = RelativeInputFile(act.what+'-control',
+            tree, 'debian/control')
+    for st in read_stanzas(control_af):
+            if 'Package' not in st:
+                    # source stanza
+                    continue
+            if 'Xc-package-type' in st:
+                    try:
+                            packages.remove(st['Package'][0][1])
+                    except ValueError:
+                            pass
+
+    return packages
+
 class Binaries:
  def __init__(b, tb):
        b.dir = TemporaryDir('binaries')