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.
This commit is contained in:
classabbyamp 2025-07-20 13:10:35 -04:00 committed by classabbyamp
parent 60b09884ec
commit 225525c039
2 changed files with 12 additions and 12 deletions

View file

@ -1,30 +1,29 @@
# vim: set ts=4 sw=4 et: # vim: set ts=4 sw=4 et:
install_base_chroot() { install_base_chroot() {
local _bootstrap_arch _target_arch="$1"
[ "$CHROOT_READY" ] && return [ "$CHROOT_READY" ] && return
if [ "$1" = "bootstrap" ]; then if [ "$_target_arch" = "bootstrap" ]; then
unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS _target_arch=""
else unset XBPS_INSTALL_ARGS
XBPS_TARGET_PKG="$1"
fi fi
# binary bootstrap # binary bootstrap
msg_normal "xbps-src: installing base-chroot...\n" msg_normal "xbps-src: installing base-chroot...\n"
# XBPS_TARGET_PKG == arch if [ -n "$_target_arch" ]; then
if [ "$XBPS_TARGET_PKG" ]; then _bootstrap_arch="env XBPS_TARGET_ARCH=$_target_arch"
_bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
fi 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 ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS} -y base-chroot
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
msg_error "xbps-src: failed to install base-chroot!\n" msg_error "xbps-src: failed to install base-chroot!\n"
fi fi
# Reconfigure base-files to create dirs/symlinks. # Reconfigure base-files to create dirs/symlinks.
if xbps-query -r $XBPS_MASTERDIR base-files &>/dev/null; then 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 fi
msg_normal "xbps-src: installed base-chroot successfully!\n" 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_check
chroot_handler clean chroot_handler clean
} }

View file

@ -501,8 +501,9 @@ setup_pkg() {
# Check if base-chroot is already installed. # Check if base-chroot is already installed.
if [ -z "$bootstrap" -a -z "$CHROOT_READY" -a "z$show_problems" != "zignore-problems" ]; then 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_red "${pkg} is not a bootstrap package and cannot be built without bootstrapping first.\n"
msg_error "Please install bootstrap packages and try again.\n" msg_normal "binary bootstrapping for ${XBPS_MACHINE} in ${XBPS_MASTERDIR}...\n"
install_base_chroot "$XBPS_MACHINE"
fi fi
sourcepkg="${pkgname}" sourcepkg="${pkgname}"