Ticket #1089: gen-build-deps.patch

File gen-build-deps.patch, 2.0 KB (added by jdreed, 10 years ago)
  • gen-build-deps

     
    1818        return @a; 
    1919} 
    2020 
     21# For each source package, add its build-deps to the list 
    2122open(DPKG, '-|', "zcat $ENV{DEBATHENA_APT}/dists/$psuite/*/source/Sources.gz | dpkg-awk -f - -- Package Build-Depends") or die; 
    2223my %src_deps = (); 
    2324while (<DPKG>) { 
     
    3435        } 
    3536} 
    3637close DPKG; 
    37 open(DPKG, '-|', "zcat $ENV{DEBATHENA_APT}/dists/$psuite/debathena/binary-amd64/Packages.gz | dpkg-awk -f - -- Package Source Provides") or die; 
     38 
     39# For each binary package, add itself as a source and provider.  If 
     40# there are actually different Sources and Provides for the package, 
     41# use them instead.  Note: This will fail miserably if we ever build 
     42# packages only for one architecture. 
     43open(DPKG, '-|', "zcat $ENV{DEBATHENA_APT}/dists/$psuite/debathena/binary-amd64/Packages.gz | dpkg-awk -f - -- Package Source Provides Depends") or die; 
    3844my %pkg_src = (); 
    3945my %pkg_provider = (); 
     46my %pkg_deps=(); 
    4047while (<DPKG>) { 
    4148        last if /^$/; 
    4249        my ($package) = /^Package: (.*)$/ or die; 
    4350        $pkg_src{$package} = $package; 
    4451        $pkg_provider{$package} = $package; 
     52        @{$pkg_deps{$package}} = (); 
    4553        while (<DPKG>) { 
    4654                last if ($_ eq "\n"); 
    4755                if (my ($source) = /^Source: (.*)$/) { 
    4856                        $pkg_src{$package} = $source; 
    4957                } elsif (my ($provides) = /^Provides: (.*)$/) { 
    5058                        $pkg_provider{$_} = $package for (list($provides)); 
     59                } elsif (my ($depends) = /^Depends: (.*)$/) { 
     60                        push @{$pkg_deps{$package}}, $_ for (list($depends)); 
    5161                } else { 
    5262                        die; 
    5363                } 
    5464        } 
    5565} 
     66 
    5667for my $source (keys %src_deps) { 
    5768        print "build-all: \$(call package,$source)\n"; 
    5869        if ($source ne "debathena-build-depends") { 
     
    6071        } 
    6172        for (@{$src_deps{$source}}) { 
    6273                print "\$(call package,$source): \$(call package,$pkg_src{$pkg_provider{$_}})\n" if (defined $pkg_provider{$_}); 
     74                foreach my $dep (@{$pkg_deps{$_}}) { 
     75                    print "\$(call package,$source): \$(call package,$pkg_src{$dep})\n" if (defined $pkg_provider{$dep}); 
     76                } 
    6377        } 
    6478}