瀏覽代碼

* 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.

Guillem Jover 19 年之前
父節點
當前提交
d0e9b50226
共有 6 個文件被更改,包括 59 次插入24 次删除
  1. 13 0
      ChangeLog
  2. 17 6
      scripts/controllib.pl
  3. 2 1
      scripts/dpkg-checkbuilddeps.pl
  4. 8 5
      scripts/dpkg-genchanges.pl
  5. 11 7
      scripts/dpkg-gencontrol.pl
  6. 8 5
      scripts/dpkg-source.pl

+ 13 - 0
ChangeLog

@@ -1,3 +1,16 @@
+2007-02-12  Guillem Jover  <guillem@debian.org>
+
+	* 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  <guillem@debian.org>
 
 	* dselect/pkglist.h (packagelist::severalinfoblurb): Do not take a

+ 17 - 6
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 ||

+ 2 - 1
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 $/='';

+ 8 - 5
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();
+

+ 11 - 7
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));
 }

+ 8 - 5
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",