From 7940dc3fb401b247e40b163381edd4eadc82b2f4 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Sat, 27 Jan 2024 16:16:39 -0800
Subject: [PATCH] xbps-src: improve check for existing "masterdir"

---
 xbps-src | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xbps-src b/xbps-src
index 3638d4f292a..b4e99f53105 100755
--- a/xbps-src
+++ b/xbps-src
@@ -535,8 +535,8 @@ if [ "$XBPS_CHROOT_CMD" = ethereal ]; then
 else
     : "${XBPS_MASTERDIR:=$XBPS_DISTDIR/masterdir-$XBPS_MACHINE}"
     # but use $XBPS_DISTDIR/masterdir if it exists and the new style doesn't
-    if [ ! -d "${XBPS_MASTERDIR}" ] && [ -d "${XBPS_DISTDIR}/masterdir" ] \
-        && [ "$(cat "${XBPS_DISTDIR}"/masterdir/.xbps_chroot_init)" = "$XBPS_MACHINE" ]; then
+    if [ ! -d "${XBPS_MASTERDIR}" ] && [ -r "${XBPS_DISTDIR}/masterdir/.xbps_chroot_init" ] \
+        && [ "$(cat "${XBPS_DISTDIR}/masterdir/.xbps_chroot_init")" = "$XBPS_MACHINE" ]; then
         XBPS_MASTERDIR="${XBPS_DISTDIR}/masterdir"
     fi
 fi