|
|
@@ -11,6 +11,8 @@
|
|
|
# "S key" where S is the source and key is the packagename
|
|
|
# %substvar - map with substitution variables
|
|
|
|
|
|
+$pkgdatadir=".";
|
|
|
+
|
|
|
$parsechangelog= 'dpkg-parsechangelog';
|
|
|
|
|
|
@pkg_dep_fields = qw(Replaces Provides Depends Pre-Depends Recommends Suggests
|
|
|
@@ -76,6 +78,114 @@ sub findarch {
|
|
|
$substvar{'Arch'}= $arch;
|
|
|
}
|
|
|
|
|
|
+sub read_cputable {
|
|
|
+ open CPUTABLE, "$pkgdatadir/cputable"
|
|
|
+ or &syserr("unable to open cputable");
|
|
|
+ while (<CPUTABLE>) {
|
|
|
+ if (m/^(?!\#)(\S+)\s+(\S+)\s+(\S+)/) {
|
|
|
+ $cputable{$1} = $2;
|
|
|
+ $cputable_re{$1} = $3;
|
|
|
+ push @cpu, $1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ close CPUTABLE;
|
|
|
+}
|
|
|
+
|
|
|
+sub read_ostable {
|
|
|
+ open OSTABLE, "$pkgdatadir/ostable"
|
|
|
+ or &syserr("unable to open ostable");
|
|
|
+ while (<OSTABLE>) {
|
|
|
+ if (m/^(?!\#)(\S+)\s+(\S+)\s+(\S+)/) {
|
|
|
+ $ostable{$1} = $2;
|
|
|
+ $ostable_re{$1} = $3;
|
|
|
+ push @os, $1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ close OSTABLE;
|
|
|
+}
|
|
|
+
|
|
|
+sub debian_arch_fix
|
|
|
+{
|
|
|
+ local ($os, $cpu) = @_;
|
|
|
+
|
|
|
+ if ($os eq "linux") {
|
|
|
+ return $cpu;
|
|
|
+ } else {
|
|
|
+ return "$os-$cpu";
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+sub debian_arch_split {
|
|
|
+ local ($_) = @_;
|
|
|
+
|
|
|
+ if (/^([^-]*)-(.*)/) {
|
|
|
+ return ($1, $2);
|
|
|
+ } elsif (/any/ || /all/) {
|
|
|
+ return ($_, $_);
|
|
|
+ } else {
|
|
|
+ return ("linux", $_);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+sub debian_arch_eq {
|
|
|
+ my ($a, $b) = @_;
|
|
|
+ my ($a_os, $a_cpu) = debian_arch_split($a);
|
|
|
+ my ($b_os, $b_cpu) = debian_arch_split($b);
|
|
|
+
|
|
|
+ return ("$a_os-$a_cpu" eq "$b_os-$b_cpu");
|
|
|
+}
|
|
|
+
|
|
|
+sub debian_arch_is {
|
|
|
+ my ($real, $alias) = @_;
|
|
|
+ my ($real_os, $real_cpu) = debian_arch_split($real);
|
|
|
+ my ($alias_os, $alias_cpu) = debian_arch_split($alias);
|
|
|
+
|
|
|
+ if ("$real_os-$real_cpu" eq "$alias_os-$alias_cpu") {
|
|
|
+ return 1;
|
|
|
+ } elsif ("$alias_os-$alias_cpu" eq "any-any") {
|
|
|
+ return 1;
|
|
|
+ } elsif ("$alias_os-$alias_cpu" eq "any-$real_cpu") {
|
|
|
+ return 1;
|
|
|
+ } elsif ("$alias_os-$alias_cpu" eq "$real_os-any") {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+&read_cputable;
|
|
|
+&read_ostable;
|
|
|
+
|
|
|
+sub debian_arch_expand
|
|
|
+{
|
|
|
+ local ($_) = @_;
|
|
|
+
|
|
|
+ /^(!)?(.*)/;
|
|
|
+
|
|
|
+ local $not = $1 || '';
|
|
|
+ local $arch = $2;
|
|
|
+ local ($os, $cpu) = debian_arch_split($arch);
|
|
|
+ local @list;
|
|
|
+
|
|
|
+ if ("$os-$cpu" eq 'any-any') {
|
|
|
+ @list = 'any';
|
|
|
+ } elsif ($os eq 'all' or $cpu eq 'all') {
|
|
|
+ @list = 'all';
|
|
|
+ } elsif ($cpu eq 'any') {
|
|
|
+ foreach my $_cpu (@cpu) {
|
|
|
+ push @list, $not.debian_arch_fix($os, $_cpu);
|
|
|
+ }
|
|
|
+ } elsif ($os eq 'any') {
|
|
|
+ foreach my $_os (@os) {
|
|
|
+ push @list, $not.debian_arch_fix($_os, $cpu);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ push @list, $not.debian_arch_fix($os, $cpu);
|
|
|
+ }
|
|
|
+
|
|
|
+ return @list;
|
|
|
+}
|
|
|
+
|
|
|
sub substvars {
|
|
|
my ($v) = @_;
|
|
|
my ($lhs,$vn,$rhs,$count);
|
|
|
@@ -186,17 +296,21 @@ ALTERNATE:
|
|
|
my $seen_arch='';
|
|
|
foreach my $arch (@arches) {
|
|
|
$arch=lc($arch);
|
|
|
- if ($arch eq $host_arch) {
|
|
|
+ if (debian_arch_is($host_arch, $arch)) {
|
|
|
$seen_arch=1;
|
|
|
next;
|
|
|
- } elsif ($arch eq "!$host_arch") {
|
|
|
- next ALTERNATE;
|
|
|
- } elsif ($arch =~ /!/) {
|
|
|
- # This is equivilant to
|
|
|
- # having seen the current arch,
|
|
|
- # unless the current arch
|
|
|
- # is also listed..
|
|
|
- $seen_arch=1;
|
|
|
+ } elsif ($arch =~ /^!/) {
|
|
|
+ ($not_arch = $arch) =~ s/^!//;
|
|
|
+
|
|
|
+ if (debian_arch_is($host_arch, $not_arch)) {
|
|
|
+ next ALTERNATE;
|
|
|
+ } else {
|
|
|
+ # This is equivilant to
|
|
|
+ # having seen the current arch,
|
|
|
+ # unless the current arch
|
|
|
+ # is also listed..
|
|
|
+ $seen_arch=1;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (! $seen_arch) {
|
|
|
@@ -221,7 +335,9 @@ sub showdep {
|
|
|
my @or_list = ();
|
|
|
foreach my $dep_or (@$dep_and) {
|
|
|
my ($package, $relation, $version, $arch_list) = @$dep_or;
|
|
|
- push @or_list, $package . ($relation && $version ? " ($relation $version)" : '') . ($show_arch && @$arch_list ? " [@$arch_list]" : '');
|
|
|
+ my @arches = map(debian_arch_expand($_), @$arch_list);
|
|
|
+ chomp @arches;
|
|
|
+ push @or_list, $package . ($relation && $version ? " ($relation $version)" : '') . ($show_arch && @arches ? " [@arches]" : '');
|
|
|
}
|
|
|
push @and_list, join(' | ', @or_list);
|
|
|
}
|