[PATCH] fix #627179 (multistrap misses some source packages)

David Kuehling <[email protected]>
Newsgroups gmane.linux.debian.devel.embedded
Message-ID <[email protected]>
Hi,

the attached patch (mostly) fixes bug #627179 [1].  Patch is against
multistrap SVN head [2].

The patch misses one occurence of the bug, when multistrap looks at
var/lib/dpkg/status looking for Source: headers only (ignoring Version:
and Package:).  Fixing that feels like beyond my perl skills, and I'm
not sure that this whole part is required anyways (it's redandant with
checking the downloaded .debs).  For now I put a big Todo: comment on
top.

That said, for me the patch fixes the problem with missing sources for
the multistrap.conf I test with.  

The patch also fixes another bug, not yet reported: multistrap could
have fetched source packages versions that differ from the binary
package versions.

cheers,

David

[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=627179
[2] http://www.emdebian.org/svn/current/host/trunk/multistrap/trunk
-- 
GnuPG public key: http://dvdkhlng.users.sourceforge.net/dk.gpg
Fingerprint: B17A DC95 D293 657B 4205  D016 7DEF 5323 C174 7D40
fix-627179-retainsources.patch (text/x-diff, 2.5 KB)
Index: multistrap
===================================================================
--- multistrap	(revision 8004)
+++ multistrap	(working copy)
@@ -465,6 +465,28 @@
 	}
 }
 
+sub get_corresponding_dsc {
+    my $debfile = shift;
+    my $ver=`LC_ALL=C dpkg -f $debfile Version`;
+    my $pkg=`LC_ALL=C dpkg -f $debfile Package`;
+    my $src=`LC_ALL=C dpkg -f $debfile Source`;
+
+    chomp ($ver);
+    chomp ($pkg);
+    chomp ($src);
+
+    if ($src =~ / \((.*)\)/) {
+		# source nanme contains an explicit version number in parens. use it.
+		$ver = $1;
+		$src =~ s/ \(.*\)//;
+    } elsif ($src eq "") {
+		# no 'Source:' line.  use package name instead.
+		$src = $pkg
+    }
+
+    return "${src}=${ver}";
+}
+
 sub force_unpack {
 	my (@limits) = @_;
 	my %unpack=();
@@ -521,13 +543,9 @@
 	printf (_g("Using directory %s for unpacking operations\n"), $dir);
 	foreach $deb (sort @archives) {
 		printf (_g("I: Extracting %s...\n"), $deb);
-		my $ver=`LC_ALL=C dpkg -f ./${cachedir}archives/$deb Version`;
 		my $pkg=`LC_ALL=C dpkg -f ./${cachedir}archives/$deb Package`;
-		my $src=`LC_ALL=C dpkg -f ./${cachedir}archives/$deb Source`;
 		my $multi=`LC_ALL=C dpkg -f ./${cachedir}archives/$deb Multi-Arch`;
-		chomp ($ver);
 		chomp ($pkg);
-		chomp ($src);
 		chomp ($multi);
 		if (($multi eq "foreign") or ($multi eq "allowed")) {
 			$multi = '';
@@ -548,7 +566,7 @@
 			warn ("$msg\n");
 			$multi = '';
 		}
-		$src =~ s/ \(.*\)//;
+		my $src = get_corresponding_dsc "./${cachedir}archives/${deb}";
 		push @dsclist, $src;
 		mkdir ("./tmp");
 		my $tmpdir = `mktemp -p ./tmp -d -t multistrap.XXXXXX`;
@@ -760,7 +778,7 @@
 			next if (-d $file);
 			next unless ($file =~ /\.deb$/);
 			if (defined $sourcedir) {
-				my $srcname = `LC_ALL dpkg -f ${dir}${cachedir}archives/$file Source`;
+				my $srcname = get_corresponding_dsc "${dir}${cachedir}archives/$file";
 				chomp ($srcname);
 				push @dsclist, $srcname;
 				system ("mv ${dir}${cachedir}archives/$file $sourcedir/$file");
@@ -775,6 +793,12 @@
 			open (STATUS, "${dir}${dpkgdir}status");
 			my @lines=<STATUS>;
 			close (STATUS);
+			# Todo: this is (still) broken: need to look at Package:,
+			# Version: and Source: to determine the correct .dsc name.
+			# look at get_corresponding_dsc() for details.  Note
+			# however, that this code is somewhat redundant, since
+			# .dsc names are already determined from downloaded .deb
+			# files.
 			foreach my $line (@lines) {
 				if ($line =~ /^Source: (.*)$/) {
 					my $c = $1;
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iD8DBQFN2keVfe9TI8F0fUARAm4oAJ4i5Pq2yxSoueamVzFQvZey8Y4XDgCeNSz1
RrgM6PkGiQlYUyKfTTjwO/s=
=BmRE
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.