From 92be32df563f455efd3297955a31e73f434b667f Mon Sep 17 00:00:00 2001 From: Reid Priedhorsky Date: Fri, 8 Sep 2023 16:22:51 -0600 Subject: [PATCH 1/8] rewrite embedded paths at install time --- .gitignore | 1 - Makefile.am | 24 ++++++++++++++++++++++++ bin/ch-convert | 4 ++-- bin/ch-fromhost | 4 ++-- bin/ch-image.py.in | 4 ++-- bin/ch-run-oci.py.in | 4 ++-- bin/ch-test | 8 +++----- lib/Makefile.am | 8 +------- lib/base.sh | 6 +++--- 9 files changed, 39 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index aaf6fc5f5..45cb05de0 100644 --- a/.gitignore +++ b/.gitignore @@ -19,7 +19,6 @@ a.out /doc/doctrees/ /doc/html/ /doc/man/*.[17] -/lib/charliecloud /lib/contributors.bash /lib/lark /lib/lark-stubs diff --git a/Makefile.am b/Makefile.am index 4c26a3560..7e567ac6e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,3 +5,27 @@ SUBDIRS = lib bin doc examples misc packaging test EXTRA_DIST = .github/PERUSEME .github/workflows/main.yml EXTRA_DIST += LICENSE README.rst VERSION autogen.sh + +# Embedded paths are in the source code suitable for running from the source +# directory (i.e., without install). When installing, those paths are often +# wrong, so re-write them with the correct paths we got from configure. Note: +# Some variables are in both Python and sh, so we use syntax valid for both; +# others are just sh. +install-exec-hook: + @echo '### re-writing embedded paths ###' + for i in @bindir@/ch-convert \ + @bindir@/ch-fromhost \ + @bindir@/ch-image \ + @bindir@/ch-run-oci \ + @bindir@/ch-test \ + @libdir@/charliecloud/base.sh; \ + do \ + sed -Ei -e 's|^(ch_lib ?= ?).+/lib"?$$|\1"@libdir@/charliecloud"|' \ + -e 's|^(CHTEST_DIR=).+$$|\1@libexecdir@/charliecloud/test|' \ + -e 's|^(CHTEST_EXAMPLES_DIR=).+$$|\1@docdir@/examples|' \ + $$i; \ + done + +#bindir: @bindir@ +# echo libdir: @libdir@ +# echo libexecdir: @libexecdir@ diff --git a/bin/ch-convert b/bin/ch-convert index 9c02bee69..5399c2efb 100755 --- a/bin/ch-convert +++ b/bin/ch-convert @@ -2,8 +2,8 @@ ## preamble ################################################################## -lib=$(cd "$(dirname "$0")" && pwd)/../lib/charliecloud -. "${lib}/base.sh" +ch_lib=$(cd "$(dirname "$0")" && pwd)/../lib +. "${ch_lib}/base.sh" PATH=${ch_bin}:$PATH usage=$(cat < Date: Fri, 8 Sep 2023 16:42:20 -0600 Subject: [PATCH 2/8] install with lots of custom directories for CI --- .github/workflows/main.yml | 12 ++++++++++-- bin/ch-test | 6 ++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 241446520..134ba66c3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -263,7 +263,15 @@ jobs: else LDD=ldd fi - ./configure --prefix=$ch_prefix/from-git + # Go wild with install directories to make sure it works (see #683). + # We do have a normal install below. + ./configure --prefix=$ch_prefix/from-git \ + --datarootdir=$ch_prefix/from-git_dataroot \ + --libexecdir=$ch_prefix/from-git_libexec \ + --libdir=$ch_prefix/from-git_lib \ + --mandir=$ch_prefix/from-git_man \ + --docdir=$ch_prefix/from-git_doc \ + --htmldir=$ch_prefix/from-git_html set -x fgrep 'documentation: yes' config.log [[ $CH_TEST_BUILDER = buildah* ]] && fgrep 'with Buildah: yes' config.log @@ -344,7 +352,7 @@ jobs: mv charliecloud-*.tar.gz $ch_prefix cd $ch_prefix tar xf charliecloud-*.tar.gz - rm charliecloud-*.tar.gz # else cd fails with "too many arguments" + rm charliecloud-*.tar.gz # else cd fails with “too many arguments” cd charliecloud-* pwd # Configure and verify output. diff --git a/bin/ch-test b/bin/ch-test index acbf189b8..76f795343 100755 --- a/bin/ch-test +++ b/bin/ch-test @@ -761,12 +761,10 @@ if [[ ! -d $TMP_ ]]; then chmod 700 "$TMP_" fi -# Find test directories. (At one point we tried to unify the paths between the -# two conditions using a deeper directory hierarchy and symlinks to . in the -# source code to keep it from being even deeper, but this became too unruly.) +# Find test directories. Note some of this gets rewritten at install time. CHTEST_DIR=${ch_base}/test CHTEST_EXAMPLES_DIR=${ch_base}/examples -if [[ -d ${ch_base}/share ]]; then +if [[ ! -f ${ch_base}/VERSION ]]; then # installed CHTEST_INSTALLED=yes CHTEST_GITWD= From 4423d55b890569398c5a6c3df65bf3376b1051ca Mon Sep 17 00:00:00 2001 From: Reid Priedhorsky Date: Fri, 8 Sep 2023 16:54:58 -0600 Subject: [PATCH 3/8] fix lark paths --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 134ba66c3..4d9d49c7f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -234,7 +234,7 @@ jobs: test -f ./lib/lark/lark.py make $ch_makej sudo make $ch_makej install - [[ $(bin/ch-image -v --dependencies) = 'lark path: /home/runner/work/charliecloud/charliecloud/lib/charliecloud/lark/__init__.py' ]] + [[ $(bin/ch-image -v --dependencies) = 'lark path: /home/runner/work/charliecloud/charliecloud/lib/lark/__init__.py' ]] [[ $($ch_prefix/from-git/bin/ch-image -v --dependencies) = 'lark path: /usr/local/lib/python3.10/dist-packages/lark/__init__.py' ]] make clean # no install, enable: build fails, untested @@ -307,9 +307,9 @@ jobs: run: | set -x [[ $(bin/ch-image gestalt python-path) = /usr/bin/python3 ]] - [[ $(bin/ch-image -v --dependencies) = "lark path: /home/runner/work/charliecloud/charliecloud/lib/charliecloud/lark/__init__.py" ]] + [[ $(bin/ch-image -v --dependencies) = "lark path: /home/runner/work/charliecloud/charliecloud/lib/lark/__init__.py" ]] [[ $($ch_prefix/from-git/bin/ch-image gestalt python-path) = /usr/bin/python3 ]] - [[ $($ch_prefix/from-git/bin/ch-image -v --dependencies) = "lark path: /var/tmp/from-git/lib/charliecloud/lark/__init__.py" ]] + [[ $($ch_prefix/from-git/bin/ch-image -v --dependencies) = "lark path: /var/tmp/from-git_lib/charliecloud/lark/__init__.py" ]] - name: late setup & validation, all run: | From ec9645260613c47323fc42d3642c83bcde0fba4f Mon Sep 17 00:00:00 2001 From: Reid Priedhorsky Date: Mon, 11 Sep 2023 12:05:10 -0600 Subject: [PATCH 4/8] deal with DESTDIR correctly --- Makefile.am | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile.am b/Makefile.am index 7e567ac6e..d00f7e1f8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,12 +13,12 @@ EXTRA_DIST += LICENSE README.rst VERSION autogen.sh # others are just sh. install-exec-hook: @echo '### re-writing embedded paths ###' - for i in @bindir@/ch-convert \ - @bindir@/ch-fromhost \ - @bindir@/ch-image \ - @bindir@/ch-run-oci \ - @bindir@/ch-test \ - @libdir@/charliecloud/base.sh; \ + for i in $(DESTDIR)@bindir@/ch-convert \ + $(DESTDIR)@bindir@/ch-fromhost \ + $(DESTDIR)@bindir@/ch-image \ + $(DESTDIR)@bindir@/ch-run-oci \ + $(DESTDIR)@bindir@/ch-test \ + $(DESTDIR)@libdir@/charliecloud/base.sh; \ do \ sed -Ei -e 's|^(ch_lib ?= ?).+/lib"?$$|\1"@libdir@/charliecloud"|' \ -e 's|^(CHTEST_DIR=).+$$|\1@libexecdir@/charliecloud/test|' \ From ed9aec2ac6794d070173f96825f2ebdd14c7ddb3 Mon Sep 17 00:00:00 2001 From: Reid Priedhorsky Date: Wed, 13 Sep 2023 16:00:21 -0600 Subject: [PATCH 5/8] don't install needless singleton test directory --- Makefile.am | 2 +- test/Makefile.am | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index d00f7e1f8..1f853c3fc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -21,7 +21,7 @@ install-exec-hook: $(DESTDIR)@libdir@/charliecloud/base.sh; \ do \ sed -Ei -e 's|^(ch_lib ?= ?).+/lib"?$$|\1"@libdir@/charliecloud"|' \ - -e 's|^(CHTEST_DIR=).+$$|\1@libexecdir@/charliecloud/test|' \ + -e 's|^(CHTEST_DIR=).+$$|\1@libexecdir@/charliecloud|' \ -e 's|^(CHTEST_EXAMPLES_DIR=).+$$|\1@docdir@/examples|' \ $$i; \ done diff --git a/test/Makefile.am b/test/Makefile.am index 9fd715ead..04ef31660 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,4 +1,4 @@ -testdir = $(pkglibexecdir)/test +testdir = $(pkglibexecdir) # These test files require no special handling. testfiles = \ From 0d26c5d0d96f2212aa65bb971d075355577ccb52 Mon Sep 17 00:00:00 2001 From: Reid Priedhorsky Date: Wed, 13 Sep 2023 16:00:37 -0600 Subject: [PATCH 6/8] rm leftover commented-out code --- Makefile.am | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index 1f853c3fc..833f33497 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,7 +25,3 @@ install-exec-hook: -e 's|^(CHTEST_EXAMPLES_DIR=).+$$|\1@docdir@/examples|' \ $$i; \ done - -#bindir: @bindir@ -# echo libdir: @libdir@ -# echo libexecdir: @libexecdir@ From 0e4be14c61c5d72833f38602d6fb66e0f31d40b5 Mon Sep 17 00:00:00 2001 From: Reid Priedhorsky Date: Wed, 13 Sep 2023 17:12:22 -0600 Subject: [PATCH 7/8] ch-test: fix image name derivation --- bin/ch-test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ch-test b/bin/ch-test index 76f795343..67c7f541f 100755 --- a/bin/ch-test +++ b/bin/ch-test @@ -612,7 +612,7 @@ test_make_tag_from_path () { case $basicname in Build|Dockerfile) case $dir in - .|test|examples) # dot is directory “test” + .|examples|charliecloud|test) # dot is directory “test” if [[ -z $extension ]]; then fatal "can't compute tag: $1" else From ceff4cc8f80c7ec542869efaec73b0ca43dcd674 Mon Sep 17 00:00:00 2001 From: Reid Priedhorsky Date: Wed, 13 Sep 2023 17:21:07 -0600 Subject: [PATCH 8/8] fix RPM spec file --- packaging/fedora/charliecloud.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/fedora/charliecloud.spec b/packaging/fedora/charliecloud.spec index 494fd90bf..52dfaeabe 100644 --- a/packaging/fedora/charliecloud.spec +++ b/packaging/fedora/charliecloud.spec @@ -169,7 +169,7 @@ ln -s "${sphinxdir}/js" %{buildroot}%{_pkgdocdir}/html/_static/js %files test %{_bindir}/ch-test -%{_libexecdir}/%{name}/test +%{_libexecdir}/%{name} %{_mandir}/man1/ch-test.1* %changelog