From 6c7e8f067dcf4c5d793d162aeb84f074f9a14664 Mon Sep 17 00:00:00 2001 From: Carl Dong Date: Mon, 9 Nov 2020 14:58:42 -0500 Subject: [PATCH 1/3] depends: Allow relative CONFIG_SITE path env var Previously, if ./configure was invoked with: ``` $ env CONFIG_SITE=depends/x86_64-pc-linux-gnu/share/config.site ./configure ``` Where $CONFIG_SITE was a relative path, ./configure would fail with the following misleading output: ``` checking for boostlib >= 1.58.0 (105800)... yes checking whether the Boost::System library is available... yes configure: error: Could not find a version of the Boost::System library! ``` Fully resolving depends_prefix in config.site.in fixes this. To make sure that there are no other side effects I ran a diff on the config.status generated by: 1. The scripts prior to this change with CONFIG_SITE set to a full path: env CONFIG_SITE=$PWD/depends/x86_64-pc-linux-gnu/share/config.site ./configure 2. The scripts after this change with CONFIG_SITE set to a relative path: env CONFIG_SITE=depends/x86_64-pc-linux-gnu/share/config.site ./configure And it looks good! Diff: https://paste.sr.ht/~dongcarl/95b469fbc555c128046e85723d87a9082a754f6b --- depends/config.site.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/config.site.in b/depends/config.site.in index 87a3379303..d6835a2d85 100644 --- a/depends/config.site.in +++ b/depends/config.site.in @@ -1,4 +1,4 @@ -depends_prefix="`dirname ${ac_site_file}`/.." +depends_prefix="$(cd "$(dirname ${ac_site_file})/.." && pwd)" cross_compiling=maybe host_alias=@HOST@ From 618cbd2c1a630a60bed9212718dce78fe5f50108 Mon Sep 17 00:00:00 2001 From: Carl Dong Date: Mon, 9 Nov 2020 15:00:48 -0500 Subject: [PATCH 2/3] lint: Also lint files with shellcheck directive Files like config.site.in are not referenced by any other script in our tree, so we need to mark it manually with a "shellcheck shell=" directive and make sure that shellcheck is run on them. --- depends/config.site.in | 12 +++++++++++- test/lint/lint-shell.sh | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/depends/config.site.in b/depends/config.site.in index d6835a2d85..c39975ecde 100644 --- a/depends/config.site.in +++ b/depends/config.site.in @@ -1,3 +1,13 @@ +# shellcheck shell=sh disable=SC2034 # Many variables set will be used in + # ./configure but shellcheck doesn't know + # that, hence: disable=SC2034 + +true # Dummy command because shellcheck treats all directives before first + # command as file-wide, and we only want to disable for one line. + # + # See: https://github.com/koalaman/shellcheck/wiki/Directive + +# shellcheck disable=SC2154 depends_prefix="$(cd "$(dirname ${ac_site_file})/.." && pwd)" cross_compiling=maybe @@ -50,7 +60,7 @@ if test x@host_os@ = xdarwin; then fi PATH=$depends_prefix/native/bin:$PATH -PKG_CONFIG="`which pkg-config` --static" +PKG_CONFIG="$(which pkg-config) --static" # These two need to remain exported because pkg-config does not see them # otherwise. That means they must be unexported at the end of configure.ac to diff --git a/test/lint/lint-shell.sh b/test/lint/lint-shell.sh index 9a26cd9c02..351b65dea6 100755 --- a/test/lint/lint-shell.sh +++ b/test/lint/lint-shell.sh @@ -36,7 +36,8 @@ fi SHELLCHECK_CMD=(shellcheck --external-sources --check-sourced) EXCLUDE="--exclude=$(IFS=','; echo "${disabled[*]}")" -if ! "${SHELLCHECK_CMD[@]}" "$EXCLUDE" $(git ls-files -- '*.sh' | grep -vE 'src/(leveldb|secp256k1|univalue)/'); then +SOURCED_FILES=$(git ls-files | xargs gawk '/^# shellcheck shell=/ {print FILENAME} {nextfile}') # Check shellcheck directive used for sourced files +if ! "${SHELLCHECK_CMD[@]}" "$EXCLUDE" $SOURCED_FILES $(git ls-files -- '*.sh' | grep -vE 'src/(leveldb|secp256k1|univalue)/'); then EXIT_CODE=1 fi From 46756a69877ab7d56f3b05f8c5a8899eb24d9ffd Mon Sep 17 00:00:00 2001 From: Carl Dong Date: Mon, 9 Nov 2020 15:57:32 -0500 Subject: [PATCH 3/3] depends: Fix PYTHONPATH setting in config.site.in Previously, when running ./configure: 1. With CONFIG_SITE pointed to our depends config.site.in, and 2. PYTHONPATH was not set either in the environment or by the user The configure would output something like: PYTHONPATH='depends/x86_64-pc-linux-gnu/share/../native/lib/python3/dist-packages:' When we really mean: PYTHONPATH='depends/x86_64-pc-linux-gnu/share/../native/lib/python3/dist-packages' ...without the colon This change makes sure that: 1. There's no trailing colon, and 2. We use the $PATH_SEPARATOR variable instead of a colon --- depends/config.site.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/config.site.in b/depends/config.site.in index c39975ecde..f4531830c8 100644 --- a/depends/config.site.in +++ b/depends/config.site.in @@ -79,7 +79,7 @@ fi if test -n "@CXX@" -a -z "${CXX}"; then CXX="@CXX@" fi -PYTHONPATH=$depends_prefix/native/lib/python3/dist-packages:$PYTHONPATH +PYTHONPATH="${depends_prefix}/native/lib/python3/dist-packages${PYTHONPATH:+${PATH_SEPARATOR}}${PYTHONPATH}" if test -n "@AR@"; then AR=@AR@