diff options
author | Guillem Jover <guillem@debian.org> | 2007-04-04 23:29:54 +0000 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2007-04-04 23:29:54 +0000 |
commit | 335e778f2eb65648fb1e8ccf66c56aae685ec30a (patch) | |
tree | 84dfedec68123dd13a26e4ae1c15a4d89e98e13c | |
parent | b6aa0a55bf3f6146a0f6c5d605c8d3f989d9a6d7 (diff) | |
download | dpkg-335e778f2eb65648fb1e8ccf66c56aae685ec30a.tar.gz |
* scripts/controllib.pl (get_host_arch): New function.
(findarch): Rename to ...
(init_substvar_arch): ... this. Use get_host_arch to set the substvar.
Fix all callers.
(parsedep): Use get_host_arch instead of directly calling
dpkg-architecture.
* scripts/dpkg-genchanges.pl: Use '$host_arch' instead of '$arch'.
(init_substvar_arch): Delay call until after init_substvars.
* scripts/dpkg-gencontrol.pl: Likewise.
-rw-r--r-- | ChangeLog | 12 | ||||
-rwxr-xr-x | scripts/controllib.pl | 28 | ||||
-rwxr-xr-x | scripts/dpkg-genchanges.pl | 13 | ||||
-rwxr-xr-x | scripts/dpkg-gencontrol.pl | 14 |
4 files changed, 46 insertions, 21 deletions
@@ -1,3 +1,15 @@ +2007-04-05 Guillem Jover <guillem@debian.org> + + * scripts/controllib.pl (get_host_arch): New function. + (findarch): Rename to ... + (init_substvar_arch): ... this. Use get_host_arch to set the substvar. + Fix all callers. + (parsedep): Use get_host_arch instead of directly calling + dpkg-architecture. + * scripts/dpkg-genchanges.pl: Use '$host_arch' instead of '$arch'. + (init_substvar_arch): Delay call until after init_substvars. + * scripts/dpkg-gencontrol.pl: Likewise. + 2007-04-03 Guillem Jover <guillem@debian.org> * dpkg-genchanges.pl: Mark string for translation. diff --git a/scripts/controllib.pl b/scripts/controllib.pl index a924d8353..fd68a5cfe 100755 --- a/scripts/controllib.pl +++ b/scripts/controllib.pl @@ -84,11 +84,18 @@ sub capit { return join '-', @pieces; } -sub findarch { - $arch=`dpkg-architecture -qDEB_HOST_ARCH`; - $? && &subprocerr("dpkg-architecture -qDEB_HOST_ARCH"); - chomp $arch; - $substvar{'Arch'}= $arch; +{ + my $host_arch; + + sub get_host_arch() + { + return $host_arch if defined $host_arch; + + $host_arch = `dpkg-architecture -qDEB_HOST_ARCH`; + $? && subprocerr("dpkg-architecture -qDEB_HOST_ARCH"); + chomp $host_arch; + return $host_arch; + } } sub debian_arch_fix @@ -242,10 +249,8 @@ sub parsesubstvars { sub parsedep { my ($dep_line, $use_arch, $reduce_arch) = @_; my @dep_list; - if (!$host_arch) { - $host_arch = `dpkg-architecture -qDEB_HOST_ARCH`; - chomp $host_arch; - } + my $host_arch = get_host_arch(); + foreach my $dep_and (split(/,\s*/m, $dep_line)) { my @or_list = (); ALTERNATE: @@ -347,6 +352,11 @@ sub init_substvars $substvar{"dpkg:Upstream-Version"} =~ s/-[^-]+$//; } +sub init_substvar_arch() +{ + $substvar{'Arch'} = get_host_arch(); +} + sub checkpackagename { my $name = shift || ''; $name =~ m/[^-+.0-9a-z]/o && diff --git a/scripts/dpkg-genchanges.pl b/scripts/dpkg-genchanges.pl index 4433f1171..32f3abc4d 100755 --- a/scripts/dpkg-genchanges.pl +++ b/scripts/dpkg-genchanges.pl @@ -131,7 +131,6 @@ while (@ARGV) { } } -&findarch; parsechangelog($changelogfile, $changelogformat, $since); parsecontrolfile($controlfile); @@ -182,11 +181,12 @@ for $_ (keys %fi) { elsif (m/|^X[BS]+-|^Standards-Version$/i) { } else { &unknown(_g('general section of control info file')); } } elsif (s/^C(\d+) //) { + my $host_arch = get_host_arch(); $i=$1; $p=$fi{"C$i Package"}; $a=$fi{"C$i Architecture"}; if (!defined($p2f{$p}) && not $sourceonly) { if ((debian_arch_eq('all', $a) && !$archspecific) || - debian_arch_is($arch, $a) || - grep(debian_arch_is($arch, $_), split(/\s+/, $a))) { + debian_arch_is($host_arch, $a) || + grep(debian_arch_is($host_arch, $_), split(/\s+/, $a))) { warning(sprintf(_g("package %s in control file but not in files list"), $p)); next; } @@ -208,9 +208,9 @@ for $_ (keys %fi) { $f{$_}= $v; } elsif (m/^Architecture$/) { if (not $sourceonly) { - if (debian_arch_is($arch, $v) || - grep(debian_arch_is($arch, $_), split(/\s+/, $v))) { - $v= $arch; + if (debian_arch_is($host_arch, $v) || + grep(debian_arch_is($host_arch, $_), split(/\s+/, $v))) { + $v = $host_arch; } elsif (!debian_arch_eq('all', $v)) { $v= ''; } @@ -283,6 +283,7 @@ for $p (keys %p2f) { } &init_substvars; +init_substvar_arch(); if (!$binaryonly) { $sec= $sourcedefault{'Section'}; diff --git a/scripts/dpkg-gencontrol.pl b/scripts/dpkg-gencontrol.pl index 67af2ed1c..14be67821 100755 --- a/scripts/dpkg-gencontrol.pl +++ b/scripts/dpkg-gencontrol.pl @@ -103,7 +103,6 @@ while (@ARGV) { } } -&findarch; parsechangelog($changelogfile, $changelogformat); parsesubstvars($varlistfile); parsecontrolfile($controlfile); @@ -143,10 +142,12 @@ for $_ (keys %fi) { } elsif (m/^Section$|^Priority$/) { $spvalue{$_}= $v; } elsif (m/^Architecture$/) { + my $host_arch = get_host_arch(); + if (debian_arch_eq('all', $v)) { $f{$_}= $v; - } elsif (debian_arch_is($arch, $v)) { - $f{$_}= $arch; + } elsif (debian_arch_is($host_arch, $v)) { + $f{$_} = $host_arch; } else { @archlist= split(/\s+/,$v); my @invalid_archs = grep m/[^\w-]/, @archlist; @@ -156,11 +157,11 @@ for $_ (keys %fi) { scalar(@invalid_archs)), join("' `", @invalid_archs))) if @invalid_archs >= 1; - grep(debian_arch_is($arch, $_), @archlist) || + grep(debian_arch_is($host_arch, $_), @archlist) || &error(sprintf(_g("current build architecture %s does not". " appear in package's list (%s)"), - $arch, "@archlist")); - $f{$_}= $arch; + $host_arch, "@archlist")); + $f{$_} = $host_arch; } } elsif (s/^X[CS]*B[CS]*-//i) { $f{$_}= $v; @@ -191,6 +192,7 @@ for $_ (keys %fi) { $f{'Version'} = $forceversion if defined($forceversion); &init_substvars; +init_substvar_arch(); for $_ (keys %fi) { $v= $fi{$_}; |