commit:     6b522acbb352eaae250d54b48456350ded50d7ce
Author:     Alexander Bezrukov <phmagic <AT> mail <DOT> ru>
AuthorDate: Sun Oct 25 08:14:22 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Oct 25 08:14:22 2020 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=6b522acb

scripts/bootstrap-prefix: fix stat invocation for Darwin/*BSD

Closes: https://bugs.gentoo.org/751037
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 scripts/bootstrap-prefix.sh | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/scripts/bootstrap-prefix.sh b/scripts/bootstrap-prefix.sh
index 3a9dd3cb87..313139c0e8 100755
--- a/scripts/bootstrap-prefix.sh
+++ b/scripts/bootstrap-prefix.sh
@@ -2687,8 +2687,15 @@ EOF
                        EPREFIX=
                        continue
                fi
-               if [[ $(stat -c '%U/%G' "${EPREFIX}"/.canihaswrite) != \
-                       $(stat -c '%U/%G' "${EPREFIX}") ]] ;
+               # GNU and BSD variants of stat take different arguments (and
+               # format specifiers are not equivalent)
+               case "${CHOST}" in
+                       *-darwin* | *-freebsd*) STAT='stat -f %u/%g' ;;
+                       *)                      STAT='stat -c %U/%G' ;;
+               esac
+
+               if [[ $(${STAT} "${EPREFIX}"/.canihaswrite) != \
+                       $(${STAT} "${EPREFIX}") ]] ;
                then
                        echo
                        echo "The $EPREFIX directory has different ownership 
than expected."

Reply via email to