From ef5cc722a967fcb0a9af1a62f6f5bb8007c10e8b Mon Sep 17 00:00:00 2001
From: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Date: Tue, 8 Jan 2019 14:27:24 +0000
Subject: When installing Bash, check if the sh link is already present

After installing Bash, we would just blindly try to build the $(ibdir)/sh'
symbolic link. But that could fail if it already existed. To make things
clean, we now remove any link first before attempting to make a new one.
---
 reproduce/src/make/dependencies-basic.mk | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

(limited to 'reproduce/src')

diff --git a/reproduce/src/make/dependencies-basic.mk b/reproduce/src/make/dependencies-basic.mk
index 89abd0a..8625cf6 100644
--- a/reproduce/src/make/dependencies-basic.mk
+++ b/reproduce/src/make/dependencies-basic.mk
@@ -433,7 +433,8 @@ $(ibdir)/which: $(tdir)/which-$(which-version).tar.gz \
 $(ibdir)/bash: $(tdir)/bash-$(bash-version).tar.gz \
                $(ibdir)/make
 
-        # Delete any possibly existing output
+        # Delete any possibly existing output (so it doesn't interfere with
+        # the build: we are building bash itself!)
 	if [ -f $@ ]; then rm $@; fi;
 
         # Build Bash.
@@ -450,8 +451,12 @@ endif
         #
         # Just to be sure that the installation step above went well,
         # before making the link, we'll see if the file actually exists
+        # there and remove any possibly existing link that might already be
         # there.
-	if [ -f $@ ]; then ln -fs $@ $(ibdir)/sh; fi
+	if [ -f $(ibdir)/sh ]; then rm $(ibdir)/sh; fi
+	if [ -f $@ ]; then ln -s $@ $(ibdir)/sh; \
+	else echo "Bash not build!"; exit 1; fi
+
 
 
 
-- 
cgit v1.2.1