Fix install.sh for Windows (#1474)

This commit is contained in:
Simon Davy 2023-01-04 19:12:19 +00:00 committed by GitHub
parent b0e6ec699b
commit a1ac579271
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 6 deletions

View File

@ -131,3 +131,8 @@ jobs:
- name: Test - name: Test
run: cargo test --all run: cargo test --all
- name: Test install.sh
run: |
bash www/install.sh --to /tmp
/tmp/just --version

View File

@ -81,7 +81,6 @@ while test $# -gt 0; do
done done
# Dependencies # Dependencies
need basename
need curl need curl
need install need install
need mkdir need mkdir
@ -90,8 +89,12 @@ need tar
# Optional dependencies # Optional dependencies
if [ -z ${tag-} ]; then if [ -z ${tag-} ]; then
need grep
need cut
fi
if [ -z ${target-} ]; then
need cut need cut
need rev
fi fi
if [ -z ${dest-} ]; then if [ -z ${dest-} ]; then
@ -106,7 +109,11 @@ if [ -z ${tag-} ]; then
fi fi
if [ -z ${target-} ]; then 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 case $uname_target in
aarch64-Linux) target=aarch64-unknown-linux-musl;; aarch64-Linux) target=aarch64-unknown-linux-musl;;
@ -114,13 +121,20 @@ if [ -z ${target-} ]; then
x86_64-Darwin) target=x86_64-apple-darwin;; x86_64-Darwin) target=x86_64-apple-darwin;;
x86_64-Linux) target=x86_64-unknown-linux-musl;; x86_64-Linux) target=x86_64-unknown-linux-musl;;
x86_64-Windows_NT) target=x86_64-pc-windows-msvc;; 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 err 'Could not determine target from output of `uname -m`-`uname -s`, please use `--target`:' $uname_target
;; ;;
esac esac
fi 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 "Repository: $url"
say_err "Crate: $crate" say_err "Crate: $crate"
@ -130,7 +144,14 @@ say_err "Destination: $dest"
say_err "Archive: $archive" say_err "Archive: $archive"
td=$(mktemp -d || mktemp -d -t tmp) 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 for f in $(ls $td); do
test -x $td/$f || continue test -x $td/$f || continue