Bug#774685: chdist: even if --arch is given, apt will download Packages files for all architectures

2015-01-06 Thread Johannes Schauer
Package: devscripts
Version: 2.14.11
Severity: normal
Tags: patch

Hi,

steps to reproduce:

$ dpkg --add-architecture armhf
$ chdist --arch=amd64 create sid-amd64 http://ftp.de.debian.org/debian sid main
$ chdist --arch=amd64 apt-get sid-amd64 update
$ ls ~/.chdist/sid-amd64/var/lib/apt/lists/*armhf*
/home/josch/.chdist/sid-amd64/var/lib/apt/lists/ftp.de.debian.org_debian_dists_sid_main_binary-armhf_Packages

so even though I passed the --arch=amd64 argument, apt will download for
another architecture as well (armhf in this case which was enabled as a
foreign arch on the host chdist was running on).

This might be an apt bug because one might argue that apt should respect
the architecture given as Apt::Architectures and not ask dpkg for more.

But since the fix is simple, I'm attaching it.

Until this is applied, a workaround is to run chdist like this:

$ chdist --arch=amd64 create sid-amd64 [arch=amd64] 
http://ftp.de.debian.org/debian sid main

which happens to work because of how chdist treats its arguments for the
create subcommand (it just concatenates them with a space).

Thanks!

cheers, josch
From 0fc9541b9ee8f82f4ba8d0c4250c2209f11db2dd Mon Sep 17 00:00:00 2001
From: josch j.scha...@email.de
Date: Tue, 6 Jan 2015 09:36:25 +0100
Subject: [PATCH] chdist: if --arch is given, make sure only that arch is
 downloaded

---
 scripts/chdist.pl | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/chdist.pl b/scripts/chdist.pl
index 3f8001f..11e03e4 100755
--- a/scripts/chdist.pl
+++ b/scripts/chdist.pl
@@ -339,8 +339,12 @@ sub dist_create
 if ($version) {
 	# Use provided method, version and sections
 	my $sections_str = join(' ', @sections);
+my $restr = ;
+if ($arch) {
+$restr = [arch=$arch];
+}
 	print FH EOF;
-deb $method $version $sections_str
+deb $restr $method $version $sections_str
 deb-src $method $version $sections_str
 EOF
 }
-- 
2.0.1



Bug#774685: chdist: even if --arch is given, apt will download Packages files for all architectures

2015-01-06 Thread Johannes Schauer
Hi,

the correct solution according to apt maintainers is to set Apt::Architectures
in addition to Apt::Architecture. Patch is attached.

In the future, it could be a useful option to also be able to set
Apt::Architectures to include foreign architectures in the apt tree.

Thanks!

cheers, josch
From 8f97dec9e7e7321bbb6de27c552adc83cd3efe4d Mon Sep 17 00:00:00 2001
From: josch j.scha...@email.de
Date: Tue, 6 Jan 2015 13:16:52 +0100
Subject: [PATCH] scripts/chdist.pl: also set Apt::Architectures

 - to prevent foreign arches to leak into the apt tree
---
 debian/changelog  | 4 
 scripts/chdist.pl | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 2b9e08f..3ed1251 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -11,6 +11,10 @@ devscripts (2.15.1+exp1) UNRELEASED; urgency=medium
   * debsnap: When specified version or architectures aren't available, warn
 and exit with error code 2.  (Closes: #774276)
 
+  [ Johannes Schauer ]
+  * chdist: Also set Apt::Architectures to prevent foreign architectures from
+the host leaking into the apt tree (Closes: #774685)
+
  -- James McCoy james...@debian.org  Sat, 03 Jan 2015 00:47:36 -0500
 
 devscripts (2.15.1) unstable; urgency=medium
diff --git a/scripts/chdist.pl b/scripts/chdist.pl
index 11e03e4..320bea8 100755
--- a/scripts/chdist.pl
+++ b/scripts/chdist.pl
@@ -237,6 +237,7 @@ sub aptopts
 if ($arch) {
 	print W: Forcing arch $arch for this command only.\n;
 	push(@opts, '-o', Apt::Architecture=$arch);
+	push(@opts, '-o', Apt::Architectures=$arch);
 }
 return @opts;
 }
@@ -374,6 +375,7 @@ EOF
 print FH EOF;
 Apt {
Architecture $arch;
+   Architectures $arch;
 };
 
 Dir $dir;
-- 
2.0.1