-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
executable file
·62 lines (48 loc) · 1.12 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
main() {
need_cmd curl
need_cmd grep
need_cmd cut
need_cmd xargs
need_cmd chmod
build
}
build() {
CDIR="$(cd "$(dirname "$0")" && pwd)"
build_dir=$CDIR/build
while getopts A:K:q option
do
case "${option}"
in
q) QUIET=1;;
A) ARCH=${OPTARG};;
K) KERNEL=${OPTARG};;
esac
done
rm -rf $build_dir
mkdir -p $build_dir
cd $CDIR
cp *prerun.sh *pluginrc.* $build_dir/
cd $build_dir
# The logic is from https://github.com/ajeetdsouza/zoxide/blob/06062e92ca591a3758f2d69c9b1cd772a6a378b0/install.sh
echo "Downloading zoxide..."
_cputype="x86_64"
_clibtype="musl"
_ostype=unknown-linux-$_clibtype
_target="$_cputype-$_ostype"
rm -rf "zoxide-$_target"
curl -s https://api.github.com/repos/ajeetdsouza/zoxide/releases/latest | grep "browser_download_url" | cut -d '"' -f 4 | grep "$_target" | xargs -n 1 curl -LJO
tar -xf zoxide-*.tar.gz zoxide
chmod +x zoxide
}
cmd_chk() {
>&2 echo Check "$1"
command -v "$1" >/dev/null 2>&1
}
need_cmd() {
if ! cmd_chk "$1"; then
error "need $1 (command not found)"
exit 1
fi
}
main "$@" || exit 1