]> git.donarmstrong.com Git - wannabuild.git/commitdiff
write the sources as fake binary packages from wanna-build (and get rid
authorAndreas Barth <aba@not.so.argh.org>
Mon, 24 May 2010 23:29:40 +0000 (23:29 +0000)
committerAndreas Barth <aba@not.so.argh.org>
Mon, 24 May 2010 23:29:40 +0000 (23:29 +0000)
of add-sources.py within wb-edos-builddebcheck)

bin/add-sources.py [deleted file]
bin/wanna-build
bin/wb-edos-builddebcheck

diff --git a/bin/add-sources.py b/bin/add-sources.py
deleted file mode 100644 (file)
index b9ffa4e..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-#!/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 8a11d11005a23d4e98f0393b627cfa1e4d48b834..b267e4a52223bf36c3e19107b118cde3e0a7a8db 100755 (executable)
@@ -2338,6 +2338,28 @@ sub build_deplist {
        return $result;
 }
 
+
+sub greparch {
+    my ($gapkglong, $gaarch) = @_;
+    my ($gapkg, $gaarchs) = split(/ \[/, $gapkglong);
+    if ($gaarchs) {
+        $_ = $gapkg;
+        chop($gaarchs); # take away the ]
+        my @gaarches = split(/ /, $gaarchs);
+        if (substr($gaarches[0], 0, 1) eq '!') {
+            return 0 if grep /^!$gaarch$/, @gaarches;
+        } else { # positive case
+            return 0 unless grep /^$gaarch$/, @gaarches;
+        }
+    };
+    return 1;
+}
+sub filterarch {
+    my $faarch = $_[1];
+    return join(', ', grep { &greparch($_, $faarch) } split(/, ?/, $_[0]));
+}
+
+
 sub call_edos_depcheck {
     my $packagesfile = shift;
     my $srcs = shift;
@@ -2366,10 +2388,15 @@ sub call_edos_depcheck {
     my ($SOURCES, $tmpfile) = tempfile( $tmpfile_pattern, UNLINK => 1 );
     for my $key (keys %interesting_packages) {
        my $pkg = $db->{$key};
-       print $SOURCES "Package: $key\n";
+        # we print the source files as binary ones (with "source---"-prefixed),
+        # so we can try if these "binary" packages are installable.
+        # If such a "binary" package is installable, the corresponding source package is buildable.
+       print $SOURCES "Package: source---$key\n";
        print $SOURCES "Version: $pkg->{'version'}\n";
-       print $SOURCES "Build-Depends: $srcs->{$key}{'dep'}\n" if $srcs->{$key}{'dep'};
-       print $SOURCES "Build-Conflicts: $srcs->{$key}{'conf'}\n" if $srcs->{$key}{'conf'};
+        my $t = &filterarch($srcs->{$key}{'dep'}, $arch);
+       print $SOURCES "Depends: $t\n" if $t;
+        my $u = &filterarch($srcs->{$key}{'conf'}, $arch);
+       print $SOURCES "Conflicts: $u\n" if $u;
        print $SOURCES "Architecture: all\n";
        print $SOURCES "\n";
     }
index bad875a5be37d34ab45d198706706865c6ff7f07..0562a95d3be189c47a308239a15a0dbbaea22f79 100755 (executable)
@@ -73,8 +73,7 @@ if ( $architecture eq "" ) {
     }
 }
 
-open(RESULT,"python /org/wanna-build/bin/add-sources.py ".
-     "--prefix \"$sourceprefix\" < /dev/null $sourcesfile $architecture ".
+open(RESULT,"cat $sourcesfile".
      "| edos-debcheck $edosoptions '-base FILE' $packagefile |");
 
 $sourcestanza=0;