Skip to content

Commit

Permalink
Fix install.sh for Windows (#1474)
Browse files Browse the repository at this point in the history
  • Loading branch information
bloodearnest authored Jan 4, 2023
1 parent b0e6ec6 commit a1ac579
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,8 @@ jobs:

- name: Test
run: cargo test --all

- name: Test install.sh
run: |
bash www/install.sh --to /tmp
/tmp/just --version
33 changes: 27 additions & 6 deletions www/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ while test $# -gt 0; do
done

# Dependencies
need basename
need curl
need install
need mkdir
Expand All @@ -90,8 +89,12 @@ need tar

# Optional dependencies
if [ -z ${tag-} ]; then
need cut
need rev
need grep
need cut
fi

if [ -z ${target-} ]; then
need cut
fi

if [ -z ${dest-} ]; then
Expand All @@ -106,21 +109,32 @@ if [ -z ${tag-} ]; then
fi

if [ -z ${target-} ]; then
uname_target=`uname -m`-`uname -s`
# bash compiled with MINGW (e.g. git-bash, used in github windows runnners),
# unhelpfully includes a version suffix in `uname -s` output, so handle that.
# e.g. MINGW64_NT-10-0.19044
kernel=$(uname -s | cut -d- -f1)
uname_target="`uname -m`-$kernel"

case $uname_target in
aarch64-Linux) target=aarch64-unknown-linux-musl;;
arm64-Darwin) target=aarch64-apple-darwin;;
x86_64-Darwin) target=x86_64-apple-darwin;;
x86_64-Linux) target=x86_64-unknown-linux-musl;;
x86_64-Windows_NT) target=x86_64-pc-windows-msvc;;
x86_64-MINGW64_NT) target=x86_64-pc-windows-msvc;;
*)
err 'Could not determine target from output of `uname -m`-`uname -s`, please use `--target`:' $uname_target
;;
esac
fi

archive="$releases/download/$tag/$crate-$tag-$target.tar.gz"
# windows archives are zips, not tarballs
case $target in
x86_64-pc-windows-msvc) extension=zip; need unzip;;
*) extension=tar.gz;;
esac

archive="$releases/download/$tag/$crate-$tag-$target.$extension"

say_err "Repository: $url"
say_err "Crate: $crate"
Expand All @@ -130,7 +144,14 @@ say_err "Destination: $dest"
say_err "Archive: $archive"

td=$(mktemp -d || mktemp -d -t tmp)
curl --proto =https --tlsv1.2 -sSfL $archive | tar -C $td -xz

if [ "$extension" = "zip" ]; then
# unzip on windows cannot always handle stdin, so download first.
curl --proto =https --tlsv1.2 -sSfL $archive > $td/just.zip
unzip -d $td $td/just.zip
else
curl --proto =https --tlsv1.2 -sSfL $archive | tar -C $td -xz
fi

for f in $(ls $td); do
test -x $td/$f || continue
Expand Down

0 comments on commit a1ac579

Please sign in to comment.