From 95b5f42a8a21bf7303e28aa5191e68ef1bdee706 Mon Sep 17 00:00:00 2001 From: Mitsos101 Date: Thu, 2 Jul 2020 00:06:58 +0300 Subject: [PATCH 1/7] Add _check-shlibs-autofix See attached PR for details. --- mk/check/check-shlibs.mk | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/mk/check/check-shlibs.mk b/mk/check/check-shlibs.mk index 229cc13b772a..1cee3c6698a0 100644 --- a/mk/check/check-shlibs.mk +++ b/mk/check/check-shlibs.mk @@ -32,10 +32,16 @@ # # Default value: yes # +# CHECK_SHLIBS_AUTOFIX +# If set to yes, there is an attempt to fix errors automatically. +# Currently only works for Mach-O. +# +# Possible values: yes, no. +# _VARGROUPS+= check-shlibs _USER_VARS.check-shlibs= CHECK_SHLIBS -_PKG_VARS.check-shlibs= CHECK_SHLIBS_SUPPORTED +_PKG_VARS.check-shlibs= CHECK_SHLIBS_SUPPORTED CHECK_SHLIBS_AUTOFIX .if ${PKG_DEVELOPER:Uno} != "no" CHECK_SHLIBS?= yes @@ -44,6 +50,7 @@ CHECK_SHLIBS?= no .endif CHECK_SHLIBS_SUPPORTED?= yes CHECK_SHLIBS_SKIP?= # none +CHECK_PERMS_AUTOFIX?= no # All binaries and shared libraries. _CHECK_SHLIBS_ERE= (bin/|sbin/|libexec/|\.(dylib|sl|so)$$|lib/lib.*\.(dylib|sl|so)) @@ -95,3 +102,21 @@ _check-shlibs: error-check .PHONY done | \ ${PKGSRC_SETENV} ${CHECK_SHLIBS_NATIVE_ENV} ${AWK} -f ${CHECK_SHLIBS_NATIVE} > ${ERROR_DIR}/${.TARGET} .endif + +.if !empty(CHECK_SHLIBS_AUTOFIX:M[Yy][Ee][Ss] && ${OBJECT_FMT} == "Mach-O") +privileged-install-hook: _check-shlibs-autofix +_check-shlibs-autofix: error-check .PHONY + @${STEP_MSG} "Attempting to fix missing run-time search paths in ${PKGNAME}" + ${RUN} rm -f ${ERROR_DIR}/${.TARGET} + ${RUN} + cd ${DESTDIR:Q}${PREFIX:Q}; \ + ${_CHECK_SHLIBS_FILELIST_CMD} | \ + ${EGREP} -h ${_CHECK_SHLIBS_ERE:Q} | \ + while read file; do \ + case "$$file" in \ + ${CHECK_SHLIBS_SKIP:@p@${p}) continue ;;@} \ + *) ;; \ + esac; \ + install_name_tool -id ${PREFIX:Q}$$file $$file >${WARNING_DIR}/${.TARGET} 2>&1 \ + done \ +.endif From 7f433172490ddc5b2ccd4d4912f0d278b83f7c0f Mon Sep 17 00:00:00 2001 From: Mitsos101 Date: Thu, 2 Jul 2020 00:10:09 +0300 Subject: [PATCH 2/7] Enable check-shlibs-autofix on Darwin See attached PR for details. --- mk/platform/Darwin.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mk/platform/Darwin.mk b/mk/platform/Darwin.mk index d81bbbad1186..d8354309bcc9 100644 --- a/mk/platform/Darwin.mk +++ b/mk/platform/Darwin.mk @@ -220,3 +220,6 @@ WRAPPER_BIN_SH?= /bin/ksh .if ${OS_VERSION:R} < 11 _OPSYS_MISSING_FEATURES+= strnlen .endif + +# Enables _check-shlibs-autofix. +CHECK_SHLIBS_AUTOFIX?= yes From 8401bb65e0c2227f7700f7b1bef6fdf615d7eb7c Mon Sep 17 00:00:00 2001 From: Mitsos101 Date: Thu, 2 Jul 2020 00:23:33 +0300 Subject: [PATCH 3/7] Fix typo, PERMS -> SHLIBS --- mk/check/check-shlibs.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/check/check-shlibs.mk b/mk/check/check-shlibs.mk index 1cee3c6698a0..8b5d08fefcc0 100644 --- a/mk/check/check-shlibs.mk +++ b/mk/check/check-shlibs.mk @@ -50,7 +50,7 @@ CHECK_SHLIBS?= no .endif CHECK_SHLIBS_SUPPORTED?= yes CHECK_SHLIBS_SKIP?= # none -CHECK_PERMS_AUTOFIX?= no +CHECK_SHLIBS_AUTOFIX?= no # All binaries and shared libraries. _CHECK_SHLIBS_ERE= (bin/|sbin/|libexec/|\.(dylib|sl|so)$$|lib/lib.*\.(dylib|sl|so)) From 704808379c1b8b9c986c52aff39ffc10c2ce882a Mon Sep 17 00:00:00 2001 From: Mitsos101 Date: Thu, 2 Jul 2020 01:49:27 +0300 Subject: [PATCH 4/7] Fix quoting --- mk/check/check-shlibs.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/check/check-shlibs.mk b/mk/check/check-shlibs.mk index 8b5d08fefcc0..ea513718ae00 100644 --- a/mk/check/check-shlibs.mk +++ b/mk/check/check-shlibs.mk @@ -117,6 +117,6 @@ _check-shlibs-autofix: error-check .PHONY ${CHECK_SHLIBS_SKIP:@p@${p}) continue ;;@} \ *) ;; \ esac; \ - install_name_tool -id ${PREFIX:Q}$$file $$file >${WARNING_DIR}/${.TARGET} 2>&1 \ + install_name_tool -id ${PREFIX:Q}"/""$$file" "$$file" >${WARNING_DIR}/${.TARGET} 2>&1 \ done \ .endif From baaa4cdad7a1cdb8404cdf5046f857aa46fd22f2 Mon Sep 17 00:00:00 2001 From: Mitsos101 Date: Thu, 2 Jul 2020 16:49:12 +0300 Subject: [PATCH 5/7] Always pass -headerpad_max_install_names to the linker. See attached PR for details. --- mk/platform/Darwin.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mk/platform/Darwin.mk b/mk/platform/Darwin.mk index d8354309bcc9..a70c09ae289b 100644 --- a/mk/platform/Darwin.mk +++ b/mk/platform/Darwin.mk @@ -221,5 +221,9 @@ WRAPPER_BIN_SH?= /bin/ksh _OPSYS_MISSING_FEATURES+= strnlen .endif +# This option enables the use of install_name_tool(1). +_WRAP_EXTRA_ARGS.LD+= -headerpad_max_install_names +CWRAPPERS_APPEND.ld+= -headerpad_max_install_names + # Enables _check-shlibs-autofix. CHECK_SHLIBS_AUTOFIX?= yes From 4bb9bc4aed675d9a8dec8245096afc9190bde4de Mon Sep 17 00:00:00 2001 From: Mitsos101 Date: Thu, 2 Jul 2020 19:39:54 +0300 Subject: [PATCH 6/7] Fix typo --- mk/check/check-shlibs.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/check/check-shlibs.mk b/mk/check/check-shlibs.mk index ea513718ae00..528876269f31 100644 --- a/mk/check/check-shlibs.mk +++ b/mk/check/check-shlibs.mk @@ -103,7 +103,7 @@ _check-shlibs: error-check .PHONY ${PKGSRC_SETENV} ${CHECK_SHLIBS_NATIVE_ENV} ${AWK} -f ${CHECK_SHLIBS_NATIVE} > ${ERROR_DIR}/${.TARGET} .endif -.if !empty(CHECK_SHLIBS_AUTOFIX:M[Yy][Ee][Ss] && ${OBJECT_FMT} == "Mach-O") +.if !empty(CHECK_SHLIBS_AUTOFIX:M[Yy][Ee][Ss]) && ${OBJECT_FMT} == "Mach-O" privileged-install-hook: _check-shlibs-autofix _check-shlibs-autofix: error-check .PHONY @${STEP_MSG} "Attempting to fix missing run-time search paths in ${PKGNAME}" From ac718eee460b8cc89c388ea983d3e3b010f29333 Mon Sep 17 00:00:00 2001 From: Mitsos101 Date: Mon, 6 Jul 2020 12:26:25 +0300 Subject: [PATCH 7/7] Run _check-shlibs-autofix before _check-shlibs. --- mk/check/check-shlibs.mk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mk/check/check-shlibs.mk b/mk/check/check-shlibs.mk index 528876269f31..ac5f21192aff 100644 --- a/mk/check/check-shlibs.mk +++ b/mk/check/check-shlibs.mk @@ -86,7 +86,7 @@ CHECK_SHLIBS_NATIVE_ENV+= CHECK_SHLIBS_BLACKLIST=${CHECK_SHLIBS_BLACKLIST:Q} . endif privileged-install-hook: _check-shlibs -_check-shlibs: error-check .PHONY +_check-shlibs: error-check _check-shlibs-autofix .PHONY @${STEP_MSG} "Checking for missing run-time search paths in ${PKGNAME}" ${RUN} rm -f ${ERROR_DIR}/${.TARGET} ${RUN} \ @@ -119,4 +119,8 @@ _check-shlibs-autofix: error-check .PHONY esac; \ install_name_tool -id ${PREFIX:Q}"/""$$file" "$$file" >${WARNING_DIR}/${.TARGET} 2>&1 \ done \ +.else +_check-shlibs-autofix: .PHONY + @${DO_NADA} .endif +