Skip to content

Commit dbf81fa

Browse files
committed
refactor(scripts): use ln -P on non-darwin arch
1 parent 3cf17d3 commit dbf81fa

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

scripts/build_docker.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,15 @@ fi
9090
# hardlinked from.
9191
cdroot
9292
temp_dir="$(TMPDIR="$(dirname "$input_file")" mktemp -d)"
93-
ln -P "$input_file" "$temp_dir/coder"
94-
ln -P Dockerfile "$temp_dir/"
93+
ln_flags=""
94+
95+
# -P is an illegal option on darwin and will cause script to fail.
96+
if [[ $(uname | tr '[:upper:]' '[:lower:]') != 'darwin' ]]; then
97+
ln_flags+=(-P)
98+
fi
99+
100+
ln "${ln_flags[@]}" "$input_file" "$temp_dir/coder"
101+
ln "${ln_flags[@]}" Dockerfile "$temp_dir/"
95102

96103
cd "$temp_dir"
97104

scripts/package.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,21 @@ if [[ "$arch" == "arm" ]] || [[ "$arch" == "armv7" ]]; then
6464
arch="armhf"
6565
fi
6666

67+
ln_flags=""
68+
# -P is an illegal option on darwin and will cause script to fail.
69+
if [[ $(uname | tr '[:upper:]' '[:lower:]') != 'darwin' ]]; then
70+
ln_flags+=(-P)
71+
fi
72+
6773
# Make temporary dir where all source files intended to be in the package will
6874
# be hardlinked from.
6975
cdroot
7076
temp_dir="$(TMPDIR="$(dirname "$input_file")" mktemp -d)"
71-
ln -P "$input_file" "$temp_dir/coder"
72-
ln -P "$(realpath coder.env)" "$temp_dir/"
73-
ln -P "$(realpath coder.service)" "$temp_dir/"
74-
ln -P "$(realpath preinstall.sh)" "$temp_dir/"
75-
ln -P "$(realpath scripts/nfpm.yaml)" "$temp_dir/"
77+
ln "${ln_flags[@]}" "$input_file" "$temp_dir/coder"
78+
ln "${ln_flags[@]}" "$(realpath coder.env)" "$temp_dir/"
79+
ln "${ln_flags[@]}" "$(realpath coder.service)" "$temp_dir/"
80+
ln "${ln_flags[@]}" "$(realpath preinstall.sh)" "$temp_dir/"
81+
ln "${ln_flags[@]}" "$(realpath scripts/nfpm.yaml)" "$temp_dir/"
7682

7783
cd "$temp_dir"
7884

0 commit comments

Comments
 (0)