Package: apt-cacher
Version: 1.7.28.1
Severity: normal
Tags: patch

Dear Maintainer,

I was creating a cross build environment for riscv64, and my downloads
failed because apt-cacher did not recognize it. I then discovered that
apt-cacher has a hardcoded list of supported architectures.

The attached patch reads the list of most common supported architectures
from dpkg directly, so that you don't need to add architectures by hand
every time one comes around.

-- System Information:
Debian Release: bookworm/sid
  APT prefers testing-debug
  APT policy: (900, 'testing-debug'), (900, 'testing'), (500, 
'unstable-debug'), (500, 'unstable'), (1, 'experimental-debug'), (1, 
'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 6.0.0-6-amd64 (SMP w/4 CPU threads; PREEMPT)
Locale: LANG=pt_BR.UTF-8, LC_CTYPE=pt_BR.UTF-8 (charmap=UTF-8), 
LANGUAGE=pt_BR:pt:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages apt-cacher depends on:
ii  debconf [debconf-2.0]      1.5.81
ii  distro-info-data           0.56
ii  ed                         1.18-1
ii  init-system-helpers        1.65.2
ii  libdpkg-perl               1.21.13
ii  libfilesys-df-perl         0.92-7+b1
ii  libio-interactive-perl     1.023-2
ii  libio-interface-perl       1.09-2+b2
ii  libipc-sharelite-perl      0.17-4+b7
ii  libnetaddr-ip-perl         4.079+dfsg-2+b1
ii  libsys-syscall-perl        0.25-7
ii  libwww-curl-perl           4.17-8+b1
ii  libwww-perl                6.67-1
ii  lsb-base                   11.5
ii  perl                       5.36.0-6
ii  sysvinit-utils [lsb-base]  3.06-2
ii  update-inetd               4.51

Versions of packages apt-cacher recommends:
ii  libberkeleydb-perl        0.64-2+b1
ii  libio-compress-lzma-perl  2.201-1

Versions of packages apt-cacher suggests:
pn  libfreezethaw-perl       <none>
ii  libio-socket-inet6-perl  2.73-1

-- debconf information:
* apt-cacher/mode: daemon
From a6dcce83a210167b2c023eb208609e909186cdd8 Mon Sep 17 00:00:00 2001
From: Antonio Terceiro <terce...@debian.org>
Date: Thu, 12 Jan 2023 09:43:33 -0300
Subject: [PATCH] Query dpkg for supported architectures

Instead of maintaining a hardcoded list, just query dpkg-architecture
for all supported architectures, and allow those. This way people
working on new ports and using apt-cacher have one less place to patch.

To avoid a giant list, and a giant configuration file line, drop the
architectures that have dashes (-) in their names, so we avoid more
exotic ports like uclinux-*, aix-* etc, keeping only the traditional
Linux + glibc ports 99.9999% of us use.
---
 config/apt-cacher.conf |  2 +-
 lib/apt-cacher.pl      | 31 +------------------------------
 2 files changed, 2 insertions(+), 31 deletions(-)

diff --git a/config/apt-cacher.conf b/config/apt-cacher.conf
index e6c95ef..1cf41f0 100644
--- a/config/apt-cacher.conf
+++ b/config/apt-cacher.conf
@@ -187,7 +187,7 @@ user = www-data
 # (see below).
 #
 #supported_archs = i386, amd64
-#supported_archs = avr32, amd64, alpha, arm, arm64, armel, armhf, hppa, hurd-i386, i386, ia64, kfreebsd-amd64, kfreebsd-i386, m32r, m68k, mips, mipsel, netbsd-alpha, netbsd-i386, powerpc, powerpcspe, ppc64, s390, s390x, sh4, sparc, sparc64, x32
+#supported_archs = armhf, armel, mipsn32, mipsn32el, mipsn32r6, mipsn32r6el, mips64, mips64el, mips64r6, mips64r6el, powerpcspe, x32, arm64ilp32, alpha, amd64, arc, armeb, arm, arm64, avr32, hppa, loong64, i386, ia64, m32r, m68k, mips, mipsel, mipsr6, mipsr6el, nios2, or1k, powerpc, powerpcel, ppc64, ppc64el, riscv64, s390, s390x, sh3, sh3eb, sh4, sh4eb, sparc, sparc64, tilegx
 
 # List of Ubuntu release names used to expand %VALID_UBUNTU_RELEASE_NAMES% in
 # *_files_regexp (see below). This is required to allow the Ubuntu installer to
diff --git a/lib/apt-cacher.pl b/lib/apt-cacher.pl
index ee14952..3002532 100755
--- a/lib/apt-cacher.pl
+++ b/lib/apt-cacher.pl
@@ -60,36 +60,7 @@ sub read_config {
 		  request_timeout => 30,
 		  return_buffer_size => 1048576, # 1Mb
 		  reverse_path_map => 1,
-		  supported_archs => join(', ', qw(
-						      avr32
-						      amd64
-						      alpha
-						      arm
-						      arm64
-						      armel
-						      armhf
-						      hppa
-						      hurd-i386
-						      i386
-						      ia64
-						      kfreebsd-amd64
-						      kfreebsd-i386
-						      m32r
-						      m68k
-						      mips
-						      mipsel
-						      netbsd-alpha
-						      netbsd-i386
-						      powerpc
-						      powerpcspe
-						      ppc64
-						      s390
-						      s390x
-						      sh4
-						      sparc
-						      sparc64
-						      x32
-						 )),
+		  supported_archs => join(', ', grep { $_ !~ /-/ } Dpkg::Arch::get_valid_arches()),
 		  ubuntu_release_names => join(', ', get_ubuntu_names()),
 		  user => $>,
 
-- 
2.39.0

Attachment: signature.asc
Description: PGP signature

Reply via email to