From d0e9b50226e7e463db20743f388803b35de790b1 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 11 Feb 2007 23:14:25 +0000 Subject: [PATCH] * scripts/controllib.pl (outputclose): Change argument from a boolean to an optional filename argument. Fix all callers. (parsecontrolfile): Take '$controlfile' as an explicit argument. Fix all callers. (parsesubstvars): Take '$varlistfile' as an explicit argument. Fix all callers. (parsechangelog): Take '$changelogfile' as an explicit argument, '$changelogformat' and '$since' as optional arguments. Fix all callers. (setsourcepackage): Take '$v' as an explicit argument. --- ChangeLog | 13 +++++++++++++ scripts/controllib.pl | 23 +++++++++++++++++------ scripts/dpkg-checkbuilddeps.pl | 3 ++- scripts/dpkg-genchanges.pl | 13 ++++++++----- scripts/dpkg-gencontrol.pl | 18 +++++++++++------- scripts/dpkg-source.pl | 13 ++++++++----- 6 files changed, 59 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1912ebfd..35cbb46c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2007-02-12 Guillem Jover + + * scripts/controllib.pl (outputclose): Change argument from a boolean + to an optional filename argument. Fix all callers. + (parsecontrolfile): Take '$controlfile' as an explicit argument. + Fix all callers. + (parsesubstvars): Take '$varlistfile' as an explicit argument. + Fix all callers. + (parsechangelog): Take '$changelogfile' as an explicit argument, + '$changelogformat' and '$since' as optional arguments. Fix all + callers. + (setsourcepackage): Take '$v' as an explicit argument. + 2007-02-11 Guillem Jover * dselect/pkglist.h (packagelist::severalinfoblurb): Do not take a diff --git a/scripts/controllib.pl b/scripts/controllib.pl index 3c998f0f..c7f25464 100755 --- a/scripts/controllib.pl +++ b/scripts/controllib.pl @@ -164,19 +164,22 @@ sub substvars { } sub outputclose { - my ($dosubstvars) = @_; + my ($varlistfile) = @_; + for $f (keys %f) { $substvar{"F:$f"}= $f{$f}; } - &parsesubstvars if ($dosubstvars); + + &parsesubstvars($varlistfile) if (defined($varlistfile)); + for $f (sort { $fieldimps{$b} <=> $fieldimps{$a} } keys %f) { $v= $f{$f}; - if ($dosubstvars) { + if (defined($varlistfile)) { $v= &substvars($v); } $v =~ m/\S/ || next; # delete whitespace-only fields $v =~ m/\n\S/ && &internerr(sprintf(_g("field %s has newline then non whitespace >%s<"), $f, $v)); $v =~ m/\n[ \t]*\n/ && &internerr(sprintf(_g("field %s has blank lines >%s<"), $f, $v)); $v =~ m/\n$/ && &internerr(sprintf(_g("field %s has trailing newline >%s<"), $f, $v)); - if ($dosubstvars) { + if (defined($varlistfile)) { $v =~ s/,[\s,]*,/,/g; $v =~ s/^\s*,\s*//; $v =~ s/\s*,\s*$//; @@ -189,6 +192,8 @@ sub outputclose { } sub parsecontrolfile { + my $controlfile = shift; + $controlfile="./$controlfile" if $controlfile =~ m/^\s/; open(CDATA,"< $controlfile") || &error(sprintf(_g("cannot read control file %s: %s"), $controlfile, $!)); @@ -210,6 +215,8 @@ sub parsecontrolfile { my $substvarsparsed = 0; sub parsesubstvars { + my $varlistfile = shift; + if (length($varlistfile) && !$substvarsparsed) { $varlistfile="./$varlistfile" if $varlistfile =~ m/\s/; if (open(SV,"< $varlistfile")) { @@ -300,13 +307,15 @@ sub showdep { } sub parsechangelog { + my ($changelogfile, $changelogformat, $since) = @_; + defined($c=open(CDATA,"-|")) || &syserr(_g("fork for parse changelog")); binmode(CDATA); if (!$c) { @al=($parsechangelog); - push(@al,"-F$changelogformat") if length($changelogformat); - push(@al,"-v$since") if length($since); push(@al,"-l$changelogfile"); + push(@al, "-F$changelogformat") if defined($changelogformat); + push(@al, "-v$since") if defined($since); exec(@al) || &syserr("exec parsechangelog $parsechangelog"); } &parsecdata('L',0,_g("parsed version of changelog")); @@ -349,6 +358,8 @@ sub checkversion { } sub setsourcepackage { + my $v = shift; + checkpackagename( $v ); if (length($sourcepackage)) { $v eq $sourcepackage || diff --git a/scripts/dpkg-checkbuilddeps.pl b/scripts/dpkg-checkbuilddeps.pl index 290b1942..7776c72a 100755 --- a/scripts/dpkg-checkbuilddeps.pl +++ b/scripts/dpkg-checkbuilddeps.pl @@ -38,7 +38,8 @@ if ($want_help) { my $control=shift || "debian/control"; $controlfile=$control; -&parsecontrolfile; +parsecontrolfile($controlfile); + my @status=parse_status(); my (@unmet, @conflicts); local $/=''; diff --git a/scripts/dpkg-genchanges.pl b/scripts/dpkg-genchanges.pl index 8bfd8ad4..82645016 100755 --- a/scripts/dpkg-genchanges.pl +++ b/scripts/dpkg-genchanges.pl @@ -132,8 +132,8 @@ while (@ARGV) { } &findarch; -&parsechangelog; -&parsecontrolfile; +parsechangelog($changelogfile, $changelogformat, $since); +parsecontrolfile($controlfile); if (not $sourceonly) { $fileslistfile="./$fileslistfile" if $fileslistfile =~ m/^\s/; @@ -173,7 +173,9 @@ if (not $sourceonly) { for $_ (keys %fi) { $v= $fi{$_}; if (s/^C //) { - if (m/^Source$/) { &setsourcepackage; } + if (m/^Source$/) { + setsourcepackage($v); + } elsif (m/^Section$|^Priority$/i) { $sourcedefault{$_}= $v; } elsif (m/^Maintainer$/i) { $f{$_}= $v; } elsif (s/^X[BS]*C[BS]*-//i) { $f{$_}= $v; } @@ -225,7 +227,7 @@ for $_ (keys %fi) { } } elsif (s/^L //) { if (m/^Source$/i) { - &setsourcepackage; + setsourcepackage($v); } elsif (m/^Maintainer$/i) { $f{"Changed-By"}=$v; } elsif (m/^(Version|Changes|Urgency|Distribution|Date|Closes)$/i) { @@ -366,4 +368,5 @@ for $f (qw(Urgency)) { for $f (keys %override) { $f{&capit($f)}= $override{$f}; } for $f (keys %remove) { delete $f{&capit($f)}; } -&outputclose(0); +outputclose(); + diff --git a/scripts/dpkg-gencontrol.pl b/scripts/dpkg-gencontrol.pl index f52b4d90..cd9dc0dc 100755 --- a/scripts/dpkg-gencontrol.pl +++ b/scripts/dpkg-gencontrol.pl @@ -104,10 +104,10 @@ while (@ARGV) { } &findarch; -&parsechangelog; -&parsesubstvars; -&parsecontrolfile; - +parsechangelog($changelogfile, $changelogformat); +parsesubstvars($varlistfile); +parsecontrolfile($controlfile); + if (length($oppackage)) { defined($p2i{"C $oppackage"}) || &error(sprintf(_g("package %s not in control info"), $oppackage)); $myindex= $p2i{"C $oppackage"}; @@ -127,7 +127,9 @@ for $_ (keys %fi) { if (s/^C //) { #print STDERR "G key >$_< value >$v<\n"; if (m/^Origin|Bugs|Maintainer$/) { $f{$_}=$v; } - elsif (m/^Source$/) { &setsourcepackage; } + elsif (m/^Source$/) { + setsourcepackage($v); + } elsif (s/^X[CS]*B[CS]*-//i) { $f{$_}= $v; } elsif (m/^X[CS]+-|^(Standards-Version|Uploaders)$|^Build-(Depends|Conflicts)(-Indep)?$/i) { } elsif (m/^Section$|^Priority$/) { $spdefault{$_}= $v; } @@ -169,7 +171,7 @@ for $_ (keys %fi) { } elsif (s/^L //) { #print STDERR "L key >$_< value >$v<\n"; if (m/^Source$/) { - &setsourcepackage; + setsourcepackage($v); } elsif (m/^Version$/) { $sourceversion= $v; $f{$_}= $v unless length($forceversion); @@ -288,7 +290,9 @@ if (!$stdout) { &syserr(sprintf(_g("cannot open new output control file \`%s'"), "$cf.new")); binmode(STDOUT); } -&outputclose(1); + +outputclose($varlistfile); + if (!$stdout) { rename("$cf.new","$cf") || &syserr(sprintf(_g("cannot install output control file \`%s'"), $cf)); } diff --git a/scripts/dpkg-source.pl b/scripts/dpkg-source.pl index 6c3e8664..a15ef8a3 100755 --- a/scripts/dpkg-source.pl +++ b/scripts/dpkg-source.pl @@ -191,8 +191,8 @@ if ($opmode eq 'build') { $changelogfile= "$dir/debian/changelog" unless defined($changelogfile); $controlfile= "$dir/debian/control" unless defined($controlfile); - &parsechangelog; - &parsecontrolfile; + parsechangelog($changelogfile, $changelogformat); + parsecontrolfile($controlfile); $f{"Format"}=$def_dscformat; &init_substvars; @@ -200,7 +200,9 @@ if ($opmode eq 'build') { for $_ (keys %fi) { $v= $fi{$_}; if (s/^C //) { - if (m/^Source$/i) { &setsourcepackage; } + if (m/^Source$/i) { + setsourcepackage($v); + } elsif (m/^(Standards-Version|Origin|Maintainer)$/i) { $f{$_}= $v; } elsif (m/^Uploaders$/i) { ($f{$_}= $v) =~ s/[\r\n]//g; } elsif (m/^Build-(Depends|Conflicts)(-Indep)?$/i) { @@ -249,7 +251,7 @@ if ($opmode eq 'build') { } } elsif (s/^L //) { if (m/^Source$/) { - &setsourcepackage; + setsourcepackage($v); } elsif (m/^Version$/) { checkversion( $v ); $f{$_}= $v; @@ -577,7 +579,8 @@ if ($opmode eq 'build') { $progname, $sourcepackage, "$basenamerev.dsc") || &syserr(_g("write building message")); open(STDOUT,"> $basenamerev.dsc") || &syserr(sprintf(_g("create %s"), "$basenamerev.dsc")); - &outputclose(1); + + outputclose($varlistfile); if ($ur) { printf(STDERR _g("%s: unrepresentable changes to source")."\n", -- 2.39.5