Skip to content

Commit

Permalink
debian: succeed distrobox-init if custom image has undergone releasei…
Browse files Browse the repository at this point in the history
…nfo 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 <[email protected]>
Co-authored-by: Luca Di Maio <[email protected]>
  • Loading branch information
3 people authored Sep 24, 2023
1 parent c831e2e commit ce97e5b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions distrobox-init
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit ce97e5b

Please sign in to comment.