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-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
}
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*$//;
}
sub parsecontrolfile {
+ my $controlfile = shift;
+
$controlfile="./$controlfile" if $controlfile =~ m/^\s/;
open(CDATA,"< $controlfile") || &error(sprintf(_g("cannot read control file %s: %s"), $controlfile, $!));
my $substvarsparsed = 0;
sub parsesubstvars {
+ my $varlistfile = shift;
+
if (length($varlistfile) && !$substvarsparsed) {
$varlistfile="./$varlistfile" if $varlistfile =~ m/\s/;
if (open(SV,"< $varlistfile")) {
}
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"));
}
sub setsourcepackage {
+ my $v = shift;
+
checkpackagename( $v );
if (length($sourcepackage)) {
$v eq $sourcepackage ||
my $control=shift || "debian/control";
$controlfile=$control;
-&parsecontrolfile;
+parsecontrolfile($controlfile);
+
my @status=parse_status();
my (@unmet, @conflicts);
local $/='';
}
&findarch;
-&parsechangelog;
-&parsecontrolfile;
+parsechangelog($changelogfile, $changelogformat, $since);
+parsecontrolfile($controlfile);
if (not $sourceonly) {
$fileslistfile="./$fileslistfile" if $fileslistfile =~ m/^\s/;
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; }
}
} 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) {
for $f (keys %override) { $f{&capit($f)}= $override{$f}; }
for $f (keys %remove) { delete $f{&capit($f)}; }
-&outputclose(0);
+outputclose();
+
}
&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"};
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; }
} 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);
&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));
}
$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;
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) {
}
} elsif (s/^L //) {
if (m/^Source$/) {
- &setsourcepackage;
+ setsourcepackage($v);
} elsif (m/^Version$/) {
checkversion( $v );
$f{$_}= $v;
$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",