:: commit 8920139e083639cd5eb682d60bd4e4643d2b6b2f

mintsuki <mintsuki@protonmail.com> — 2024-07-05 00:24

parents: ac882a6032

build: bootstrap: Misc updates and improvements

diff --git a/bootstrap b/bootstrap
index 72dcde91..b8f025c4 100755
--- a/bootstrap
+++ b/bootstrap
@@ -22,25 +22,25 @@ DTC_COMMIT_HASH=039a99414e778332d8f9c04cbd3072e1dcc62798
 AUXFILES="config.guess config.sub install-sh"
 
 clone_repo_commit() {
-    if [ -d $2/.git ]; then
+    if test -d $2/.git; then
         git -C $2 reset --hard
         git -C $2 clean -fd
         if ! git -C $2 checkout $3; then
             rm -rf $2
         fi
     else
-        if [ -d $2 ]; then
+        if test -d $2; then
             echo "error: '$2' is not a Git repository"
             exit 1
         fi
     fi
-    if ! [ -d $2 ]; then
+    if ! test -d $2; then
         git clone $1 $2
         git -C $2 checkout $3
     fi
 }
 
-if ! [ -f version ]; then
+if test -d .git; then
     clone_repo_commit https://github.com/osdev0/freestanding-toolchain.git build-aux/freestanding-toolchain $FREESTANDING_TOOLCHAIN_COMMIT_HASH
     clone_repo_commit https://github.com/osdev0/freestanding-headers.git freestanding-headers $FREESTANDING_HEADERS_COMMIT_HASH
 
@@ -75,7 +75,7 @@ if ! [ -f version ]; then
 fi
 
 # Create timestamps file
-if git log -1 >/dev/null 2>&1; then
+if test -d .git && git log -1 >/dev/null 2>&1; then
     cat >timestamps <<EOF
 REGEN_DATE="$(git log -1 --pretty=%cd --date='format:%B %Y')"
 SOURCE_DATE_EPOCH="$(git log -1 --pretty=%ct)"
@@ -98,14 +98,14 @@ $AUTORECONF -fvi -Wall
 # install auxiliary files, sometimes... Check if that is the
 # case and work around...
 for auxfile in $AUXFILES; do
-    if ! [ -f build-aux/$auxfile ]; then
+    if ! test -f build-aux/$auxfile; then
         if ! $AUTOMAKE --print-libdir >/dev/null 2>&1; then
             echo "error: Broken autoreconf detected, but missing or broken automake."
             echo "       Please make sure automake is installed and working."
             exit 1
         fi
         AUTOMAKE_LIBDIR="$($AUTOMAKE --print-libdir)"
-        if [ -z "$AUTOMAKE_LIBDIR" ]; then
+        if test -z "$AUTOMAKE_LIBDIR"; then
             # Assume `true` was passed as $AUTOMAKE
             continue
         fi
tab: 248 wrap: offon