Fix install script (#1844)
This commit is contained in:
parent
639ed74c23
commit
22d462bd55
@ -30,19 +30,15 @@ url=https://github.com/casey/just
|
|||||||
releases=$url/releases
|
releases=$url/releases
|
||||||
|
|
||||||
say() {
|
say() {
|
||||||
echo "install: $@"
|
echo "install: $@" >&2
|
||||||
}
|
|
||||||
|
|
||||||
say_err() {
|
|
||||||
say "$@" >&2
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err() {
|
err() {
|
||||||
if [ ! -z ${td-} ]; then
|
if [ ! -z ${td-} ]; then
|
||||||
rm -rf $td
|
rm -rf "$td"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
say_err "error: $@"
|
say "error: $@"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,14 +76,12 @@ while test $# -gt 0; do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
# Dependencies
|
|
||||||
need curl
|
need curl
|
||||||
need install
|
need install
|
||||||
need mkdir
|
need mkdir
|
||||||
need mktemp
|
need mktemp
|
||||||
need tar
|
need tar
|
||||||
|
|
||||||
# Optional dependencies
|
|
||||||
if [ -z ${tag-} ]; then
|
if [ -z ${tag-} ]; then
|
||||||
need grep
|
need grep
|
||||||
need cut
|
need cut
|
||||||
@ -102,7 +96,9 @@ if [ -z ${dest-} ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z ${tag-} ]; then
|
if [ -z ${tag-} ]; then
|
||||||
tag=$(curl --proto =https --tlsv1.2 -sSf https://api.github.com/repos/casey/just/releases/latest |
|
tag=$(
|
||||||
|
curl --proto =https --tlsv1.2 -sSf \
|
||||||
|
https://api.github.com/repos/casey/just/releases/latest |
|
||||||
grep tag_name |
|
grep tag_name |
|
||||||
cut -d'"' -f4
|
cut -d'"' -f4
|
||||||
)
|
)
|
||||||
@ -120,15 +116,14 @@ if [ -z ${target-} ]; then
|
|||||||
arm64-Darwin) target=aarch64-apple-darwin;;
|
arm64-Darwin) target=aarch64-apple-darwin;;
|
||||||
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-MINGW64_NT) target=x86_64-pc-windows-msvc;;
|
x86_64-MINGW64_NT) target=x86_64-pc-windows-msvc;;
|
||||||
|
x86_64-Windows_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
|
||||||
|
|
||||||
# windows archives are zips, not tarballs
|
|
||||||
case $target in
|
case $target in
|
||||||
x86_64-pc-windows-msvc) extension=zip; need unzip;;
|
x86_64-pc-windows-msvc) extension=zip; need unzip;;
|
||||||
*) extension=tar.gz;;
|
*) extension=tar.gz;;
|
||||||
@ -136,32 +131,27 @@ esac
|
|||||||
|
|
||||||
archive="$releases/download/$tag/$crate-$tag-$target.$extension"
|
archive="$releases/download/$tag/$crate-$tag-$target.$extension"
|
||||||
|
|
||||||
say_err "Repository: $url"
|
say "Repository: $url"
|
||||||
say_err "Crate: $crate"
|
say "Crate: $crate"
|
||||||
say_err "Tag: $tag"
|
say "Tag: $tag"
|
||||||
say_err "Target: $target"
|
say "Target: $target"
|
||||||
say_err "Destination: $dest"
|
say "Destination: $dest"
|
||||||
say_err "Archive: $archive"
|
say "Archive: $archive"
|
||||||
|
|
||||||
td=$(mktemp -d || mktemp -d -t tmp)
|
td=$(mktemp -d || mktemp -d -t tmp)
|
||||||
|
|
||||||
if [ "$extension" = "zip" ]; then
|
if [ "$extension" = "zip" ]; then
|
||||||
# unzip on windows cannot always handle stdin, so download first.
|
|
||||||
curl --proto =https --tlsv1.2 -sSfL $archive > $td/just.zip
|
curl --proto =https --tlsv1.2 -sSfL $archive > $td/just.zip
|
||||||
unzip -d $td $td/just.zip
|
unzip -d $td $td/just.zip
|
||||||
else
|
else
|
||||||
curl --proto =https --tlsv1.2 -sSfL $archive | tar -C $td -xz
|
curl --proto =https --tlsv1.2 -sSfL $archive | tar -C $td -xz
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for f in $(ls $td); do
|
if [ -e "$dest/just" ] && [ $force = false ]; then
|
||||||
test -x $td/$f || continue
|
err "\`$dest/just\` already exists"
|
||||||
|
else
|
||||||
if [ -e "$dest/$f" ] && [ $force = false ]; then
|
|
||||||
err "$f already exists in $dest"
|
|
||||||
else
|
|
||||||
mkdir -p $dest
|
mkdir -p $dest
|
||||||
install -m 755 $td/$f $dest
|
install -m 755 "$td/just" $dest
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
|
|
||||||
rm -rf $td
|
rm -rf $td
|
||||||
|
Loading…
Reference in New Issue
Block a user