From 87d6b6935f1e31cb4a9f40482ee9638c499a9b70 Mon Sep 17 00:00:00 2001 From: Sam Lunt Date: Wed, 9 Mar 2022 16:40:44 -0600 Subject: [PATCH] Fixes to support building from non-Debian hosts This fixes some behaviors that assume a Debian build host: * Use the chroot's dpkg binaries instead of the host's * The grub script was missing an escape that caused it to use the build environment's PATH variable instead of the one set by the Chroot command. This is more noticable on systems with a merged /usr --- functions/chroot.sh | 10 +++++----- scripts/build/binary_grub-efi | 4 ++-- scripts/build/installer_debian-installer | 14 ++++++++------ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/functions/chroot.sh b/functions/chroot.sh index 3804bf88c..3022b2afa 100755 --- a/functions/chroot.sh +++ b/functions/chroot.sh @@ -35,10 +35,10 @@ Chroot () } Chroot_has_package() { - local PACKAGE="${1}"; shift - local CHROOT="${2:-chroot}"; shift + local PACKAGE="${1}" + local CHROOT="${2:-chroot}" - if dpkg-query --admindir=${CHROOT}/var/lib/dpkg -s ${PACKAGE} >/dev/null 2>&1 | grep -q "^Status: install" + if Chroot "${CHROOT}" dpkg-query -s ${PACKAGE} 2>/dev/null | grep -q "^Status: install" then return 0 fi @@ -46,9 +46,9 @@ Chroot_has_package() { } Chroot_package_list() { - local CHROOT="${1:-chroot}"; shift + local CHROOT="${1:-chroot}" - dpkg-query --admindir=${CHROOT}/var/lib/dpkg -W -f'${Package}\n' + Chroot "${CHROOT}" dpkg-query -W -f'${Package}\n' } Chroot_copy_dir() { diff --git a/scripts/build/binary_grub-efi b/scripts/build/binary_grub-efi index d504569cb..8cebbdb11 100755 --- a/scripts/build/binary_grub-efi +++ b/scripts/build/binary_grub-efi @@ -195,14 +195,14 @@ gen_efi_boot_img(){ fi } -PRE_EFI_IMAGE_PATH="${PATH}" +PRE_EFI_IMAGE_PATH="\${PATH}" if [ ! -e "${LIVE_BUILD}" ] ; then LIVE_BUILD_PATH="/usr/lib/live/build" else LIVE_BUILD_PATH="${LIVE_BUILD}/scripts/build" fi -PATH="${PATH}:\${LIVE_BUILD_PATH}" # Make sure grub-cpmodules is used as if it was installed in the system +PATH="\${PATH}:\${LIVE_BUILD_PATH}" # Make sure grub-cpmodules is used as if it was installed in the system case "${LB_ARCHITECTURE}" in amd64|i386) diff --git a/scripts/build/installer_debian-installer b/scripts/build/installer_debian-installer index 8a663e5dd..ff48398e5 100755 --- a/scripts/build/installer_debian-installer +++ b/scripts/build/installer_debian-installer @@ -140,11 +140,13 @@ esac Install_file() { local FILE="${1}" + local DEST="${2}" + local CHROOT="${3:-chroot}" Echo_debug "Installing file %s" "${FILE}" local ARCHIVE_AREA - ARCHIVE_AREA="$(dpkg -I ${FILE} | awk '/^.*Section: / { print $2 }')" + ARCHIVE_AREA="$(Chroot "${CHROOT}" dpkg -f ${FILE} Section)" if echo "${ARCHIVE_AREA}" | grep -qs '/' then @@ -153,10 +155,10 @@ Install_file() { ARCHIVE_AREA="main" fi - local TARGET="${2}/${ARCHIVE_AREA}" + local TARGET="${DEST}/${ARCHIVE_AREA}" local SOURCE - SOURCE="$(dpkg -f ${FILE} Source | awk '{ print $1 }')" + SOURCE="$(Chroot "${CHROOT}" dpkg -f ${FILE} Source | awk '{ print $1 }')" if [ -z "${SOURCE}" ] then @@ -590,7 +592,7 @@ EOF do if [ -e "${FILE}" ] then - Install_file "${FILE}" "pool-udeb" + Install_file "${FILE}" "pool-udeb" "${OLDPWD}/chroot" # Prefer local udebs over downloaded udebs rm -f "$(basename ${FILE} | awk -F_ '{ print $1 }')"_*.udeb @@ -604,7 +606,7 @@ EOF do if [ -e "${FILE}" ] then - Install_file "${FILE}" "pool-udeb" + Install_file "${FILE}" "pool-udeb" "${OLDPWD}/chroot" # Prefer local udebs over downloaded udebs rm -f "$(basename ${FILE} | awk -F_ '{ print $1 }')"_*.udeb @@ -650,7 +652,7 @@ EOF for UDEB in ${UDEBS} ${UDEBS_DERIVED}; do _UDEB_FILENAME="$(basename ${UDEB})" if [ -f "${_UDEB_FILENAME}" ]; then - Install_file "${_UDEB_FILENAME}" "pool-udeb" + Install_file "${_UDEB_FILENAME}" "pool-udeb" "${OLDPWD}/chroot" rm "${_UDEB_FILENAME}" fi done