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..1bef6e33a9d 100644 --- a/common/xbps-src/shutils/common.sh +++ b/common/xbps-src/shutils/common.sh @@ -502,7 +502,18 @@ 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" + # if this isn't a script, ask to bootstrap + if [ -t 1 ]; then + msg_normal "Would you like to binary-bootstrap for ${XBPS_MACHINE} in ${XBPS_MASTERDIR}?" + read -rp " [Y/n] " _bin_bootstrap_resp + [ -z "$_bin_bootstrap_resp" ] && _bin_bootstrap_resp=y + fi + if [ "${_bin_bootstrap_resp,,}" = "y" ]; then + msg_normal "binary bootstrapping for ${XBPS_MACHINE} in ${XBPS_MASTERDIR}...\n" + install_base_chroot "$XBPS_MACHINE" + else + msg_error "Please run '${PROGNAME} -A ${XBPS_MACHINE} binary-bootstrap' or install bootstrap packages, then try again.\n" + fi fi sourcepkg="${pkgname}"