summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-08-07 18:15:09 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-08-09 02:31:14 -0400
commit1c582f44e41f534a8506a76618f6cffe5d71ed42 (patch)
tree9066fd1fea4ed72c4af1f0c9f3c7baf4bd9a083a
parentc1c08bd829fb33a185f0a71f08babe5d7e6556fc (diff)
downloadhaskell-1c582f44e41f534a8506a76618f6cffe5d71ed42.tar.gz
hadrian: Fix bindist installation on Darwin
It turns out that `cp -P` on Darwin does not always copy a symlink as a symlink. In order to get these semantics one must pass `-RP`. It's not entirely clear whether this is valid under POSIX, but it is nevertheless what Apple does.
-rw-r--r--hadrian/bindist/Makefile44
-rw-r--r--hadrian/bindist/config.mk.in8
-rw-r--r--hadrian/src/Rules/BinaryDist.hs1
-rwxr-xr-xmk/install_script.sh34
4 files changed, 41 insertions, 46 deletions
diff --git a/hadrian/bindist/Makefile b/hadrian/bindist/Makefile
index 94a74b2162..9bf9ad119f 100644
--- a/hadrian/bindist/Makefile
+++ b/hadrian/bindist/Makefile
@@ -23,43 +23,6 @@ ifeq "$(Darwin_Host)" "YES"
XATTR ?= /usr/bin/xattr
endif
-# installscript
-#
-# $1 = package name
-# $2 = wrapper path
-# $3 = bindir
-# $4 = ghcbindir
-# $5 = Executable binary path
-# $6 = Library Directory
-# $7 = Docs Directory
-# $8 = Includes Directory
-# We are installing wrappers to programs by searching corresponding
-# wrappers. If wrapper is not found, we are attaching the common wrapper
-# to it. This implementation is a bit hacky and depends on consistency
-# of program names. For hadrian build this will work as programs have a
-# consistent naming procedure.
-define installscript
- echo "installscript $1 -> $2"
- @if [ -L 'wrappers/$1' ]; then \
- $(CP) -P 'wrappers/$1' '$2' ; \
- else \
- rm -f '$2' && \
- $(CREATE_SCRIPT) '$2' && \
- echo "#!$(SHELL)" >> '$2' && \
- echo "exedir=\"$4\"" >> '$2' && \
- echo "exeprog=\"$1\"" >> '$2' && \
- echo "executablename=\"$5\"" >> '$2' && \
- echo "bindir=\"$3\"" >> '$2' && \
- echo "libdir=\"$6\"" >> '$2' && \
- echo "docdir=\"$7\"" >> '$2' && \
- echo "includedir=\"$8\"" >> '$2' && \
- echo "" >> '$2' && \
- cat 'wrappers/$1' >> '$2' && \
- $(EXECUTABLE_FILE) '$2' ; \
- fi
- @echo "$1 installed to $2"
-endef
-
# patchpackageconf
#
# Hacky function to patch up the 'haddock-interfaces' and 'haddock-html'
@@ -230,12 +193,13 @@ install_docs:
$(INSTALL_SCRIPT) docs-utils/gen_contents_index "$(DESTDIR)$(docdir)/html/libraries/"; \
fi
-BINARY_NAMES=$(shell ls ./wrappers/)
+export SHELL
install_wrappers: install_bin_libdir
@echo "Installing wrapper scripts"
$(INSTALL_DIR) "$(DESTDIR)$(WrapperBinsDir)"
- $(foreach p, $(BINARY_NAMES),\
- $(call installscript,$p,$(DESTDIR)$(WrapperBinsDir)/$p,$(WrapperBinsDir),$(ActualBinsDir),$(ActualBinsDir)/$p,$(ActualLibsDir),$(docdir),$(includedir)))
+ for p in `cd wrappers; $(FIND) . ! -type d`; do \
+ mk/install_script.sh "$$p" "$(DESTDIR)/$(WrapperBinsDir)/$$p" "$(WrapperBinsDir)" "$(ActualBinsDir)" "$(ActualBinsDir)/$$p" "$(ActualLibsDir)" "$(docdir)" "$(includedir)"; \
+ done
PKG_CONFS = $(shell find "$(DESTDIR)$(ActualLibsDir)/package.conf.d" -name '*.conf' | sed "s: :\0xxx\0:g")
update_package_db: install_bin install_lib
diff --git a/hadrian/bindist/config.mk.in b/hadrian/bindist/config.mk.in
index 3c665b8fc5..c76c1c9414 100644
--- a/hadrian/bindist/config.mk.in
+++ b/hadrian/bindist/config.mk.in
@@ -93,9 +93,6 @@ ghcheaderdir = $(ghclibdir)/rts/include
#-----------------------------------------------------------------------------
# Utilities needed by the installation Makefile
-GENERATED_FILE = chmod a-w
-EXECUTABLE_FILE = chmod +x
-CP = cp
FIND = @FindCmd@
INSTALL = @INSTALL@
INSTALL := $(subst .././install-sh,$(TOP)/install-sh,$(INSTALL))
@@ -103,6 +100,8 @@ LN_S = @LN_S@
MV = mv
SED = @SedCmd@
SHELL = @SHELL@
+RANLIB_CMD = @RanlibCmd@
+STRIP_CMD = @StripCmd@
#
# Invocations of `install' for different classes
@@ -117,9 +116,6 @@ INSTALL_MAN = $(INSTALL) -m 644
INSTALL_DOC = $(INSTALL) -m 644
INSTALL_DIR = $(INSTALL) -m 755 -d
-CREATE_SCRIPT = create () { touch "$$1" && chmod 755 "$$1" ; } && create
-CREATE_DATA = create () { touch "$$1" && chmod 644 "$$1" ; } && create
-
#-----------------------------------------------------------------------------
# Build configuration
diff --git a/hadrian/src/Rules/BinaryDist.hs b/hadrian/src/Rules/BinaryDist.hs
index c83df35d8d..5a4539afc0 100644
--- a/hadrian/src/Rules/BinaryDist.hs
+++ b/hadrian/src/Rules/BinaryDist.hs
@@ -352,6 +352,7 @@ bindistInstallFiles =
, "mk" -/- "project.mk"
, "mk" -/- "relpath.sh"
, "mk" -/- "system-cxx-std-lib-1.0.conf.in"
+ , "mk" -/- "install_script.sh"
, "README", "INSTALL" ]
-- | This auxiliary function gives us a top-level 'Filepath' that we can 'need'
diff --git a/mk/install_script.sh b/mk/install_script.sh
new file mode 100755
index 0000000000..9118795cb9
--- /dev/null
+++ b/mk/install_script.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+# $1 = executable name
+# $2 = wrapper path
+# $3 = bindir
+# $4 = ghcbindir
+# $5 = Executable binary path
+# $6 = Library Directory
+# $7 = Docs Directory
+# $8 = Includes Directory
+# We are installing wrappers to programs by searching corresponding
+# wrappers. If wrapper is not found, we are attaching the common wrapper
+# to it. This implementation is a bit hacky and depends on consistency
+# of program names. For hadrian build this will work as programs have a
+# consistent naming procedure.
+
+echo "Installing $1 -> $2"
+if [ -L "wrappers/$1" ]; then
+ cp -RP "wrappers/$1" "$2"
+else
+ rm -f "$2" &&
+ touch "$2" &&
+ echo "#!$SHELL" >> "$2" &&
+ echo "exedir=\"$4\"" >> "$2" &&
+ echo "exeprog=\"$1\"" >> "$2" &&
+ echo "executablename=\"$5\"" >> "$2" &&
+ echo "bindir=\"$3\"" >> "$2" &&
+ echo "libdir=\"$6\"" >> "$2" &&
+ echo "docdir=\"$7\"" >> "$2" &&
+ echo "includedir=\"$8\"" >> "$2" &&
+ echo "" >> "$2" &&
+ cat "wrappers/$1" >> "$2" &&
+ chmod 755 "$2"
+fi