Update scripts to really replace rust coreutils with GNU coreutils

This commit is contained in:
PikachuEXE
2026-05-20 16:12:29 +08:00
parent af5f71b4d4
commit 785d124a70
3 changed files with 14 additions and 40 deletions
+3 -3
View File
@@ -4,9 +4,9 @@ FROM $BASE_IMAGE
ARG QEMU_ARCH ARG QEMU_ARCH
#ADD x86_64_qemu-${QEMU_ARCH}-static.tar.gz /usr/bin #ADD x86_64_qemu-${QEMU_ARCH}-static.tar.gz /usr/bin
# Ubuntu 26.04+ ships uutils-coreutils (Rust) and sudo-rs (Rust) by default. # Ubuntu 26.04+ ships uutils-coreutils (Rust) by default.
# Set INSTALL_GNU_COREUTILS=1 to replace them with GNU Coreutils and # Set INSTALL_GNU_COREUTILS=1 to replace them with GNU Coreutils.
# traditional sudo. Has no effect on Ubuntu releases prior to 26.04. # Has no effect on Ubuntu releases prior to 26.04.
ARG INSTALL_GNU_COREUTILS=0 ARG INSTALL_GNU_COREUTILS=0
COPY . /bd_build COPY . /bd_build
+3 -3
View File
@@ -8,7 +8,7 @@ export DISABLE_SYSLOG=${DISABLE_SYSLOG:-0}
export DISABLE_SSH=${DISABLE_SSH:-0} export DISABLE_SSH=${DISABLE_SSH:-0}
export DISABLE_CRON=${DISABLE_CRON:-0} export DISABLE_CRON=${DISABLE_CRON:-0}
# Ubuntu 26.04+ ships uutils-coreutils (Rust) and sudo-rs (Rust) by default. # Ubuntu 26.04+ ships uutils-coreutils (Rust) by default.
# Set INSTALL_GNU_COREUTILS=1 to replace them with GNU Coreutils and # Set INSTALL_GNU_COREUTILS=1 to replace them with GNU Coreutils.
# traditional sudo. Has no effect on Ubuntu releases prior to 26.04. # Has no effect on Ubuntu releases prior to 26.04.
export INSTALL_GNU_COREUTILS=${INSTALL_GNU_COREUTILS:-0} export INSTALL_GNU_COREUTILS=${INSTALL_GNU_COREUTILS:-0}
+8 -34
View File
@@ -55,8 +55,8 @@ $minimal_apt_get_install software-properties-common
## Upgrade all packages. ## Upgrade all packages.
apt-get dist-upgrade -y --no-install-recommends -o Dpkg::Options::="--force-confold" apt-get dist-upgrade -y --no-install-recommends -o Dpkg::Options::="--force-confold"
## Ubuntu 26.04+ ships uutils-coreutils (Rust) and sudo-rs (Rust) by default. ## Ubuntu 26.04+ ships uutils-coreutils (Rust) by default.
## Optionally replace them with GNU Coreutils and traditional sudo when ## Optionally replace them with GNU Coreutils when
## INSTALL_GNU_COREUTILS=1 is set at build time. ## INSTALL_GNU_COREUTILS=1 is set at build time.
if grep -E '^ID=' /etc/os-release | grep -q ubuntu; then if grep -E '^ID=' /etc/os-release | grep -q ubuntu; then
UBUNTU_VERSION=$(grep '^VERSION_ID=' /etc/os-release | cut -d'"' -f2) UBUNTU_VERSION=$(grep '^VERSION_ID=' /etc/os-release | cut -d'"' -f2)
@@ -72,40 +72,14 @@ if grep -E '^ID=' /etc/os-release | grep -q ubuntu; then
;; ;;
esac esac
if [ "$INSTALL_GNU_COREUTILS_NORMALIZED" = "1" ]; then if [ "$INSTALL_GNU_COREUTILS_NORMALIZED" = "1" ]; then
echo "*** Installing GNU Coreutils and traditional sudo to replace Rust variants..." echo "*** Removing Rust to restore GNU Coreutils..."
GNU_COREUTILS_INSTALLED=0 # GNU Coreutils can only be installed by removing `coreutils-from-uutils`
TRADITIONAL_SUDO_INSTALLED=0 apt-get remove -y --allow-remove-essential coreutils-from-uutils
# Install GNU Coreutils if available (package name may vary by Ubuntu release).
# 'coreutils-gnu' is the expected package name for the GNU implementation
# when uutils-coreutils is the default.
if apt-cache show coreutils-gnu > /dev/null 2>&1; then
$minimal_apt_get_install coreutils-gnu
GNU_COREUTILS_INSTALLED=1
fi
# Install traditional sudo if available (package name may vary).
# 'sudo-traditional' or similar may be provided alongside 'sudo-rs'.
if apt-cache show sudo-traditional > /dev/null 2>&1; then
$minimal_apt_get_install sudo-traditional
TRADITIONAL_SUDO_INSTALLED=1
elif apt-cache show sudo-classic > /dev/null 2>&1; then
$minimal_apt_get_install sudo-classic
TRADITIONAL_SUDO_INSTALLED=1
fi
if [ "$GNU_COREUTILS_INSTALLED" -ne 1 ] || [ "$TRADITIONAL_SUDO_INSTALLED" -ne 1 ]; then
echo "*** ERROR: INSTALL_GNU_COREUTILS=1 was requested, but the requested replacements could not be fully installed." >&2
if [ "$GNU_COREUTILS_INSTALLED" -ne 1 ]; then
echo "*** ERROR: No GNU coreutils replacement package was found (tried: coreutils-gnu)." >&2
fi
if [ "$TRADITIONAL_SUDO_INSTALLED" -ne 1 ]; then
echo "*** ERROR: No traditional sudo replacement package was found (tried: sudo-traditional, sudo-classic)." >&2
fi
exit 1
fi
# Verify that GNU coreutils are now the active implementation on PATH. # Verify that GNU coreutils are now the active implementation on PATH.
# Some packages may install binaries under a non-default path and rely on # Some packages may install binaries under a non-default path and rely on
# update-alternatives; if so the replacement has not taken effect. # update-alternatives; if so the replacement has not taken effect.
if ! ls --version 2>&1 | grep -qi 'gnu coreutils'; then if ! ls --version 2>&1 | grep -qi 'gnu coreutils'; then
echo "*** ERROR: coreutils-gnu was installed but GNU coreutils are not active on PATH." >&2 echo "*** ERROR: coreutils-from-gnu was installed but GNU coreutils are not active on PATH." >&2
echo "*** 'ls --version' does not report 'GNU coreutils'." >&2 echo "*** 'ls --version' does not report 'GNU coreutils'." >&2
echo "*** The package may place binaries outside the default PATH or require" >&2 echo "*** The package may place binaries outside the default PATH or require" >&2
echo "*** manual update-alternatives configuration. Check Ubuntu 26.04 packaging." >&2 echo "*** manual update-alternatives configuration. Check Ubuntu 26.04 packaging." >&2
@@ -114,8 +88,8 @@ if grep -E '^ID=' /etc/os-release | grep -q ubuntu; then
LS_VER=$(ls --version | head -1) LS_VER=$(ls --version | head -1)
echo "*** GNU Coreutils are active ($LS_VER)." echo "*** GNU Coreutils are active ($LS_VER)."
else else
echo "*** Ubuntu 26.04 detected: using default uutils-coreutils (Rust) and sudo-rs (Rust)." echo "*** Ubuntu 26.04 detected: using default uutils-coreutils (Rust)."
echo "*** Set INSTALL_GNU_COREUTILS=1 at build time to use GNU Coreutils and traditional sudo instead." echo "*** Set INSTALL_GNU_COREUTILS=1 at build time to use GNU Coreutils instead."
fi fi
fi fi
fi fi