Skip to content

Commit 07448c4

Browse files
committed
fix(bootstrap): recover runtime path when JAROWORKDIR is invalid
1 parent b243895 commit 07448c4

3 files changed

Lines changed: 43 additions & 0 deletions

File tree

.github/workflows/pr-tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
chmod +x extras/test/test-filtering.sh
3232
chmod +x extras/test/test-sieve-import.sh
3333
chmod +x extras/test/test-helpers.sh
34+
chmod +x extras/test/test-bootstrap-paths.sh
3435
3536
- name: Build
3637
run: make
@@ -55,3 +56,6 @@ jobs:
5556

5657
- name: Helper binary tests
5758
run: extras/test/test-helpers.sh
59+
60+
- name: Bootstrap path tests
61+
run: extras/test/test-bootstrap-paths.sh
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env zsh
2+
3+
set -euo pipefail
4+
5+
script_dir="${0:A:h}"
6+
source "${script_dir}/lib/test_helpers.zsh"
7+
test_setup "${0}"
8+
9+
cleanup() {
10+
test_cleanup
11+
}
12+
trap cleanup EXIT INT TERM
13+
14+
bad_root="${tmp_root}/missing-workdir"
15+
mkdir -p "${bad_root}"
16+
17+
output="$(
18+
JAROMAILDIR="${mail_root}" \
19+
JAROWORKDIR="${bad_root}" \
20+
"${repo_root}/src/jaro" source addr 2>&1
21+
)"
22+
23+
assert_contains "${output}" "System in ${repo_root}/src" "bootstrap recovers workdir"
24+
assert_contains "${output}" "Mail in ${mail_root}" "bootstrap keeps maildir"

src/zlibs/bootstrap

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Resolve runtime paths and load the core framework + libraries.
44
# use GNU/Linux default in local
55
WORKDIR="/usr/local/share/jaromail"
6+
bootstrap_file="${(%):-%x}"
7+
bootstrap_root="${bootstrap_file:A:h:h}"
68

79
# check if we are testing from source
810
if [[ -r ../src/jaro ]]; then
@@ -18,6 +20,19 @@ WORKDIR="/usr/local/share/jaromail"
1820
# env override
1921
WORKDIR=${JAROWORKDIR:-$WORKDIR}
2022

23+
# If WORKDIR is blank or does not contain zlibs, derive it from this file.
24+
if [[ -z "$WORKDIR" || ! -d "$WORKDIR/zlibs" ]]; then
25+
if [[ -d "$bootstrap_root/zlibs" ]]; then
26+
WORKDIR="$bootstrap_root"
27+
fi
28+
fi
29+
30+
# Abort early if no valid runtime path can be found.
31+
if [[ ! -d "$WORKDIR/zlibs" ]]; then
32+
print -u2 "Cannot find Jaro Mail runtime in WORKDIR: ${WORKDIR}"
33+
exit 1
34+
fi
35+
2136
# load our zuper extension
2237
# different load paths from inside source or installed
2338
if [[ -r "$WORKDIR/zuper/zuper" ]]; then

0 commit comments

Comments
 (0)