build source packages can also be unpacked.
Closes: #6820, #7014
* scripts/controllib.pl:
(checkversion) add generic check for valid version numbers
(checkpackagename) add generic check for valid package
names
(readmd5sum) add generic function to extract md5sum from
md5sum program output
(setsourcepackage) call checkpackagename on new value
* scripts/dpkg-source.pl: Use the new checks added to
controllib to ensure validity of version and packagename
on build, too. Previously this was only done on
unpack.
Test on build if directories added by diff already exist with
other type in the original source since we already tested that
on unpack.
(addfile): Test if files are added
twice. Should not happen but as we error out on unpack
better make sure it doesn't.
+2005-10-07 Frank Lichtenheld <djpig@debian.org>
+
+ * scripts/controllib.pl:
+ (checkversion) add generic check for valid version numbers
+ (checkpackagename) add generic check for valid package
+ names
+ (readmd5sum) add generic function to extract md5sum from
+ md5sum program output
+ (setsourcepackage) call checkpackagename on new value
+ * scripts/dpkg-source.pl: Use the new checks added to
+ controllib to ensure validity of version and packagename
+ on build, too. Previously this was only done on
+ unpack.
+
+ * scripts/dpkg-source.pl: Test on build if directories
+ added by diff already exist with other type in the original
+ source since we already tested that on unpack.
+
+ * scripts/dpkg-source.pl (addfile): Test if files are added
+ twice. Should not happen but as we error out on unpack
+ better make sure it doesn't.
+
2005-10-04 Frank Lichtenheld <djpig@debian.org>
* scripts/dpkg-source.pl: Check build relation
* Check the gpg signatures of .dsc files before unpacking. See
the upstream changelog for a full description of the semantics.
Based on a patch by Matt Zimmerman. Closes: #48711
+ * Let dpkg-source ensure (as good as possible) that all
+ build source packages can also be unpacked.
+ Closes: #6820, #7014
--
$substvar{'Source-Version'}= $fi{"L Version"};
}
+sub checkpackagename {
+ my $name = shift || '';
+ $name =~ m/[^-+.0-9a-z]/o &&
+ &error("source package name `$name' contains illegal character `$&'");
+ $name =~ m/^[0-9a-z]/o ||
+ &error("source package name `$name' starts with non-alphanum");
+}
+
+sub checkversion {
+ my $version = shift || '';
+ $version =~ m/[^-+:.0-9a-zA-Z~]/o &&
+ &error("version number contains illegal character `$&'");
+}
sub setsourcepackage {
+ checkpackagename( $v );
if (length($sourcepackage)) {
$v eq $sourcepackage ||
&error("source package has two conflicting values - $sourcepackage and $v");
}
}
+sub readmd5sum {
+ (my $md5sum = shift) or return;
+ $md5sum =~ s/^([0-9a-f]{32})\s*\*?-?\s*\n?$/$1/o
+ || &failure("md5sum gave bogus output `$md5sum'");
+ return $md5sum;
+}
+
sub parsecdata {
local ($source,$many,$whatmsg) = @_;
# many=0: ordinary control data like output from dpkg-parsechangelog
if (m/^Source$/) {
&setsourcepackage;
} elsif (m/^Version$/) {
+ checkversion( $v );
$f{$_}= $v;
} elsif (s/^X[BS]*C[BS]*-//i) {
$f{$_}= $v;
&unrepdiff("device or socket is not allowed");
} elsif (-d _) {
$type{$fn}= 'directory';
+ if (!lstat("$origdir/$fn")) {
+ $! == ENOENT
+ || &syserr("cannot stat orig file $origdir/$fn");
+ } elsif (! -d _) {
+ &unrepdiff2('not a directory', 'directory');
+ }
} else {
&unrepdiff("unknown file type ($!)");
}
}
$sourcepackage = $fi{'S Source'};
- $sourcepackage =~ m/[^-+.0-9a-z]/ &&
- &error("source package name contains illegal character `$&'");
- $sourcepackage =~ m/^[0-9a-z]/ ||
- &error("source package name starts with non-alphanum");
+ checkpackagename( $sourcepackage );
$version= $fi{'S Version'};
- $version =~ m/[^-+:.0-9a-zA-Z~]/ &&
- &error("version number contains illegal character `$&'");
+ checkversion( $version );
$version =~ s/^\d+://;
if ($version =~ m/-([^-]+)$/) {
$baseversion= $`; $revision= $1;
(@s= stat(STDIN)) || &syserr("cannot fstat $dscdir/$f");
$s[7] == $size{$f} || &error("file $f has size $s[7] instead of expected $size{$f}");
$m= `md5sum`; $? && subprocerr("md5sum $f"); $m =~ s/\n$//;
- $m =~ s/ *-$//; # Remove trailing spaces and -, to work with GNU md5sum
- $m =~ m/^[0-9a-f]{32}$/ || &failure("md5sum of $f gave bad output `$m'");
+ $m = readmd5sum( $m );
$m eq $md5sum{$f} || &error("file $f has md5sum $m instead of expected $md5sum{$f}");
open(STDIN,"</dev/null") || &syserr("reopen stdin from /dev/null");
}
close(GZIPFILE);
}
+my %added_files;
sub addfile {
my ($filename)= @_;
+ $added_files{$filename}++ &&
+ &internerr( "tried to add file `$filename' twice" );
stat($filename) || &syserr("could not stat output file `$filename'");
$size= (stat _)[7];
my $md5sum= `md5sum <$filename`;
$? && &subprocerr("md5sum $filename");
- $md5sum =~ s/^([0-9a-f]{32})\s*-?\s*\n$/$1/ || &failure("md5sum gave bogus output `$_'");
+ $md5sum = readmd5sum( $md5sum );
$f{'Files'}.= "\n $md5sum $size $filename";
}