From ce97e5b991e63136d8f76df9084c47b6aace7470 Mon Sep 17 00:00:00 2001 From: Hakan Erduman Date: Mon, 25 Sep 2023 00:26:54 +0200 Subject: [PATCH] debian: succeed distrobox-init if custom image has undergone releaseinfo change (#898) * debian: pass init if custom image is oldstable now If you use an old development image that has changed from stable to oldstable or from oldstable to oldoldstable, plain apt-update will require you to interactively or explicitly allow it. This patch fixes both the first run and upgrade scenarios. Additionally, if you use the vanilla PS1 prompt of a debian install on the host, debian defaults to prepend ($debian_chroot) to it. Set this to either CONTAINER_ID or distrobox makes it easier. * amend review results * possible fix for debian wheezy * move acquire from dpkg to apt --------- Co-authored-by: Hakan Erduman Co-authored-by: Luca Di Maio --- distrobox-init | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/distrobox-init b/distrobox-init index 9259536079..8ce9e78cf8 100755 --- a/distrobox-init +++ b/distrobox-init @@ -502,9 +502,11 @@ if [ "${upgrade}" -ne 0 ] || fi elif command -v apt-get; then + # If we have a vanilla prompt, see CONTAINER_ID in it + export debian_chroot="${CONTAINER_ID:-distrobox}" # If we need to upgrade, do it and exit, no further action required. if [ "${upgrade}" -ne 0 ]; then - apt-get update + apt-get update -y apt-get upgrade -y exit fi @@ -514,7 +516,7 @@ if [ "${upgrade}" -ne 0 ] || rm -f /etc/dpkg/dpkg.cfg.d/excludes export DEBIAN_FRONTEND=noninteractive - apt-get update + apt-get update -o 'Acquire::AllowReleaseInfoChange::Suite=true' -y # Check if shell_pkg is available in distro's repo. If not we # fall back to bash, and we set the SHELL variable to bash so # that it is set up correctly for the user. @@ -1676,13 +1678,14 @@ if [ -d "/etc/dpkg/dpkg.cfg.d/" ] && [ "${init}" -eq 0 ]; then for net_mount in ${HOST_MOUNTS_RO} ${HOST_MOUNTS}; do printf "path-exclude %s/*\n" "${net_mount}" >> /etc/dpkg/dpkg.cfg.d/00_distrobox done - # Also we put a hook to clear some critical paths that do not play well # with read only filesystems, like Systemd. if [ -d "/etc/apt/apt.conf.d/" ]; then printf "distrobox: Setting up apt hooks...\n" printf 'DPkg::Pre-Invoke {/etc/distrobox-pre-hook.sh};\n' > /etc/apt/apt.conf.d/00_distrobox printf 'DPkg::Post-Invoke {/etc/distrobox-post-hook.sh};\n' >> /etc/apt/apt.conf.d/00_distrobox + # let distrobox upgrade succeed even if a transition from stable to oldstable happens + printf 'Acquire::AllowReleaseInfoChange::Suite "true";' >> /etc/apt/apt.conf.d/00_distrobox fi fi