Bug#1120555: debootstrap: debootstrap fails for ubuntu/focal
Package: debootstrap
Version: 1.0.141
Severity: normal
Hi. Today this happens:
$ sudo debootstrap focal tst/
I: Target architecture can be executed
I: Keyring file not available at /usr/share/keyrings/ubuntu-archive-removed-keys.gpg; switching to https mirror https://old-releases.ubuntu.com/ubuntu
I: Retrieving InRelease
I: Retrieving Release
E: Failed getting release file https://old-releases.ubuntu.com/ubuntu/dists/focal/Release
This is due to ubuntu doing something weird, but still it would be nice
if it worked. The problem is that focal is Ubuntu 20.04, which is very
old. debootstrap checks to see if this distro is "supported"; it decides
that it isn't supported, and thus it uses the old-releases.u.c url. This
is apparently wrong.
The logic is in /usr/share/debootstrap/scripts/focal, which is a symlink
to /usr/share/debootstrap/scripts/gutsy. The relevant logic in that file
is:
if command -v ubuntu-distro-info >/dev/null 2>&1; then
if ubuntu-distro-info --supported | grep -q "$SUITE" >/dev/null 2>&1; then
supported=true
else
supported=false
fi
elif command -v curl >/dev/null 2>&1 && command -v jq >/dev/null 2>&1; then
supported="$(curl -s https://endoflife.date/api/ubuntu.json | jq --arg suite $SUITE '[.[] | select((.extendedSupport // .support) > (now | strftime("%Y-%m-%d")) and (.codename | test($suite; "i")))] | isempty(.[]) | not')"
elif command -v wget >/dev/null 2>&1 && command -v jq >/dev/null 2>&1; then
supported="$(wget -qO- https://endoflife.date/api/ubuntu.json | jq --arg suite $SUITE '[.[] | select((.extendedSupport // .support) > (now | strftime("%Y-%m-%d")) and (.codename | test($suite; "i")))] | isempty(.[]) | not')"
else
supported=true
fi
if [ "$supported" = true ]; then
case "$ARCH" in
amd64|i386)
default_mirror http://archive.ubuntu.com/ubuntu
;;
*)
default_mirror http://ports.ubuntu.com/ubuntu-ports
;;
esac
keyring /usr/share/keyrings/ubuntu-archive-keyring.gpg
else
default_mirror http://old-releases.ubuntu.com/ubuntu
keyring /usr/share/keyrings/ubuntu-archive-removed-keys.gpg
fi
So there are several "supported" checks. The very first one is triggered
on my box. I get:
$ ubuntu-distro-info --supported
jammy
noble
Note that "focal" is not on the "supported" list.
OK. So since ultimately we want to figure out which server we should
use, how about we ask the server what exists and what doesn't. I
replaced that whole block above with:
if curl -sf http://archive.ubuntu.com/ubuntu/dists/$SUITE/main/binary-$ARCH > /dev/null; then
default_mirror http://archive.ubuntu.com/ubuntu/
keyring /usr/share/keyrings/ubuntu-archive-keyring.gpg
elif curl -sf http://ports.ubuntu.com/ubuntu-ports/dists/$SUITE/main/binary-$ARCH > /dev/null; then
default_mirror http://ports.ubuntu.com/ubuntu-ports/
keyring /usr/share/keyrings/ubuntu-archive-keyring.gpg
elif curl -sf http://old-releases.ubuntu.com/ubuntu/dists/$SUITE/main/binary-$ARCH > /dev/null; then
default_mirror http://old-releases.ubuntu.com/ubuntu/
keyring /usr/share/keyrings/ubuntu-archive-removed-keys.gpg
else
error 1 SOMETHING "No ubuntu mirror for suite $SUITE, arch $ARCH"
fi
And it works for focal for both amd64 and arm64. Probably worrks for
more than just focal too. Should we make this change?
Note that I don't know how to report the error, so "SOMETHING" above
should be replaced.
Thanks!
Reply to: