diff --git a/xbps-src b/xbps-src
index 91ab57850eb..e32b6ff6215 100755
--- a/xbps-src
+++ b/xbps-src
@@ -250,9 +250,6 @@ check_config_vars() {
 check_build_requirements() {
     local found
 
-    for f in $XBPS_SHUTILSDIR/*.sh; do
-        [ -r $f ] && . $f
-    done
     case "$XBPS_TARGET" in
         *bootstrap*) found=1;;
         *) ;;
@@ -265,29 +262,6 @@ check_build_requirements() {
             exit 1
         fi
     fi
-    # Set XBPS_REPOSITORY to our current branch.
-    if [ -z "$XBPS_ALT_REPOSITORY" ]; then
-        pushd "$PWD" &>/dev/null
-        cd $XBPS_DISTDIR
-        if [ -n "$IN_CHROOT" ]; then
-            _gitbranch="$(chroot-git symbolic-ref --short HEAD 2>/dev/null)"
-        else
-            _gitbranch="$($XBPS_GIT_CMD symbolic-ref --short HEAD 2>/dev/null)"
-        fi
-        if [ -n "${_gitbranch}" -a "${_gitbranch}" != "master" ]; then
-            export XBPS_ALT_REPOSITORY="${_gitbranch}"
-            export XBPS_REPOSITORY="${XBPS_REPOSITORY}/${_gitbranch}"
-            if [ -z "$IN_CHROOT" ]; then
-                msg_normal "Using \`$XBPS_REPOSITORY\' as local repository.\n"
-            fi
-        fi
-        popd &>/dev/null
-    else
-        export XBPS_REPOSITORY="${XBPS_REPOSITORY}/${XBPS_ALT_REPOSITORY}"
-        if [ -z "$IN_CHROOT" ]; then
-            msg_normal "Using \`$XBPS_REPOSITORY\' as local repository.\n"
-        fi
-    fi
 }
 
 install_bbootstrap() {
@@ -519,6 +493,10 @@ fi
 #
 check_config_vars
 
+for f in $XBPS_DISTDIR/common/xbps-src/shutils/*.sh; do
+    [ -r $f ] && . $f
+done
+
 if [ -n "$XBPS_HOSTDIR" ]; then
     export XBPS_REPOSITORY=$XBPS_HOSTDIR/binpkgs
     readonly XBPS_SRCDISTDIR=$XBPS_HOSTDIR/sources
@@ -526,6 +504,31 @@ else
     export XBPS_REPOSITORY=$XBPS_MASTERDIR/host/binpkgs
     readonly XBPS_SRCDISTDIR=$XBPS_MASTERDIR/host/sources
 fi
+
+# Set XBPS_REPOSITORY to our current branch.
+if [ -z "$XBPS_ALT_REPOSITORY" ]; then
+    pushd "$PWD" &>/dev/null
+    cd $XBPS_DISTDIR
+    if [ -n "$IN_CHROOT" ]; then
+        _gitbranch="$(chroot-git symbolic-ref --short HEAD 2>/dev/null)"
+    else
+        _gitbranch="$($XBPS_GIT_CMD symbolic-ref --short HEAD 2>/dev/null)"
+    fi
+    if [ -n "${_gitbranch}" -a "${_gitbranch}" != "master" ]; then
+        export XBPS_ALT_REPOSITORY="${_gitbranch}"
+        export XBPS_REPOSITORY="${XBPS_REPOSITORY}/${_gitbranch}"
+        if [ -z "$IN_CHROOT" ]; then
+            msg_normal "Using \`$XBPS_REPOSITORY\' as local repository.\n"
+        fi
+     fi
+     popd &>/dev/null
+else
+    export XBPS_REPOSITORY="${XBPS_REPOSITORY}/${XBPS_ALT_REPOSITORY}"
+    if [ -z "$IN_CHROOT" ]; then
+        msg_normal "Using \`$XBPS_REPOSITORY\' as local repository.\n"
+    fi
+fi
+
 if [ -n "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
     readonly XBPS_INSTALL_CMD="xbps-install"
@@ -602,6 +605,7 @@ if [ -z "$XBPS_TARGET_MACHINE" ]; then
     export XBPS_TARGET_MACHINE=${XBPS_ARCH:=$XBPS_MACHINE}
 fi
 
+
 export XBPS_SHUTILSDIR XBPS_CROSSPFDIR XBPS_TRIGGERSDIR \
     XBPS_SRCPKGDIR XBPS_COMMONDIR XBPS_BUILDDIR XBPS_REPO_DELTAS \
     XBPS_REPOSITORY XBPS_ALT_REPOSITORY XBPS_SRCDISTDIR XBPS_DIGEST_CMD \