From 225525c039d92729ba633649e8872932eb40a93f Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Sun, 20 Jul 2025 13:10:35 -0400 Subject: [PATCH] common/xbps-src/shutils/common: automatically binary-bootstrap if not already done instead of just giving an error message, we can just do this automatically. if the user wants to do a source bootstrap, they should know to do this explicitly. so many people ask how to fix this error, especially now that `-a` implies the matching libc's `-A`, so let's make it more automatic. --- common/xbps-src/shutils/chroot.sh | 19 +++++++++---------- common/xbps-src/shutils/common.sh | 5 +++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh index f6be75c5fdc..a65774d2320 100644 --- a/common/xbps-src/shutils/chroot.sh +++ b/common/xbps-src/shutils/chroot.sh @@ -1,30 +1,29 @@ # vim: set ts=4 sw=4 et: install_base_chroot() { + local _bootstrap_arch _target_arch="$1" [ "$CHROOT_READY" ] && return - if [ "$1" = "bootstrap" ]; then - unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS - else - XBPS_TARGET_PKG="$1" + if [ "$_target_arch" = "bootstrap" ]; then + _target_arch="" + unset XBPS_INSTALL_ARGS fi # binary bootstrap msg_normal "xbps-src: installing base-chroot...\n" - # XBPS_TARGET_PKG == arch - if [ "$XBPS_TARGET_PKG" ]; then - _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG" + if [ -n "$_target_arch" ]; then + _bootstrap_arch="env XBPS_TARGET_ARCH=$_target_arch" fi - (export XBPS_MACHINE=$XBPS_TARGET_PKG XBPS_ARCH=$XBPS_TARGET_PKG; chroot_sync_repodata) + (export XBPS_MACHINE="$_target_arch" XBPS_ARCH="$_target_arch"; chroot_sync_repodata) ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS} -y base-chroot if [ $? -ne 0 ]; then msg_error "xbps-src: failed to install base-chroot!\n" fi # Reconfigure base-files to create dirs/symlinks. if xbps-query -r $XBPS_MASTERDIR base-files &>/dev/null; then - XBPS_ARCH=$XBPS_TARGET_PKG xbps-reconfigure -r $XBPS_MASTERDIR -f base-files &>/dev/null + XBPS_ARCH="$_target_arch" xbps-reconfigure -r $XBPS_MASTERDIR -f base-files &>/dev/null fi msg_normal "xbps-src: installed base-chroot successfully!\n" - chroot_prepare $XBPS_TARGET_PKG || msg_error "xbps-src: failed to initialize chroot!\n" + chroot_prepare "$_target_arch" || msg_error "xbps-src: failed to initialize chroot!\n" chroot_check chroot_handler clean } diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh index e0a67bc8a5e..aa09bf2497f 100644 --- a/common/xbps-src/shutils/common.sh +++ b/common/xbps-src/shutils/common.sh @@ -501,8 +501,9 @@ setup_pkg() { # Check if base-chroot is already installed. if [ -z "$bootstrap" -a -z "$CHROOT_READY" -a "z$show_problems" != "zignore-problems" ]; then - msg_red "${pkg} is not a bootstrap package and cannot be built without it.\n" - msg_error "Please install bootstrap packages and try again.\n" + msg_red "${pkg} is not a bootstrap package and cannot be built without bootstrapping first.\n" + msg_normal "binary bootstrapping for ${XBPS_MACHINE} in ${XBPS_MASTERDIR}...\n" + install_base_chroot "$XBPS_MACHINE" fi sourcepkg="${pkgname}"