]> git.donarmstrong.com Git - wannabuild.git/commitdiff
wb-edos-builddebcheck: only check the source packages
authorAndreas Barth <aba@not.so.argh.org>
Mon, 24 May 2010 18:35:30 +0000 (18:35 +0000)
committerAndreas Barth <aba@not.so.argh.org>
Mon, 24 May 2010 18:35:30 +0000 (18:35 +0000)
(need to move add-sources.py local, and fix it to work if there is no input)

bin/add-sources.py [new file with mode: 0644]
bin/wb-edos-builddebcheck

diff --git a/bin/add-sources.py b/bin/add-sources.py
new file mode 100644 (file)
index 0000000..b9ffa4e
--- /dev/null
@@ -0,0 +1,138 @@
+#!/usr/bin/python
+
+# Given as input a Packages and a Sources file, produces as output a new
+# Packages containing fake packages which are installable if and only if the
+# corresponding source package has satisfiable build dependencies.
+
+# Copyright (C) 2008 Stefano Zacchiroli <zack@debian.org>
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation, either version 3 of the License, or (at your option) any later
+# version.
+
+# $Id: add-sources.py 5957 2008-08-16 18:32:17Z zack $
+
+# build-essential packages. All build-dependencies and build-conflicts
+# to one of these packages is simply ignored.
+# TODO: this list should be obtained from the binary package file,
+# by grep-dctrl -F Build-Essential --pattern=yes -s Package -n
+# but then we have to change the way this command is called.
+buildessentials = ['apt', 'binutils', 'cpio', 'cpp', 'dpkg-dev',
+                   'g++', 'gcc', 'libc6-dev', 'make', 'patch',
+                   'perl', 'perl-modules']
+
+
+import string
+import sys
+
+from optparse import OptionParser
+from debian_bundle import deb822
+
+usage = 'Usage: cat Packages | add-sources [OPTION...] Sources ARCH > Packages.new'
+cli = OptionParser(usage=usage)
+cli.add_option('-p', '--prefix', dest='prefix', default='source---',
+        help='set the prefix for fake source packages to PREFIX (default: source---)',
+        metavar='PREFIX')
+(options, args) = cli.parse_args()
+if len(args) != 2:
+    cli.print_help()
+    sys.exit(2)
+sources_file = args[0]
+architecture = args[1]
+
+def pkg_of_src(src):
+    global architecture, options
+    pkg = deb822.Packages()
+    pkg['Package'] = options.prefix + src['Package']
+
+    def dep_for_me(dep):
+        for_me = None
+        if buildessentials.count(dep['name']) > 0:
+            for_me = False
+        elif dep['arch'] is None:
+            for_me = True
+        elif dep['arch']:
+            (polarity, _) = dep['arch'][0]
+            if polarity:    # list is inclusive
+                for_me = (True, architecture) in dep['arch']
+            else:   # list is exclusive
+                for_me = not ((False, architecture) in dep['arch'])
+        else:
+            for_me = False
+        return for_me
+
+    def mk_bin_rels(fields, relations):
+        def strip_arch(dep):
+            dep['arch'] = None
+            return dep
+
+        def get_rels(fields, relations):
+            rels = []
+            for name in fields:
+                if relations.has_key(name):
+                    rels.extend(relations[name])
+            return rels
+
+        src_rels = get_rels(fields, relations)
+        bin_rels = []
+        for or_deps in src_rels:
+            my_or_deps = map(strip_arch, filter(dep_for_me, or_deps))
+            if my_or_deps:
+                bin_rels.append(my_or_deps)
+
+        return bin_rels
+
+    def str_of_relations(rels):
+        # XXX this is cut and paste from python-debian's deb822.py, more
+        # precisely it matches the str() method of the PkgRelation class
+        # TODO to be removed as soon as python-debian 0.1.12 hits unstable
+        def pp_arch(arch_spec):
+            (excl, arch) = arch_spec
+            if excl:
+                return arch
+            else:
+                return '!' + arch
+        def pp_atomic_dep(dep):
+            s = dep['name']
+            if dep.has_key('version') and dep['version'] is not None:
+                s += ' (%s %s)' % dep['version']
+            if dep.has_key('arch') and dep['arch'] is not None:
+                s += ' [%s]' % string.join(map(pp_arch, dep['arch']))
+            return s
+        pp_or_dep = lambda deps: string.join(map(pp_atomic_dep, deps), ' | ')
+        return string.join(map(pp_or_dep, rels), ', ')
+
+    for field in ['Version', 'Priority', 'Section', 'Maintainer', 'Architecture']:
+        if src.has_key(field):
+            pkg[field] = src[field]
+    bin_depends = mk_bin_rels(['build-depends', 'build-depends-indep'],
+            src.relations)
+    if bin_depends:
+        #pkg['Depends'] = deb822.PkgRelation.str(bin_depends)
+        pkg['Depends'] = str_of_relations(bin_depends)
+    bin_conflicts = mk_bin_rels(['build-conflicts', 'build-conflicts-indep'],
+            src.relations)
+    if bin_conflicts:
+        #pkg['Conflicts'] = deb822.PkgRelation.str(bin_conflicts)
+        pkg['Conflicts'] = str_of_relations(bin_conflicts)
+    pkg['Description'] = 'dummy counterpart of "%s" source package' % \
+            src['Package']
+    pkg['Description'] += "\n I don't exist, go away."
+
+    return pkg
+
+#for pkg in deb822.Packages.iter_paragraphs(sys.stdin):
+line = None
+for line in sys.stdin:
+    print line,
+# stanzas have to be separated by a blank line
+if line and not line.isspace(): print 
+for src in deb822.Sources.iter_paragraphs(file(sources_file)):
+    if src['Architecture'] in ['any', 'all']:
+        pkg = pkg_of_src(src)
+        print pkg
+    elif architecture in src['Architecture'].split():
+        pkg = pkg_of_src(src)
+        pkg['Architecture'] = architecture
+        print pkg
+
index 400d1e3d9b7dfea47b8e1c700b6be408fccdbd04..bad875a5be37d34ab45d198706706865c6ff7f07 100755 (executable)
@@ -73,9 +73,9 @@ if ( $architecture eq "" ) {
     }
 }
 
-open(RESULT,"python /usr/share/edos-distcheck/add-sources.py ".
-     "--prefix \"$sourceprefix\" < $packagefile $sourcesfile $architecture ".
-     "| edos-debcheck $edosoptions|");
+open(RESULT,"python /org/wanna-build/bin/add-sources.py ".
+     "--prefix \"$sourceprefix\" < /dev/null $sourcesfile $architecture ".
+     "| edos-debcheck $edosoptions '-base FILE' $packagefile |");
 
 $sourcestanza=0;
 $explanation="";