Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps)
@ 2020-01-01 10:37 voidlinux-github
  2020-01-01 10:41 ` voidlinux-github
                   ` (97 more replies)
  0 siblings, 98 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 10:37 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1750 bytes --]

There is a new pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 51166 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
@ 2020-01-01 10:41 ` voidlinux-github
  2020-01-01 10:46 ` [PR PATCH] [Updated] " voidlinux-github
                   ` (96 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 10:41 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 280 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570041910

Comment:
@void-linux/pkg-committers please give this a test, I'll wait some days for more testing. But I've been running it for days with no issues.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
  2020-01-01 10:41 ` voidlinux-github
@ 2020-01-01 10:46 ` voidlinux-github
  2020-01-01 10:50 ` voidlinux-github
                   ` (95 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 10:46 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1804 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 52051 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 1/2] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 2/2] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
  2020-01-01 10:41 ` voidlinux-github
  2020-01-01 10:46 ` [PR PATCH] [Updated] " voidlinux-github
@ 2020-01-01 10:50 ` voidlinux-github
  2020-01-01 10:59 ` [PR PATCH] [Updated] " voidlinux-github
                   ` (94 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 10:50 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 166 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570042625

Comment:
Ok, now to fix travis :-)

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (2 preceding siblings ...)
  2020-01-01 10:50 ` voidlinux-github
@ 2020-01-01 10:59 ` voidlinux-github
  2020-01-01 11:05 ` voidlinux-github
                   ` (93 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 10:59 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1804 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 54023 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 1/3] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 2/3] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 3/3] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (3 preceding siblings ...)
  2020-01-01 10:59 ` [PR PATCH] [Updated] " voidlinux-github
@ 2020-01-01 11:05 ` voidlinux-github
  2020-01-01 11:11 ` voidlinux-github
                   ` (92 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 11:05 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1804 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 55688 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 1/5] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 2/5] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 3/5] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 4/5] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 5/5] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (4 preceding siblings ...)
  2020-01-01 11:05 ` voidlinux-github
@ 2020-01-01 11:11 ` voidlinux-github
  2020-01-01 11:22 ` voidlinux-github
                   ` (91 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 11:11 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1804 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 56356 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 1/6] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 2/6] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 3/6] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 4/6] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 5/6] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 6/6] chroot_init: return 0 at the end to not inherit last cmd
 errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (5 preceding siblings ...)
  2020-01-01 11:11 ` voidlinux-github
@ 2020-01-01 11:22 ` voidlinux-github
  2020-01-01 11:25 ` voidlinux-github
                   ` (90 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 11:22 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1804 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 58160 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 1/8] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 2/8] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 3/8] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 4/8] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 5/8] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 6/8] chroot_init: return 0 at the end to not inherit last cmd
 errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 7/8] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 8/8] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (6 preceding siblings ...)
  2020-01-01 11:22 ` voidlinux-github
@ 2020-01-01 11:25 ` voidlinux-github
  2020-01-01 11:29 ` voidlinux-github
                   ` (89 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 11:25 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1804 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 59297 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 1/9] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 2/9] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 3/9] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 4/9] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 5/9] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 6/9] chroot_init: return 0 at the end to not inherit last cmd
 errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 7/9] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 8/9] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 9/9] travis: rebuild base-chroot via build.sh not prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (7 preceding siblings ...)
  2020-01-01 11:25 ` voidlinux-github
@ 2020-01-01 11:29 ` voidlinux-github
  2020-01-01 11:40 ` voidlinux-github
                   ` (88 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 11:29 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1804 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 60020 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/10] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/10] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/10] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/10] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/10] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/10] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/10] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/10] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/10] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/10] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (8 preceding siblings ...)
  2020-01-01 11:29 ` voidlinux-github
@ 2020-01-01 11:40 ` voidlinux-github
  2020-01-01 11:42 ` voidlinux-github
                   ` (87 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 11:40 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1804 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 60798 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/11] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/11] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/11] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/11] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/11] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/11] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/11] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/11] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/11] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/11] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/11] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (9 preceding siblings ...)
  2020-01-01 11:40 ` voidlinux-github
@ 2020-01-01 11:42 ` voidlinux-github
  2020-01-01 11:48 ` voidlinux-github
                   ` (86 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 11:42 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1804 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 61785 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/12] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/12] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/12] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/12] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/12] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/12] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/12] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/12] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/12] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/12] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/12] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/12] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (10 preceding siblings ...)
  2020-01-01 11:42 ` voidlinux-github
@ 2020-01-01 11:48 ` voidlinux-github
  2020-01-01 11:53 ` voidlinux-github
                   ` (85 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 11:48 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1804 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 62613 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/13] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/13] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/13] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/13] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/13] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/13] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/13] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/13] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/13] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/13] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/13] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/13] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/13] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (11 preceding siblings ...)
  2020-01-01 11:48 ` voidlinux-github
@ 2020-01-01 11:53 ` voidlinux-github
  2020-01-01 11:56 ` voidlinux-github
                   ` (84 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 11:53 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1804 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 63462 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/14] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/14] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/14] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/14] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/14] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/14] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/14] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/14] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/14] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/14] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/14] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/14] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/14] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/14] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (12 preceding siblings ...)
  2020-01-01 11:53 ` voidlinux-github
@ 2020-01-01 11:56 ` voidlinux-github
  2020-01-01 11:58 ` voidlinux-github
                   ` (83 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 11:56 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1804 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 64231 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/15] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/15] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/15] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/15] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/15] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/15] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/15] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/15] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/15] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/15] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/15] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/15] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/15] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/15] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 88c135d6642a9e84d4042174889b487912aa1548 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:55:35 +0100
Subject: [PATCH 15/15] travis/build.sh: local repo path v2

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 7e679ecc843..09705565427 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (13 preceding siblings ...)
  2020-01-01 11:56 ` voidlinux-github
@ 2020-01-01 11:58 ` voidlinux-github
  2020-01-01 12:02 ` voidlinux-github
                   ` (82 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 11:58 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1804 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 65032 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/16] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/16] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/16] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/16] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/16] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/16] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/16] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/16] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/16] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/16] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/16] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/16] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/16] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/16] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 88c135d6642a9e84d4042174889b487912aa1548 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:55:35 +0100
Subject: [PATCH 15/16] travis/build.sh: local repo path v2

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 7e679ecc843..09705565427 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 1dedb200d46899cddf3a94ba5d618c592e69fb85 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:58:19 +0100
Subject: [PATCH 16/16] travis/build.sh: also use xbps.d repos, to resolve
 missing deps.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 09705565427..c7049c260c6 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (14 preceding siblings ...)
  2020-01-01 11:58 ` voidlinux-github
@ 2020-01-01 12:02 ` voidlinux-github
  2020-01-01 12:07 ` voidlinux-github
                   ` (81 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 12:02 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1804 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 65799 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/17] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/17] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/17] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/17] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/17] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/17] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/17] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/17] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/17] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/17] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/17] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/17] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/17] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/17] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 88c135d6642a9e84d4042174889b487912aa1548 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:55:35 +0100
Subject: [PATCH 15/17] travis/build.sh: local repo path v2

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 7e679ecc843..09705565427 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 1dedb200d46899cddf3a94ba5d618c592e69fb85 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:58:19 +0100
Subject: [PATCH 16/17] travis/build.sh: also use xbps.d repos, to resolve
 missing deps.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 09705565427..c7049c260c6 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From b261543632c599c2c92a27d7a02ce04e382a5550 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:01:18 +0100
Subject: [PATCH 17/17] travis/build.sh: perform sysup before installing
 base-chroot.

---
 common/travis/build.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c7049c260c6..916c25515d7 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,6 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (15 preceding siblings ...)
  2020-01-01 12:02 ` voidlinux-github
@ 2020-01-01 12:07 ` voidlinux-github
  2020-01-01 12:12 ` voidlinux-github
                   ` (80 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 12:07 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1804 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 66524 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/18] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/18] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/18] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/18] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/18] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/18] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/18] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/18] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/18] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/18] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/18] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/18] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/18] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/18] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 88c135d6642a9e84d4042174889b487912aa1548 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:55:35 +0100
Subject: [PATCH 15/18] travis/build.sh: local repo path v2

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 7e679ecc843..09705565427 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 1dedb200d46899cddf3a94ba5d618c592e69fb85 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:58:19 +0100
Subject: [PATCH 16/18] travis/build.sh: also use xbps.d repos, to resolve
 missing deps.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 09705565427..c7049c260c6 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From b261543632c599c2c92a27d7a02ce04e382a5550 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:01:18 +0100
Subject: [PATCH 17/18] travis/build.sh: perform sysup before installing
 base-chroot.

---
 common/travis/build.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c7049c260c6..916c25515d7 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,6 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1

From b0140b84b7846c1ecb820da819fc50aefdb5383e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:06:53 +0100
Subject: [PATCH 18/18] tar: fix for ethereal chroot-style

---
 srcpkgs/tar/template | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 0a49caa7e91..2ec183c02f1 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -13,6 +13,8 @@ distfiles="${GNU_SITE}/tar/${pkgname}-${version}.tar.xz"
 checksum=d0d3ae07f103323be809bc3eac0dcc386d52c5262499fe05511ac4788af1fdd8
 
 pre_configure() {
+	# chroot-style=ethereal
+	export FORCE_UNSAFE_CONFIGURE=1
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (16 preceding siblings ...)
  2020-01-01 12:07 ` voidlinux-github
@ 2020-01-01 12:12 ` voidlinux-github
  2020-01-01 12:13 ` voidlinux-github
                   ` (79 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 12:12 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1804 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 67267 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/19] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/19] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/19] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/19] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/19] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/19] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/19] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/19] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/19] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/19] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/19] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/19] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/19] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/19] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 88c135d6642a9e84d4042174889b487912aa1548 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:55:35 +0100
Subject: [PATCH 15/19] travis/build.sh: local repo path v2

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 7e679ecc843..09705565427 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 1dedb200d46899cddf3a94ba5d618c592e69fb85 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:58:19 +0100
Subject: [PATCH 16/19] travis/build.sh: also use xbps.d repos, to resolve
 missing deps.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 09705565427..c7049c260c6 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From b261543632c599c2c92a27d7a02ce04e382a5550 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:01:18 +0100
Subject: [PATCH 17/19] travis/build.sh: perform sysup before installing
 base-chroot.

---
 common/travis/build.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c7049c260c6..916c25515d7 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,6 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1

From b0140b84b7846c1ecb820da819fc50aefdb5383e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:06:53 +0100
Subject: [PATCH 18/19] tar: fix for ethereal chroot-style

---
 srcpkgs/tar/template | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 0a49caa7e91..2ec183c02f1 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -13,6 +13,8 @@ distfiles="${GNU_SITE}/tar/${pkgname}-${version}.tar.xz"
 checksum=d0d3ae07f103323be809bc3eac0dcc386d52c5262499fe05511ac4788af1fdd8
 
 pre_configure() {
+	# chroot-style=ethereal
+	export FORCE_UNSAFE_CONFIGURE=1
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }

From d34dc4783cabd6562e1a64cc09518d31b3c43119 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:12:04 +0100
Subject: [PATCH 19/19] base-chroot: fix license?

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 1f73f00d56d..d4614bf3f27 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -6,7 +6,7 @@ bootstrap=yes
 build_style=meta
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
-license="Public domain"
+license="Public Domain"
 homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (17 preceding siblings ...)
  2020-01-01 12:12 ` voidlinux-github
@ 2020-01-01 12:13 ` voidlinux-github
  2020-01-01 12:14 ` voidlinux-github
                   ` (78 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 12:13 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 423 bytes --]

New comment by leahneukirchen on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570048280

Comment:
Additional notes:

1) This should now support .zip out of the box.
2) Making texinfo a proper dependency was always a wish of me, but I think we need to add it now to the packages that need it.

Will give this a try when I have better network than on this train. Thanks.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (18 preceding siblings ...)
  2020-01-01 12:13 ` voidlinux-github
@ 2020-01-01 12:14 ` voidlinux-github
  2020-01-01 12:16 ` voidlinux-github
                   ` (77 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 12:14 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 234 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570048369

Comment:
@leahneukirchen yeah, .zip should now be handled by bsdtar as well. I could also change this.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (19 preceding siblings ...)
  2020-01-01 12:14 ` voidlinux-github
@ 2020-01-01 12:16 ` voidlinux-github
  2020-01-01 12:18 ` voidlinux-github
                   ` (76 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 12:16 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 344 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570048584

Comment:
The key point of this branch is reducing dependencies (gettext, texinfo) and the switch to bsdtar, as well as always using latest base-chroot before building, effectively making this always reproducible.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (20 preceding siblings ...)
  2020-01-01 12:16 ` voidlinux-github
@ 2020-01-01 12:18 ` voidlinux-github
  2020-01-01 12:19 ` voidlinux-github
                   ` (75 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 12:18 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 193 bytes --]

New comment by leahneukirchen on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570048661

Comment:
Also why again does ada need to be in chroot?

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (21 preceding siblings ...)
  2020-01-01 12:18 ` voidlinux-github
@ 2020-01-01 12:19 ` voidlinux-github
  2020-01-01 12:19 ` voidlinux-github
                   ` (74 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 12:19 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 292 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570048737

Comment:
@leahneukirchen I said this like 6 months ago, @pullmoll said he couldn't find any other way. Don't worry I'll address this once this branch is merged.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (22 preceding siblings ...)
  2020-01-01 12:19 ` voidlinux-github
@ 2020-01-01 12:19 ` voidlinux-github
  2020-01-01 12:22 ` voidlinux-github
                   ` (73 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 12:19 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 211 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570048792

Comment:
The correct way to not require ada in the host is taking the rust way.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (23 preceding siblings ...)
  2020-01-01 12:19 ` voidlinux-github
@ 2020-01-01 12:22 ` voidlinux-github
  2020-01-01 12:25 ` voidlinux-github
                   ` (72 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 12:22 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 173 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570049034

Comment:
Looks like travis dtrt now, cool

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (24 preceding siblings ...)
  2020-01-01 12:22 ` voidlinux-github
@ 2020-01-01 12:25 ` voidlinux-github
  2020-01-01 12:28 ` voidlinux-github
                   ` (71 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 12:25 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 261 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570049181

Comment:
With this branch we are now sure that **everyone** use the same set of dependencies while building **any** package, yay!

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (25 preceding siblings ...)
  2020-01-01 12:25 ` voidlinux-github
@ 2020-01-01 12:28 ` voidlinux-github
  2020-01-01 12:30 ` voidlinux-github
                   ` (70 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 12:28 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 377 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570049445

Comment:
BTW, this also makes the xbps repository order always reproducible:

- local alternative (/host/binpkgs/$gitbranch)
- local (/host/binpkgs)
- remote

You can now easily switch the remote repos: edit `etc/xbps.d/repos-remote*.conf`

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (26 preceding siblings ...)
  2020-01-01 12:28 ` voidlinux-github
@ 2020-01-01 12:30 ` voidlinux-github
  2020-01-01 12:36 ` voidlinux-github
                   ` (69 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 12:30 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 187 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570049556

Comment:
@pullmoll please test! -Nt now rocks :dancer: 

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (27 preceding siblings ...)
  2020-01-01 12:30 ` voidlinux-github
@ 2020-01-01 12:36 ` voidlinux-github
  2020-01-01 21:14 ` voidlinux-github
                   ` (68 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 12:36 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 158 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570049908

Comment:
This is now ready

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (28 preceding siblings ...)
  2020-01-01 12:36 ` voidlinux-github
@ 2020-01-01 21:14 ` voidlinux-github
  2020-01-01 21:32 ` voidlinux-github
                   ` (67 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 21:14 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 318 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570084043

Comment:
@the-maldridge with these changes xbps-src will always use latest base-chroot. If the docker image gets rebuilt xbps-src will skip the update process and will continue normally.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (29 preceding siblings ...)
  2020-01-01 21:14 ` voidlinux-github
@ 2020-01-01 21:32 ` voidlinux-github
  2020-01-01 21:32 ` voidlinux-github
                   ` (66 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 21:32 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 256 bytes --]

New comment by the-maldridge on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570085097

Comment:
Exactly, I want to avoid pulling a huge amount of data through travis (well, any huger than we already do).  

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (30 preceding siblings ...)
  2020-01-01 21:32 ` voidlinux-github
@ 2020-01-01 21:32 ` voidlinux-github
  2020-01-01 21:33 ` voidlinux-github
                   ` (65 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 21:32 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1244 bytes --]

New comment by the-maldridge on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570085138

Comment:
Bootstrap fails with:

```
=> gcc-9.2.0_3: the following build options are set:
   ada: Enable Ada build (ON)
   gnatboot: Enable Ada bootstrap using adacore.com binaries (OFF)
=> gcc-9.2.0_3: building (dependency of base-chroot) for x86_64...
   [check] dejagnu-1.6.2_1: not found
   [target] zlib-devel-1.2.11_3: found (/home/maldridge/Documents/void/packages/hostdir/binpkgs/chroot-v2)
   [runtime] binutils-2.33.1_1: found (/home/maldridge/Documents/void/packages/hostdir/binpkgs/chroot-v2)
   [runtime] libgcc-devel-9.2.0_3: not found (subpkg, ignored)
   [runtime] libstdc++-devel-9.2.0_3: not found (subpkg, ignored)
   [runtime] libssp-devel-9.2.0_3: not found (subpkg, ignored)
   [runtime] glibc-devel-2.30_1: found (/home/maldridge/Documents/void/packages/hostdir/binpkgs/chroot-v2)
=> ERROR: dejagnu is not a bootstrap package and cannot be built without it.
=> ERROR: Please install bootstrap packages and try again.
=> ERROR: xbps-src: failed to build host dependency 'dejagnu-1.6.2_1' (1)
=> ERROR: xbps-src: failed to build target dependency 'gcc-9.2.0_3' (1)
```

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (31 preceding siblings ...)
  2020-01-01 21:32 ` voidlinux-github
@ 2020-01-01 21:33 ` voidlinux-github
  2020-01-01 21:34 ` voidlinux-github
                   ` (64 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 21:33 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1435 bytes --]

New comment by the-maldridge on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570085138

Comment:
Bootstrap fails with:

```
=> gcc-9.2.0_3: the following build options are set:
   ada: Enable Ada build (ON)
   gnatboot: Enable Ada bootstrap using adacore.com binaries (OFF)
=> gcc-9.2.0_3: building (dependency of base-chroot) for x86_64...
   [check] dejagnu-1.6.2_1: not found
   [target] zlib-devel-1.2.11_3: found (/home/maldridge/Documents/void/packages/hostdir/binpkgs/chroot-v2)
   [runtime] binutils-2.33.1_1: found (/home/maldridge/Documents/void/packages/hostdir/binpkgs/chroot-v2)
   [runtime] libgcc-devel-9.2.0_3: not found (subpkg, ignored)
   [runtime] libstdc++-devel-9.2.0_3: not found (subpkg, ignored)
   [runtime] libssp-devel-9.2.0_3: not found (subpkg, ignored)
   [runtime] glibc-devel-2.30_1: found (/home/maldridge/Documents/void/packages/hostdir/binpkgs/chroot-v2)
=> ERROR: dejagnu is not a bootstrap package and cannot be built without it.
=> ERROR: Please install bootstrap packages and try again.
=> ERROR: xbps-src: failed to build host dependency 'dejagnu-1.6.2_1' (1)
=> ERROR: xbps-src: failed to build target dependency 'gcc-9.2.0_3' (1)
```

I can disable tests and this should clear, but bootstrap either should handle the tests correctly, or coerce them to off since the test executables may not be available at bootstrap time.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (32 preceding siblings ...)
  2020-01-01 21:33 ` voidlinux-github
@ 2020-01-01 21:34 ` voidlinux-github
  2020-01-01 21:35 ` voidlinux-github
                   ` (63 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 21:34 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 176 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570085255

Comment:
You've got XBPS_CHECK_PKGS enabled?

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (33 preceding siblings ...)
  2020-01-01 21:34 ` voidlinux-github
@ 2020-01-01 21:35 ` voidlinux-github
  2020-01-01 21:35 ` voidlinux-github
                   ` (62 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 21:35 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 163 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570085269

Comment:
will fix this tomorrow

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (34 preceding siblings ...)
  2020-01-01 21:35 ` voidlinux-github
@ 2020-01-01 21:35 ` voidlinux-github
  2020-01-01 21:37 ` voidlinux-github
                   ` (61 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 21:35 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2265 bytes --]

New comment by the-maldridge on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570085319

Comment:
I do indeed.  I disabled it and the build failed a little while after:

```
=> gcc-9.2.0_3: running do_configure ...
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /home/maldridge/Documents/void/packages/masterdir/builddir/.xbps-gcc/wrappers/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /bin/sed
checking for gawk... gawk
checking for libatomic support... yes
checking for libitm support... yes
checking for libsanitizer support... yes
checking for libvtv support... yes
checking for libhsail-rt support... yes
checking for libphobos support... yes
checking for gcc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking whether g++ accepts -static-libstdc++ -static-libgcc... yes
checking for gnatbind... no
checking for gnatmake... no
checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2
checking for objdir... .libs
configure: WARNING: using in-tree isl, disabling version check
configure: error: GNAT is required to build ada
=> ERROR: gcc-9.2.0_3: do_configure: 'CONFIG_SHELL=/bin/bash ${wrksrc}/configure ${_args}' exited with 1
=> ERROR:   in do_configure() at srcpkgs/gcc/template:311
=> ERROR: xbps-src: failed to build target dependency 'gcc-9.2.0_3' (1)
```

If you'd rather wait until Ada can be removed from the bootstrap set that's fine by me, but I believe its currently impossible to bootstrap.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (35 preceding siblings ...)
  2020-01-01 21:35 ` voidlinux-github
@ 2020-01-01 21:37 ` voidlinux-github
  2020-01-01 21:37 ` voidlinux-github
                   ` (60 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 21:37 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 186 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570085427

Comment:
The ada issue is unrelated to these changes. 

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (36 preceding siblings ...)
  2020-01-01 21:37 ` voidlinux-github
@ 2020-01-01 21:37 ` voidlinux-github
  2020-01-01 21:38 ` voidlinux-github
                   ` (59 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 21:37 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 198 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570085455

Comment:
it will be addressed later on, once this one gets merged.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (37 preceding siblings ...)
  2020-01-01 21:37 ` voidlinux-github
@ 2020-01-01 21:38 ` voidlinux-github
  2020-01-01 23:29 ` voidlinux-github
                   ` (58 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 21:38 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 207 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570085555

Comment:
Right now, `bootstrap` needs `gcc-ada` and `libada-devel` in host.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (38 preceding siblings ...)
  2020-01-01 21:38 ` voidlinux-github
@ 2020-01-01 23:29 ` voidlinux-github
  2020-01-01 23:32 ` voidlinux-github
                   ` (57 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 23:29 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 188 bytes --]

New comment by Piraty on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570092572

Comment:
make bsdtar a host requirement like libtool etc?

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (39 preceding siblings ...)
  2020-01-01 23:29 ` voidlinux-github
@ 2020-01-01 23:32 ` voidlinux-github
  2020-01-02 11:18 ` voidlinux-github
                   ` (56 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-01 23:32 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 197 bytes --]

New comment by Piraty on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570092572

Comment:
regarding bsdtar: adapt `REQHOST_UTILS_BOOTSTRAP` as well

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (40 preceding siblings ...)
  2020-01-01 23:32 ` voidlinux-github
@ 2020-01-02 11:18 ` voidlinux-github
  2020-01-02 17:48 ` voidlinux-github
                   ` (55 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-02 11:18 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 310 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570179987

Comment:
You can bootstrap gcc with `-o gnatboot` without `gcc-ada` and `libada-devel` in the host. I fact this is how Void's first instance of `gcc-ada` for `x86_64` was built.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (41 preceding siblings ...)
  2020-01-02 11:18 ` voidlinux-github
@ 2020-01-02 17:48 ` voidlinux-github
  2020-01-02 20:32 ` voidlinux-github
                   ` (54 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-02 17:48 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 254 bytes --]

New comment by q66 on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570284946

Comment:
it's better to keep ada in core bootstrap, in order to keep it portable and not require proprietary software binaries

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (42 preceding siblings ...)
  2020-01-02 17:48 ` voidlinux-github
@ 2020-01-02 20:32 ` voidlinux-github
  2020-01-02 20:34 ` voidlinux-github
                   ` (53 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-02 20:32 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 401 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570335779

Comment:
After a `./xbps-src -o gnatboot bootstrap` there are some packages which were not built and instead downloaded: `mpfr-4.0.2_1`, `ncurses-libs-6.1_5`, and `libreadline8-8.0.001_1`.
I suppose they need to be listed somewhere. Perhaps in `base-chroot/template`?

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (43 preceding siblings ...)
  2020-01-02 20:32 ` voidlinux-github
@ 2020-01-02 20:34 ` voidlinux-github
  2020-01-02 20:37 ` voidlinux-github
                   ` (52 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-02 20:34 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 510 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570335779

Comment:
After a `./xbps-src -o gnatboot bootstrap` there are some packages which were not built and instead downloaded: `mpfr-4.0.2_1`, `ncurses-libs-6.1_5`, and `libreadline8-8.0.001_1`.
I suppose they need to be listed somewhere. Perhaps in `base-chroot/template`?
After building them manually `./xbps-src binary-bootstrap` works as expected, i.e. uses my local repo only.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (44 preceding siblings ...)
  2020-01-02 20:34 ` voidlinux-github
@ 2020-01-02 20:37 ` voidlinux-github
  2020-01-02 22:20 ` voidlinux-github
                   ` (51 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-02 20:37 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 177 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570337614

Comment:
@pullmoll will look at this tomorrow

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (45 preceding siblings ...)
  2020-01-02 20:37 ` voidlinux-github
@ 2020-01-02 22:20 ` voidlinux-github
  2020-01-02 22:29 ` voidlinux-github
                   ` (50 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-02 22:20 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 391 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570375836

Comment:
When cross compiling `glibc` with `$CHROOT_READY`, e.g. for `i686` from `x86_64`, we need to add `texinfo` to the `hostmakedepends` or otherwise there is nothing installed in `usr/share/info` and thus cannot be vmoved in the `glibc-devel_package()`.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (46 preceding siblings ...)
  2020-01-02 22:20 ` voidlinux-github
@ 2020-01-02 22:29 ` voidlinux-github
  2020-01-03  1:18 ` voidlinux-github
                   ` (49 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-02 22:29 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 532 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570378832

Comment:
When cross compiling `make` with `$CHROOT_READY` we need to add `tar` to the hostmakedepends:
```
=> make-4.2.1_5: running pre_configure ...

/usr/bin/autopoint: line 496: tar: command not found
autopoint: *** infrastructure files for version 0.19.4 not found; this is autopoint from GNU gettext-tools 0.20.1
autopoint: *** Stop.
autoreconf: autopoint failed with exit status: 1
```

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (47 preceding siblings ...)
  2020-01-02 22:29 ` voidlinux-github
@ 2020-01-03  1:18 ` voidlinux-github
  2020-01-03  1:51 ` voidlinux-github
                   ` (48 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-03  1:18 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 242 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570426435

Comment:
`chroot-git` needs `gettext` and `tar` in the hostmakedepends for cross builds with `$CHROOT_READY`.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (48 preceding siblings ...)
  2020-01-03  1:18 ` voidlinux-github
@ 2020-01-03  1:51 ` voidlinux-github
  2020-01-03  1:53 ` voidlinux-github
                   ` (47 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-03  1:51 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 986 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570432833

Comment:
Building `lm_sensors` requires a dummy (empty) `/etc/ld.so.cache` for `glibc` because the `Modules.mk` file(s) use `/sbin/ldconfig` to tell whether to link against an `libiconv.so`. Without `/etc/ld.so.cache` all that `ldconfig` does is printing an error message.
Perhaps the `base-files` should create this (empty) file for `glibc` targets.
But even with this file created manually in the chroot the build fails with:
```
Please install bison, then run "make clean" and try again
Makefile:175: lib/conf-lex.ad: No such file or directory
make: *** [Makefile:270: lib/conf-parse.c] Error 1
```
`bison` is a dependency of `flex` and already installed so the comment is misleading.
I haven't found what's missing. There's a lexer file `conf-lex.l` which should be handled by `flex` but why it would create a `conf-lex.ad` file escapes me.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (49 preceding siblings ...)
  2020-01-03  1:51 ` voidlinux-github
@ 2020-01-03  1:53 ` voidlinux-github
  2020-01-03  7:40 ` voidlinux-github
                   ` (46 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-03  1:53 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1126 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570432833

Comment:
Building `lm_sensors` requires a dummy (empty) `/etc/ld.so.cache` for `glibc` because the `Modules.mk` file(s) use `/sbin/ldconfig` to tell whether to link against an `libiconv.so`. Without `/etc/ld.so.cache` all that `ldconfig` does is printing an error message.
```
=> lm_sensors-3.5.0_2: running do_build ...
/sbin/ldconfig: Can't open cache file /etc/ld.so.cache
: No such file or directory
```
Perhaps the `base-files` should create this (empty) file for `glibc` targets.
But even with this file created manually in the chroot the build fails with:
```
Please install bison, then run "make clean" and try again
Makefile:175: lib/conf-lex.ad: No such file or directory
make: *** [Makefile:270: lib/conf-parse.c] Error 1
```
`bison` is a dependency of `flex` and already installed so the comment is misleading.
I haven't found what's missing. There's a lexer file `conf-lex.l` which should be handled by `flex` but why it would create a `conf-lex.ad` file escapes me.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (50 preceding siblings ...)
  2020-01-03  1:53 ` voidlinux-github
@ 2020-01-03  7:40 ` voidlinux-github
  2020-01-03  8:24 ` voidlinux-github
                   ` (45 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-03  7:40 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 200 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570432833

Comment:
Building `lm_sensors` requires `which` in hostmakedepends.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (51 preceding siblings ...)
  2020-01-03  7:40 ` voidlinux-github
@ 2020-01-03  8:24 ` voidlinux-github
  2020-01-03  9:29 ` voidlinux-github
                   ` (44 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-03  8:24 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 265 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570500539

Comment:
Just listing what I find and what may be useful to add to this PR:
`git` needs `gettext` and `tar` in the hostmakedepends.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (52 preceding siblings ...)
  2020-01-03  8:24 ` voidlinux-github
@ 2020-01-03  9:29 ` voidlinux-github
  2020-01-03 11:51 ` voidlinux-github
                   ` (43 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-03  9:29 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 281 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570516154

Comment:
@pullmoll please add the missing deps you've reported. There's no harm in adding them because xbps-src will detect them as installed. Thanks

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (53 preceding siblings ...)
  2020-01-03  9:29 ` voidlinux-github
@ 2020-01-03 11:51 ` voidlinux-github
  2020-01-03 12:07 ` voidlinux-github
                   ` (42 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-03 11:51 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 179 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570551833

Comment:
@xtraeme done for all I found so far.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (54 preceding siblings ...)
  2020-01-03 11:51 ` voidlinux-github
@ 2020-01-03 12:07 ` voidlinux-github
  2020-01-03 12:58 ` voidlinux-github
                   ` (41 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-03 12:07 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1154 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570555104

Comment:
It seems `binpkgs/multilib` is missing from the repo paths scanned for `x86_64`:
```
$ ./xbps-src -N -t pkg gcc-multilib
=> xbps-src: updating repositories for host (x86_64)...
=> xbps-src: cleaning up / masterdir...
=> xbps-src: updating software in / masterdir...
=> xbps-src: cleaning up / masterdir...
=> gcc-multilib-9.2.0_1: building for x86_64...
   [host] perl-5.30.1_1: found (/host/binpkgs)
   [host] flex-2.6.4_3: found (/host/binpkgs)
   [host] zip-3.0_5: found (/host/binpkgs)
   [host] unzip-6.0_13: found (/host/binpkgs)
=> ERROR: gcc-multilib-9.2.0_1: target dependency 'glibc-32bit' does not exist!
```
```
ls -l /work/void/binpkgs/multilib/glibc*

-rw-r--r-- 1 jbu jbu  6997544  2. Jan 23:22 glibc-32bit-2.30_1.x86_64.xbps
-rw-r--r-- 1 jbu jbu      512  2. Jan 23:23 glibc-32bit-2.30_1.x86_64.xbps.sig
-rw-r--r-- 1 jbu jbu  1269892  2. Jan 23:21 glibc-devel-32bit-2.30_1.x86_64.xbps
-rw-r--r-- 1 jbu jbu      512  2. Jan 23:23 glibc-devel-32bit-2.30_1.x86_64.xbps.sig
```


^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (55 preceding siblings ...)
  2020-01-03 12:07 ` voidlinux-github
@ 2020-01-03 12:58 ` voidlinux-github
  2020-01-03 13:12 ` voidlinux-github
                   ` (40 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-03 12:58 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 204 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570565294

Comment:
@pullmoll try `xbps-src - Nt chroot` and then `xbps-query - dL`

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (56 preceding siblings ...)
  2020-01-03 12:58 ` voidlinux-github
@ 2020-01-03 13:12 ` voidlinux-github
  2020-01-03 13:16 ` voidlinux-github
                   ` (39 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-03 13:12 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2196 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570568297

Comment:
```
=> xbps-src: updating repositories for host (x86_64)...
[jbu@/work/build/void/glibc-1 /]$ xbps-query -dL
[DEBUG] XBPS: 0.57.1 API: 20190707 GIT: UNSET
[DEBUG] Processing configuration directory: /etc/xbps.d
[DEBUG] Parsing configuration file: /etc/xbps.d/00-repository-main.conf
[DEBUG] Parsing configuration file: /etc/xbps.d/10-repository-local.conf
[DEBUG] [repo] `/host/binpkgs' stored successfully
[DEBUG] /etc/xbps.d/10-repository-local.conf: added repository /host/binpkgs
[DEBUG] [repo] `/host/binpkgs/nonfree' stored successfully
[DEBUG] /etc/xbps.d/10-repository-local.conf: added repository /host/binpkgs/nonfree
[DEBUG] [repo] `/host/binpkgs/debug' stored successfully
[DEBUG] /etc/xbps.d/10-repository-local.conf: added repository /host/binpkgs/debug
[DEBUG] Processing system configuration directory: /usr/share/xbps.d
[DEBUG] Parsing configuration file: /usr/share/xbps.d/xbps.conf
[DEBUG] rootdir=/
[DEBUG] metadir=//var/db/xbps
[DEBUG] cachedir=/var/cache/xbps
[DEBUG] confdir=/etc/xbps.d
[DEBUG] sysconfdir=/usr/share/xbps.d
[DEBUG] syslog=true
[DEBUG] bestmatching=false
[DEBUG] Architecture: x86_64
[DEBUG] Target Architecture: (null)
[DEBUG] Repository[0]=/host/binpkgs
[DEBUG] Repository[1]=/host/binpkgs/nonfree
[DEBUG] Repository[2]=/host/binpkgs/debug
[DEBUG] [rpool] checking `/host/binpkgs' at index 0
[DEBUG] [repo] `/host/binpkgs/x86_64-stagedata' open stagedata No such file or directory
[DEBUG] [rpool] `/host/binpkgs' registered.
  530 /host/binpkgs (RSA signed)
[DEBUG] [rpool] checking `/host/binpkgs/nonfree' at index 1
[DEBUG] [repo] `/host/binpkgs/nonfree/x86_64-repodata' open repodata No such file or directory
[DEBUG] [repo] `/host/binpkgs/nonfree' removed
[DEBUG] [rpool] checking `/host/binpkgs/debug' at index 1
[DEBUG] [repo] `/host/binpkgs/debug/x86_64-stagedata' open stagedata No such file or directory
[DEBUG] [rpool] `/host/binpkgs/debug' registered.
  286 /host/binpkgs/debug (RSA signed)
[DEBUG] xbps_pkgdb_unlock: pkgdb_fd -1
[DEBUG] [pkgdb] released ok.
```

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (57 preceding siblings ...)
  2020-01-03 13:12 ` voidlinux-github
@ 2020-01-03 13:16 ` voidlinux-github
  2020-01-03 13:21 ` voidlinux-github
                   ` (38 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-03 13:16 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 746 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570569038

Comment:
`linux5.3` fails for (yet) unknown reason. It exits with
```
…
  LD [M]  drivers/gpu/drm/nouveau/nouveau.o
  AR      drivers/gpu/drm/built-in.a
  AR      drivers/gpu/built-in.a
  AR      drivers/built-in.a
=> ERROR: linux5.3-5.3.18_1: do_build: 'make ARCH=$arch ${_version} ${_cross} ${makejobs} ${_args}' exited with 2
=> ERROR:   in do_build() at srcpkgs/linux5.3/template:100
=> ERROR: xbps-src: failed to build target dependency 'linux5.3-5.3.18_1' (1)
=> ERROR: xbps-src: failed to build target dependency 'linux-5.3_1' (1)
```
Probably again something missing in hostmakedepends.


^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (58 preceding siblings ...)
  2020-01-03 13:16 ` voidlinux-github
@ 2020-01-03 13:21 ` voidlinux-github
  2020-01-03 13:24 ` voidlinux-github
                   ` (37 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-03 13:21 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2267 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570568297

Comment:
```
=> xbps-src: updating repositories for host (x86_64)...
[jbu@/work/build/void/glibc-1 /]$ xbps-query -dL
[DEBUG] XBPS: 0.57.1 API: 20190707 GIT: UNSET
[DEBUG] Processing configuration directory: /etc/xbps.d
[DEBUG] Parsing configuration file: /etc/xbps.d/00-repository-main.conf
[DEBUG] Parsing configuration file: /etc/xbps.d/10-repository-local.conf
[DEBUG] [repo] `/host/binpkgs' stored successfully
[DEBUG] /etc/xbps.d/10-repository-local.conf: added repository /host/binpkgs
[DEBUG] [repo] `/host/binpkgs/nonfree' stored successfully
[DEBUG] /etc/xbps.d/10-repository-local.conf: added repository /host/binpkgs/nonfree
[DEBUG] [repo] `/host/binpkgs/debug' stored successfully
[DEBUG] /etc/xbps.d/10-repository-local.conf: added repository /host/binpkgs/debug
[DEBUG] Processing system configuration directory: /usr/share/xbps.d
[DEBUG] Parsing configuration file: /usr/share/xbps.d/xbps.conf
[DEBUG] rootdir=/
[DEBUG] metadir=//var/db/xbps
[DEBUG] cachedir=/var/cache/xbps
[DEBUG] confdir=/etc/xbps.d
[DEBUG] sysconfdir=/usr/share/xbps.d
[DEBUG] syslog=true
[DEBUG] bestmatching=false
[DEBUG] Architecture: x86_64
[DEBUG] Target Architecture: (null)
[DEBUG] Repository[0]=/host/binpkgs
[DEBUG] Repository[1]=/host/binpkgs/nonfree
[DEBUG] Repository[2]=/host/binpkgs/debug
[DEBUG] [rpool] checking `/host/binpkgs' at index 0
[DEBUG] [repo] `/host/binpkgs/x86_64-stagedata' open stagedata No such file or directory
[DEBUG] [rpool] `/host/binpkgs' registered.
  530 /host/binpkgs (RSA signed)
[DEBUG] [rpool] checking `/host/binpkgs/nonfree' at index 1
[DEBUG] [repo] `/host/binpkgs/nonfree/x86_64-repodata' open repodata No such file or directory
[DEBUG] [repo] `/host/binpkgs/nonfree' removed
[DEBUG] [rpool] checking `/host/binpkgs/debug' at index 1
[DEBUG] [repo] `/host/binpkgs/debug/x86_64-stagedata' open stagedata No such file or directory
[DEBUG] [rpool] `/host/binpkgs/debug' registered.
  286 /host/binpkgs/debug (RSA signed)
[DEBUG] xbps_pkgdb_unlock: pkgdb_fd -1
[DEBUG] [pkgdb] released ok.
```
No `/host/binpkgs/multilib` in `/etc/xbps.d/10-repository-local.conf`

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (59 preceding siblings ...)
  2020-01-03 13:21 ` voidlinux-github
@ 2020-01-03 13:24 ` voidlinux-github
  2020-01-03 13:28 ` voidlinux-github
                   ` (36 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-03 13:24 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 775 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570569038

Comment:
`linux5.3` fails for (yet) unknown reason. It exits with
```
…
  LD [M]  drivers/gpu/drm/nouveau/nouveau.o
  AR      drivers/gpu/drm/built-in.a
  AR      drivers/gpu/built-in.a
  AR      drivers/built-in.a
=> ERROR: linux5.3-5.3.18_1: do_build: 'make ARCH=$arch ${_version} ${_cross} ${makejobs} ${_args}' exited with 2
=> ERROR:   in do_build() at srcpkgs/linux5.3/template:100
=> ERROR: xbps-src: failed to build target dependency 'linux5.3-5.3.18_1' (1)
=> ERROR: xbps-src: failed to build target dependency 'linux-5.3_1' (1)
```
Probably again something missing in hostmakedepends. Trying with `which` added...


^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (60 preceding siblings ...)
  2020-01-03 13:24 ` voidlinux-github
@ 2020-01-03 13:28 ` voidlinux-github
  2020-01-03 13:29 ` voidlinux-github
                   ` (35 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-03 13:28 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 261 bytes --]

New comment by q66 on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570571681

Comment:
Adding `texinfo` to `hostmakedepends` at this point will make builds fail because of `chroot-texinfo` conflict by the way...

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (61 preceding siblings ...)
  2020-01-03 13:28 ` voidlinux-github
@ 2020-01-03 13:29 ` voidlinux-github
  2020-01-03 13:30 ` voidlinux-github
                   ` (34 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-03 13:29 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 203 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570572022

Comment:
@q66 `chroot-texinfo` is no longer in `base-chroot/template`.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (62 preceding siblings ...)
  2020-01-03 13:29 ` voidlinux-github
@ 2020-01-03 13:30 ` voidlinux-github
  2020-01-03 13:31 ` voidlinux-github
                   ` (33 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-03 13:30 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 260 bytes --]

New comment by q66 on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570572322

Comment:
Not after this PR is merged, but it is still present in `master`, and I noticed you already added it in `glibc` for example

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (63 preceding siblings ...)
  2020-01-03 13:30 ` voidlinux-github
@ 2020-01-03 13:31 ` voidlinux-github
  2020-01-03 13:32 ` voidlinux-github
                   ` (32 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-03 13:31 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 227 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570572601

Comment:
@xtraeme suggested it would not cause trouble to add that but I guess it will. *sigh*

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (64 preceding siblings ...)
  2020-01-03 13:31 ` voidlinux-github
@ 2020-01-03 13:32 ` voidlinux-github
  2020-01-03 13:34 ` voidlinux-github
                   ` (31 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-03 13:32 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 317 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570572601

Comment:
@xtraeme suggested it would not cause trouble to add that but I guess it will. *sigh*
We would need a check for the `xbps-src` version and conditionally add `texinfo` for v2.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (65 preceding siblings ...)
  2020-01-03 13:32 ` voidlinux-github
@ 2020-01-03 13:34 ` voidlinux-github
  2020-01-03 13:35 ` voidlinux-github
                   ` (30 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-03 13:34 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 380 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570572601

Comment:
@xtraeme suggested it would not cause trouble to add that but I guess it will. *sigh*
We would need a check for the `xbps-src` version and conditionally add `texinfo` for v2.
Or we could check for an existing `/usr/bin/texinfo` perhaps.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (66 preceding siblings ...)
  2020-01-03 13:34 ` voidlinux-github
@ 2020-01-03 13:35 ` voidlinux-github
  2020-01-03 13:36 ` voidlinux-github
                   ` (29 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-03 13:35 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 410 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570572601

Comment:
@xtraeme suggested it would not cause trouble to add that but I guess it will. *sigh*
We would need a check for the `xbps-src` version and conditionally add `texinfo` for v2.
Or we could check for an existing `/usr/bin/makeinfo` or one of the other binaries perhaps.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (67 preceding siblings ...)
  2020-01-03 13:35 ` voidlinux-github
@ 2020-01-03 13:36 ` voidlinux-github
  2020-01-03 13:38 ` voidlinux-github
                   ` (28 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-03 13:36 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 432 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570572601

Comment:
@xtraeme suggested it would not cause trouble to add that but I guess it will. *sigh*
We would need a check for the `xbps-src` version and conditionally add `texinfo` for v2.
Or we could check for an existing `/usr/bin/makeinfo` or one of the other binaries from `chroot-texinfo` perhaps.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (68 preceding siblings ...)
  2020-01-03 13:36 ` voidlinux-github
@ 2020-01-03 13:38 ` voidlinux-github
  2020-01-03 15:26 ` voidlinux-github
                   ` (27 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-03 13:38 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 282 bytes --]

New comment by q66 on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570574161

Comment:
It's fine for the others which don't have a `chroot-` variant, but for `texinfo` itself it's problematic, as it has `conflicts="texinfo>=0"` set.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (69 preceding siblings ...)
  2020-01-03 13:38 ` voidlinux-github
@ 2020-01-03 15:26 ` voidlinux-github
  2020-01-04  8:02 ` [PR PATCH] [Updated] " voidlinux-github
                   ` (26 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-03 15:26 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 986 bytes --]

New comment by pullmoll on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570603937

Comment:
@xtraeme  This fixes the multilib issue:
```
index b463278c29..b89877777a 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -226,7 +226,15 @@ chroot_sync_repodata() {
     sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
         > $confdir/10-repository-local.conf
 
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+    if [ "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            ;;
+        esac
+    else
         case "$XBPS_MACHINE" in
             *-musl)
                 install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
```


^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (70 preceding siblings ...)
  2020-01-03 15:26 ` voidlinux-github
@ 2020-01-04  8:02 ` voidlinux-github
  2020-01-04  8:31 ` voidlinux-github
                   ` (25 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-04  8:02 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1946 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- update `base-chroot` deps before building any pkg.
- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Gets rid of `-I` to skip file conflicts while installing deps via `xbps-install(1)`.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 69336 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/21] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/21] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/21] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/21] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/21] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/21] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/21] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/21] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/21] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/21] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/21] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/21] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/21] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/21] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 88c135d6642a9e84d4042174889b487912aa1548 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:55:35 +0100
Subject: [PATCH 15/21] travis/build.sh: local repo path v2

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 7e679ecc843..09705565427 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 1dedb200d46899cddf3a94ba5d618c592e69fb85 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:58:19 +0100
Subject: [PATCH 16/21] travis/build.sh: also use xbps.d repos, to resolve
 missing deps.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 09705565427..c7049c260c6 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From b261543632c599c2c92a27d7a02ce04e382a5550 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:01:18 +0100
Subject: [PATCH 17/21] travis/build.sh: perform sysup before installing
 base-chroot.

---
 common/travis/build.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c7049c260c6..916c25515d7 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,6 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1

From b0140b84b7846c1ecb820da819fc50aefdb5383e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:06:53 +0100
Subject: [PATCH 18/21] tar: fix for ethereal chroot-style

---
 srcpkgs/tar/template | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 0a49caa7e91..2ec183c02f1 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -13,6 +13,8 @@ distfiles="${GNU_SITE}/tar/${pkgname}-${version}.tar.xz"
 checksum=d0d3ae07f103323be809bc3eac0dcc386d52c5262499fe05511ac4788af1fdd8
 
 pre_configure() {
+	# chroot-style=ethereal
+	export FORCE_UNSAFE_CONFIGURE=1
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }

From d34dc4783cabd6562e1a64cc09518d31b3c43119 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:12:04 +0100
Subject: [PATCH 19/21] base-chroot: fix license?

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 1f73f00d56d..d4614bf3f27 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -6,7 +6,7 @@ bootstrap=yes
 build_style=meta
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
-license="Public domain"
+license="Public Domain"
 homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in

From 0941fa44d521639ab1528879a7f514f1286f7fba Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 08:59:10 +0100
Subject: [PATCH 20/21] xbps-src: fix for x86_64 local multilib repos.

Found and fixed by @pullmoll
---
 common/xbps-src/shutils/chroot.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index b463278c29e..744b99a8a0c 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -226,7 +226,15 @@ chroot_sync_repodata() {
     sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
         > $confdir/10-repository-local.conf
 
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+    if [ "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            ;;
+        esac
+    else
         case "$XBPS_MACHINE" in
             *-musl)
                 install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \

From 0ec18a9d60504a890c44723ea6159e0918d1a34e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 09:01:29 +0100
Subject: [PATCH 21/21] travis/build.sh: use -E (and get rid of -f) while
 building base-chroot.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 916c25515d7..c6a71afb6be 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (71 preceding siblings ...)
  2020-01-04  8:02 ` [PR PATCH] [Updated] " voidlinux-github
@ 2020-01-04  8:31 ` voidlinux-github
  2020-01-04 10:19 ` [PR PATCH] [Updated] " voidlinux-github
                   ` (24 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-04  8:31 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 210 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570767352

Comment:
has anybody found any other issue? otherwise it's ready to be merged.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (72 preceding siblings ...)
  2020-01-04  8:31 ` voidlinux-github
@ 2020-01-04 10:19 ` voidlinux-github
  2020-01-04 10:46 ` voidlinux-github
                   ` (23 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-04 10:19 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1946 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- update `base-chroot` deps before building any pkg.
- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Gets rid of `-I` to skip file conflicts while installing deps via `xbps-install(1)`.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 70280 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/22] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/22] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/22] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/22] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/22] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/22] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/22] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/22] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/22] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/22] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/22] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/22] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/22] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/22] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 88c135d6642a9e84d4042174889b487912aa1548 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:55:35 +0100
Subject: [PATCH 15/22] travis/build.sh: local repo path v2

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 7e679ecc843..09705565427 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 1dedb200d46899cddf3a94ba5d618c592e69fb85 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:58:19 +0100
Subject: [PATCH 16/22] travis/build.sh: also use xbps.d repos, to resolve
 missing deps.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 09705565427..c7049c260c6 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From b261543632c599c2c92a27d7a02ce04e382a5550 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:01:18 +0100
Subject: [PATCH 17/22] travis/build.sh: perform sysup before installing
 base-chroot.

---
 common/travis/build.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c7049c260c6..916c25515d7 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,6 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1

From b0140b84b7846c1ecb820da819fc50aefdb5383e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:06:53 +0100
Subject: [PATCH 18/22] tar: fix for ethereal chroot-style

---
 srcpkgs/tar/template | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 0a49caa7e91..2ec183c02f1 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -13,6 +13,8 @@ distfiles="${GNU_SITE}/tar/${pkgname}-${version}.tar.xz"
 checksum=d0d3ae07f103323be809bc3eac0dcc386d52c5262499fe05511ac4788af1fdd8
 
 pre_configure() {
+	# chroot-style=ethereal
+	export FORCE_UNSAFE_CONFIGURE=1
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }

From d34dc4783cabd6562e1a64cc09518d31b3c43119 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:12:04 +0100
Subject: [PATCH 19/22] base-chroot: fix license?

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 1f73f00d56d..d4614bf3f27 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -6,7 +6,7 @@ bootstrap=yes
 build_style=meta
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
-license="Public domain"
+license="Public Domain"
 homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in

From 0941fa44d521639ab1528879a7f514f1286f7fba Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 08:59:10 +0100
Subject: [PATCH 20/22] xbps-src: fix for x86_64 local multilib repos.

Found and fixed by @pullmoll
---
 common/xbps-src/shutils/chroot.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index b463278c29e..744b99a8a0c 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -226,7 +226,15 @@ chroot_sync_repodata() {
     sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
         > $confdir/10-repository-local.conf
 
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+    if [ "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            ;;
+        esac
+    else
         case "$XBPS_MACHINE" in
             *-musl)
                 install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \

From 0ec18a9d60504a890c44723ea6159e0918d1a34e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 09:01:29 +0100
Subject: [PATCH 21/22] travis/build.sh: use -E (and get rid of -f) while
 building base-chroot.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 916c25515d7..c6a71afb6be 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps

From d0decae241fd8ba9d608c80bec18378318e7666f Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:19:05 +0100
Subject: [PATCH 22/22] xbps-src: updated list of required host utils.

---
 xbps-src | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xbps-src b/xbps-src
index 50f2032deeb..1ba52432707 100755
--- a/xbps-src
+++ b/xbps-src
@@ -382,9 +382,9 @@ umask 022
 #
 # Required utilities in host system for the bootstrap target.
 readonly REQHOST_UTILS_BOOTSTRAP="make gawk bash bison sed gcc g++ msgfmt makeinfo \
-    perl tar xz gzip bzip2 patch flex automake libtool pkg-config"
+    perl bsdtar xz gzip bzip2 patch flock flex libtool pkg-config"
 
-# Required utilities in host system for chroot ops.
+# Required utilities in host.
 readonly REQHOST_UTILS="xbps-install xbps-query xbps-rindex xbps-uhelper \
     xbps-reconfigure xbps-remove xbps-create xbps-uchroot xbps-uunshare"
 

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (73 preceding siblings ...)
  2020-01-04 10:19 ` [PR PATCH] [Updated] " voidlinux-github
@ 2020-01-04 10:46 ` voidlinux-github
  2020-01-04 10:54 ` voidlinux-github
                   ` (22 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-04 10:46 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1946 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- update `base-chroot` deps before building any pkg.
- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Gets rid of `-I` to skip file conflicts while installing deps via `xbps-install(1)`.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 71333 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/23] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/23] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/23] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/23] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/23] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/23] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/23] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/23] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/23] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/23] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/23] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/23] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/23] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/23] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 88c135d6642a9e84d4042174889b487912aa1548 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:55:35 +0100
Subject: [PATCH 15/23] travis/build.sh: local repo path v2

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 7e679ecc843..09705565427 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 1dedb200d46899cddf3a94ba5d618c592e69fb85 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:58:19 +0100
Subject: [PATCH 16/23] travis/build.sh: also use xbps.d repos, to resolve
 missing deps.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 09705565427..c7049c260c6 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From b261543632c599c2c92a27d7a02ce04e382a5550 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:01:18 +0100
Subject: [PATCH 17/23] travis/build.sh: perform sysup before installing
 base-chroot.

---
 common/travis/build.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c7049c260c6..916c25515d7 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,6 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1

From b0140b84b7846c1ecb820da819fc50aefdb5383e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:06:53 +0100
Subject: [PATCH 18/23] tar: fix for ethereal chroot-style

---
 srcpkgs/tar/template | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 0a49caa7e91..2ec183c02f1 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -13,6 +13,8 @@ distfiles="${GNU_SITE}/tar/${pkgname}-${version}.tar.xz"
 checksum=d0d3ae07f103323be809bc3eac0dcc386d52c5262499fe05511ac4788af1fdd8
 
 pre_configure() {
+	# chroot-style=ethereal
+	export FORCE_UNSAFE_CONFIGURE=1
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }

From d34dc4783cabd6562e1a64cc09518d31b3c43119 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:12:04 +0100
Subject: [PATCH 19/23] base-chroot: fix license?

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 1f73f00d56d..d4614bf3f27 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -6,7 +6,7 @@ bootstrap=yes
 build_style=meta
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
-license="Public domain"
+license="Public Domain"
 homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in

From 0941fa44d521639ab1528879a7f514f1286f7fba Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 08:59:10 +0100
Subject: [PATCH 20/23] xbps-src: fix for x86_64 local multilib repos.

Found and fixed by @pullmoll
---
 common/xbps-src/shutils/chroot.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index b463278c29e..744b99a8a0c 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -226,7 +226,15 @@ chroot_sync_repodata() {
     sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
         > $confdir/10-repository-local.conf
 
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+    if [ "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            ;;
+        esac
+    else
         case "$XBPS_MACHINE" in
             *-musl)
                 install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \

From 0ec18a9d60504a890c44723ea6159e0918d1a34e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 09:01:29 +0100
Subject: [PATCH 21/23] travis/build.sh: use -E (and get rid of -f) while
 building base-chroot.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 916c25515d7..c6a71afb6be 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps

From d0decae241fd8ba9d608c80bec18378318e7666f Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:19:05 +0100
Subject: [PATCH 22/23] xbps-src: updated list of required host utils.

---
 xbps-src | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xbps-src b/xbps-src
index 50f2032deeb..1ba52432707 100755
--- a/xbps-src
+++ b/xbps-src
@@ -382,9 +382,9 @@ umask 022
 #
 # Required utilities in host system for the bootstrap target.
 readonly REQHOST_UTILS_BOOTSTRAP="make gawk bash bison sed gcc g++ msgfmt makeinfo \
-    perl tar xz gzip bzip2 patch flex automake libtool pkg-config"
+    perl bsdtar xz gzip bzip2 patch flock flex libtool pkg-config"
 
-# Required utilities in host system for chroot ops.
+# Required utilities in host.
 readonly REQHOST_UTILS="xbps-install xbps-query xbps-rindex xbps-uhelper \
     xbps-reconfigure xbps-remove xbps-create xbps-uchroot xbps-uunshare"
 

From a3ca971472bc715910be7713d5a4c40df46ece33 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:46:05 +0100
Subject: [PATCH 23/23] travis/build.sh: update xbps/sys before building
 base-chroot.

---
 common/travis/build.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c6a71afb6be..84f86a7ee86 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,10 +6,13 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Make sure `base-chroot` is really up-to-date
+# Update `xbps` and then `base-chroot`
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
+# Build up-to-date `base-chroot`
 /hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
+# Perform system update
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (74 preceding siblings ...)
  2020-01-04 10:46 ` voidlinux-github
@ 2020-01-04 10:54 ` voidlinux-github
  2020-01-04 11:12 ` voidlinux-github
                   ` (21 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-04 10:54 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1946 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- update `base-chroot` deps before building any pkg.
- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Gets rid of `-I` to skip file conflicts while installing deps via `xbps-install(1)`.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 72495 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/24] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/24] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/24] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/24] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/24] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/24] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/24] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/24] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/24] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/24] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/24] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/24] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/24] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/24] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 88c135d6642a9e84d4042174889b487912aa1548 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:55:35 +0100
Subject: [PATCH 15/24] travis/build.sh: local repo path v2

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 7e679ecc843..09705565427 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 1dedb200d46899cddf3a94ba5d618c592e69fb85 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:58:19 +0100
Subject: [PATCH 16/24] travis/build.sh: also use xbps.d repos, to resolve
 missing deps.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 09705565427..c7049c260c6 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From b261543632c599c2c92a27d7a02ce04e382a5550 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:01:18 +0100
Subject: [PATCH 17/24] travis/build.sh: perform sysup before installing
 base-chroot.

---
 common/travis/build.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c7049c260c6..916c25515d7 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,6 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1

From b0140b84b7846c1ecb820da819fc50aefdb5383e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:06:53 +0100
Subject: [PATCH 18/24] tar: fix for ethereal chroot-style

---
 srcpkgs/tar/template | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 0a49caa7e91..2ec183c02f1 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -13,6 +13,8 @@ distfiles="${GNU_SITE}/tar/${pkgname}-${version}.tar.xz"
 checksum=d0d3ae07f103323be809bc3eac0dcc386d52c5262499fe05511ac4788af1fdd8
 
 pre_configure() {
+	# chroot-style=ethereal
+	export FORCE_UNSAFE_CONFIGURE=1
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }

From d34dc4783cabd6562e1a64cc09518d31b3c43119 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:12:04 +0100
Subject: [PATCH 19/24] base-chroot: fix license?

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 1f73f00d56d..d4614bf3f27 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -6,7 +6,7 @@ bootstrap=yes
 build_style=meta
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
-license="Public domain"
+license="Public Domain"
 homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in

From 0941fa44d521639ab1528879a7f514f1286f7fba Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 08:59:10 +0100
Subject: [PATCH 20/24] xbps-src: fix for x86_64 local multilib repos.

Found and fixed by @pullmoll
---
 common/xbps-src/shutils/chroot.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index b463278c29e..744b99a8a0c 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -226,7 +226,15 @@ chroot_sync_repodata() {
     sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
         > $confdir/10-repository-local.conf
 
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+    if [ "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            ;;
+        esac
+    else
         case "$XBPS_MACHINE" in
             *-musl)
                 install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \

From 0ec18a9d60504a890c44723ea6159e0918d1a34e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 09:01:29 +0100
Subject: [PATCH 21/24] travis/build.sh: use -E (and get rid of -f) while
 building base-chroot.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 916c25515d7..c6a71afb6be 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps

From d0decae241fd8ba9d608c80bec18378318e7666f Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:19:05 +0100
Subject: [PATCH 22/24] xbps-src: updated list of required host utils.

---
 xbps-src | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xbps-src b/xbps-src
index 50f2032deeb..1ba52432707 100755
--- a/xbps-src
+++ b/xbps-src
@@ -382,9 +382,9 @@ umask 022
 #
 # Required utilities in host system for the bootstrap target.
 readonly REQHOST_UTILS_BOOTSTRAP="make gawk bash bison sed gcc g++ msgfmt makeinfo \
-    perl tar xz gzip bzip2 patch flex automake libtool pkg-config"
+    perl bsdtar xz gzip bzip2 patch flock flex libtool pkg-config"
 
-# Required utilities in host system for chroot ops.
+# Required utilities in host.
 readonly REQHOST_UTILS="xbps-install xbps-query xbps-rindex xbps-uhelper \
     xbps-reconfigure xbps-remove xbps-create xbps-uchroot xbps-uunshare"
 

From a3ca971472bc715910be7713d5a4c40df46ece33 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:46:05 +0100
Subject: [PATCH 23/24] travis/build.sh: update xbps/sys before building
 base-chroot.

---
 common/travis/build.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c6a71afb6be..84f86a7ee86 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,10 +6,13 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Make sure `base-chroot` is really up-to-date
+# Update `xbps` and then `base-chroot`
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
+# Build up-to-date `base-chroot`
 /hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
+# Perform system update
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From c7268cc1f7082f684c5dfe18aea277e899d2a1ea Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:53:50 +0100
Subject: [PATCH 24/24] xbps-src/shutils/chroot.sh: silence grep output

---
 common/xbps-src/shutils/chroot.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 744b99a8a0c..d3951a395ad 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -51,7 +51,7 @@ update_base_chroot() {
     [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
     msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
     # no need to sync repodata, chroot_sync_repodata() does it for us.
-    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep -q xbps); then
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (75 preceding siblings ...)
  2020-01-04 10:54 ` voidlinux-github
@ 2020-01-04 11:12 ` voidlinux-github
  2020-01-04 11:16 ` voidlinux-github
                   ` (20 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-04 11:12 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1946 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- update `base-chroot` deps before building any pkg.
- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Gets rid of `-I` to skip file conflicts while installing deps via `xbps-install(1)`.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 74258 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/25] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/25] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/25] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/25] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/25] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/25] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/25] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/25] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/25] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/25] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/25] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/25] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/25] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/25] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 88c135d6642a9e84d4042174889b487912aa1548 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:55:35 +0100
Subject: [PATCH 15/25] travis/build.sh: local repo path v2

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 7e679ecc843..09705565427 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 1dedb200d46899cddf3a94ba5d618c592e69fb85 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:58:19 +0100
Subject: [PATCH 16/25] travis/build.sh: also use xbps.d repos, to resolve
 missing deps.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 09705565427..c7049c260c6 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From b261543632c599c2c92a27d7a02ce04e382a5550 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:01:18 +0100
Subject: [PATCH 17/25] travis/build.sh: perform sysup before installing
 base-chroot.

---
 common/travis/build.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c7049c260c6..916c25515d7 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,6 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1

From b0140b84b7846c1ecb820da819fc50aefdb5383e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:06:53 +0100
Subject: [PATCH 18/25] tar: fix for ethereal chroot-style

---
 srcpkgs/tar/template | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 0a49caa7e91..2ec183c02f1 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -13,6 +13,8 @@ distfiles="${GNU_SITE}/tar/${pkgname}-${version}.tar.xz"
 checksum=d0d3ae07f103323be809bc3eac0dcc386d52c5262499fe05511ac4788af1fdd8
 
 pre_configure() {
+	# chroot-style=ethereal
+	export FORCE_UNSAFE_CONFIGURE=1
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }

From d34dc4783cabd6562e1a64cc09518d31b3c43119 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:12:04 +0100
Subject: [PATCH 19/25] base-chroot: fix license?

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 1f73f00d56d..d4614bf3f27 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -6,7 +6,7 @@ bootstrap=yes
 build_style=meta
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
-license="Public domain"
+license="Public Domain"
 homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in

From 0941fa44d521639ab1528879a7f514f1286f7fba Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 08:59:10 +0100
Subject: [PATCH 20/25] xbps-src: fix for x86_64 local multilib repos.

Found and fixed by @pullmoll
---
 common/xbps-src/shutils/chroot.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index b463278c29e..744b99a8a0c 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -226,7 +226,15 @@ chroot_sync_repodata() {
     sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
         > $confdir/10-repository-local.conf
 
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+    if [ "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            ;;
+        esac
+    else
         case "$XBPS_MACHINE" in
             *-musl)
                 install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \

From 0ec18a9d60504a890c44723ea6159e0918d1a34e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 09:01:29 +0100
Subject: [PATCH 21/25] travis/build.sh: use -E (and get rid of -f) while
 building base-chroot.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 916c25515d7..c6a71afb6be 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps

From d0decae241fd8ba9d608c80bec18378318e7666f Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:19:05 +0100
Subject: [PATCH 22/25] xbps-src: updated list of required host utils.

---
 xbps-src | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xbps-src b/xbps-src
index 50f2032deeb..1ba52432707 100755
--- a/xbps-src
+++ b/xbps-src
@@ -382,9 +382,9 @@ umask 022
 #
 # Required utilities in host system for the bootstrap target.
 readonly REQHOST_UTILS_BOOTSTRAP="make gawk bash bison sed gcc g++ msgfmt makeinfo \
-    perl tar xz gzip bzip2 patch flex automake libtool pkg-config"
+    perl bsdtar xz gzip bzip2 patch flock flex libtool pkg-config"
 
-# Required utilities in host system for chroot ops.
+# Required utilities in host.
 readonly REQHOST_UTILS="xbps-install xbps-query xbps-rindex xbps-uhelper \
     xbps-reconfigure xbps-remove xbps-create xbps-uchroot xbps-uunshare"
 

From a3ca971472bc715910be7713d5a4c40df46ece33 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:46:05 +0100
Subject: [PATCH 23/25] travis/build.sh: update xbps/sys before building
 base-chroot.

---
 common/travis/build.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c6a71afb6be..84f86a7ee86 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,10 +6,13 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Make sure `base-chroot` is really up-to-date
+# Update `xbps` and then `base-chroot`
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
+# Build up-to-date `base-chroot`
 /hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
+# Perform system update
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From c7268cc1f7082f684c5dfe18aea277e899d2a1ea Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:53:50 +0100
Subject: [PATCH 24/25] xbps-src/shutils/chroot.sh: silence grep output

---
 common/xbps-src/shutils/chroot.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 744b99a8a0c..d3951a395ad 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -51,7 +51,7 @@ update_base_chroot() {
     [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
     msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
     # no need to sync repodata, chroot_sync_repodata() does it for us.
-    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep -q xbps); then
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"

From 378db8b077b8956032bb7185f3e89a315ceb2250 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 12:12:07 +0100
Subject: [PATCH 25/25] travis: move xbps/base-chroot stuff to prepare.sh.

---
 common/travis/build.sh   | 10 ----------
 common/travis/prepare.sh | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 84f86a7ee86..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,16 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Update `xbps` and then `base-chroot`
-xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-# Build up-to-date `base-chroot`
-/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
-# Perform system update
-xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-# remove autodeps
-xbps-remove -yo || exit 1
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..9aa475265e4 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,13 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Update `xbps` and then `base-chroot`
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu xbps || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu || exit 1
+# Build up-to-date `base-chroot`
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
+# Perform system update
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (76 preceding siblings ...)
  2020-01-04 11:12 ` voidlinux-github
@ 2020-01-04 11:16 ` voidlinux-github
  2020-01-04 11:19 ` voidlinux-github
                   ` (19 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-04 11:16 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1946 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- update `base-chroot` deps before building any pkg.
- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Gets rid of `-I` to skip file conflicts while installing deps via `xbps-install(1)`.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 75313 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/26] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/26] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/26] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/26] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/26] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/26] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/26] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/26] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/26] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/26] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/26] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/26] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/26] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/26] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 88c135d6642a9e84d4042174889b487912aa1548 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:55:35 +0100
Subject: [PATCH 15/26] travis/build.sh: local repo path v2

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 7e679ecc843..09705565427 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 1dedb200d46899cddf3a94ba5d618c592e69fb85 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:58:19 +0100
Subject: [PATCH 16/26] travis/build.sh: also use xbps.d repos, to resolve
 missing deps.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 09705565427..c7049c260c6 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From b261543632c599c2c92a27d7a02ce04e382a5550 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:01:18 +0100
Subject: [PATCH 17/26] travis/build.sh: perform sysup before installing
 base-chroot.

---
 common/travis/build.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c7049c260c6..916c25515d7 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,6 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1

From b0140b84b7846c1ecb820da819fc50aefdb5383e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:06:53 +0100
Subject: [PATCH 18/26] tar: fix for ethereal chroot-style

---
 srcpkgs/tar/template | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 0a49caa7e91..2ec183c02f1 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -13,6 +13,8 @@ distfiles="${GNU_SITE}/tar/${pkgname}-${version}.tar.xz"
 checksum=d0d3ae07f103323be809bc3eac0dcc386d52c5262499fe05511ac4788af1fdd8
 
 pre_configure() {
+	# chroot-style=ethereal
+	export FORCE_UNSAFE_CONFIGURE=1
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }

From d34dc4783cabd6562e1a64cc09518d31b3c43119 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:12:04 +0100
Subject: [PATCH 19/26] base-chroot: fix license?

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 1f73f00d56d..d4614bf3f27 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -6,7 +6,7 @@ bootstrap=yes
 build_style=meta
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
-license="Public domain"
+license="Public Domain"
 homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in

From 0941fa44d521639ab1528879a7f514f1286f7fba Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 08:59:10 +0100
Subject: [PATCH 20/26] xbps-src: fix for x86_64 local multilib repos.

Found and fixed by @pullmoll
---
 common/xbps-src/shutils/chroot.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index b463278c29e..744b99a8a0c 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -226,7 +226,15 @@ chroot_sync_repodata() {
     sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
         > $confdir/10-repository-local.conf
 
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+    if [ "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            ;;
+        esac
+    else
         case "$XBPS_MACHINE" in
             *-musl)
                 install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \

From 0ec18a9d60504a890c44723ea6159e0918d1a34e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 09:01:29 +0100
Subject: [PATCH 21/26] travis/build.sh: use -E (and get rid of -f) while
 building base-chroot.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 916c25515d7..c6a71afb6be 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps

From d0decae241fd8ba9d608c80bec18378318e7666f Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:19:05 +0100
Subject: [PATCH 22/26] xbps-src: updated list of required host utils.

---
 xbps-src | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xbps-src b/xbps-src
index 50f2032deeb..1ba52432707 100755
--- a/xbps-src
+++ b/xbps-src
@@ -382,9 +382,9 @@ umask 022
 #
 # Required utilities in host system for the bootstrap target.
 readonly REQHOST_UTILS_BOOTSTRAP="make gawk bash bison sed gcc g++ msgfmt makeinfo \
-    perl tar xz gzip bzip2 patch flex automake libtool pkg-config"
+    perl bsdtar xz gzip bzip2 patch flock flex libtool pkg-config"
 
-# Required utilities in host system for chroot ops.
+# Required utilities in host.
 readonly REQHOST_UTILS="xbps-install xbps-query xbps-rindex xbps-uhelper \
     xbps-reconfigure xbps-remove xbps-create xbps-uchroot xbps-uunshare"
 

From a3ca971472bc715910be7713d5a4c40df46ece33 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:46:05 +0100
Subject: [PATCH 23/26] travis/build.sh: update xbps/sys before building
 base-chroot.

---
 common/travis/build.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c6a71afb6be..84f86a7ee86 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,10 +6,13 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Make sure `base-chroot` is really up-to-date
+# Update `xbps` and then `base-chroot`
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
+# Build up-to-date `base-chroot`
 /hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
+# Perform system update
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From c7268cc1f7082f684c5dfe18aea277e899d2a1ea Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:53:50 +0100
Subject: [PATCH 24/26] xbps-src/shutils/chroot.sh: silence grep output

---
 common/xbps-src/shutils/chroot.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 744b99a8a0c..d3951a395ad 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -51,7 +51,7 @@ update_base_chroot() {
     [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
     msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
     # no need to sync repodata, chroot_sync_repodata() does it for us.
-    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep -q xbps); then
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"

From 378db8b077b8956032bb7185f3e89a315ceb2250 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 12:12:07 +0100
Subject: [PATCH 25/26] travis: move xbps/base-chroot stuff to prepare.sh.

---
 common/travis/build.sh   | 10 ----------
 common/travis/prepare.sh | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 84f86a7ee86..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,16 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Update `xbps` and then `base-chroot`
-xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-# Build up-to-date `base-chroot`
-/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
-# Perform system update
-xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-# remove autodeps
-xbps-remove -yo || exit 1
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..9aa475265e4 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,13 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Update `xbps` and then `base-chroot`
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu xbps || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu || exit 1
+# Build up-to-date `base-chroot`
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
+# Perform system update
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1

From bd1ef1fc64eec81608817f5bde80884eec50b66b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 12:15:49 +0100
Subject: [PATCH 26/26] travis/prepare.sh: set PATH

---
 common/travis/prepare.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 9aa475265e4..0d2375afb62 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -4,14 +4,16 @@
 
 [ "$XLINT" ] && exit 0
 
-/bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
+export PATH=/bin
+
+echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
-/bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'
+echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'
 echo XBPS_CHROOT_CMD=ethereal >> etc/conf
 echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
-/bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
+echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
 
 # Update `xbps` and then `base-chroot`

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (77 preceding siblings ...)
  2020-01-04 11:16 ` voidlinux-github
@ 2020-01-04 11:19 ` voidlinux-github
  2020-01-04 11:20 ` voidlinux-github
                   ` (18 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-04 11:19 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1946 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- update `base-chroot` deps before building any pkg.
- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Gets rid of `-I` to skip file conflicts while installing deps via `xbps-install(1)`.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 76178 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/27] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/27] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/27] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/27] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/27] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/27] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/27] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/27] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/27] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/27] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/27] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/27] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/27] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/27] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 88c135d6642a9e84d4042174889b487912aa1548 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:55:35 +0100
Subject: [PATCH 15/27] travis/build.sh: local repo path v2

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 7e679ecc843..09705565427 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 1dedb200d46899cddf3a94ba5d618c592e69fb85 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:58:19 +0100
Subject: [PATCH 16/27] travis/build.sh: also use xbps.d repos, to resolve
 missing deps.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 09705565427..c7049c260c6 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From b261543632c599c2c92a27d7a02ce04e382a5550 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:01:18 +0100
Subject: [PATCH 17/27] travis/build.sh: perform sysup before installing
 base-chroot.

---
 common/travis/build.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c7049c260c6..916c25515d7 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,6 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1

From b0140b84b7846c1ecb820da819fc50aefdb5383e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:06:53 +0100
Subject: [PATCH 18/27] tar: fix for ethereal chroot-style

---
 srcpkgs/tar/template | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 0a49caa7e91..2ec183c02f1 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -13,6 +13,8 @@ distfiles="${GNU_SITE}/tar/${pkgname}-${version}.tar.xz"
 checksum=d0d3ae07f103323be809bc3eac0dcc386d52c5262499fe05511ac4788af1fdd8
 
 pre_configure() {
+	# chroot-style=ethereal
+	export FORCE_UNSAFE_CONFIGURE=1
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }

From d34dc4783cabd6562e1a64cc09518d31b3c43119 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:12:04 +0100
Subject: [PATCH 19/27] base-chroot: fix license?

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 1f73f00d56d..d4614bf3f27 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -6,7 +6,7 @@ bootstrap=yes
 build_style=meta
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
-license="Public domain"
+license="Public Domain"
 homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in

From 0941fa44d521639ab1528879a7f514f1286f7fba Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 08:59:10 +0100
Subject: [PATCH 20/27] xbps-src: fix for x86_64 local multilib repos.

Found and fixed by @pullmoll
---
 common/xbps-src/shutils/chroot.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index b463278c29e..744b99a8a0c 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -226,7 +226,15 @@ chroot_sync_repodata() {
     sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
         > $confdir/10-repository-local.conf
 
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+    if [ "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            ;;
+        esac
+    else
         case "$XBPS_MACHINE" in
             *-musl)
                 install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \

From 0ec18a9d60504a890c44723ea6159e0918d1a34e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 09:01:29 +0100
Subject: [PATCH 21/27] travis/build.sh: use -E (and get rid of -f) while
 building base-chroot.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 916c25515d7..c6a71afb6be 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps

From d0decae241fd8ba9d608c80bec18378318e7666f Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:19:05 +0100
Subject: [PATCH 22/27] xbps-src: updated list of required host utils.

---
 xbps-src | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xbps-src b/xbps-src
index 50f2032deeb..1ba52432707 100755
--- a/xbps-src
+++ b/xbps-src
@@ -382,9 +382,9 @@ umask 022
 #
 # Required utilities in host system for the bootstrap target.
 readonly REQHOST_UTILS_BOOTSTRAP="make gawk bash bison sed gcc g++ msgfmt makeinfo \
-    perl tar xz gzip bzip2 patch flex automake libtool pkg-config"
+    perl bsdtar xz gzip bzip2 patch flock flex libtool pkg-config"
 
-# Required utilities in host system for chroot ops.
+# Required utilities in host.
 readonly REQHOST_UTILS="xbps-install xbps-query xbps-rindex xbps-uhelper \
     xbps-reconfigure xbps-remove xbps-create xbps-uchroot xbps-uunshare"
 

From a3ca971472bc715910be7713d5a4c40df46ece33 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:46:05 +0100
Subject: [PATCH 23/27] travis/build.sh: update xbps/sys before building
 base-chroot.

---
 common/travis/build.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c6a71afb6be..84f86a7ee86 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,10 +6,13 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Make sure `base-chroot` is really up-to-date
+# Update `xbps` and then `base-chroot`
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
+# Build up-to-date `base-chroot`
 /hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
+# Perform system update
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From c7268cc1f7082f684c5dfe18aea277e899d2a1ea Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:53:50 +0100
Subject: [PATCH 24/27] xbps-src/shutils/chroot.sh: silence grep output

---
 common/xbps-src/shutils/chroot.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 744b99a8a0c..d3951a395ad 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -51,7 +51,7 @@ update_base_chroot() {
     [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
     msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
     # no need to sync repodata, chroot_sync_repodata() does it for us.
-    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep -q xbps); then
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"

From 378db8b077b8956032bb7185f3e89a315ceb2250 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 12:12:07 +0100
Subject: [PATCH 25/27] travis: move xbps/base-chroot stuff to prepare.sh.

---
 common/travis/build.sh   | 10 ----------
 common/travis/prepare.sh | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 84f86a7ee86..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,16 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Update `xbps` and then `base-chroot`
-xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-# Build up-to-date `base-chroot`
-/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
-# Perform system update
-xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-# remove autodeps
-xbps-remove -yo || exit 1
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..9aa475265e4 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,13 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Update `xbps` and then `base-chroot`
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu xbps || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu || exit 1
+# Build up-to-date `base-chroot`
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
+# Perform system update
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1

From bd1ef1fc64eec81608817f5bde80884eec50b66b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 12:15:49 +0100
Subject: [PATCH 26/27] travis/prepare.sh: set PATH

---
 common/travis/prepare.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 9aa475265e4..0d2375afb62 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -4,14 +4,16 @@
 
 [ "$XLINT" ] && exit 0
 
-/bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
+export PATH=/bin
+
+echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
-/bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'
+echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'
 echo XBPS_CHROOT_CMD=ethereal >> etc/conf
 echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
-/bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
+echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
 
 # Update `xbps` and then `base-chroot`

From 2c48d158370850bfe02acf8c9c4a8575331a46b1 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 12:18:52 +0100
Subject: [PATCH 27/27] travis/prepare.sh: restore /bin/echo -e

---
 common/travis/prepare.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 0d2375afb62..585853d6eb8 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -6,10 +6,10 @@
 
 export PATH=/bin
 
-echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
+/bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
-echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'
+/bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'
 echo XBPS_CHROOT_CMD=ethereal >> etc/conf
 echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (78 preceding siblings ...)
  2020-01-04 11:19 ` voidlinux-github
@ 2020-01-04 11:20 ` voidlinux-github
  2020-01-04 11:25 ` [PR PATCH] [Updated] " voidlinux-github
                   ` (17 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-04 11:20 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 198 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570777146

Comment:
Fixing the xbps update process... not yet ready to merge.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (79 preceding siblings ...)
  2020-01-04 11:20 ` voidlinux-github
@ 2020-01-04 11:25 ` voidlinux-github
  2020-01-04 11:32 ` voidlinux-github
                   ` (16 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-04 11:25 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1946 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- update `base-chroot` deps before building any pkg.
- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Gets rid of `-I` to skip file conflicts while installing deps via `xbps-install(1)`.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 76825 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/28] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/28] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/28] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/28] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/28] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/28] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/28] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/28] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/28] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/28] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/28] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/28] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/28] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/28] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 88c135d6642a9e84d4042174889b487912aa1548 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:55:35 +0100
Subject: [PATCH 15/28] travis/build.sh: local repo path v2

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 7e679ecc843..09705565427 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 1dedb200d46899cddf3a94ba5d618c592e69fb85 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:58:19 +0100
Subject: [PATCH 16/28] travis/build.sh: also use xbps.d repos, to resolve
 missing deps.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 09705565427..c7049c260c6 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From b261543632c599c2c92a27d7a02ce04e382a5550 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:01:18 +0100
Subject: [PATCH 17/28] travis/build.sh: perform sysup before installing
 base-chroot.

---
 common/travis/build.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c7049c260c6..916c25515d7 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,6 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1

From b0140b84b7846c1ecb820da819fc50aefdb5383e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:06:53 +0100
Subject: [PATCH 18/28] tar: fix for ethereal chroot-style

---
 srcpkgs/tar/template | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 0a49caa7e91..2ec183c02f1 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -13,6 +13,8 @@ distfiles="${GNU_SITE}/tar/${pkgname}-${version}.tar.xz"
 checksum=d0d3ae07f103323be809bc3eac0dcc386d52c5262499fe05511ac4788af1fdd8
 
 pre_configure() {
+	# chroot-style=ethereal
+	export FORCE_UNSAFE_CONFIGURE=1
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }

From d34dc4783cabd6562e1a64cc09518d31b3c43119 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:12:04 +0100
Subject: [PATCH 19/28] base-chroot: fix license?

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 1f73f00d56d..d4614bf3f27 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -6,7 +6,7 @@ bootstrap=yes
 build_style=meta
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
-license="Public domain"
+license="Public Domain"
 homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in

From 0941fa44d521639ab1528879a7f514f1286f7fba Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 08:59:10 +0100
Subject: [PATCH 20/28] xbps-src: fix for x86_64 local multilib repos.

Found and fixed by @pullmoll
---
 common/xbps-src/shutils/chroot.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index b463278c29e..744b99a8a0c 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -226,7 +226,15 @@ chroot_sync_repodata() {
     sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
         > $confdir/10-repository-local.conf
 
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+    if [ "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            ;;
+        esac
+    else
         case "$XBPS_MACHINE" in
             *-musl)
                 install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \

From 0ec18a9d60504a890c44723ea6159e0918d1a34e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 09:01:29 +0100
Subject: [PATCH 21/28] travis/build.sh: use -E (and get rid of -f) while
 building base-chroot.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 916c25515d7..c6a71afb6be 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps

From d0decae241fd8ba9d608c80bec18378318e7666f Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:19:05 +0100
Subject: [PATCH 22/28] xbps-src: updated list of required host utils.

---
 xbps-src | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xbps-src b/xbps-src
index 50f2032deeb..1ba52432707 100755
--- a/xbps-src
+++ b/xbps-src
@@ -382,9 +382,9 @@ umask 022
 #
 # Required utilities in host system for the bootstrap target.
 readonly REQHOST_UTILS_BOOTSTRAP="make gawk bash bison sed gcc g++ msgfmt makeinfo \
-    perl tar xz gzip bzip2 patch flex automake libtool pkg-config"
+    perl bsdtar xz gzip bzip2 patch flock flex libtool pkg-config"
 
-# Required utilities in host system for chroot ops.
+# Required utilities in host.
 readonly REQHOST_UTILS="xbps-install xbps-query xbps-rindex xbps-uhelper \
     xbps-reconfigure xbps-remove xbps-create xbps-uchroot xbps-uunshare"
 

From a3ca971472bc715910be7713d5a4c40df46ece33 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:46:05 +0100
Subject: [PATCH 23/28] travis/build.sh: update xbps/sys before building
 base-chroot.

---
 common/travis/build.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c6a71afb6be..84f86a7ee86 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,10 +6,13 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Make sure `base-chroot` is really up-to-date
+# Update `xbps` and then `base-chroot`
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
+# Build up-to-date `base-chroot`
 /hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
+# Perform system update
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From c7268cc1f7082f684c5dfe18aea277e899d2a1ea Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:53:50 +0100
Subject: [PATCH 24/28] xbps-src/shutils/chroot.sh: silence grep output

---
 common/xbps-src/shutils/chroot.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 744b99a8a0c..d3951a395ad 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -51,7 +51,7 @@ update_base_chroot() {
     [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
     msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
     # no need to sync repodata, chroot_sync_repodata() does it for us.
-    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep -q xbps); then
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"

From 378db8b077b8956032bb7185f3e89a315ceb2250 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 12:12:07 +0100
Subject: [PATCH 25/28] travis: move xbps/base-chroot stuff to prepare.sh.

---
 common/travis/build.sh   | 10 ----------
 common/travis/prepare.sh | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 84f86a7ee86..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,16 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Update `xbps` and then `base-chroot`
-xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-# Build up-to-date `base-chroot`
-/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
-# Perform system update
-xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-# remove autodeps
-xbps-remove -yo || exit 1
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..9aa475265e4 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,13 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Update `xbps` and then `base-chroot`
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu xbps || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu || exit 1
+# Build up-to-date `base-chroot`
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
+# Perform system update
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1

From bd1ef1fc64eec81608817f5bde80884eec50b66b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 12:15:49 +0100
Subject: [PATCH 26/28] travis/prepare.sh: set PATH

---
 common/travis/prepare.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 9aa475265e4..0d2375afb62 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -4,14 +4,16 @@
 
 [ "$XLINT" ] && exit 0
 
-/bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
+export PATH=/bin
+
+echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
-/bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'
+echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'
 echo XBPS_CHROOT_CMD=ethereal >> etc/conf
 echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
-/bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
+echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
 
 # Update `xbps` and then `base-chroot`

From 2c48d158370850bfe02acf8c9c4a8575331a46b1 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 12:18:52 +0100
Subject: [PATCH 27/28] travis/prepare.sh: restore /bin/echo -e

---
 common/travis/prepare.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 0d2375afb62..585853d6eb8 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -6,10 +6,10 @@
 
 export PATH=/bin
 
-echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
+/bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
-echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'
+/bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'
 echo XBPS_CHROOT_CMD=ethereal >> etc/conf
 echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 

From 8ece9a40f5b2171f70d79a7b5de0beb6311fa7d1 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 12:25:05 +0100
Subject: [PATCH 28/28] travis/prepare.sh: fix PATH?

---
 common/travis/prepare.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 585853d6eb8..d1b799118e7 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -4,7 +4,7 @@
 
 [ "$XLINT" ] && exit 0
 
-export PATH=/bin
+export PATH=/bin:$PWD/masterdir/usr/bin
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (80 preceding siblings ...)
  2020-01-04 11:25 ` [PR PATCH] [Updated] " voidlinux-github
@ 2020-01-04 11:32 ` voidlinux-github
  2020-01-04 11:39 ` voidlinux-github
                   ` (15 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-04 11:32 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1946 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- update `base-chroot` deps before building any pkg.
- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Gets rid of `-I` to skip file conflicts while installing deps via `xbps-install(1)`.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 78814 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/29] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/29] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/29] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/29] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/29] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/29] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/29] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/29] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/29] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/29] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/29] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/29] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/29] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/29] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 88c135d6642a9e84d4042174889b487912aa1548 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:55:35 +0100
Subject: [PATCH 15/29] travis/build.sh: local repo path v2

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 7e679ecc843..09705565427 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 1dedb200d46899cddf3a94ba5d618c592e69fb85 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:58:19 +0100
Subject: [PATCH 16/29] travis/build.sh: also use xbps.d repos, to resolve
 missing deps.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 09705565427..c7049c260c6 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From b261543632c599c2c92a27d7a02ce04e382a5550 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:01:18 +0100
Subject: [PATCH 17/29] travis/build.sh: perform sysup before installing
 base-chroot.

---
 common/travis/build.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c7049c260c6..916c25515d7 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,6 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1

From b0140b84b7846c1ecb820da819fc50aefdb5383e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:06:53 +0100
Subject: [PATCH 18/29] tar: fix for ethereal chroot-style

---
 srcpkgs/tar/template | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 0a49caa7e91..2ec183c02f1 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -13,6 +13,8 @@ distfiles="${GNU_SITE}/tar/${pkgname}-${version}.tar.xz"
 checksum=d0d3ae07f103323be809bc3eac0dcc386d52c5262499fe05511ac4788af1fdd8
 
 pre_configure() {
+	# chroot-style=ethereal
+	export FORCE_UNSAFE_CONFIGURE=1
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }

From d34dc4783cabd6562e1a64cc09518d31b3c43119 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:12:04 +0100
Subject: [PATCH 19/29] base-chroot: fix license?

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 1f73f00d56d..d4614bf3f27 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -6,7 +6,7 @@ bootstrap=yes
 build_style=meta
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
-license="Public domain"
+license="Public Domain"
 homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in

From 0941fa44d521639ab1528879a7f514f1286f7fba Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 08:59:10 +0100
Subject: [PATCH 20/29] xbps-src: fix for x86_64 local multilib repos.

Found and fixed by @pullmoll
---
 common/xbps-src/shutils/chroot.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index b463278c29e..744b99a8a0c 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -226,7 +226,15 @@ chroot_sync_repodata() {
     sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
         > $confdir/10-repository-local.conf
 
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+    if [ "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            ;;
+        esac
+    else
         case "$XBPS_MACHINE" in
             *-musl)
                 install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \

From 0ec18a9d60504a890c44723ea6159e0918d1a34e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 09:01:29 +0100
Subject: [PATCH 21/29] travis/build.sh: use -E (and get rid of -f) while
 building base-chroot.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 916c25515d7..c6a71afb6be 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps

From d0decae241fd8ba9d608c80bec18378318e7666f Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:19:05 +0100
Subject: [PATCH 22/29] xbps-src: updated list of required host utils.

---
 xbps-src | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xbps-src b/xbps-src
index 50f2032deeb..1ba52432707 100755
--- a/xbps-src
+++ b/xbps-src
@@ -382,9 +382,9 @@ umask 022
 #
 # Required utilities in host system for the bootstrap target.
 readonly REQHOST_UTILS_BOOTSTRAP="make gawk bash bison sed gcc g++ msgfmt makeinfo \
-    perl tar xz gzip bzip2 patch flex automake libtool pkg-config"
+    perl bsdtar xz gzip bzip2 patch flock flex libtool pkg-config"
 
-# Required utilities in host system for chroot ops.
+# Required utilities in host.
 readonly REQHOST_UTILS="xbps-install xbps-query xbps-rindex xbps-uhelper \
     xbps-reconfigure xbps-remove xbps-create xbps-uchroot xbps-uunshare"
 

From a3ca971472bc715910be7713d5a4c40df46ece33 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:46:05 +0100
Subject: [PATCH 23/29] travis/build.sh: update xbps/sys before building
 base-chroot.

---
 common/travis/build.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c6a71afb6be..84f86a7ee86 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,10 +6,13 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Make sure `base-chroot` is really up-to-date
+# Update `xbps` and then `base-chroot`
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
+# Build up-to-date `base-chroot`
 /hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
+# Perform system update
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From c7268cc1f7082f684c5dfe18aea277e899d2a1ea Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:53:50 +0100
Subject: [PATCH 24/29] xbps-src/shutils/chroot.sh: silence grep output

---
 common/xbps-src/shutils/chroot.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 744b99a8a0c..d3951a395ad 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -51,7 +51,7 @@ update_base_chroot() {
     [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
     msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
     # no need to sync repodata, chroot_sync_repodata() does it for us.
-    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep -q xbps); then
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"

From 378db8b077b8956032bb7185f3e89a315ceb2250 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 12:12:07 +0100
Subject: [PATCH 25/29] travis: move xbps/base-chroot stuff to prepare.sh.

---
 common/travis/build.sh   | 10 ----------
 common/travis/prepare.sh | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 84f86a7ee86..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,16 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Update `xbps` and then `base-chroot`
-xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-# Build up-to-date `base-chroot`
-/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
-# Perform system update
-xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-# remove autodeps
-xbps-remove -yo || exit 1
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..9aa475265e4 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,13 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Update `xbps` and then `base-chroot`
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu xbps || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu || exit 1
+# Build up-to-date `base-chroot`
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
+# Perform system update
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1

From bd1ef1fc64eec81608817f5bde80884eec50b66b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 12:15:49 +0100
Subject: [PATCH 26/29] travis/prepare.sh: set PATH

---
 common/travis/prepare.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 9aa475265e4..0d2375afb62 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -4,14 +4,16 @@
 
 [ "$XLINT" ] && exit 0
 
-/bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
+export PATH=/bin
+
+echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
-/bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'
+echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'
 echo XBPS_CHROOT_CMD=ethereal >> etc/conf
 echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
-/bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
+echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
 
 # Update `xbps` and then `base-chroot`

From 2c48d158370850bfe02acf8c9c4a8575331a46b1 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 12:18:52 +0100
Subject: [PATCH 27/29] travis/prepare.sh: restore /bin/echo -e

---
 common/travis/prepare.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 0d2375afb62..585853d6eb8 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -6,10 +6,10 @@
 
 export PATH=/bin
 
-echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
+/bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
-echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'
+/bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'
 echo XBPS_CHROOT_CMD=ethereal >> etc/conf
 echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 

From 8ece9a40f5b2171f70d79a7b5de0beb6311fa7d1 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 12:25:05 +0100
Subject: [PATCH 28/29] travis/prepare.sh: fix PATH?

---
 common/travis/prepare.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 585853d6eb8..d1b799118e7 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -4,7 +4,7 @@
 
 [ "$XLINT" ] && exit 0
 
-export PATH=/bin
+export PATH=/bin:$PWD/masterdir/usr/bin
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf

From 7a07c40346d21124c7aa84a2577d105198176e52 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 12:31:21 +0100
Subject: [PATCH 29/29] travis: re-add stuff to build.sh;

wtf is going on with PATH on prepare.sh?
---
 common/travis/build.sh   | 10 ++++++++++
 common/travis/prepare.sh | 12 ------------
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..2a736b21d73 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,16 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Update `xbps` and then system
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu xbps || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu || exit 1
+# Build up-to-date `base-chroot`
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
+# install/update `base-chroot`
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index d1b799118e7..009c1bf8f8e 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -4,8 +4,6 @@
 
 [ "$XLINT" ] && exit 0
 
-export PATH=/bin:$PWD/masterdir/usr/bin
-
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
@@ -15,13 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Update `xbps` and then `base-chroot`
-xbps-install --repo="$HOME"/hostdir/binpkgs -Syu xbps || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -Syu || exit 1
-# Build up-to-date `base-chroot`
-/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
-# Perform system update
-xbps-install --repo="$HOME"/hostdir/binpkgs -Syu || exit 1
-# remove autodeps
-xbps-remove -yo || exit 1

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (81 preceding siblings ...)
  2020-01-04 11:32 ` voidlinux-github
@ 2020-01-04 11:39 ` voidlinux-github
  2020-01-04 11:46 ` voidlinux-github
                   ` (14 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-04 11:39 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1946 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- update `base-chroot` deps before building any pkg.
- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Gets rid of `-I` to skip file conflicts while installing deps via `xbps-install(1)`.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 81071 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/30] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/30] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/30] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/30] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/30] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/30] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/30] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/30] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/30] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/30] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/30] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/30] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/30] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/30] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 88c135d6642a9e84d4042174889b487912aa1548 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:55:35 +0100
Subject: [PATCH 15/30] travis/build.sh: local repo path v2

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 7e679ecc843..09705565427 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 1dedb200d46899cddf3a94ba5d618c592e69fb85 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:58:19 +0100
Subject: [PATCH 16/30] travis/build.sh: also use xbps.d repos, to resolve
 missing deps.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 09705565427..c7049c260c6 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From b261543632c599c2c92a27d7a02ce04e382a5550 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:01:18 +0100
Subject: [PATCH 17/30] travis/build.sh: perform sysup before installing
 base-chroot.

---
 common/travis/build.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c7049c260c6..916c25515d7 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,6 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1

From b0140b84b7846c1ecb820da819fc50aefdb5383e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:06:53 +0100
Subject: [PATCH 18/30] tar: fix for ethereal chroot-style

---
 srcpkgs/tar/template | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 0a49caa7e91..2ec183c02f1 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -13,6 +13,8 @@ distfiles="${GNU_SITE}/tar/${pkgname}-${version}.tar.xz"
 checksum=d0d3ae07f103323be809bc3eac0dcc386d52c5262499fe05511ac4788af1fdd8
 
 pre_configure() {
+	# chroot-style=ethereal
+	export FORCE_UNSAFE_CONFIGURE=1
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }

From d34dc4783cabd6562e1a64cc09518d31b3c43119 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:12:04 +0100
Subject: [PATCH 19/30] base-chroot: fix license?

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 1f73f00d56d..d4614bf3f27 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -6,7 +6,7 @@ bootstrap=yes
 build_style=meta
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
-license="Public domain"
+license="Public Domain"
 homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in

From 0941fa44d521639ab1528879a7f514f1286f7fba Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 08:59:10 +0100
Subject: [PATCH 20/30] xbps-src: fix for x86_64 local multilib repos.

Found and fixed by @pullmoll
---
 common/xbps-src/shutils/chroot.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index b463278c29e..744b99a8a0c 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -226,7 +226,15 @@ chroot_sync_repodata() {
     sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
         > $confdir/10-repository-local.conf
 
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+    if [ "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            ;;
+        esac
+    else
         case "$XBPS_MACHINE" in
             *-musl)
                 install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \

From 0ec18a9d60504a890c44723ea6159e0918d1a34e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 09:01:29 +0100
Subject: [PATCH 21/30] travis/build.sh: use -E (and get rid of -f) while
 building base-chroot.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 916c25515d7..c6a71afb6be 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps

From d0decae241fd8ba9d608c80bec18378318e7666f Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:19:05 +0100
Subject: [PATCH 22/30] xbps-src: updated list of required host utils.

---
 xbps-src | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xbps-src b/xbps-src
index 50f2032deeb..1ba52432707 100755
--- a/xbps-src
+++ b/xbps-src
@@ -382,9 +382,9 @@ umask 022
 #
 # Required utilities in host system for the bootstrap target.
 readonly REQHOST_UTILS_BOOTSTRAP="make gawk bash bison sed gcc g++ msgfmt makeinfo \
-    perl tar xz gzip bzip2 patch flex automake libtool pkg-config"
+    perl bsdtar xz gzip bzip2 patch flock flex libtool pkg-config"
 
-# Required utilities in host system for chroot ops.
+# Required utilities in host.
 readonly REQHOST_UTILS="xbps-install xbps-query xbps-rindex xbps-uhelper \
     xbps-reconfigure xbps-remove xbps-create xbps-uchroot xbps-uunshare"
 

From a3ca971472bc715910be7713d5a4c40df46ece33 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:46:05 +0100
Subject: [PATCH 23/30] travis/build.sh: update xbps/sys before building
 base-chroot.

---
 common/travis/build.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c6a71afb6be..84f86a7ee86 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,10 +6,13 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Make sure `base-chroot` is really up-to-date
+# Update `xbps` and then `base-chroot`
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
+# Build up-to-date `base-chroot`
 /hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
+# Perform system update
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From c7268cc1f7082f684c5dfe18aea277e899d2a1ea Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:53:50 +0100
Subject: [PATCH 24/30] xbps-src/shutils/chroot.sh: silence grep output

---
 common/xbps-src/shutils/chroot.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 744b99a8a0c..d3951a395ad 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -51,7 +51,7 @@ update_base_chroot() {
     [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
     msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
     # no need to sync repodata, chroot_sync_repodata() does it for us.
-    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep -q xbps); then
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"

From 378db8b077b8956032bb7185f3e89a315ceb2250 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 12:12:07 +0100
Subject: [PATCH 25/30] travis: move xbps/base-chroot stuff to prepare.sh.

---
 common/travis/build.sh   | 10 ----------
 common/travis/prepare.sh | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 84f86a7ee86..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,16 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Update `xbps` and then `base-chroot`
-xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-# Build up-to-date `base-chroot`
-/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
-# Perform system update
-xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-# remove autodeps
-xbps-remove -yo || exit 1
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..9aa475265e4 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,13 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Update `xbps` and then `base-chroot`
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu xbps || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu || exit 1
+# Build up-to-date `base-chroot`
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
+# Perform system update
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1

From bd1ef1fc64eec81608817f5bde80884eec50b66b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 12:15:49 +0100
Subject: [PATCH 26/30] travis/prepare.sh: set PATH

---
 common/travis/prepare.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 9aa475265e4..0d2375afb62 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -4,14 +4,16 @@
 
 [ "$XLINT" ] && exit 0
 
-/bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
+export PATH=/bin
+
+echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
-/bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'
+echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'
 echo XBPS_CHROOT_CMD=ethereal >> etc/conf
 echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
-/bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
+echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
 
 # Update `xbps` and then `base-chroot`

From 2c48d158370850bfe02acf8c9c4a8575331a46b1 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 12:18:52 +0100
Subject: [PATCH 27/30] travis/prepare.sh: restore /bin/echo -e

---
 common/travis/prepare.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 0d2375afb62..585853d6eb8 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -6,10 +6,10 @@
 
 export PATH=/bin
 
-echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
+/bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
-echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'
+/bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'
 echo XBPS_CHROOT_CMD=ethereal >> etc/conf
 echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 

From 8ece9a40f5b2171f70d79a7b5de0beb6311fa7d1 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 12:25:05 +0100
Subject: [PATCH 28/30] travis/prepare.sh: fix PATH?

---
 common/travis/prepare.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 585853d6eb8..d1b799118e7 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -4,7 +4,7 @@
 
 [ "$XLINT" ] && exit 0
 
-export PATH=/bin
+export PATH=/bin:$PWD/masterdir/usr/bin
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf

From 7a07c40346d21124c7aa84a2577d105198176e52 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 12:31:21 +0100
Subject: [PATCH 29/30] travis: re-add stuff to build.sh;

wtf is going on with PATH on prepare.sh?
---
 common/travis/build.sh   | 10 ++++++++++
 common/travis/prepare.sh | 12 ------------
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..2a736b21d73 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,16 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Update `xbps` and then system
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu xbps || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu || exit 1
+# Build up-to-date `base-chroot`
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
+# install/update `base-chroot`
+xbps-install --repo="$HOME"/hostdir/binpkgs -Syu base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index d1b799118e7..009c1bf8f8e 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -4,8 +4,6 @@
 
 [ "$XLINT" ] && exit 0
 
-export PATH=/bin:$PWD/masterdir/usr/bin
-
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
@@ -15,13 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Update `xbps` and then `base-chroot`
-xbps-install --repo="$HOME"/hostdir/binpkgs -Syu xbps || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -Syu || exit 1
-# Build up-to-date `base-chroot`
-/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
-# Perform system update
-xbps-install --repo="$HOME"/hostdir/binpkgs -Syu || exit 1
-# remove autodeps
-xbps-remove -yo || exit 1

From 3b6090d5943e3c5d409b97d7040f7b0273855a0d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 12:38:18 +0100
Subject: [PATCH 30/30] update xbps/sys via xbps<0.58 method to unbreak travis.

Get rid of the update process in travis/build.sh; let
xbps-src update everything.
---
 common/travis/build.sh            | 12 +-----------
 common/xbps-src/shutils/chroot.sh |  4 +---
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2a736b21d73..7732211a59e 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # build.sh
 
@@ -6,16 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Update `xbps` and then system
-xbps-install --repo="$HOME"/hostdir/binpkgs -Syu xbps || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -Syu || exit 1
-# Build up-to-date `base-chroot`
-/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
-# install/update `base-chroot`
-xbps-install --repo="$HOME"/hostdir/binpkgs -Syu base-chroot || exit 1
-# remove autodeps
-xbps-remove -yo || exit 1
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index d3951a395ad..4662df7993d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -51,9 +51,7 @@ update_base_chroot() {
     [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
     msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
     # no need to sync repodata, chroot_sync_repodata() does it for us.
-    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep -q xbps); then
-        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
-    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update xbps!\n"
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
     [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
     msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (82 preceding siblings ...)
  2020-01-04 11:39 ` voidlinux-github
@ 2020-01-04 11:46 ` voidlinux-github
  2020-01-04 12:03 ` voidlinux-github
                   ` (13 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-04 11:46 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 214 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570778775

Comment:
I see what's the issue. I'm preparing a new patch for xbps to fix this...

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (83 preceding siblings ...)
  2020-01-04 11:46 ` voidlinux-github
@ 2020-01-04 12:03 ` voidlinux-github
  2020-01-04 12:29 ` voidlinux-github
                   ` (12 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-04 12:03 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 276 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570779966

Comment:
Fixed the issue finally, easier than expected :-)

https://github.com/void-linux/xbps/commit/10075c28e5065e948cac707285681f6541759873

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (84 preceding siblings ...)
  2020-01-04 12:03 ` voidlinux-github
@ 2020-01-04 12:29 ` voidlinux-github
  2020-01-05  6:49 ` [PR PATCH] [Updated] " voidlinux-github
                   ` (11 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-04 12:29 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 212 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570781728

Comment:
Waiting for https://github.com/void-linux/void-infrastructure/issues/54

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (85 preceding siblings ...)
  2020-01-04 12:29 ` voidlinux-github
@ 2020-01-05  6:49 ` voidlinux-github
  2020-01-05  7:21 ` voidlinux-github
                   ` (10 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-05  6:49 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1946 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- update `base-chroot` deps before building any pkg.
- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Gets rid of `-I` to skip file conflicts while installing deps via `xbps-install(1)`.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 71025 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/23] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/23] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/23] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/23] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/23] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/23] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/23] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/23] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/23] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/23] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/23] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/23] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/23] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/23] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 88c135d6642a9e84d4042174889b487912aa1548 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:55:35 +0100
Subject: [PATCH 15/23] travis/build.sh: local repo path v2

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 7e679ecc843..09705565427 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 1dedb200d46899cddf3a94ba5d618c592e69fb85 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:58:19 +0100
Subject: [PATCH 16/23] travis/build.sh: also use xbps.d repos, to resolve
 missing deps.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 09705565427..c7049c260c6 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From b261543632c599c2c92a27d7a02ce04e382a5550 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:01:18 +0100
Subject: [PATCH 17/23] travis/build.sh: perform sysup before installing
 base-chroot.

---
 common/travis/build.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c7049c260c6..916c25515d7 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,6 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1

From b0140b84b7846c1ecb820da819fc50aefdb5383e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:06:53 +0100
Subject: [PATCH 18/23] tar: fix for ethereal chroot-style

---
 srcpkgs/tar/template | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 0a49caa7e91..2ec183c02f1 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -13,6 +13,8 @@ distfiles="${GNU_SITE}/tar/${pkgname}-${version}.tar.xz"
 checksum=d0d3ae07f103323be809bc3eac0dcc386d52c5262499fe05511ac4788af1fdd8
 
 pre_configure() {
+	# chroot-style=ethereal
+	export FORCE_UNSAFE_CONFIGURE=1
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }

From d34dc4783cabd6562e1a64cc09518d31b3c43119 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:12:04 +0100
Subject: [PATCH 19/23] base-chroot: fix license?

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 1f73f00d56d..d4614bf3f27 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -6,7 +6,7 @@ bootstrap=yes
 build_style=meta
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
-license="Public domain"
+license="Public Domain"
 homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in

From 0941fa44d521639ab1528879a7f514f1286f7fba Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 08:59:10 +0100
Subject: [PATCH 20/23] xbps-src: fix for x86_64 local multilib repos.

Found and fixed by @pullmoll
---
 common/xbps-src/shutils/chroot.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index b463278c29e..744b99a8a0c 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -226,7 +226,15 @@ chroot_sync_repodata() {
     sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
         > $confdir/10-repository-local.conf
 
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+    if [ "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            ;;
+        esac
+    else
         case "$XBPS_MACHINE" in
             *-musl)
                 install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \

From 0ec18a9d60504a890c44723ea6159e0918d1a34e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 09:01:29 +0100
Subject: [PATCH 21/23] travis/build.sh: use -E (and get rid of -f) while
 building base-chroot.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 916c25515d7..c6a71afb6be 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps

From d0decae241fd8ba9d608c80bec18378318e7666f Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:19:05 +0100
Subject: [PATCH 22/23] xbps-src: updated list of required host utils.

---
 xbps-src | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xbps-src b/xbps-src
index 50f2032deeb..1ba52432707 100755
--- a/xbps-src
+++ b/xbps-src
@@ -382,9 +382,9 @@ umask 022
 #
 # Required utilities in host system for the bootstrap target.
 readonly REQHOST_UTILS_BOOTSTRAP="make gawk bash bison sed gcc g++ msgfmt makeinfo \
-    perl tar xz gzip bzip2 patch flex automake libtool pkg-config"
+    perl bsdtar xz gzip bzip2 patch flock flex libtool pkg-config"
 
-# Required utilities in host system for chroot ops.
+# Required utilities in host.
 readonly REQHOST_UTILS="xbps-install xbps-query xbps-rindex xbps-uhelper \
     xbps-reconfigure xbps-remove xbps-create xbps-uchroot xbps-uunshare"
 

From c6d1da9777539539d66fcca2c3065688e087c408 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 07:47:43 +0100
Subject: [PATCH 23/23] .travis.yml: bump voidlinux docker tag.

Original commit in https://github.com/void-linux/void-packages/pull/18049
will be reverted after testing.

@the-maldridge
---
 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 5f4f30f85cd..13650b2bd31 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,7 +8,7 @@ env:
     global:
         - PATH=$PATH:/tmp/bin
         - DOCKER_BASE=voidlinux/masterdir
-        - TAG=2019102301
+        - TAG=20200104
 
     matrix:
         - XLINT=1 LICENSE_LIST=common/travis/license.lst

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (86 preceding siblings ...)
  2020-01-05  6:49 ` [PR PATCH] [Updated] " voidlinux-github
@ 2020-01-05  7:21 ` voidlinux-github
  2020-01-05  7:25 ` voidlinux-github
                   ` (9 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-05  7:21 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1946 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- update `base-chroot` deps before building any pkg.
- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Gets rid of `-I` to skip file conflicts while installing deps via `xbps-install(1)`.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 74504 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/24] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/24] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/24] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/24] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/24] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/24] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/24] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/24] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/24] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/24] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/24] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/24] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/24] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/24] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 88c135d6642a9e84d4042174889b487912aa1548 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:55:35 +0100
Subject: [PATCH 15/24] travis/build.sh: local repo path v2

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 7e679ecc843..09705565427 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 1dedb200d46899cddf3a94ba5d618c592e69fb85 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:58:19 +0100
Subject: [PATCH 16/24] travis/build.sh: also use xbps.d repos, to resolve
 missing deps.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 09705565427..c7049c260c6 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From b261543632c599c2c92a27d7a02ce04e382a5550 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:01:18 +0100
Subject: [PATCH 17/24] travis/build.sh: perform sysup before installing
 base-chroot.

---
 common/travis/build.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c7049c260c6..916c25515d7 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,6 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1

From b0140b84b7846c1ecb820da819fc50aefdb5383e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:06:53 +0100
Subject: [PATCH 18/24] tar: fix for ethereal chroot-style

---
 srcpkgs/tar/template | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 0a49caa7e91..2ec183c02f1 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -13,6 +13,8 @@ distfiles="${GNU_SITE}/tar/${pkgname}-${version}.tar.xz"
 checksum=d0d3ae07f103323be809bc3eac0dcc386d52c5262499fe05511ac4788af1fdd8
 
 pre_configure() {
+	# chroot-style=ethereal
+	export FORCE_UNSAFE_CONFIGURE=1
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }

From d34dc4783cabd6562e1a64cc09518d31b3c43119 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:12:04 +0100
Subject: [PATCH 19/24] base-chroot: fix license?

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 1f73f00d56d..d4614bf3f27 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -6,7 +6,7 @@ bootstrap=yes
 build_style=meta
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
-license="Public domain"
+license="Public Domain"
 homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in

From 0941fa44d521639ab1528879a7f514f1286f7fba Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 08:59:10 +0100
Subject: [PATCH 20/24] xbps-src: fix for x86_64 local multilib repos.

Found and fixed by @pullmoll
---
 common/xbps-src/shutils/chroot.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index b463278c29e..744b99a8a0c 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -226,7 +226,15 @@ chroot_sync_repodata() {
     sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
         > $confdir/10-repository-local.conf
 
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+    if [ "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            ;;
+        esac
+    else
         case "$XBPS_MACHINE" in
             *-musl)
                 install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \

From 0ec18a9d60504a890c44723ea6159e0918d1a34e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 09:01:29 +0100
Subject: [PATCH 21/24] travis/build.sh: use -E (and get rid of -f) while
 building base-chroot.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 916c25515d7..c6a71afb6be 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps

From d0decae241fd8ba9d608c80bec18378318e7666f Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:19:05 +0100
Subject: [PATCH 22/24] xbps-src: updated list of required host utils.

---
 xbps-src | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xbps-src b/xbps-src
index 50f2032deeb..1ba52432707 100755
--- a/xbps-src
+++ b/xbps-src
@@ -382,9 +382,9 @@ umask 022
 #
 # Required utilities in host system for the bootstrap target.
 readonly REQHOST_UTILS_BOOTSTRAP="make gawk bash bison sed gcc g++ msgfmt makeinfo \
-    perl tar xz gzip bzip2 patch flex automake libtool pkg-config"
+    perl bsdtar xz gzip bzip2 patch flock flex libtool pkg-config"
 
-# Required utilities in host system for chroot ops.
+# Required utilities in host.
 readonly REQHOST_UTILS="xbps-install xbps-query xbps-rindex xbps-uhelper \
     xbps-reconfigure xbps-remove xbps-create xbps-uchroot xbps-uunshare"
 

From c6d1da9777539539d66fcca2c3065688e087c408 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 07:47:43 +0100
Subject: [PATCH 23/24] .travis.yml: bump voidlinux docker tag.

Original commit in https://github.com/void-linux/void-packages/pull/18049
will be reverted after testing.

@the-maldridge
---
 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 5f4f30f85cd..13650b2bd31 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,7 +8,7 @@ env:
     global:
         - PATH=$PATH:/tmp/bin
         - DOCKER_BASE=voidlinux/masterdir
-        - TAG=2019102301
+        - TAG=20200104
 
     matrix:
         - XLINT=1 LICENSE_LIST=common/travis/license.lst

From 37470cfc1587478693d11890c935f4b544fb8a33 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 08:20:26 +0100
Subject: [PATCH 24/24] hooks: 00-distfiles.sh: detect bsdtar and then tar
 (GNU).

This way xbps-src is able to work with any of them.
---
 common/hooks/do-extract/00-distfiles.sh |  7 ++++++-
 common/hooks/do-fetch/00-distfiles.sh   | 17 ++++++++++++++---
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index 303fe27e0a1..d1f457edcc5 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -4,6 +4,7 @@
 hook() {
 	local srcdir="$XBPS_SRCDISTDIR/$pkgname-$version"
 	local f j curfile found extractdir
+	local TAR_CMD
 
 	if [ -z "$distfiles" -a -z "$checksum" ]; then
 		mkdir -p $wrksrc
@@ -23,6 +24,10 @@ hook() {
 		mkdir -p ${wrksrc} || msg_error "$pkgver: failed to create wrksrc.\n"
 	fi
 
+	TAR_CMD="$(command -v bsdtar)"
+	[ -z "$TAR_CMD" ] && TAR_CMD="$(command -v tar)"
+	[ -z "$TAR_CMD" ] && msg_error "xbps-src: no suitable tar cmd (bsdtar, tar)\n"
+
 	msg_normal "$pkgver: extracting distfile(s), please wait...\n"
 
 	for f in ${distfiles}; do
@@ -71,7 +76,7 @@ hook() {
 
 		case ${cursufx} in
 		tar|txz|tbz|tlz|tgz|crate)
-			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+			$TAR_CMD -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index 73239da1c73..db4f29c73a2 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
+		cksum=$($XBPS_DIGEST_CMD <($TAR_CMD xf "$curfile" $TAR_CMD_STDOUT))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -73,7 +73,7 @@ contents_cksum() {
 		;;
 	rpm)
 		if command -v rpmextract &>/dev/null; then
-			cksum=$($XBPS_DIGEST_CMD <(rpm2cpio "$curfile" | bsdtar xf - --to-stdout))
+			cksum=$($XBPS_DIGEST_CMD <(rpm2cpio "$curfile" | $TAR_CMD xf - $TAR_CMD_STDOUT))
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile to pipe.\n"
 			fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <($TAR_CMD -xf "$curfile" data.tar.gz $TAR_CMD_STDOUT | $TAR_CMD -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
@@ -210,6 +210,15 @@ hook() {
 	# Disable trap on ERR; the code is smart enough to report errors and abort.
 	trap - ERR
 
+	# Detect bsdtar and GNU tar (in that order of preference)
+	TAR_CMD="$(command -v bsdtar)"
+	if [ "$TAR_CMD" ]; then
+		TAR_CMD_STDOUT="--list"
+	else
+		TAR_CMD="$(command -v tar)"
+		TAR_CMD_STDOUT="--to-stdout"
+	fi
+
 	# Detect distfiles with obsolete checksum and purge them from the cache
 	for f in ${distfiles}; do
 		curfile="${f#*>}"
@@ -273,6 +282,8 @@ hook() {
 		dfcount=$((dfcount + 1))
 	done
 
+	unset TAR_CMD TAR_CMD_STDOUT
+
 	if [ $errors -gt 0 ]; then
 		msg_error "$pkgver: couldn't verify distfiles, exiting...\n"
 	fi

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (87 preceding siblings ...)
  2020-01-05  7:21 ` voidlinux-github
@ 2020-01-05  7:25 ` voidlinux-github
  2020-01-05  7:32 ` voidlinux-github
                   ` (8 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-05  7:25 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1946 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- update `base-chroot` deps before building any pkg.
- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Gets rid of `-I` to skip file conflicts while installing deps via `xbps-install(1)`.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 75404 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/25] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/25] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/25] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/25] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/25] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/25] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/25] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/25] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/25] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/25] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/25] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/25] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/25] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/25] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 88c135d6642a9e84d4042174889b487912aa1548 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:55:35 +0100
Subject: [PATCH 15/25] travis/build.sh: local repo path v2

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 7e679ecc843..09705565427 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 1dedb200d46899cddf3a94ba5d618c592e69fb85 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:58:19 +0100
Subject: [PATCH 16/25] travis/build.sh: also use xbps.d repos, to resolve
 missing deps.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 09705565427..c7049c260c6 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From b261543632c599c2c92a27d7a02ce04e382a5550 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:01:18 +0100
Subject: [PATCH 17/25] travis/build.sh: perform sysup before installing
 base-chroot.

---
 common/travis/build.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c7049c260c6..916c25515d7 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,6 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1

From b0140b84b7846c1ecb820da819fc50aefdb5383e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:06:53 +0100
Subject: [PATCH 18/25] tar: fix for ethereal chroot-style

---
 srcpkgs/tar/template | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 0a49caa7e91..2ec183c02f1 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -13,6 +13,8 @@ distfiles="${GNU_SITE}/tar/${pkgname}-${version}.tar.xz"
 checksum=d0d3ae07f103323be809bc3eac0dcc386d52c5262499fe05511ac4788af1fdd8
 
 pre_configure() {
+	# chroot-style=ethereal
+	export FORCE_UNSAFE_CONFIGURE=1
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }

From d34dc4783cabd6562e1a64cc09518d31b3c43119 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:12:04 +0100
Subject: [PATCH 19/25] base-chroot: fix license?

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 1f73f00d56d..d4614bf3f27 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -6,7 +6,7 @@ bootstrap=yes
 build_style=meta
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
-license="Public domain"
+license="Public Domain"
 homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in

From 0941fa44d521639ab1528879a7f514f1286f7fba Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 08:59:10 +0100
Subject: [PATCH 20/25] xbps-src: fix for x86_64 local multilib repos.

Found and fixed by @pullmoll
---
 common/xbps-src/shutils/chroot.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index b463278c29e..744b99a8a0c 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -226,7 +226,15 @@ chroot_sync_repodata() {
     sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
         > $confdir/10-repository-local.conf
 
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+    if [ "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            ;;
+        esac
+    else
         case "$XBPS_MACHINE" in
             *-musl)
                 install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \

From 0ec18a9d60504a890c44723ea6159e0918d1a34e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 09:01:29 +0100
Subject: [PATCH 21/25] travis/build.sh: use -E (and get rid of -f) while
 building base-chroot.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 916c25515d7..c6a71afb6be 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps

From d0decae241fd8ba9d608c80bec18378318e7666f Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:19:05 +0100
Subject: [PATCH 22/25] xbps-src: updated list of required host utils.

---
 xbps-src | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xbps-src b/xbps-src
index 50f2032deeb..1ba52432707 100755
--- a/xbps-src
+++ b/xbps-src
@@ -382,9 +382,9 @@ umask 022
 #
 # Required utilities in host system for the bootstrap target.
 readonly REQHOST_UTILS_BOOTSTRAP="make gawk bash bison sed gcc g++ msgfmt makeinfo \
-    perl tar xz gzip bzip2 patch flex automake libtool pkg-config"
+    perl bsdtar xz gzip bzip2 patch flock flex libtool pkg-config"
 
-# Required utilities in host system for chroot ops.
+# Required utilities in host.
 readonly REQHOST_UTILS="xbps-install xbps-query xbps-rindex xbps-uhelper \
     xbps-reconfigure xbps-remove xbps-create xbps-uchroot xbps-uunshare"
 

From c6d1da9777539539d66fcca2c3065688e087c408 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 07:47:43 +0100
Subject: [PATCH 23/25] .travis.yml: bump voidlinux docker tag.

Original commit in https://github.com/void-linux/void-packages/pull/18049
will be reverted after testing.

@the-maldridge
---
 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 5f4f30f85cd..13650b2bd31 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,7 +8,7 @@ env:
     global:
         - PATH=$PATH:/tmp/bin
         - DOCKER_BASE=voidlinux/masterdir
-        - TAG=2019102301
+        - TAG=20200104
 
     matrix:
         - XLINT=1 LICENSE_LIST=common/travis/license.lst

From 37470cfc1587478693d11890c935f4b544fb8a33 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 08:20:26 +0100
Subject: [PATCH 24/25] hooks: 00-distfiles.sh: detect bsdtar and then tar
 (GNU).

This way xbps-src is able to work with any of them.
---
 common/hooks/do-extract/00-distfiles.sh |  7 ++++++-
 common/hooks/do-fetch/00-distfiles.sh   | 17 ++++++++++++++---
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index 303fe27e0a1..d1f457edcc5 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -4,6 +4,7 @@
 hook() {
 	local srcdir="$XBPS_SRCDISTDIR/$pkgname-$version"
 	local f j curfile found extractdir
+	local TAR_CMD
 
 	if [ -z "$distfiles" -a -z "$checksum" ]; then
 		mkdir -p $wrksrc
@@ -23,6 +24,10 @@ hook() {
 		mkdir -p ${wrksrc} || msg_error "$pkgver: failed to create wrksrc.\n"
 	fi
 
+	TAR_CMD="$(command -v bsdtar)"
+	[ -z "$TAR_CMD" ] && TAR_CMD="$(command -v tar)"
+	[ -z "$TAR_CMD" ] && msg_error "xbps-src: no suitable tar cmd (bsdtar, tar)\n"
+
 	msg_normal "$pkgver: extracting distfile(s), please wait...\n"
 
 	for f in ${distfiles}; do
@@ -71,7 +76,7 @@ hook() {
 
 		case ${cursufx} in
 		tar|txz|tbz|tlz|tgz|crate)
-			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+			$TAR_CMD -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index 73239da1c73..db4f29c73a2 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
+		cksum=$($XBPS_DIGEST_CMD <($TAR_CMD xf "$curfile" $TAR_CMD_STDOUT))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -73,7 +73,7 @@ contents_cksum() {
 		;;
 	rpm)
 		if command -v rpmextract &>/dev/null; then
-			cksum=$($XBPS_DIGEST_CMD <(rpm2cpio "$curfile" | bsdtar xf - --to-stdout))
+			cksum=$($XBPS_DIGEST_CMD <(rpm2cpio "$curfile" | $TAR_CMD xf - $TAR_CMD_STDOUT))
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile to pipe.\n"
 			fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <($TAR_CMD -xf "$curfile" data.tar.gz $TAR_CMD_STDOUT | $TAR_CMD -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
@@ -210,6 +210,15 @@ hook() {
 	# Disable trap on ERR; the code is smart enough to report errors and abort.
 	trap - ERR
 
+	# Detect bsdtar and GNU tar (in that order of preference)
+	TAR_CMD="$(command -v bsdtar)"
+	if [ "$TAR_CMD" ]; then
+		TAR_CMD_STDOUT="--list"
+	else
+		TAR_CMD="$(command -v tar)"
+		TAR_CMD_STDOUT="--to-stdout"
+	fi
+
 	# Detect distfiles with obsolete checksum and purge them from the cache
 	for f in ${distfiles}; do
 		curfile="${f#*>}"
@@ -273,6 +282,8 @@ hook() {
 		dfcount=$((dfcount + 1))
 	done
 
+	unset TAR_CMD TAR_CMD_STDOUT
+
 	if [ $errors -gt 0 ]; then
 		msg_error "$pkgver: couldn't verify distfiles, exiting...\n"
 	fi

From 71b686118b44aedf234270e180de320125f4d341 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 08:24:52 +0100
Subject: [PATCH 25/25] hooks/do-extract: 00-distfiles.sh: disable trap on ERR.

---
 common/hooks/do-extract/00-distfiles.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index d1f457edcc5..8b0a5e0dc84 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -24,6 +24,9 @@ hook() {
 		mkdir -p ${wrksrc} || msg_error "$pkgver: failed to create wrksrc.\n"
 	fi
 
+	# Disable trap on ERR; the code is smart enough to report errors and abort.
+	trap - ERR
+
 	TAR_CMD="$(command -v bsdtar)"
 	[ -z "$TAR_CMD" ] && TAR_CMD="$(command -v tar)"
 	[ -z "$TAR_CMD" ] && msg_error "xbps-src: no suitable tar cmd (bsdtar, tar)\n"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (88 preceding siblings ...)
  2020-01-05  7:25 ` voidlinux-github
@ 2020-01-05  7:32 ` voidlinux-github
  2020-01-05  7:54 ` voidlinux-github
                   ` (7 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-05  7:32 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1946 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- update `base-chroot` deps before building any pkg.
- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Gets rid of `-I` to skip file conflicts while installing deps via `xbps-install(1)`.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 76139 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/26] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/26] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/26] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/26] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/26] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/26] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/26] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/26] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/26] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/26] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/26] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/26] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/26] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/26] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 88c135d6642a9e84d4042174889b487912aa1548 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:55:35 +0100
Subject: [PATCH 15/26] travis/build.sh: local repo path v2

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 7e679ecc843..09705565427 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 1dedb200d46899cddf3a94ba5d618c592e69fb85 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:58:19 +0100
Subject: [PATCH 16/26] travis/build.sh: also use xbps.d repos, to resolve
 missing deps.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 09705565427..c7049c260c6 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From b261543632c599c2c92a27d7a02ce04e382a5550 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:01:18 +0100
Subject: [PATCH 17/26] travis/build.sh: perform sysup before installing
 base-chroot.

---
 common/travis/build.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c7049c260c6..916c25515d7 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,6 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1

From b0140b84b7846c1ecb820da819fc50aefdb5383e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:06:53 +0100
Subject: [PATCH 18/26] tar: fix for ethereal chroot-style

---
 srcpkgs/tar/template | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 0a49caa7e91..2ec183c02f1 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -13,6 +13,8 @@ distfiles="${GNU_SITE}/tar/${pkgname}-${version}.tar.xz"
 checksum=d0d3ae07f103323be809bc3eac0dcc386d52c5262499fe05511ac4788af1fdd8
 
 pre_configure() {
+	# chroot-style=ethereal
+	export FORCE_UNSAFE_CONFIGURE=1
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }

From d34dc4783cabd6562e1a64cc09518d31b3c43119 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:12:04 +0100
Subject: [PATCH 19/26] base-chroot: fix license?

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 1f73f00d56d..d4614bf3f27 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -6,7 +6,7 @@ bootstrap=yes
 build_style=meta
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
-license="Public domain"
+license="Public Domain"
 homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in

From 0941fa44d521639ab1528879a7f514f1286f7fba Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 08:59:10 +0100
Subject: [PATCH 20/26] xbps-src: fix for x86_64 local multilib repos.

Found and fixed by @pullmoll
---
 common/xbps-src/shutils/chroot.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index b463278c29e..744b99a8a0c 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -226,7 +226,15 @@ chroot_sync_repodata() {
     sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
         > $confdir/10-repository-local.conf
 
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+    if [ "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            ;;
+        esac
+    else
         case "$XBPS_MACHINE" in
             *-musl)
                 install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \

From 0ec18a9d60504a890c44723ea6159e0918d1a34e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 09:01:29 +0100
Subject: [PATCH 21/26] travis/build.sh: use -E (and get rid of -f) while
 building base-chroot.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 916c25515d7..c6a71afb6be 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps

From d0decae241fd8ba9d608c80bec18378318e7666f Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:19:05 +0100
Subject: [PATCH 22/26] xbps-src: updated list of required host utils.

---
 xbps-src | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xbps-src b/xbps-src
index 50f2032deeb..1ba52432707 100755
--- a/xbps-src
+++ b/xbps-src
@@ -382,9 +382,9 @@ umask 022
 #
 # Required utilities in host system for the bootstrap target.
 readonly REQHOST_UTILS_BOOTSTRAP="make gawk bash bison sed gcc g++ msgfmt makeinfo \
-    perl tar xz gzip bzip2 patch flex automake libtool pkg-config"
+    perl bsdtar xz gzip bzip2 patch flock flex libtool pkg-config"
 
-# Required utilities in host system for chroot ops.
+# Required utilities in host.
 readonly REQHOST_UTILS="xbps-install xbps-query xbps-rindex xbps-uhelper \
     xbps-reconfigure xbps-remove xbps-create xbps-uchroot xbps-uunshare"
 

From c6d1da9777539539d66fcca2c3065688e087c408 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 07:47:43 +0100
Subject: [PATCH 23/26] .travis.yml: bump voidlinux docker tag.

Original commit in https://github.com/void-linux/void-packages/pull/18049
will be reverted after testing.

@the-maldridge
---
 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 5f4f30f85cd..13650b2bd31 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,7 +8,7 @@ env:
     global:
         - PATH=$PATH:/tmp/bin
         - DOCKER_BASE=voidlinux/masterdir
-        - TAG=2019102301
+        - TAG=20200104
 
     matrix:
         - XLINT=1 LICENSE_LIST=common/travis/license.lst

From 37470cfc1587478693d11890c935f4b544fb8a33 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 08:20:26 +0100
Subject: [PATCH 24/26] hooks: 00-distfiles.sh: detect bsdtar and then tar
 (GNU).

This way xbps-src is able to work with any of them.
---
 common/hooks/do-extract/00-distfiles.sh |  7 ++++++-
 common/hooks/do-fetch/00-distfiles.sh   | 17 ++++++++++++++---
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index 303fe27e0a1..d1f457edcc5 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -4,6 +4,7 @@
 hook() {
 	local srcdir="$XBPS_SRCDISTDIR/$pkgname-$version"
 	local f j curfile found extractdir
+	local TAR_CMD
 
 	if [ -z "$distfiles" -a -z "$checksum" ]; then
 		mkdir -p $wrksrc
@@ -23,6 +24,10 @@ hook() {
 		mkdir -p ${wrksrc} || msg_error "$pkgver: failed to create wrksrc.\n"
 	fi
 
+	TAR_CMD="$(command -v bsdtar)"
+	[ -z "$TAR_CMD" ] && TAR_CMD="$(command -v tar)"
+	[ -z "$TAR_CMD" ] && msg_error "xbps-src: no suitable tar cmd (bsdtar, tar)\n"
+
 	msg_normal "$pkgver: extracting distfile(s), please wait...\n"
 
 	for f in ${distfiles}; do
@@ -71,7 +76,7 @@ hook() {
 
 		case ${cursufx} in
 		tar|txz|tbz|tlz|tgz|crate)
-			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+			$TAR_CMD -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index 73239da1c73..db4f29c73a2 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
+		cksum=$($XBPS_DIGEST_CMD <($TAR_CMD xf "$curfile" $TAR_CMD_STDOUT))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -73,7 +73,7 @@ contents_cksum() {
 		;;
 	rpm)
 		if command -v rpmextract &>/dev/null; then
-			cksum=$($XBPS_DIGEST_CMD <(rpm2cpio "$curfile" | bsdtar xf - --to-stdout))
+			cksum=$($XBPS_DIGEST_CMD <(rpm2cpio "$curfile" | $TAR_CMD xf - $TAR_CMD_STDOUT))
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile to pipe.\n"
 			fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <($TAR_CMD -xf "$curfile" data.tar.gz $TAR_CMD_STDOUT | $TAR_CMD -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
@@ -210,6 +210,15 @@ hook() {
 	# Disable trap on ERR; the code is smart enough to report errors and abort.
 	trap - ERR
 
+	# Detect bsdtar and GNU tar (in that order of preference)
+	TAR_CMD="$(command -v bsdtar)"
+	if [ "$TAR_CMD" ]; then
+		TAR_CMD_STDOUT="--list"
+	else
+		TAR_CMD="$(command -v tar)"
+		TAR_CMD_STDOUT="--to-stdout"
+	fi
+
 	# Detect distfiles with obsolete checksum and purge them from the cache
 	for f in ${distfiles}; do
 		curfile="${f#*>}"
@@ -273,6 +282,8 @@ hook() {
 		dfcount=$((dfcount + 1))
 	done
 
+	unset TAR_CMD TAR_CMD_STDOUT
+
 	if [ $errors -gt 0 ]; then
 		msg_error "$pkgver: couldn't verify distfiles, exiting...\n"
 	fi

From 71b686118b44aedf234270e180de320125f4d341 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 08:24:52 +0100
Subject: [PATCH 25/26] hooks/do-extract: 00-distfiles.sh: disable trap on ERR.

---
 common/hooks/do-extract/00-distfiles.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index d1f457edcc5..8b0a5e0dc84 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -24,6 +24,9 @@ hook() {
 		mkdir -p ${wrksrc} || msg_error "$pkgver: failed to create wrksrc.\n"
 	fi
 
+	# Disable trap on ERR; the code is smart enough to report errors and abort.
+	trap - ERR
+
 	TAR_CMD="$(command -v bsdtar)"
 	[ -z "$TAR_CMD" ] && TAR_CMD="$(command -v tar)"
 	[ -z "$TAR_CMD" ] && msg_error "xbps-src: no suitable tar cmd (bsdtar, tar)\n"

From 043eaec32b64e56b9c8d09affefe380a15f8c0ff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 08:32:29 +0100
Subject: [PATCH 26/26] travis/build.sh: simplify logic

---
 common/travis/build.sh | 1 -
 1 file changed, 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c6a71afb6be..3a5da41a533 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -9,7 +9,6 @@ fi
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (89 preceding siblings ...)
  2020-01-05  7:32 ` voidlinux-github
@ 2020-01-05  7:54 ` voidlinux-github
  2020-01-05  8:44 ` [PR PATCH] [Updated] " voidlinux-github
                   ` (6 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-05  7:54 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 376 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570887188

Comment:
This seems to be 100% ready and working, it's able to update base-chroot and always use the latest pkg versions, no matter if it's from source.

The extract/fetch hooks now can use any of bsdtar and tar (in that order of preference).

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (90 preceding siblings ...)
  2020-01-05  7:54 ` voidlinux-github
@ 2020-01-05  8:44 ` voidlinux-github
  2020-01-05  8:53 ` voidlinux-github
                   ` (5 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-05  8:44 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1946 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- update `base-chroot` deps before building any pkg.
- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Gets rid of `-I` to skip file conflicts while installing deps via `xbps-install(1)`.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 77035 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/27] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/27] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/27] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/27] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/27] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/27] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/27] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/27] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/27] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/27] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/27] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/27] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/27] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/27] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 88c135d6642a9e84d4042174889b487912aa1548 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:55:35 +0100
Subject: [PATCH 15/27] travis/build.sh: local repo path v2

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 7e679ecc843..09705565427 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 1dedb200d46899cddf3a94ba5d618c592e69fb85 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:58:19 +0100
Subject: [PATCH 16/27] travis/build.sh: also use xbps.d repos, to resolve
 missing deps.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 09705565427..c7049c260c6 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From b261543632c599c2c92a27d7a02ce04e382a5550 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:01:18 +0100
Subject: [PATCH 17/27] travis/build.sh: perform sysup before installing
 base-chroot.

---
 common/travis/build.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c7049c260c6..916c25515d7 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,6 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1

From b0140b84b7846c1ecb820da819fc50aefdb5383e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:06:53 +0100
Subject: [PATCH 18/27] tar: fix for ethereal chroot-style

---
 srcpkgs/tar/template | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 0a49caa7e91..2ec183c02f1 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -13,6 +13,8 @@ distfiles="${GNU_SITE}/tar/${pkgname}-${version}.tar.xz"
 checksum=d0d3ae07f103323be809bc3eac0dcc386d52c5262499fe05511ac4788af1fdd8
 
 pre_configure() {
+	# chroot-style=ethereal
+	export FORCE_UNSAFE_CONFIGURE=1
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }

From d34dc4783cabd6562e1a64cc09518d31b3c43119 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:12:04 +0100
Subject: [PATCH 19/27] base-chroot: fix license?

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 1f73f00d56d..d4614bf3f27 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -6,7 +6,7 @@ bootstrap=yes
 build_style=meta
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
-license="Public domain"
+license="Public Domain"
 homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in

From 0941fa44d521639ab1528879a7f514f1286f7fba Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 08:59:10 +0100
Subject: [PATCH 20/27] xbps-src: fix for x86_64 local multilib repos.

Found and fixed by @pullmoll
---
 common/xbps-src/shutils/chroot.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index b463278c29e..744b99a8a0c 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -226,7 +226,15 @@ chroot_sync_repodata() {
     sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
         > $confdir/10-repository-local.conf
 
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+    if [ "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            ;;
+        esac
+    else
         case "$XBPS_MACHINE" in
             *-musl)
                 install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \

From 0ec18a9d60504a890c44723ea6159e0918d1a34e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 09:01:29 +0100
Subject: [PATCH 21/27] travis/build.sh: use -E (and get rid of -f) while
 building base-chroot.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 916c25515d7..c6a71afb6be 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps

From d0decae241fd8ba9d608c80bec18378318e7666f Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:19:05 +0100
Subject: [PATCH 22/27] xbps-src: updated list of required host utils.

---
 xbps-src | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xbps-src b/xbps-src
index 50f2032deeb..1ba52432707 100755
--- a/xbps-src
+++ b/xbps-src
@@ -382,9 +382,9 @@ umask 022
 #
 # Required utilities in host system for the bootstrap target.
 readonly REQHOST_UTILS_BOOTSTRAP="make gawk bash bison sed gcc g++ msgfmt makeinfo \
-    perl tar xz gzip bzip2 patch flex automake libtool pkg-config"
+    perl bsdtar xz gzip bzip2 patch flock flex libtool pkg-config"
 
-# Required utilities in host system for chroot ops.
+# Required utilities in host.
 readonly REQHOST_UTILS="xbps-install xbps-query xbps-rindex xbps-uhelper \
     xbps-reconfigure xbps-remove xbps-create xbps-uchroot xbps-uunshare"
 

From c6d1da9777539539d66fcca2c3065688e087c408 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 07:47:43 +0100
Subject: [PATCH 23/27] .travis.yml: bump voidlinux docker tag.

Original commit in https://github.com/void-linux/void-packages/pull/18049
will be reverted after testing.

@the-maldridge
---
 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 5f4f30f85cd..13650b2bd31 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,7 +8,7 @@ env:
     global:
         - PATH=$PATH:/tmp/bin
         - DOCKER_BASE=voidlinux/masterdir
-        - TAG=2019102301
+        - TAG=20200104
 
     matrix:
         - XLINT=1 LICENSE_LIST=common/travis/license.lst

From 37470cfc1587478693d11890c935f4b544fb8a33 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 08:20:26 +0100
Subject: [PATCH 24/27] hooks: 00-distfiles.sh: detect bsdtar and then tar
 (GNU).

This way xbps-src is able to work with any of them.
---
 common/hooks/do-extract/00-distfiles.sh |  7 ++++++-
 common/hooks/do-fetch/00-distfiles.sh   | 17 ++++++++++++++---
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index 303fe27e0a1..d1f457edcc5 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -4,6 +4,7 @@
 hook() {
 	local srcdir="$XBPS_SRCDISTDIR/$pkgname-$version"
 	local f j curfile found extractdir
+	local TAR_CMD
 
 	if [ -z "$distfiles" -a -z "$checksum" ]; then
 		mkdir -p $wrksrc
@@ -23,6 +24,10 @@ hook() {
 		mkdir -p ${wrksrc} || msg_error "$pkgver: failed to create wrksrc.\n"
 	fi
 
+	TAR_CMD="$(command -v bsdtar)"
+	[ -z "$TAR_CMD" ] && TAR_CMD="$(command -v tar)"
+	[ -z "$TAR_CMD" ] && msg_error "xbps-src: no suitable tar cmd (bsdtar, tar)\n"
+
 	msg_normal "$pkgver: extracting distfile(s), please wait...\n"
 
 	for f in ${distfiles}; do
@@ -71,7 +76,7 @@ hook() {
 
 		case ${cursufx} in
 		tar|txz|tbz|tlz|tgz|crate)
-			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+			$TAR_CMD -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index 73239da1c73..db4f29c73a2 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
+		cksum=$($XBPS_DIGEST_CMD <($TAR_CMD xf "$curfile" $TAR_CMD_STDOUT))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -73,7 +73,7 @@ contents_cksum() {
 		;;
 	rpm)
 		if command -v rpmextract &>/dev/null; then
-			cksum=$($XBPS_DIGEST_CMD <(rpm2cpio "$curfile" | bsdtar xf - --to-stdout))
+			cksum=$($XBPS_DIGEST_CMD <(rpm2cpio "$curfile" | $TAR_CMD xf - $TAR_CMD_STDOUT))
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile to pipe.\n"
 			fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <($TAR_CMD -xf "$curfile" data.tar.gz $TAR_CMD_STDOUT | $TAR_CMD -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
@@ -210,6 +210,15 @@ hook() {
 	# Disable trap on ERR; the code is smart enough to report errors and abort.
 	trap - ERR
 
+	# Detect bsdtar and GNU tar (in that order of preference)
+	TAR_CMD="$(command -v bsdtar)"
+	if [ "$TAR_CMD" ]; then
+		TAR_CMD_STDOUT="--list"
+	else
+		TAR_CMD="$(command -v tar)"
+		TAR_CMD_STDOUT="--to-stdout"
+	fi
+
 	# Detect distfiles with obsolete checksum and purge them from the cache
 	for f in ${distfiles}; do
 		curfile="${f#*>}"
@@ -273,6 +282,8 @@ hook() {
 		dfcount=$((dfcount + 1))
 	done
 
+	unset TAR_CMD TAR_CMD_STDOUT
+
 	if [ $errors -gt 0 ]; then
 		msg_error "$pkgver: couldn't verify distfiles, exiting...\n"
 	fi

From 71b686118b44aedf234270e180de320125f4d341 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 08:24:52 +0100
Subject: [PATCH 25/27] hooks/do-extract: 00-distfiles.sh: disable trap on ERR.

---
 common/hooks/do-extract/00-distfiles.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index d1f457edcc5..8b0a5e0dc84 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -24,6 +24,9 @@ hook() {
 		mkdir -p ${wrksrc} || msg_error "$pkgver: failed to create wrksrc.\n"
 	fi
 
+	# Disable trap on ERR; the code is smart enough to report errors and abort.
+	trap - ERR
+
 	TAR_CMD="$(command -v bsdtar)"
 	[ -z "$TAR_CMD" ] && TAR_CMD="$(command -v tar)"
 	[ -z "$TAR_CMD" ] && msg_error "xbps-src: no suitable tar cmd (bsdtar, tar)\n"

From 043eaec32b64e56b9c8d09affefe380a15f8c0ff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 08:32:29 +0100
Subject: [PATCH 26/27] travis/build.sh: simplify logic

---
 common/travis/build.sh | 1 -
 1 file changed, 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c6a71afb6be..3a5da41a533 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -9,7 +9,6 @@ fi
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 6514d67b479b703b9ad226fe31813f21ae7d7614 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 09:44:14 +0100
Subject: [PATCH 27/27] README.md: update requirements.

---
 README.md | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 6870df7a9da..f9e8ab25486 100644
--- a/README.md
+++ b/README.md
@@ -15,10 +15,12 @@ for details of how to create source packages.
 ### Requirements
 
 - GNU bash
-- xbps >= 0.55
+- xbps >= 0.56
 - curl(1) - required by `xbps-src update-check`
 - flock(1) - util-linux
-- install(1) - coreutils
+- bsdtar or GNU tar (in that order of preference)
+- install(1) - GNU coreutils
+- objcopy(1), objdump(1), strip(1): binutils
 - other common POSIX utilities included by default in almost all UNIX systems.
 
 `xbps-src` requires a utility to chroot and bind mount existing directories

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (91 preceding siblings ...)
  2020-01-05  8:44 ` [PR PATCH] [Updated] " voidlinux-github
@ 2020-01-05  8:53 ` voidlinux-github
  2020-01-05  9:12 ` voidlinux-github
                   ` (4 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-05  8:53 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1946 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- update `base-chroot` deps before building any pkg.
- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Gets rid of `-I` to skip file conflicts while installing deps via `xbps-install(1)`.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 78189 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/28] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/28] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/28] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/28] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/28] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/28] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/28] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/28] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/28] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/28] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/28] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/28] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/28] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/28] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 88c135d6642a9e84d4042174889b487912aa1548 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:55:35 +0100
Subject: [PATCH 15/28] travis/build.sh: local repo path v2

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 7e679ecc843..09705565427 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 1dedb200d46899cddf3a94ba5d618c592e69fb85 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:58:19 +0100
Subject: [PATCH 16/28] travis/build.sh: also use xbps.d repos, to resolve
 missing deps.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 09705565427..c7049c260c6 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From b261543632c599c2c92a27d7a02ce04e382a5550 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:01:18 +0100
Subject: [PATCH 17/28] travis/build.sh: perform sysup before installing
 base-chroot.

---
 common/travis/build.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c7049c260c6..916c25515d7 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,6 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1

From b0140b84b7846c1ecb820da819fc50aefdb5383e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:06:53 +0100
Subject: [PATCH 18/28] tar: fix for ethereal chroot-style

---
 srcpkgs/tar/template | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 0a49caa7e91..2ec183c02f1 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -13,6 +13,8 @@ distfiles="${GNU_SITE}/tar/${pkgname}-${version}.tar.xz"
 checksum=d0d3ae07f103323be809bc3eac0dcc386d52c5262499fe05511ac4788af1fdd8
 
 pre_configure() {
+	# chroot-style=ethereal
+	export FORCE_UNSAFE_CONFIGURE=1
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }

From d34dc4783cabd6562e1a64cc09518d31b3c43119 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:12:04 +0100
Subject: [PATCH 19/28] base-chroot: fix license?

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 1f73f00d56d..d4614bf3f27 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -6,7 +6,7 @@ bootstrap=yes
 build_style=meta
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
-license="Public domain"
+license="Public Domain"
 homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in

From 0941fa44d521639ab1528879a7f514f1286f7fba Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 08:59:10 +0100
Subject: [PATCH 20/28] xbps-src: fix for x86_64 local multilib repos.

Found and fixed by @pullmoll
---
 common/xbps-src/shutils/chroot.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index b463278c29e..744b99a8a0c 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -226,7 +226,15 @@ chroot_sync_repodata() {
     sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
         > $confdir/10-repository-local.conf
 
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+    if [ "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            ;;
+        esac
+    else
         case "$XBPS_MACHINE" in
             *-musl)
                 install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \

From 0ec18a9d60504a890c44723ea6159e0918d1a34e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 09:01:29 +0100
Subject: [PATCH 21/28] travis/build.sh: use -E (and get rid of -f) while
 building base-chroot.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 916c25515d7..c6a71afb6be 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps

From d0decae241fd8ba9d608c80bec18378318e7666f Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:19:05 +0100
Subject: [PATCH 22/28] xbps-src: updated list of required host utils.

---
 xbps-src | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xbps-src b/xbps-src
index 50f2032deeb..1ba52432707 100755
--- a/xbps-src
+++ b/xbps-src
@@ -382,9 +382,9 @@ umask 022
 #
 # Required utilities in host system for the bootstrap target.
 readonly REQHOST_UTILS_BOOTSTRAP="make gawk bash bison sed gcc g++ msgfmt makeinfo \
-    perl tar xz gzip bzip2 patch flex automake libtool pkg-config"
+    perl bsdtar xz gzip bzip2 patch flock flex libtool pkg-config"
 
-# Required utilities in host system for chroot ops.
+# Required utilities in host.
 readonly REQHOST_UTILS="xbps-install xbps-query xbps-rindex xbps-uhelper \
     xbps-reconfigure xbps-remove xbps-create xbps-uchroot xbps-uunshare"
 

From c6d1da9777539539d66fcca2c3065688e087c408 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 07:47:43 +0100
Subject: [PATCH 23/28] .travis.yml: bump voidlinux docker tag.

Original commit in https://github.com/void-linux/void-packages/pull/18049
will be reverted after testing.

@the-maldridge
---
 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 5f4f30f85cd..13650b2bd31 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,7 +8,7 @@ env:
     global:
         - PATH=$PATH:/tmp/bin
         - DOCKER_BASE=voidlinux/masterdir
-        - TAG=2019102301
+        - TAG=20200104
 
     matrix:
         - XLINT=1 LICENSE_LIST=common/travis/license.lst

From 37470cfc1587478693d11890c935f4b544fb8a33 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 08:20:26 +0100
Subject: [PATCH 24/28] hooks: 00-distfiles.sh: detect bsdtar and then tar
 (GNU).

This way xbps-src is able to work with any of them.
---
 common/hooks/do-extract/00-distfiles.sh |  7 ++++++-
 common/hooks/do-fetch/00-distfiles.sh   | 17 ++++++++++++++---
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index 303fe27e0a1..d1f457edcc5 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -4,6 +4,7 @@
 hook() {
 	local srcdir="$XBPS_SRCDISTDIR/$pkgname-$version"
 	local f j curfile found extractdir
+	local TAR_CMD
 
 	if [ -z "$distfiles" -a -z "$checksum" ]; then
 		mkdir -p $wrksrc
@@ -23,6 +24,10 @@ hook() {
 		mkdir -p ${wrksrc} || msg_error "$pkgver: failed to create wrksrc.\n"
 	fi
 
+	TAR_CMD="$(command -v bsdtar)"
+	[ -z "$TAR_CMD" ] && TAR_CMD="$(command -v tar)"
+	[ -z "$TAR_CMD" ] && msg_error "xbps-src: no suitable tar cmd (bsdtar, tar)\n"
+
 	msg_normal "$pkgver: extracting distfile(s), please wait...\n"
 
 	for f in ${distfiles}; do
@@ -71,7 +76,7 @@ hook() {
 
 		case ${cursufx} in
 		tar|txz|tbz|tlz|tgz|crate)
-			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+			$TAR_CMD -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index 73239da1c73..db4f29c73a2 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
+		cksum=$($XBPS_DIGEST_CMD <($TAR_CMD xf "$curfile" $TAR_CMD_STDOUT))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -73,7 +73,7 @@ contents_cksum() {
 		;;
 	rpm)
 		if command -v rpmextract &>/dev/null; then
-			cksum=$($XBPS_DIGEST_CMD <(rpm2cpio "$curfile" | bsdtar xf - --to-stdout))
+			cksum=$($XBPS_DIGEST_CMD <(rpm2cpio "$curfile" | $TAR_CMD xf - $TAR_CMD_STDOUT))
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile to pipe.\n"
 			fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <($TAR_CMD -xf "$curfile" data.tar.gz $TAR_CMD_STDOUT | $TAR_CMD -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
@@ -210,6 +210,15 @@ hook() {
 	# Disable trap on ERR; the code is smart enough to report errors and abort.
 	trap - ERR
 
+	# Detect bsdtar and GNU tar (in that order of preference)
+	TAR_CMD="$(command -v bsdtar)"
+	if [ "$TAR_CMD" ]; then
+		TAR_CMD_STDOUT="--list"
+	else
+		TAR_CMD="$(command -v tar)"
+		TAR_CMD_STDOUT="--to-stdout"
+	fi
+
 	# Detect distfiles with obsolete checksum and purge them from the cache
 	for f in ${distfiles}; do
 		curfile="${f#*>}"
@@ -273,6 +282,8 @@ hook() {
 		dfcount=$((dfcount + 1))
 	done
 
+	unset TAR_CMD TAR_CMD_STDOUT
+
 	if [ $errors -gt 0 ]; then
 		msg_error "$pkgver: couldn't verify distfiles, exiting...\n"
 	fi

From 71b686118b44aedf234270e180de320125f4d341 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 08:24:52 +0100
Subject: [PATCH 25/28] hooks/do-extract: 00-distfiles.sh: disable trap on ERR.

---
 common/hooks/do-extract/00-distfiles.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index d1f457edcc5..8b0a5e0dc84 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -24,6 +24,9 @@ hook() {
 		mkdir -p ${wrksrc} || msg_error "$pkgver: failed to create wrksrc.\n"
 	fi
 
+	# Disable trap on ERR; the code is smart enough to report errors and abort.
+	trap - ERR
+
 	TAR_CMD="$(command -v bsdtar)"
 	[ -z "$TAR_CMD" ] && TAR_CMD="$(command -v tar)"
 	[ -z "$TAR_CMD" ] && msg_error "xbps-src: no suitable tar cmd (bsdtar, tar)\n"

From 043eaec32b64e56b9c8d09affefe380a15f8c0ff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 08:32:29 +0100
Subject: [PATCH 26/28] travis/build.sh: simplify logic

---
 common/travis/build.sh | 1 -
 1 file changed, 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c6a71afb6be..3a5da41a533 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -9,7 +9,6 @@ fi
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 6514d67b479b703b9ad226fe31813f21ae7d7614 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 09:44:14 +0100
Subject: [PATCH 27/28] README.md: update requirements.

---
 README.md | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 6870df7a9da..f9e8ab25486 100644
--- a/README.md
+++ b/README.md
@@ -15,10 +15,12 @@ for details of how to create source packages.
 ### Requirements
 
 - GNU bash
-- xbps >= 0.55
+- xbps >= 0.56
 - curl(1) - required by `xbps-src update-check`
 - flock(1) - util-linux
-- install(1) - coreutils
+- bsdtar or GNU tar (in that order of preference)
+- install(1) - GNU coreutils
+- objcopy(1), objdump(1), strip(1): binutils
 - other common POSIX utilities included by default in almost all UNIX systems.
 
 `xbps-src` requires a utility to chroot and bind mount existing directories

From 9af92d22bfb52738b36478448036a92e999d71af Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 09:53:14 +0100
Subject: [PATCH 28/28] xbps-src/chroot.sh: silence grep output

---
 common/xbps-src/shutils/chroot.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 744b99a8a0c..d3951a395ad 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -51,7 +51,7 @@ update_base_chroot() {
     [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
     msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
     # no need to sync repodata, chroot_sync_repodata() does it for us.
-    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep -q xbps); then
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (92 preceding siblings ...)
  2020-01-05  8:53 ` voidlinux-github
@ 2020-01-05  9:12 ` voidlinux-github
  2020-01-05  9:25 ` voidlinux-github
                   ` (3 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-05  9:12 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1946 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- update `base-chroot` deps before building any pkg.
- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Gets rid of `-I` to skip file conflicts while installing deps via `xbps-install(1)`.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 79144 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/29] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/29] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/29] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/29] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/29] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/29] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/29] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/29] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/29] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/29] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/29] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/29] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/29] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/29] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 88c135d6642a9e84d4042174889b487912aa1548 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:55:35 +0100
Subject: [PATCH 15/29] travis/build.sh: local repo path v2

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 7e679ecc843..09705565427 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 1dedb200d46899cddf3a94ba5d618c592e69fb85 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:58:19 +0100
Subject: [PATCH 16/29] travis/build.sh: also use xbps.d repos, to resolve
 missing deps.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 09705565427..c7049c260c6 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From b261543632c599c2c92a27d7a02ce04e382a5550 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:01:18 +0100
Subject: [PATCH 17/29] travis/build.sh: perform sysup before installing
 base-chroot.

---
 common/travis/build.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c7049c260c6..916c25515d7 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,6 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1

From b0140b84b7846c1ecb820da819fc50aefdb5383e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:06:53 +0100
Subject: [PATCH 18/29] tar: fix for ethereal chroot-style

---
 srcpkgs/tar/template | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 0a49caa7e91..2ec183c02f1 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -13,6 +13,8 @@ distfiles="${GNU_SITE}/tar/${pkgname}-${version}.tar.xz"
 checksum=d0d3ae07f103323be809bc3eac0dcc386d52c5262499fe05511ac4788af1fdd8
 
 pre_configure() {
+	# chroot-style=ethereal
+	export FORCE_UNSAFE_CONFIGURE=1
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }

From d34dc4783cabd6562e1a64cc09518d31b3c43119 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:12:04 +0100
Subject: [PATCH 19/29] base-chroot: fix license?

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 1f73f00d56d..d4614bf3f27 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -6,7 +6,7 @@ bootstrap=yes
 build_style=meta
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
-license="Public domain"
+license="Public Domain"
 homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in

From 0941fa44d521639ab1528879a7f514f1286f7fba Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 08:59:10 +0100
Subject: [PATCH 20/29] xbps-src: fix for x86_64 local multilib repos.

Found and fixed by @pullmoll
---
 common/xbps-src/shutils/chroot.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index b463278c29e..744b99a8a0c 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -226,7 +226,15 @@ chroot_sync_repodata() {
     sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
         > $confdir/10-repository-local.conf
 
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+    if [ "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            ;;
+        esac
+    else
         case "$XBPS_MACHINE" in
             *-musl)
                 install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \

From 0ec18a9d60504a890c44723ea6159e0918d1a34e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 09:01:29 +0100
Subject: [PATCH 21/29] travis/build.sh: use -E (and get rid of -f) while
 building base-chroot.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 916c25515d7..c6a71afb6be 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps

From d0decae241fd8ba9d608c80bec18378318e7666f Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:19:05 +0100
Subject: [PATCH 22/29] xbps-src: updated list of required host utils.

---
 xbps-src | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xbps-src b/xbps-src
index 50f2032deeb..1ba52432707 100755
--- a/xbps-src
+++ b/xbps-src
@@ -382,9 +382,9 @@ umask 022
 #
 # Required utilities in host system for the bootstrap target.
 readonly REQHOST_UTILS_BOOTSTRAP="make gawk bash bison sed gcc g++ msgfmt makeinfo \
-    perl tar xz gzip bzip2 patch flex automake libtool pkg-config"
+    perl bsdtar xz gzip bzip2 patch flock flex libtool pkg-config"
 
-# Required utilities in host system for chroot ops.
+# Required utilities in host.
 readonly REQHOST_UTILS="xbps-install xbps-query xbps-rindex xbps-uhelper \
     xbps-reconfigure xbps-remove xbps-create xbps-uchroot xbps-uunshare"
 

From c6d1da9777539539d66fcca2c3065688e087c408 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 07:47:43 +0100
Subject: [PATCH 23/29] .travis.yml: bump voidlinux docker tag.

Original commit in https://github.com/void-linux/void-packages/pull/18049
will be reverted after testing.

@the-maldridge
---
 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 5f4f30f85cd..13650b2bd31 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,7 +8,7 @@ env:
     global:
         - PATH=$PATH:/tmp/bin
         - DOCKER_BASE=voidlinux/masterdir
-        - TAG=2019102301
+        - TAG=20200104
 
     matrix:
         - XLINT=1 LICENSE_LIST=common/travis/license.lst

From 37470cfc1587478693d11890c935f4b544fb8a33 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 08:20:26 +0100
Subject: [PATCH 24/29] hooks: 00-distfiles.sh: detect bsdtar and then tar
 (GNU).

This way xbps-src is able to work with any of them.
---
 common/hooks/do-extract/00-distfiles.sh |  7 ++++++-
 common/hooks/do-fetch/00-distfiles.sh   | 17 ++++++++++++++---
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index 303fe27e0a1..d1f457edcc5 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -4,6 +4,7 @@
 hook() {
 	local srcdir="$XBPS_SRCDISTDIR/$pkgname-$version"
 	local f j curfile found extractdir
+	local TAR_CMD
 
 	if [ -z "$distfiles" -a -z "$checksum" ]; then
 		mkdir -p $wrksrc
@@ -23,6 +24,10 @@ hook() {
 		mkdir -p ${wrksrc} || msg_error "$pkgver: failed to create wrksrc.\n"
 	fi
 
+	TAR_CMD="$(command -v bsdtar)"
+	[ -z "$TAR_CMD" ] && TAR_CMD="$(command -v tar)"
+	[ -z "$TAR_CMD" ] && msg_error "xbps-src: no suitable tar cmd (bsdtar, tar)\n"
+
 	msg_normal "$pkgver: extracting distfile(s), please wait...\n"
 
 	for f in ${distfiles}; do
@@ -71,7 +76,7 @@ hook() {
 
 		case ${cursufx} in
 		tar|txz|tbz|tlz|tgz|crate)
-			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+			$TAR_CMD -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index 73239da1c73..db4f29c73a2 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
+		cksum=$($XBPS_DIGEST_CMD <($TAR_CMD xf "$curfile" $TAR_CMD_STDOUT))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -73,7 +73,7 @@ contents_cksum() {
 		;;
 	rpm)
 		if command -v rpmextract &>/dev/null; then
-			cksum=$($XBPS_DIGEST_CMD <(rpm2cpio "$curfile" | bsdtar xf - --to-stdout))
+			cksum=$($XBPS_DIGEST_CMD <(rpm2cpio "$curfile" | $TAR_CMD xf - $TAR_CMD_STDOUT))
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile to pipe.\n"
 			fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <($TAR_CMD -xf "$curfile" data.tar.gz $TAR_CMD_STDOUT | $TAR_CMD -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
@@ -210,6 +210,15 @@ hook() {
 	# Disable trap on ERR; the code is smart enough to report errors and abort.
 	trap - ERR
 
+	# Detect bsdtar and GNU tar (in that order of preference)
+	TAR_CMD="$(command -v bsdtar)"
+	if [ "$TAR_CMD" ]; then
+		TAR_CMD_STDOUT="--list"
+	else
+		TAR_CMD="$(command -v tar)"
+		TAR_CMD_STDOUT="--to-stdout"
+	fi
+
 	# Detect distfiles with obsolete checksum and purge them from the cache
 	for f in ${distfiles}; do
 		curfile="${f#*>}"
@@ -273,6 +282,8 @@ hook() {
 		dfcount=$((dfcount + 1))
 	done
 
+	unset TAR_CMD TAR_CMD_STDOUT
+
 	if [ $errors -gt 0 ]; then
 		msg_error "$pkgver: couldn't verify distfiles, exiting...\n"
 	fi

From 71b686118b44aedf234270e180de320125f4d341 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 08:24:52 +0100
Subject: [PATCH 25/29] hooks/do-extract: 00-distfiles.sh: disable trap on ERR.

---
 common/hooks/do-extract/00-distfiles.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index d1f457edcc5..8b0a5e0dc84 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -24,6 +24,9 @@ hook() {
 		mkdir -p ${wrksrc} || msg_error "$pkgver: failed to create wrksrc.\n"
 	fi
 
+	# Disable trap on ERR; the code is smart enough to report errors and abort.
+	trap - ERR
+
 	TAR_CMD="$(command -v bsdtar)"
 	[ -z "$TAR_CMD" ] && TAR_CMD="$(command -v tar)"
 	[ -z "$TAR_CMD" ] && msg_error "xbps-src: no suitable tar cmd (bsdtar, tar)\n"

From 043eaec32b64e56b9c8d09affefe380a15f8c0ff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 08:32:29 +0100
Subject: [PATCH 26/29] travis/build.sh: simplify logic

---
 common/travis/build.sh | 1 -
 1 file changed, 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c6a71afb6be..3a5da41a533 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -9,7 +9,6 @@ fi
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 6514d67b479b703b9ad226fe31813f21ae7d7614 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 09:44:14 +0100
Subject: [PATCH 27/29] README.md: update requirements.

---
 README.md | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 6870df7a9da..f9e8ab25486 100644
--- a/README.md
+++ b/README.md
@@ -15,10 +15,12 @@ for details of how to create source packages.
 ### Requirements
 
 - GNU bash
-- xbps >= 0.55
+- xbps >= 0.56
 - curl(1) - required by `xbps-src update-check`
 - flock(1) - util-linux
-- install(1) - coreutils
+- bsdtar or GNU tar (in that order of preference)
+- install(1) - GNU coreutils
+- objcopy(1), objdump(1), strip(1): binutils
 - other common POSIX utilities included by default in almost all UNIX systems.
 
 `xbps-src` requires a utility to chroot and bind mount existing directories

From 9af92d22bfb52738b36478448036a92e999d71af Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 09:53:14 +0100
Subject: [PATCH 28/29] xbps-src/chroot.sh: silence grep output

---
 common/xbps-src/shutils/chroot.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 744b99a8a0c..d3951a395ad 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -51,7 +51,7 @@ update_base_chroot() {
     [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
     msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
     # no need to sync repodata, chroot_sync_repodata() does it for us.
-    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep -q xbps); then
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"

From 3c5468c0f109f6ab57cc4e4dc2fee0e5c64647de Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 10:11:30 +0100
Subject: [PATCH 29/29] travis/build.sh: xbps-src takes care of everything now.

Also this file does not contain any bashism, so use /bin/sh.
---
 common/travis/build.sh | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 3a5da41a533..7732211a59e 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # build.sh
 
@@ -6,12 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-# remove autodeps
-xbps-remove -yo || exit 1
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (93 preceding siblings ...)
  2020-01-05  9:12 ` voidlinux-github
@ 2020-01-05  9:25 ` voidlinux-github
  2020-01-05  9:36 ` voidlinux-github
                   ` (2 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-05  9:25 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1946 bytes --]

There is an updated pull request by xtraeme against master on the void-packages repository

https://github.com/xtraeme/void-packages base-chroot-v2
https://github.com/void-linux/void-packages/pull/17969

xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- update `base-chroot` deps before building any pkg.
- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Gets rid of `-I` to skip file conflicts while installing deps via `xbps-install(1)`.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

A patch file from https://github.com/void-linux/void-packages/pull/17969.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-base-chroot-v2-17969.patch --]
[-- Type: text/x-diff, Size: 80837 bytes --]

From 88b70eebdb444b7056a6d3dc7398e2c0562c037d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:15:35 +0100
Subject: [PATCH 01/30] xbps-src: base-chroot-v2 (reduce artifacts/deps)

This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
---
 .gitignore                                    |   2 +-
 common/hooks/do-extract/00-distfiles.sh       |  10 +-
 common/hooks/do-fetch/00-distfiles.sh         |   4 +-
 common/xbps-src/libexec/build.sh              |  16 --
 common/xbps-src/libexec/xbps-src-dopatch.sh   |   4 -
 common/xbps-src/shutils/build_dependencies.sh |  33 +--
 common/xbps-src/shutils/bulk.sh               |   2 +-
 common/xbps-src/shutils/chroot.sh             | 254 ++++++++++++------
 common/xbps-src/shutils/common.sh             |  79 +++---
 common/xbps-src/shutils/cross.sh              |  29 +-
 etc/defaults.conf                             |  17 +-
 etc/repos-remote.conf                         |  13 -
 etc/xbps.conf                                 |   1 -
 etc/{ => xbps.d}/repos-local-x86_64.conf      |   3 +-
 etc/{ => xbps.d}/repos-local.conf             |   1 +
 etc/xbps.d/repos-remote-aarch64.conf          |   4 +
 etc/xbps.d/repos-remote-musl.conf             |   4 +
 etc/{ => xbps.d}/repos-remote-x86_64.conf     |   2 +-
 etc/xbps.d/repos-remote.conf                  |   4 +
 srcpkgs/base-chroot-musl/template             |  21 --
 srcpkgs/base-chroot/template                  |  24 +-
 srcpkgs/chroot-texinfo/template               |  39 ---
 srcpkgs/gettext/template                      |   3 +-
 srcpkgs/tar/template                          |   1 -
 srcpkgs/texinfo/template                      |   4 +-
 xbps-src                                      | 107 ++------
 26 files changed, 325 insertions(+), 356 deletions(-)
 delete mode 100644 etc/repos-remote.conf
 delete mode 100644 etc/xbps.conf
 rename etc/{ => xbps.d}/repos-local-x86_64.conf (57%)
 rename etc/{ => xbps.d}/repos-local.conf (82%)
 create mode 100644 etc/xbps.d/repos-remote-aarch64.conf
 create mode 100644 etc/xbps.d/repos-remote-musl.conf
 rename etc/{ => xbps.d}/repos-remote-x86_64.conf (74%)
 create mode 100644 etc/xbps.d/repos-remote.conf
 delete mode 100644 srcpkgs/base-chroot-musl/template
 delete mode 100644 srcpkgs/chroot-texinfo/template

diff --git a/.gitignore b/.gitignore
index 591b3507593..8721a8b702f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ masterdir*
 hostdir*
 etc/conf
 etc/virtual
-.xbps-checkvers.plist
+.xbps-checkvers*.plist
diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c1eacf47009..303fe27e0a1 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -70,8 +70,8 @@ hook() {
 		fi
 
 		case ${cursufx} in
-		txz|tbz|tlz|tgz|crate)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+		tar|txz|tbz|tlz|tgz|crate)
+			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
@@ -84,12 +84,6 @@ hook() {
 				cd $extractdir && bunzip2 -f $curfile
 			fi
 			;;
-		tar)
-			tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
-			if [ $? -ne 0 ]; then
-				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
-			fi
-			;;
 		zip)
 			if command -v unzip &>/dev/null; then
 				unzip -o -q $srcdir/$curfile -d $extractdir
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index e2220789c59..73239da1c73 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(tar xf "$curfile" --to-stdout))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(tar -xf "$curfile" data.tar.gz --to-stdout | tar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 024bb11d18b..cba71fbacad 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -129,20 +129,4 @@ if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
     remove_pkg_statedir
 fi
 
-# If base-chroot not installed, install "base-files" into masterdir
-# from local repository; this is the only pkg required to be able to build
-# the bootstrap pkgs from scratch.
-if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then
-    msg_normal "Installing $PKGNAME into masterdir...\n"
-    _log=$(mktemp) || exit 1
-    XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1
-    if [ $? -ne 0 ]; then
-        msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n"
-        cat ${_log}
-        rm -f ${_log}
-        msg_error "Cannot continue!\n"
-    fi
-    rm -f ${_log}
-fi
-
 exit 0
diff --git a/common/xbps-src/libexec/xbps-src-dopatch.sh b/common/xbps-src/libexec/xbps-src-dopatch.sh
index a83acd88a84..c1b3b0468d4 100755
--- a/common/xbps-src/libexec/xbps-src-dopatch.sh
+++ b/common/xbps-src/libexec/xbps-src-dopatch.sh
@@ -20,10 +20,6 @@ done
 
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 
-for f in $XBPS_COMMONDIR/environment/patch/*.sh; do
-    source_file "$f"
-done
-
 XBPS_PATCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_patch_done"
 
 if [ -f $XBPS_PATCH_DONE ]; then
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 1c25da38dc6..5751a6cf584 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -43,10 +43,9 @@ setup_pkg_depends() {
 #
 # Install required package dependencies, like:
 #
-#	xbps-install -AIy <pkgs>
+#	xbps-install -Ay <pkgs>
 #
 #       -A automatic mode
-#       -I to ignore file conflicts
 #       -y yes
 #
 # Returns 0 if package already installed or installed successfully.
@@ -56,10 +55,12 @@ setup_pkg_depends() {
 # ENOENT   (2): package missing in repositories.
 # ENXIO    (6): package depends on invalid dependencies.
 # EAGAIN  (11): package conflicts.
+# EBUSY   (16): package 'xbps' needs to be updated.
 # EEXIST  (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
 # ENODEV  (19): package depends on missing dependencies.
 # ENOTSUP (95): no repositories registered.
-#
+# -1     (255): unexpected error.
+
 install_pkg_from_repos() {
     local cross="$1" rval tmplogf cmd
     shift
@@ -71,7 +72,7 @@ install_pkg_from_repos() {
 
     cmd=$XBPS_INSTALL_CMD
     [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
-    $cmd -AIy "$@" >$tmplogf 2>&1
+    $cmd -Ay "$@" >$tmplogf 2>&1
     rval=$?
 
     case "$rval" in
@@ -137,9 +138,9 @@ install_pkg_deps() {
     done
 
     if [ "$pkg" != "$targetpkg" ]; then
-        msg_normal "$pkgver: building${style} (dependency of $targetpkg) ...\n"
+        msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
     else
-        msg_normal "$pkgver: building${style} ...\n"
+        msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
     fi
 
     #
@@ -189,7 +190,7 @@ install_pkg_deps() {
                 echo "   [host] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -239,7 +240,7 @@ install_pkg_deps() {
                 echo "   [check] ${_vpkg}: not found"
                 host_missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${templates})
+        done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
     fi
 
     #
@@ -253,7 +254,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 binpkg_deps+=("$f")
@@ -289,7 +290,7 @@ install_pkg_deps() {
                 echo "   [target] ${_vpkg}: not found"
                 missing_deps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     #
@@ -303,7 +304,7 @@ install_pkg_deps() {
                 templates+=" $f"
                 continue
             fi
-            local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
+            local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
             if [ "$_repourl" ]; then
                 echo "   [target] ${f}: found (${_repourl})"
                 continue
@@ -337,7 +338,7 @@ install_pkg_deps() {
                 echo "   [runtime] ${_vpkg}: not found"
                 missing_rdeps+=("$_vpkg")
             fi
-        done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $templates)
+        done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
     fi
 
     if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
@@ -359,8 +360,8 @@ install_pkg_deps() {
         curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
         setup_pkg $curpkgdepname
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
-            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
-        ) || exit $?
+            $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
+        ) || msg_error "xbps-src: failed to build host dependency '$i' ($?)\n"
         host_binpkg_deps+=("$i")
     done
 
@@ -373,7 +374,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
         binpkg_deps+=("$i")
     done
 
@@ -391,7 +392,7 @@ install_pkg_deps() {
         setup_pkg $curpkgdepname $cross
         exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
             $XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
-        ) || exit $?
+        ) || msg_error "xbps-src: failed to build target dependency '$i' ($?)\n"
     done
 
     if [[ ${host_binpkg_deps} ]]; then
diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh
index f19b12f6006..2b8afb36b55 100644
--- a/common/xbps-src/shutils/bulk.sh
+++ b/common/xbps-src/shutils/bulk.sh
@@ -115,6 +115,6 @@ bulk_update() {
     if [ -n "$pkgs" -a -n "$args" ]; then
         echo
         msg_normal "xbps-src: updating your system, confirm to proceed...\n"
-        ${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}" || return 1
+        ${XBPS_SUCMD} "$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -u ${pkgs}" || return 1
     fi
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8eac338a733..fcb0c4a04cc 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -1,5 +1,62 @@
 # vim: set ts=4 sw=4 et:
 
+install_base_chroot() {
+    [ "$CHROOT_READY" ] && return
+    chroot_sync_repodata
+    if [ "$1" = "bootstrap" ]; then
+        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
+    else
+        XBPS_TARGET_PKG="$1"
+    fi
+    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
+    # 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"
+    fi
+    ${_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
+    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_check
+    chroot_handler clean
+}
+
+reconfigure_base_chroot() {
+    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
+    local pkgs="glibc-locales ca-certificates"
+    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
+    # Reconfigure ca-certificates.
+    msg_normal "xbps-src: reconfiguring base-chroot...\n"
+    for f in ${pkgs}; do
+        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
+            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
+        fi
+    done
+    touch -f $statefile
+}
+
+update_base_chroot() {
+    [ -z "$CHROOT_READY" ] && return
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
+    msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
+    # no need to sync repodata, chroot_sync_repodata() does it for us.
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+        ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
+    fi
+    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+}
+
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
 # It is set in common/build-profiles/bootstrap.sh but lost somewhere?
 chroot_init() {
@@ -36,26 +93,7 @@ exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DI
 _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
-
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
-
-    # Update xbps alternative repository if set.
-    mkdir -p $XBPS_MASTERDIR/etc/xbps.d
-    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
-        ( \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
-            echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
-            ) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        if [ "$XBPS_MACHINE" = "x86_64" ]; then
-            ( \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
-                echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
-            ) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-        fi
-    else
-        rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
-    fi
 }
 
 chroot_prepare() {
@@ -90,8 +128,6 @@ chroot_prepare() {
 
     mkdir -p $XBPS_MASTERDIR/etc/xbps.d
     echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
-    ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
 
     # Prepare default locale: en_US.UTF-8.
     if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
@@ -104,62 +140,11 @@ chroot_prepare() {
     return 0
 }
 
-chroot_sync_repos() {
-    local f=
-
-    # Copy xbps configuration files to the masterdir.
-    install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
-    install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
-        ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-
-    if [ "$XBPS_MACHINE" = "x86_64" ]; then
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
-        install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
-            ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # if -N is set, get rid of remote repos from x86_64 (glibc).
-    if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
-        rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
-    fi
-
-    # Copy host repos to the cross root.
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
-        rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
-    fi
-
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-        # Make sure to sync index for remote repositories.
-        xbps-install -r $XBPS_MASTERDIR -S
-    fi
-
-    if [ -n "$XBPS_CROSS_BUILD" ]; then
-        # Copy host keys to the target rootdir.
-        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
-            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
-        # Make sure to sync index for remote repositories.
-        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
-            env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
-                xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
-        fi
-    fi
-
-    return 0
-}
-
 chroot_handler() {
     local action="$1" pkg="$2" rv=0 arg= _envargs=
 
+    [ -z "$action" -a -z "$pkg" ] && return 1
+
     if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
         return 0
     fi
@@ -167,13 +152,10 @@ chroot_handler() {
         mkdir -p $XBPS_MASTERDIR/void-packages
     fi
 
-    [ -z "$action" -a -z "$pkg" ] && return 1
-
     case "$action" in
         fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
             chroot_prepare || return $?
             chroot_init || return $?
-            chroot_sync_repos || return $?
             ;;
     esac
 
@@ -200,3 +182,121 @@ chroot_handler() {
 
     return $rv
 }
+
+chroot_sync_repodata() {
+    local f= hostdir= confdir= crossconfdir=
+
+    # always start with an empty xbps.d
+    confdir=$XBPS_MASTERDIR/etc/xbps.d
+    crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+
+    [ -d $confdir ] && rm -rf $confdir
+
+    if [ "$CHROOT_READY" ]; then
+        hostdir=/host
+    else
+        hostdir=$XBPS_HOSTDIR
+    fi
+
+    # Update xbps alternative repository if set.
+    mkdir -p $confdir
+    if [ -n "$XBPS_ALT_REPOSITORY" ]; then
+        ( \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
+            echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
+            ) > $confdir/00-repository-alt-local.conf
+        if [ "$XBPS_MACHINE" = "x86_64" ]; then
+            ( \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
+                echo "repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
+            ) >> $confdir/00-repository-alt-local.conf
+        fi
+    else
+        rm -f $confdir/00-repository-alt-local.conf
+    fi
+
+    # Disable 00-repository-main.conf from share/xbps.d (part of xbps)
+    ln -s /dev/null $confdir/00-repository-main.conf
+
+    # Generate xbps.d(5) configuration files for repositories
+    sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
+        > $confdir/10-repository-local.conf
+
+    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            *-musl)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+            *)
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $confdir/20-repository-remote.conf
+                ;;
+        esac
+        case "$XBPS_MACHINE" in
+        x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-x86_64.conf \
+                $confdir/22-repository-remote-x86_64.conf
+            ;;
+        aarch64*)
+            # aarch64 glibc/musl
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                $confdir/22-repository-remote-aarch64.conf
+            ;;
+        esac
+    fi
+
+    # Copy host repos to the cross root.
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        # copy xbps.d files from host for local repos
+        cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
+        if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+            # and then remote repos for target machine
+            case "$XBPS_TARGET_MACHINE" in
+            aarch64*)
+                # aarch64 glibc/musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-aarch64.conf \
+                    $crossconfdir/22-repository-remote-aarch64.conf
+                ;;
+            *-musl)
+                # !aarch64 && musl
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            *)
+                # !aarch64 && glibc
+                install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote.conf \
+                    $crossconfdir/20-repository-remote.conf
+                ;;
+            esac
+        fi
+    fi
+
+    # Copy xbps repository keys to the masterdir.
+    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
+    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
+
+    # Make sure to sync index for remote repositories.
+    msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
+    xbps-install -r $XBPS_MASTERDIR -S
+
+    if [ -n "$XBPS_CROSS_BUILD" ]; then
+        # Copy host keys to the target rootdir.
+        mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
+            $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
+        # Make sure to sync index for remote repositories.
+        msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
+        env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
+            xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
+    fi
+
+    return 0
+}
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 952221d8937..5ca4d7132de 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -28,43 +28,43 @@ run_func() {
 }
 
 ch_wrksrc() {
-  cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
-  if [ -n "$build_wrksrc" ]; then
-    cd $build_wrksrc || \
-        msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
-  fi
+    cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
+    if [ -n "$build_wrksrc" ]; then
+        cd $build_wrksrc || \
+            msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
+    fi
 }
 
 # runs {pre,do,post}_X tripplets
 run_step() {
-  local step_name="$1" optional_step="$2" skip_post_hook="$3"
+    local step_name="$1" optional_step="$2" skip_post_hook="$3"
 
-  ch_wrksrc
-  run_pkg_hooks "pre-$step_name"
+    ch_wrksrc
+    run_pkg_hooks "pre-$step_name"
 
   # Run pre_* Phase
   if declare -f "pre_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "pre_$step_name"
+      ch_wrksrc
+      run_func "pre_$step_name"
   fi
 
   ch_wrksrc
   # Run do_* Phase
   if declare -f "do_$step_name" >/dev/null; then
-    run_func "do_$step_name"
+      run_func "do_$step_name"
   elif [ -n "$build_style" ]; then
-    if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
-      . $XBPS_BUILDSTYLEDIR/${build_style}.sh
-      if declare -f "do_$step_name" >/dev/null; then
-        run_func "do_$step_name"
-      elif [ ! "$optional_step" ]; then
-        msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+      if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
+          . $XBPS_BUILDSTYLEDIR/${build_style}.sh
+          if declare -f "do_$step_name" >/dev/null; then
+              run_func "do_$step_name"
+          elif [ ! "$optional_step" ]; then
+              msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
+          fi
+      else
+          msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
       fi
-    else
-      msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
-    fi
   elif [ ! "$optional_step" ]; then
-    msg_error "$pkgver: cannot find do_$step_name()!\n"
+      msg_error "$pkgver: cannot find do_$step_name()!\n"
   fi
 
   # Run do_ phase hooks
@@ -72,13 +72,13 @@ run_step() {
 
   # Run post_* Phase
   if declare -f "post_$step_name" >/dev/null; then
-    ch_wrksrc
-    run_func "post_$step_name"
+      ch_wrksrc
+      run_func "post_$step_name"
   fi
 
   if ! [ "$skip_post_hook" ]; then
-    ch_wrksrc
-    run_pkg_hooks "post-$step_name"
+      ch_wrksrc
+      run_pkg_hooks "post-$step_name"
   fi
 }
 
@@ -171,8 +171,8 @@ set_build_options() {
         OIFS="$IFS"; IFS=','
         for j in ${pkgopts}; do
             case "$j" in
-            "$f") options[$j]=1 ;;
-            "~$f") options[${j#\~}]=0 ;;
+                "$f") options[$j]=1 ;;
+                "~$f") options[${j#\~}]=0 ;;
             esac
         done
         IFS="$OIFS"
@@ -239,9 +239,9 @@ unset_package_funcs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            unset -f "$f"
-            ;;
+            *_package)
+                unset -f "$f"
+                ;;
         esac
     done
 }
@@ -297,9 +297,9 @@ get_subpkgs() {
 
     for f in $(typeset -F); do
         case "$f" in
-        *_package)
-            echo "${f%_package}"
-            ;;
+            *_package)
+                echo "${f%_package}"
+                ;;
         esac
     done
 }
@@ -340,7 +340,7 @@ setup_pkg() {
         XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
         XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
         XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
-        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE --repository=$XBPS_REPOSITORY"
+        XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
     else
         export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
         unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@@ -455,11 +455,12 @@ setup_pkg() {
         arch="$XBPS_TARGET_MACHINE"
     fi
     if [ -n "$XBPS_BINPKG_EXISTS" ]; then
-        # nonfree packages need this otherwise they'll rebuild even with -E
-        if [ -n "$repository" ]; then
-            extrarepo=" --repository=$XBPS_REPOSITORY/$repository"
-        fi
-        if [ "$($XBPS_QUERY_XCMD $extrarepo -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
+        local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
+        if [ "$_binpkgver" = "$pkgver" ]; then
+            if [ -z "$XBPS_DEPENDENCY" ]; then
+                local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
+                msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
+            fi
             exit_and_cleanup
         fi
     fi
diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh
index 66454fd9186..033d2048316 100644
--- a/common/xbps-src/shutils/cross.sh
+++ b/common/xbps-src/shutils/cross.sh
@@ -39,15 +39,27 @@ prepare_cross_sysroot() {
 
     [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
 
-    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
-    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
-    if [ $? -eq 0 ]; then
-        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
+    # Check if the cross pkg is installed in host.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
+    # Check if the cross compiler pkg is available in repos, otherwise build it.
+    pkg_available cross-${XBPS_CROSS_TRIPLET}
+    rval=$?
+    if [ $rval -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
+    # Check if cross-vpkg-dummy is installed.
     check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
     [ $? -eq 0 ] && return 0
 
+    # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
+    pkg_available 'cross-vpkg-dummy>=0.33_1' $cross
+    if [ $? -eq 0 ]; then
+        $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
+    fi
+
     msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
     errlog=$(mktemp) || exit 1
     $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
@@ -75,6 +87,10 @@ install_cross_pkg() {
 
     [ -z "$cross" -o "$cross" = "" ] && return 0
 
+    # Check if installed.
+    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
+    [ $? -eq 0 ] && return 0
+
     # Check if the cross compiler pkg is available in repos, otherwise build it.
     pkg_available cross-${XBPS_CROSS_TRIPLET}
     rval=$?
@@ -82,11 +98,8 @@ install_cross_pkg() {
         $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
     fi
 
-    check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
-    [ $? -eq 0 ] && return 0
-
     errlog=$(mktemp) || exit 1
-    msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
+    msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
     $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
     rval=$?
     if [ $rval -ne 0 -a $rval -ne 17 ]; then
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 8e74759ad7b..eda2966b47b 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -15,9 +15,14 @@
 #
 
 # [OPTIONAL]
-# Enable optional arguments to xbps-install for the host system.
-# Currently used in the binary-bootstrap bootstrap-update targets.
-XBPS_INSTALL_ARGS="--repository=https://alpha.de.repo.voidlinux.org/current --repository=https://alpha.de.repo.voidlinux.org/current/musl --repository=https://alpha.de.repo.voidlinux.org/current/aarch64"
+# Enable optional arguments to xbps-install(1) for the host system.
+# Currently used in the 'binary-bootstrap' and 'bootstrap-update' targets.
+#
+# NOTE: local repositories are handled automatically by xbps-src,
+# but you can modify the default remote repositories at
+# 'etc/xbps.d/repos-remote*.conf'
+#
+#XBPS_INSTALL_ARGS=""
 
 # [OPTIONAL]
 # Native Compilation/Preprocessor flags for C and C++. Additional settings
@@ -60,7 +65,7 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Enable recording git revisions in final binary packages; enable this
 # if you are sure the package you are building is available in the
-# xbps-packages git repository.
+# void-packages git repository.
 #
 #XBPS_USE_GIT_REVS=yes
 
@@ -113,8 +118,8 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # [OPTIONAL]
 # Set the preferred chroot style. Available styles at common/chroot-style/*.sh:
 #
-# 	- uunshare (uses xbps-uunshare(8), user namespaces)
-# 	- uchroot (uses xbps-uchroot(8), namespaces, setgid)
+# 	- uunshare (uses xbps-uunshare(1), user namespaces)
+# 	- uchroot (uses xbps-uchroot(1), namespaces, setgid)
 # 	- proot (uses proot, external, does not need special permissions)
 # 	- bwrap (uses bwrap, external, does not need special permissions)
 #	- ethereal (uses root, needs no permissions, for disposable containers)
diff --git a/etc/repos-remote.conf b/etc/repos-remote.conf
deleted file mode 100644
index ec534bab0e7..00000000000
--- a/etc/repos-remote.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Remote repositories
-repository=https://alpha.de.repo.voidlinux.org/current/musl
-repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current
-repository=https://alpha.de.repo.voidlinux.org/current/nonfree
-repository=https://alpha.de.repo.voidlinux.org/current/aarch64
-
-# Additional mirrors
-#
-# http://mirror.clarkson.edu/voidlinux/current/		US
-# http://www.gtlib.gatech.edu/pub/VoidLinux/current/	US
-# https://lug.utdallas.edu/mirror/void/			US
-# http://mirror.aarnet.edu.au/pub/voidlinux/current/	AU
diff --git a/etc/xbps.conf b/etc/xbps.conf
deleted file mode 100644
index 3b1211fbc65..00000000000
--- a/etc/xbps.conf
+++ /dev/null
@@ -1 +0,0 @@
-syslog=false
diff --git a/etc/repos-local-x86_64.conf b/etc/xbps.d/repos-local-x86_64.conf
similarity index 57%
rename from etc/repos-local-x86_64.conf
rename to etc/xbps.d/repos-local-x86_64.conf
index a724a1ec722..3c531e4f9c0 100644
--- a/etc/repos-local-x86_64.conf
+++ b/etc/xbps.d/repos-local-x86_64.conf
@@ -1,3 +1,4 @@
-# Local repositories
+# DON'T EDIT THIS FILE
+# x86_64/glibc local repositories
 repository=/host/binpkgs/multilib
 repository=/host/binpkgs/multilib/nonfree
diff --git a/etc/repos-local.conf b/etc/xbps.d/repos-local.conf
similarity index 82%
rename from etc/repos-local.conf
rename to etc/xbps.d/repos-local.conf
index 19e47ac7a23..916c3b750d3 100644
--- a/etc/repos-local.conf
+++ b/etc/xbps.d/repos-local.conf
@@ -1,3 +1,4 @@
+# DON'T EDIT THIS FILE
 # Local repositories
 repository=/host/binpkgs
 repository=/host/binpkgs/nonfree
diff --git a/etc/xbps.d/repos-remote-aarch64.conf b/etc/xbps.d/repos-remote-aarch64.conf
new file mode 100644
index 00000000000..4c81aaa9aa8
--- /dev/null
+++ b/etc/xbps.d/repos-remote-aarch64.conf
@@ -0,0 +1,4 @@
+# aarch64 voidlinux remote repositories
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/aarch64/debug
diff --git a/etc/xbps.d/repos-remote-musl.conf b/etc/xbps.d/repos-remote-musl.conf
new file mode 100644
index 00000000000..b47df7393ab
--- /dev/null
+++ b/etc/xbps.d/repos-remote-musl.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (musl)
+repository=https://alpha.de.repo.voidlinux.org/current/musl
+repository=https://alpha.de.repo.voidlinux.org/current/musl/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/musl/debug
diff --git a/etc/repos-remote-x86_64.conf b/etc/xbps.d/repos-remote-x86_64.conf
similarity index 74%
rename from etc/repos-remote-x86_64.conf
rename to etc/xbps.d/repos-remote-x86_64.conf
index fcc7b822f0f..e770aa1f4b5 100644
--- a/etc/repos-remote-x86_64.conf
+++ b/etc/xbps.d/repos-remote-x86_64.conf
@@ -1,3 +1,3 @@
-# Remote repositories
+# voidlinux remote repositories (x86_64/glibc)
 repository=https://alpha.de.repo.voidlinux.org/current/multilib
 repository=https://alpha.de.repo.voidlinux.org/current/multilib/nonfree
diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
new file mode 100644
index 00000000000..47c867ecac0
--- /dev/null
+++ b/etc/xbps.d/repos-remote.conf
@@ -0,0 +1,4 @@
+# voidlinux remote repositories (glibc)
+repository=https://alpha.de.repo.voidlinux.org/current
+repository=https://alpha.de.repo.voidlinux.org/current/nonfree
+repository=https://alpha.de.repo.voidlinux.org/current/debug
diff --git a/srcpkgs/base-chroot-musl/template b/srcpkgs/base-chroot-musl/template
deleted file mode 100644
index c95e27a9527..00000000000
--- a/srcpkgs/base-chroot-musl/template
+++ /dev/null
@@ -1,21 +0,0 @@
-# Template file for 'base-chroot-musl'
-pkgname=base-chroot-musl
-version=0.19
-revision=6
-archs="*-musl"
-bootstrap=yes
-build_style=meta
-homepage="https://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src (musl libc)"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="Public domain"
-
-conflicts="base-chroot>=0"
-provides="base-chroot-${version}_${revision}"
-
-depends="
- base-files kernel-libc-headers musl-devel musl-legacy-compat
- gcc patch chroot-bash chroot-grep coreutils findutils
- mpfr gettext chroot-texinfo sed chroot-gawk diffutils
- make gzip file tar chroot-util-linux chroot-git ccache
- chroot-distcc xbps xz which libada-devel gcc-ada"
diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 972039909fd..90ac72c9095 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -1,17 +1,21 @@
 # Template file for 'base-chroot'
 pkgname=base-chroot
-version=0.65
-revision=6
-archs="~*-musl"
+version=0.66
+revision=1
 bootstrap=yes
 build_style=meta
 homepage="http://www.voidlinux.org"
-short_desc="Bootstrap packages for xbps-src"
-maintainer="Enno Boland <gottox@voidlinux.org>"
+short_desc="Minimal set of packages required for chroot with xbps-src"
+maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
 
-depends="
- base-files>=0.127 kernel-libc-headers glibc-devel glibc-locales binutils gcc
- mpfr patch chroot-bash chroot-grep coreutils gettext libada-devel gcc-ada
- chroot-texinfo sed chroot-gawk findutils diffutils make gzip file tar
- chroot-distcc chroot-util-linux chroot-git ccache xbps readline xz which"
+case "$XBPS_TARGET_LIBC" in
+	musl) depends="musl-devel";;
+	*) depends="glibc-devel glibc-locales";;
+esac
+
+depends+="
+ base-files binutils gcc gcc-ada libada-devel
+ patch sed findutils diffutils make gzip coreutils
+ file bsdtar ccache xbps chroot-bash chroot-grep
+ chroot-gawk chroot-distcc chroot-util-linux chroot-git"
diff --git a/srcpkgs/chroot-texinfo/template b/srcpkgs/chroot-texinfo/template
deleted file mode 100644
index b59d1e0da1b..00000000000
--- a/srcpkgs/chroot-texinfo/template
+++ /dev/null
@@ -1,39 +0,0 @@
-# Template file for 'chroot-texinfo'
-pkgname=chroot-texinfo
-reverts="6.5_1"
-version=4.13a
-revision=10
-wrksrc=texinfo-4.13
-bootstrap=yes
-hostmakedepends="ncurses-devel"
-makedepends="ncurses-devel"
-conflicts="texinfo>=0"
-provides="texinfo-${version}_${revision}"
-short_desc="The GNU Documentation System -- for xbps-src use"
-maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
-homepage="http://www.gnu.org/software/texinfo/"
-distfiles="${GNU_SITE}/texinfo/texinfo-${version}.tar.lzma"
-checksum=6d28b0ceae866e3536142fc552e7a3bc9f84c8303119c25731b2478eef64c9e5
-
-do_configure() {
-	cp -f ${XBPS_COMMONDIR}/environment/configure/automake/config.sub build-aux
-
-	./configure ${configure_args} --disable-nls
-}
-
-do_build() {
-	if [ -d tools ]; then
-		make ${makejobs} -C tools/gnulib/lib
-		make ${makejobs} -C tools
-	fi
-	make ${makejobs}
-}
-
-do_install() {
-	make DESTDIR=${DESTDIR} install
-
-	rm -f ${DESTDIR}/usr/bin/info
-	rm -f ${DESTDIR}/usr/bin/infokey
-	rm -rf ${DESTDIR}/usr/share
-}
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 7176faf2709..f138ff13225 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -2,7 +2,6 @@
 pkgname=gettext
 version=0.20.1
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -23,7 +22,7 @@ case "$XBPS_TARGET_MACHINE" in
 esac
 
 if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool git"
+	hostmakedepends="automake libtool"
 	pre_configure() {
 		autoreconf -fi
 	}
diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index bda2f78625e..776a7d4ccce 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -2,7 +2,6 @@
 pkgname=tar
 version=1.32
 revision=1
-bootstrap=yes
 build_style=gnu-configure
 configure_args="gl_cv_struct_dirent_d_ino=yes"
 makedepends="acl-devel"
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 0fafafe3f7c..fabe35316b3 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -1,13 +1,12 @@
 # Template file for 'texinfo'
 pkgname=texinfo
 version=6.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
 checkdepends="ncurses gzip"
-conflicts="chroot-texinfo>=0"
 depends="gzip perl"
 short_desc="The GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -16,7 +15,6 @@ homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62
 
-
 post_install() {
 	rm -f ${DESTDIR}/usr/share/info/dir
 	# Compress manually info files.
diff --git a/xbps-src b/xbps-src
index 529bdcce4db..50f2032deeb 100755
--- a/xbps-src
+++ b/xbps-src
@@ -269,69 +269,10 @@ check_native_arch() {
     fi
 }
 
-install_bbootstrap() {
-    [ "$CHROOT_READY" ] && return
-    if [ "$1" = "bootstrap" ]; then
-        unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
-    else
-        XBPS_TARGET_PKG="$1"
-    fi
-    [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
-    # binary bootstrap
-    msg_normal "Installing bootstrap from binary package repositories...\n"
-    # XBPS_TARGET_PKG == arch
-    if [ "$XBPS_TARGET_PKG" ]; then
-        _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
-        if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
-            _subarch="-${XBPS_TARGET_PKG#*-}"
-        fi
-    fi
-    mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
-    cd $XBPS_MASTERDIR
-    cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
-    ${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
-    if [ $? -ne 0 ]; then
-        msg_error "Failed to install bootstrap packages!\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
-    fi
-
-    msg_normal "Installed bootstrap successfully!\n"
-    chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
-    chroot_check
-    chroot_handler clean
-}
-
-reconfigure_bootstrap_pkgs() {
-    local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
-    local pkgs="glibc-locales ca-certificates"
-    [ -z "$IN_CHROOT" -o -e $statefile ] && return 0
-    # Reconfigure ca-certificates.
-    msg_normal "Reconfiguring bootstrap packages...\n"
-    for f in ${pkgs}; do
-        if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
-            xbps-reconfigure -r $XBPS_MASTERDIR -f $f
-        fi
-    done
-    touch -f $statefile
-}
-
-bootstrap_update() {
-    [ -z "$CHROOT_READY" ] && return
-    remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up masterdir...\n"
-    rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
-    msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
-    ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
-    return $?
-}
-
 masterdir_zap() {
     rm -rf "$XBPS_MASTERDIR"
     mkdir -p "$XBPS_MASTERDIR"
-    msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
+    msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
 }
 
 exit_func() {
@@ -347,7 +288,7 @@ exit_func() {
 
 read_pkg() {
     if [ -z "${XBPS_TARGET_PKG}" ]; then
-        [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
+        [ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
         XBPS_TARGET_PKG=${PWD##*/}
     fi
     setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
@@ -368,13 +309,13 @@ setup_distfiles_mirror() {
         [ "$scheme" != "file" ] && continue
         if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
             if [ ! -d "$path" ]; then
-                msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
+                msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
                 continue
             fi
             mkdir -p "$XBPS_MASTERDIR/$path"
             XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
         else
-            msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
+            msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
         fi
     done
 }
@@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
-    readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
-    readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
+    readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
+    readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
     readonly XBPS_REMOVE_CMD="xbps-remove"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
     readonly XBPS_DESTDIR=/destdir
     readonly XBPS_BUILDDIR=/builddir
 else
     readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
-    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
-    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
+    readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
+    readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
     readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
     readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
-    readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
+    readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
     readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
     readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
 fi
@@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
     [ -r "$f" ] && . $f
 done
 
-reconfigure_bootstrap_pkgs
+reconfigure_base_chroot
 
 #
 # Main switch.
 #
 case "$XBPS_TARGET" in
     binary-bootstrap)
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        # bootstrap from sources
+        # base-chroot building on host
         # check for required host utils
         check_reqhost_utils bootstrap
-        [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
-        [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
-            msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
-        bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
-        mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
-        if [ ! -s ${bootstrap_vpkg} ]; then
-            # Fool xbps to resolve dependencies.
-            echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
-            echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
-        fi
         (
             export XBPS_ARCH=$XBPS_MACHINE
             export XBPS_SKIP_REMOTEREPOS=1
+            chroot_sync_repodata
             $XBPS_LIBEXECDIR/build.sh \
-                base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
+                base-chroot base-chroot $XBPS_TARGET || exit 1
         ) || exit 1
         [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
-        install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
+        install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
-            bootstrap_update
+            chroot_sync_repodata
+            update_base_chroot
         fi
         ;;
     chroot)
+        chroot_sync_repodata
         chroot_handler chroot dummy
         ;;
     clean)
@@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
         if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
-            [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+            chroot_sync_repodata
+            update_base_chroot
             $XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
                 $XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
         fi

From 4bede478faddffedabf736c10e8ff0d20d07bce7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:45:45 +0100
Subject: [PATCH 02/30] travis: update set_mirror.sh for `etc/xbps.d`.

---
 common/travis/set_mirror.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/set_mirror.sh b/common/travis/set_mirror.sh
index 8e5353f55d8..a10190a48f6 100755
--- a/common/travis/set_mirror.sh
+++ b/common/travis/set_mirror.sh
@@ -3,7 +3,7 @@
 TRAVIS_PROTO=http
 TRAVIS_MIRROR=alpha.us.repo.voidlinux.org
 
-for _i in etc/repos-remote.conf etc/defaults.conf etc/repos-remote-x86_64.conf ; do
+for _i in etc/xbps.d/repos-remote*.conf ; do
     /bin/echo -e "\x1b[32mUpdating $_i...\x1b[0m"
     # First fix the proto, ideally we'd serve everything with HTTPS,
     # but key management and rotation is a pain, and things are signed

From 08cbbf1764554f2a800634ad627535e1b5608ab4 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 11:57:45 +0100
Subject: [PATCH 03/30] travis: some tweaks for base-chroot-v2:

- no need to perform `boostrap-update` anymore, xbps-src does it now.
- don't set useless values to `etc/conf`.
---
 common/travis/build.sh   | 21 ---------------------
 common/travis/prepare.sh |  2 --
 2 files changed, 23 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 9bbc048ab15..31d1c58c10b 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,27 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Tell xbps-src what is our arch, this is done when doing
-# binary-bootstrap, but we need to do it every time since
-# our masterdir is ethereal.
-# /bin/echo -e '\x1b[32mWriting bootstrap arch into .xbps_chroot_init of masterdir\x1b[0m'
-# echo "$1" > /hostrepo/masterdir/.xbps_chroot_init
-
-/bin/echo -e '\x1b[32mPreparing chroot with chroot_prepare()\x1b[0m'
-source hostrepo/common/xbps-src/shutils/chroot.sh || {
-	echo "Failed to source chroot.sh for chroot_prepare()" >&2 ;
-	exit 1
-}
-
-XBPS_SRCPKGDIR=/hostrepo/srcpkgs XBPS_MASTERDIR=/ chroot_prepare $1 || {
-	echo "Failed to prepare chroot!" >&2 ;
-	exit 1
-}
-
-# Two times due to updating xbps itself
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-/hostrepo/xbps-src -H "$HOME"/hostdir bootstrap-update
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 869cc4b72d1..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -5,8 +5,6 @@
 [ "$XLINT" ] && exit 0
 
 /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
-echo XBPS_CHROOT_CMD=uchroot >> etc/conf
-echo XBPS_MAKEJOBS=4 >> etc/conf
 echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m'

From 14d39cc28069571e82b56a83c86c1ee67d6bfe63 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:36 +0100
Subject: [PATCH 04/30] base-chroot: xlintify

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 90ac72c9095..1f73f00d56d 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -4,10 +4,10 @@ version=0.66
 revision=1
 bootstrap=yes
 build_style=meta
-homepage="http://www.voidlinux.org"
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="Public domain"
+homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in
 	musl) depends="musl-devel";;

From bbd8112de6bc495f3d7bb4c0921e5199a19a6e43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:04:45 +0100
Subject: [PATCH 05/30] texinfo: xlintify

---
 srcpkgs/texinfo/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index fabe35316b3..4b3a30fdb68 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -6,9 +6,9 @@ build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="perl ncurses-devel"
 makedepends="ncurses-devel"
-checkdepends="ncurses gzip"
 depends="gzip perl"
-short_desc="The GNU Documentation System"
+checkdepends="ncurses gzip"
+short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/texinfo/"

From 447635db52fb5e2be0b56569289e212138624a46 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:10:59 +0100
Subject: [PATCH 06/30] chroot_init: return 0 at the end to not inherit last
 cmd errval.

---
 common/xbps-src/shutils/chroot.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index fcb0c4a04cc..2f40697657d 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -94,6 +94,7 @@ _EOF
 
     chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
     cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
+    return 0
 }
 
 chroot_prepare() {

From a7606f9e25c0d0699fd89938b30712b8040c4dff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:18:36 +0100
Subject: [PATCH 07/30] tar, texinfo: xlintify

---
 srcpkgs/tar/template     | 1 -
 srcpkgs/texinfo/template | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 776a7d4ccce..0a49caa7e91 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -16,4 +16,3 @@ pre_configure() {
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }
-
diff --git a/srcpkgs/texinfo/template b/srcpkgs/texinfo/template
index 4b3a30fdb68..457726e19ea 100644
--- a/srcpkgs/texinfo/template
+++ b/srcpkgs/texinfo/template
@@ -10,7 +10,7 @@ depends="gzip perl"
 checkdepends="ncurses gzip"
 short_desc="GNU Documentation System"
 maintainer="Enno Boland <gottox@voidlinux.org>"
-license="GPL-3"
+license="GPL-3.0-or-later"
 homepage="http://www.gnu.org/software/texinfo/"
 distfiles="${GNU_SITE}/$pkgname/$pkgname-$version.tar.xz"
 checksum=77774b3f4a06c20705cc2ef1c804864422e3cf95235e965b1f00a46df7da5f62

From c8dfc2c551f11210056b6f186cefcb40e824ca9b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:22:03 +0100
Subject: [PATCH 08/30] travis: always build a recent `base-chroot` pkg

---
 common/travis/prepare.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 04fff2a1392..6390e7c5df5 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,3 +13,6 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
+
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot

From b9a1641c94e226915e6b1c78f3ed744cc8638a17 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:25:22 +0100
Subject: [PATCH 09/30] travis: rebuild base-chroot via build.sh not
 prepare.sh.

---
 common/travis/build.sh   | 3 +++
 common/travis/prepare.sh | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31d1c58c10b..dc49e045a45 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -6,6 +6,9 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
+# Make sure `base-chroot` is really up-to-date
+/hostrepo/xbps-src -Ntf pkg base-chroot
+
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1
diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh
index 6390e7c5df5..04fff2a1392 100755
--- a/common/travis/prepare.sh
+++ b/common/travis/prepare.sh
@@ -13,6 +13,3 @@ echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
 
 /bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m'
 ln -s / masterdir
-
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot

From cc50da8623176ea0b41e56ddbf882f7aea781019 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:29:25 +0100
Subject: [PATCH 10/30] travis/build.sh: fix xbps-src opts for ethereal.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index dc49e045a45..31402cdc3e1 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -Ntf pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From b5331d6779311f4b678ada205f006f9f798d88ed Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:40:15 +0100
Subject: [PATCH 11/30] travis/build.sh: always update base-chroot in
 masterdir.

---
 common/travis/build.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 31402cdc3e1..d00d57f12f2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot
+/hostrepo/xbps-src -f pkg base-chroot || exit 1
+xbps-install --repository=/host/binpkgs -yu || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 2d496efcef5bae3d311fb120ccaa8ff0f816b1b0 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:42:13 +0100
Subject: [PATCH 12/30] xbps-src: update_base_chroot(): remove autodeps after
 sysup.

---
 common/xbps-src/shutils/chroot.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 2f40697657d..b463278c29e 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -55,6 +55,8 @@ update_base_chroot() {
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

From c00d38fa33e01da606db263ae4c87ea07e89270b Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:48:18 +0100
Subject: [PATCH 13/30] travis/build.sh: install base-chroot and remove
 autodeps.

---
 common/travis/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index d00d57f12f2..2c2a00d5cc2 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,9 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yu || exit 1
+xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+# remove autodeps
+xbps-remove -yo || exit 1
 
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 

From 81b4fe4f413aacf18d7398ea033edddeb3e23b45 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:52:43 +0100
Subject: [PATCH 14/30] travis/build.sh: fix repo path, use -H.

---
 common/travis/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 2c2a00d5cc2..7e679ecc843 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,8 +7,8 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -f pkg base-chroot || exit 1
-xbps-install --repository=/host/binpkgs -yif base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 88c135d6642a9e84d4042174889b487912aa1548 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:55:35 +0100
Subject: [PATCH 15/30] travis/build.sh: local repo path v2

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 7e679ecc843..09705565427 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/host/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 1dedb200d46899cddf3a94ba5d618c592e69fb85 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 12:58:19 +0100
Subject: [PATCH 16/30] travis/build.sh: also use xbps.d repos, to resolve
 missing deps.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 09705565427..c7049c260c6 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,7 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yif base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From b261543632c599c2c92a27d7a02ce04e382a5550 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:01:18 +0100
Subject: [PATCH 17/30] travis/build.sh: perform sysup before installing
 base-chroot.

---
 common/travis/build.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c7049c260c6..916c25515d7 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -8,6 +8,7 @@ fi
 
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1

From b0140b84b7846c1ecb820da819fc50aefdb5383e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:06:53 +0100
Subject: [PATCH 18/30] tar: fix for ethereal chroot-style

---
 srcpkgs/tar/template | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/srcpkgs/tar/template b/srcpkgs/tar/template
index 0a49caa7e91..2ec183c02f1 100644
--- a/srcpkgs/tar/template
+++ b/srcpkgs/tar/template
@@ -13,6 +13,8 @@ distfiles="${GNU_SITE}/tar/${pkgname}-${version}.tar.xz"
 checksum=d0d3ae07f103323be809bc3eac0dcc386d52c5262499fe05511ac4788af1fdd8
 
 pre_configure() {
+	# chroot-style=ethereal
+	export FORCE_UNSAFE_CONFIGURE=1
 	# avoid regenerating doc on install
 	touch -r doc/stamp-vti configure
 }

From d34dc4783cabd6562e1a64cc09518d31b3c43119 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 1 Jan 2020 13:12:04 +0100
Subject: [PATCH 19/30] base-chroot: fix license?

---
 srcpkgs/base-chroot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template
index 1f73f00d56d..d4614bf3f27 100644
--- a/srcpkgs/base-chroot/template
+++ b/srcpkgs/base-chroot/template
@@ -6,7 +6,7 @@ bootstrap=yes
 build_style=meta
 short_desc="Minimal set of packages required for chroot with xbps-src"
 maintainer="Juan RP <xtraeme@gmail.com>"
-license="Public domain"
+license="Public Domain"
 homepage="http://www.voidlinux.org"
 
 case "$XBPS_TARGET_LIBC" in

From 0941fa44d521639ab1528879a7f514f1286f7fba Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 08:59:10 +0100
Subject: [PATCH 20/30] xbps-src: fix for x86_64 local multilib repos.

Found and fixed by @pullmoll
---
 common/xbps-src/shutils/chroot.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index b463278c29e..744b99a8a0c 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -226,7 +226,15 @@ chroot_sync_repodata() {
     sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
         > $confdir/10-repository-local.conf
 
-    if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
+    if [ "$XBPS_SKIP_REMOTEREPOS" ]; then
+        case "$XBPS_MACHINE" in
+            x86_64)
+            # x86_64/glibc
+            install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-x86_64.conf \
+                $confdir/12-repository-local-x86_64.conf
+            ;;
+        esac
+    else
         case "$XBPS_MACHINE" in
             *-musl)
                 install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-musl.conf \

From 0ec18a9d60504a890c44723ea6159e0918d1a34e Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 09:01:29 +0100
Subject: [PATCH 21/30] travis/build.sh: use -E (and get rid of -f) while
 building base-chroot.

---
 common/travis/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 916c25515d7..c6a71afb6be 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -7,7 +7,7 @@ if [ "$1" != "$2" ]; then
 fi
 
 # Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -H "$HOME"/hostdir -f pkg base-chroot || exit 1
+/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps

From d0decae241fd8ba9d608c80bec18378318e7666f Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 4 Jan 2020 11:19:05 +0100
Subject: [PATCH 22/30] xbps-src: updated list of required host utils.

---
 xbps-src | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xbps-src b/xbps-src
index 50f2032deeb..1ba52432707 100755
--- a/xbps-src
+++ b/xbps-src
@@ -382,9 +382,9 @@ umask 022
 #
 # Required utilities in host system for the bootstrap target.
 readonly REQHOST_UTILS_BOOTSTRAP="make gawk bash bison sed gcc g++ msgfmt makeinfo \
-    perl tar xz gzip bzip2 patch flex automake libtool pkg-config"
+    perl bsdtar xz gzip bzip2 patch flock flex libtool pkg-config"
 
-# Required utilities in host system for chroot ops.
+# Required utilities in host.
 readonly REQHOST_UTILS="xbps-install xbps-query xbps-rindex xbps-uhelper \
     xbps-reconfigure xbps-remove xbps-create xbps-uchroot xbps-uunshare"
 

From c6d1da9777539539d66fcca2c3065688e087c408 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 07:47:43 +0100
Subject: [PATCH 23/30] .travis.yml: bump voidlinux docker tag.

Original commit in https://github.com/void-linux/void-packages/pull/18049
will be reverted after testing.

@the-maldridge
---
 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 5f4f30f85cd..13650b2bd31 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,7 +8,7 @@ env:
     global:
         - PATH=$PATH:/tmp/bin
         - DOCKER_BASE=voidlinux/masterdir
-        - TAG=2019102301
+        - TAG=20200104
 
     matrix:
         - XLINT=1 LICENSE_LIST=common/travis/license.lst

From 37470cfc1587478693d11890c935f4b544fb8a33 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 08:20:26 +0100
Subject: [PATCH 24/30] hooks: 00-distfiles.sh: detect bsdtar and then tar
 (GNU).

This way xbps-src is able to work with any of them.
---
 common/hooks/do-extract/00-distfiles.sh |  7 ++++++-
 common/hooks/do-fetch/00-distfiles.sh   | 17 ++++++++++++++---
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index 303fe27e0a1..d1f457edcc5 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -4,6 +4,7 @@
 hook() {
 	local srcdir="$XBPS_SRCDISTDIR/$pkgname-$version"
 	local f j curfile found extractdir
+	local TAR_CMD
 
 	if [ -z "$distfiles" -a -z "$checksum" ]; then
 		mkdir -p $wrksrc
@@ -23,6 +24,10 @@ hook() {
 		mkdir -p ${wrksrc} || msg_error "$pkgver: failed to create wrksrc.\n"
 	fi
 
+	TAR_CMD="$(command -v bsdtar)"
+	[ -z "$TAR_CMD" ] && TAR_CMD="$(command -v tar)"
+	[ -z "$TAR_CMD" ] && msg_error "xbps-src: no suitable tar cmd (bsdtar, tar)\n"
+
 	msg_normal "$pkgver: extracting distfile(s), please wait...\n"
 
 	for f in ${distfiles}; do
@@ -71,7 +76,7 @@ hook() {
 
 		case ${cursufx} in
 		tar|txz|tbz|tlz|tgz|crate)
-			bsdtar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
+			$TAR_CMD -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
 			fi
diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh
index 73239da1c73..db4f29c73a2 100644
--- a/common/hooks/do-fetch/00-distfiles.sh
+++ b/common/hooks/do-fetch/00-distfiles.sh
@@ -50,7 +50,7 @@ contents_cksum() {
 
 	case ${cursufx} in
 	tar|txz|tbz|tlz|tgz|crate)
-		cksum=$($XBPS_DIGEST_CMD <(bsdtar xf "$curfile" --list))
+		cksum=$($XBPS_DIGEST_CMD <($TAR_CMD xf "$curfile" $TAR_CMD_STDOUT))
 		if [ $? -ne 0 ]; then
 			msg_error "$pkgver: extracting $curfile to pipe.\n"
 		fi
@@ -73,7 +73,7 @@ contents_cksum() {
 		;;
 	rpm)
 		if command -v rpmextract &>/dev/null; then
-			cksum=$($XBPS_DIGEST_CMD <(rpm2cpio "$curfile" | bsdtar xf - --to-stdout))
+			cksum=$($XBPS_DIGEST_CMD <(rpm2cpio "$curfile" | $TAR_CMD xf - $TAR_CMD_STDOUT))
 			if [ $? -ne 0 ]; then
 				msg_error "$pkgver: extracting $curfile to pipe.\n"
 			fi
@@ -95,7 +95,7 @@ contents_cksum() {
 		fi
 		;;
 	gem)
-		cksum=$($XBPS_DIGEST_CMD <(bsdtar -xf "$curfile" data.tar.gz --list | bsdtar -xzO ))
+		cksum=$($XBPS_DIGEST_CMD <($TAR_CMD -xf "$curfile" data.tar.gz $TAR_CMD_STDOUT | $TAR_CMD -xzO ))
 		;;
 	*)
 		msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
@@ -210,6 +210,15 @@ hook() {
 	# Disable trap on ERR; the code is smart enough to report errors and abort.
 	trap - ERR
 
+	# Detect bsdtar and GNU tar (in that order of preference)
+	TAR_CMD="$(command -v bsdtar)"
+	if [ "$TAR_CMD" ]; then
+		TAR_CMD_STDOUT="--list"
+	else
+		TAR_CMD="$(command -v tar)"
+		TAR_CMD_STDOUT="--to-stdout"
+	fi
+
 	# Detect distfiles with obsolete checksum and purge them from the cache
 	for f in ${distfiles}; do
 		curfile="${f#*>}"
@@ -273,6 +282,8 @@ hook() {
 		dfcount=$((dfcount + 1))
 	done
 
+	unset TAR_CMD TAR_CMD_STDOUT
+
 	if [ $errors -gt 0 ]; then
 		msg_error "$pkgver: couldn't verify distfiles, exiting...\n"
 	fi

From 71b686118b44aedf234270e180de320125f4d341 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 08:24:52 +0100
Subject: [PATCH 25/30] hooks/do-extract: 00-distfiles.sh: disable trap on ERR.

---
 common/hooks/do-extract/00-distfiles.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index d1f457edcc5..8b0a5e0dc84 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -24,6 +24,9 @@ hook() {
 		mkdir -p ${wrksrc} || msg_error "$pkgver: failed to create wrksrc.\n"
 	fi
 
+	# Disable trap on ERR; the code is smart enough to report errors and abort.
+	trap - ERR
+
 	TAR_CMD="$(command -v bsdtar)"
 	[ -z "$TAR_CMD" ] && TAR_CMD="$(command -v tar)"
 	[ -z "$TAR_CMD" ] && msg_error "xbps-src: no suitable tar cmd (bsdtar, tar)\n"

From 043eaec32b64e56b9c8d09affefe380a15f8c0ff Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 08:32:29 +0100
Subject: [PATCH 26/30] travis/build.sh: simplify logic

---
 common/travis/build.sh | 1 -
 1 file changed, 1 deletion(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index c6a71afb6be..3a5da41a533 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -9,7 +9,6 @@ fi
 # Make sure `base-chroot` is really up-to-date
 /hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
 xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yf base-chroot || exit 1
 # remove autodeps
 xbps-remove -yo || exit 1
 

From 6514d67b479b703b9ad226fe31813f21ae7d7614 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 09:44:14 +0100
Subject: [PATCH 27/30] README.md: update requirements.

---
 README.md | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 6870df7a9da..f9e8ab25486 100644
--- a/README.md
+++ b/README.md
@@ -15,10 +15,12 @@ for details of how to create source packages.
 ### Requirements
 
 - GNU bash
-- xbps >= 0.55
+- xbps >= 0.56
 - curl(1) - required by `xbps-src update-check`
 - flock(1) - util-linux
-- install(1) - coreutils
+- bsdtar or GNU tar (in that order of preference)
+- install(1) - GNU coreutils
+- objcopy(1), objdump(1), strip(1): binutils
 - other common POSIX utilities included by default in almost all UNIX systems.
 
 `xbps-src` requires a utility to chroot and bind mount existing directories

From 9af92d22bfb52738b36478448036a92e999d71af Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 09:53:14 +0100
Subject: [PATCH 28/30] xbps-src/chroot.sh: silence grep output

---
 common/xbps-src/shutils/chroot.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 744b99a8a0c..d3951a395ad 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -51,7 +51,7 @@ update_base_chroot() {
     [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
     msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
     # no need to sync repodata, chroot_sync_repodata() does it for us.
-    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep xbps); then
+    if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep -q xbps); then
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"

From 3c5468c0f109f6ab57cc4e4dc2fee0e5c64647de Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 10:11:30 +0100
Subject: [PATCH 29/30] travis/build.sh: xbps-src takes care of everything now.

Also this file does not contain any bashism, so use /bin/sh.
---
 common/travis/build.sh | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/common/travis/build.sh b/common/travis/build.sh
index 3a5da41a533..7732211a59e 100755
--- a/common/travis/build.sh
+++ b/common/travis/build.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # build.sh
 
@@ -6,12 +6,6 @@ if [ "$1" != "$2" ]; then
 	arch="-a $2"
 fi
 
-# Make sure `base-chroot` is really up-to-date
-/hostrepo/xbps-src -H "$HOME"/hostdir -E pkg base-chroot || exit 1
-xbps-install --repo="$HOME"/hostdir/binpkgs -yu || exit 1
-# remove autodeps
-xbps-remove -yo || exit 1
-
 PKGS=$(/hostrepo/xbps-src sort-dependencies $(cat /tmp/templates))
 
 NPROCS=1

From 9cb12c42ce04e490c79b334201a040187b4ce3e1 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sun, 5 Jan 2020 10:25:02 +0100
Subject: [PATCH 30/30] xbps-src/chroot.sh: simplify update_base_chroot().

---
 common/xbps-src/shutils/chroot.sh | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index d3951a395ad..9fcf16562d6 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -46,17 +46,15 @@ reconfigure_base_chroot() {
 
 update_base_chroot() {
     [ -z "$CHROOT_READY" ] && return
-    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
-    msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
-    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
     msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
     # no need to sync repodata, chroot_sync_repodata() does it for us.
     if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep -q xbps); then
         ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
     fi
     ${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
-    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
     msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
+    [ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
+    [ -z "$XBPS_KEEP_ALL" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
 }
 
 # FIXME: $XBPS_FFLAGS is not set when chroot_init() is run

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (94 preceding siblings ...)
  2020-01-05  9:25 ` voidlinux-github
@ 2020-01-05  9:36 ` voidlinux-github
  2020-01-05  9:37 ` voidlinux-github
  2020-01-05  9:44 ` [PR PATCH] [Merged]: " voidlinux-github
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-05  9:36 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 183 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570893527

Comment:
This is ready, will merge in a short time.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (95 preceding siblings ...)
  2020-01-05  9:36 ` voidlinux-github
@ 2020-01-05  9:37 ` voidlinux-github
  2020-01-05  9:44 ` [PR PATCH] [Merged]: " voidlinux-github
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-05  9:37 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 171 bytes --]

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/17969#issuecomment-570893631

Comment:
This PR closes #18049 as well.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Merged]: xbps-src: base-chroot-v2 (reduce artifacts/deps)
  2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
                   ` (96 preceding siblings ...)
  2020-01-05  9:37 ` voidlinux-github
@ 2020-01-05  9:44 ` voidlinux-github
  97 siblings, 0 replies; 99+ messages in thread
From: voidlinux-github @ 2020-01-05  9:44 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1783 bytes --]

There's a merged pull request on the void-packages repository

xbps-src: base-chroot-v2 (reduce artifacts/deps)
https://github.com/void-linux/void-packages/pull/17969

Description:
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.

- update `base-chroot` deps before building any pkg.
- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
  xbps-src now simply populates `rootdir/etc/xbps.d` with correct
  settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
  entering to the chroot (if CHROOT_READY is set), xbps-src will
  clean up the masterdir and then perform a system update to always
  use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Gets rid of `-I` to skip file conflicts while installing deps via `xbps-install(1)`.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
  - base-chroot-musl is gone, now unified for glibc/musl.
  - deps removed: gettext, mpfr, readline, texinfo, which, xz.
  - deps changed: tar -> bsdtar.
  - chroot-texinfo: removed; texinfo is enough.

Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.

I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`

^ permalink raw reply	[flat|nested] 99+ messages in thread

end of thread, other threads:[~2020-01-05  9:44 UTC | newest]

Thread overview: 99+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-01 10:37 [PR PATCH] xbps-src: base-chroot-v2 (reduce artifacts/deps) voidlinux-github
2020-01-01 10:41 ` voidlinux-github
2020-01-01 10:46 ` [PR PATCH] [Updated] " voidlinux-github
2020-01-01 10:50 ` voidlinux-github
2020-01-01 10:59 ` [PR PATCH] [Updated] " voidlinux-github
2020-01-01 11:05 ` voidlinux-github
2020-01-01 11:11 ` voidlinux-github
2020-01-01 11:22 ` voidlinux-github
2020-01-01 11:25 ` voidlinux-github
2020-01-01 11:29 ` voidlinux-github
2020-01-01 11:40 ` voidlinux-github
2020-01-01 11:42 ` voidlinux-github
2020-01-01 11:48 ` voidlinux-github
2020-01-01 11:53 ` voidlinux-github
2020-01-01 11:56 ` voidlinux-github
2020-01-01 11:58 ` voidlinux-github
2020-01-01 12:02 ` voidlinux-github
2020-01-01 12:07 ` voidlinux-github
2020-01-01 12:12 ` voidlinux-github
2020-01-01 12:13 ` voidlinux-github
2020-01-01 12:14 ` voidlinux-github
2020-01-01 12:16 ` voidlinux-github
2020-01-01 12:18 ` voidlinux-github
2020-01-01 12:19 ` voidlinux-github
2020-01-01 12:19 ` voidlinux-github
2020-01-01 12:22 ` voidlinux-github
2020-01-01 12:25 ` voidlinux-github
2020-01-01 12:28 ` voidlinux-github
2020-01-01 12:30 ` voidlinux-github
2020-01-01 12:36 ` voidlinux-github
2020-01-01 21:14 ` voidlinux-github
2020-01-01 21:32 ` voidlinux-github
2020-01-01 21:32 ` voidlinux-github
2020-01-01 21:33 ` voidlinux-github
2020-01-01 21:34 ` voidlinux-github
2020-01-01 21:35 ` voidlinux-github
2020-01-01 21:35 ` voidlinux-github
2020-01-01 21:37 ` voidlinux-github
2020-01-01 21:37 ` voidlinux-github
2020-01-01 21:38 ` voidlinux-github
2020-01-01 23:29 ` voidlinux-github
2020-01-01 23:32 ` voidlinux-github
2020-01-02 11:18 ` voidlinux-github
2020-01-02 17:48 ` voidlinux-github
2020-01-02 20:32 ` voidlinux-github
2020-01-02 20:34 ` voidlinux-github
2020-01-02 20:37 ` voidlinux-github
2020-01-02 22:20 ` voidlinux-github
2020-01-02 22:29 ` voidlinux-github
2020-01-03  1:18 ` voidlinux-github
2020-01-03  1:51 ` voidlinux-github
2020-01-03  1:53 ` voidlinux-github
2020-01-03  7:40 ` voidlinux-github
2020-01-03  8:24 ` voidlinux-github
2020-01-03  9:29 ` voidlinux-github
2020-01-03 11:51 ` voidlinux-github
2020-01-03 12:07 ` voidlinux-github
2020-01-03 12:58 ` voidlinux-github
2020-01-03 13:12 ` voidlinux-github
2020-01-03 13:16 ` voidlinux-github
2020-01-03 13:21 ` voidlinux-github
2020-01-03 13:24 ` voidlinux-github
2020-01-03 13:28 ` voidlinux-github
2020-01-03 13:29 ` voidlinux-github
2020-01-03 13:30 ` voidlinux-github
2020-01-03 13:31 ` voidlinux-github
2020-01-03 13:32 ` voidlinux-github
2020-01-03 13:34 ` voidlinux-github
2020-01-03 13:35 ` voidlinux-github
2020-01-03 13:36 ` voidlinux-github
2020-01-03 13:38 ` voidlinux-github
2020-01-03 15:26 ` voidlinux-github
2020-01-04  8:02 ` [PR PATCH] [Updated] " voidlinux-github
2020-01-04  8:31 ` voidlinux-github
2020-01-04 10:19 ` [PR PATCH] [Updated] " voidlinux-github
2020-01-04 10:46 ` voidlinux-github
2020-01-04 10:54 ` voidlinux-github
2020-01-04 11:12 ` voidlinux-github
2020-01-04 11:16 ` voidlinux-github
2020-01-04 11:19 ` voidlinux-github
2020-01-04 11:20 ` voidlinux-github
2020-01-04 11:25 ` [PR PATCH] [Updated] " voidlinux-github
2020-01-04 11:32 ` voidlinux-github
2020-01-04 11:39 ` voidlinux-github
2020-01-04 11:46 ` voidlinux-github
2020-01-04 12:03 ` voidlinux-github
2020-01-04 12:29 ` voidlinux-github
2020-01-05  6:49 ` [PR PATCH] [Updated] " voidlinux-github
2020-01-05  7:21 ` voidlinux-github
2020-01-05  7:25 ` voidlinux-github
2020-01-05  7:32 ` voidlinux-github
2020-01-05  7:54 ` voidlinux-github
2020-01-05  8:44 ` [PR PATCH] [Updated] " voidlinux-github
2020-01-05  8:53 ` voidlinux-github
2020-01-05  9:12 ` voidlinux-github
2020-01-05  9:25 ` voidlinux-github
2020-01-05  9:36 ` voidlinux-github
2020-01-05  9:37 ` voidlinux-github
2020-01-05  9:44 ` [PR PATCH] [Merged]: " voidlinux-github

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).