[Git][ghc/ghc][wip/bindist-install] 2 commits: gitlab-ci: Don't use coreutils on Darwin

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Mon Aug 8 19:26:07 UTC 2022



Ben Gamari pushed to branch wip/bindist-install at Glasgow Haskell Compiler / GHC


Commits:
2d98e6b9 by Ben Gamari at 2022-08-08T15:26:02-04:00
gitlab-ci: Don't use coreutils on Darwin

In general we want to ensure that the tested environment is as similar
as possible to the environment the user will use. In the case of Darwin,
this means we want to use the system's BSD command-line utilities, not
coreutils.

This would have caught #21974.

- - - - -
b230cda3 by Ben Gamari at 2022-08-08T15:26:02-04:00
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.

- - - - -


5 changed files:

- .gitlab/darwin/toolchain.nix
- hadrian/bindist/Makefile
- hadrian/bindist/config.mk.in
- hadrian/src/Rules/BinaryDist.hs
- + mk/install_script.sh


Changes:

=====================================
.gitlab/darwin/toolchain.nix
=====================================
@@ -85,7 +85,6 @@ pkgs.writeTextFile {
     export PATH
     PATH="${pkgs.autoconf}/bin:$PATH"
     PATH="${pkgs.automake}/bin:$PATH"
-    PATH="${pkgs.coreutils}/bin:$PATH"
     export FONTCONFIG_FILE=${fonts}
     export XELATEX="${ourtexlive}/bin/xelatex"
     export MAKEINDEX="${ourtexlive}/bin/makeindex"


=====================================
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 f`; 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


=====================================
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
 


=====================================
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'


=====================================
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



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d3fdbb04c35a250c36d3c9aa6263fde851abb2ad...b230cda34119557ba4e8a01f3081d8d64ce38aaa

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d3fdbb04c35a250c36d3c9aa6263fde851abb2ad...b230cda34119557ba4e8a01f3081d8d64ce38aaa
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20220808/5c2a8459/attachment-0001.html>


More information about the ghc-commits mailing list