-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·33 lines (24 loc) · 882 Bytes
/
install.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
repo=DvvCz/cpkg
triple=x86_64-unknown-linux-gnu
if command -v cpkg &> /dev/null; then
echo "Failed to install cpkg -- already exists."
exit 1
fi
# Get latest release
release_json=$(curl -s https://api.github.com/repos/$repo/releases/latest)
release_url=$(grep -o "https://.*/cpkg-v.*-$triple" <<< $release_json)
release_filename=$(grep -o "cpkg-v.*" <<< $release_url)
# CPKG_DIR defaults to ~/.cpkg
cpkg_dir=${CPKG_DIR:=~/.cpkg}
if ! test -v $cpkg_dir; then
mkdir $cpkg_dir
fi
if ! test -v $cpkg_dir/bin; then
mkdir $cpkg_dir/bin
fi
# wget handles folder creation for you
wget -qi - <<< $release_url -O $cpkg_dir/bin/cpkg
chmod +x $cpkg_dir/bin/cpkg
echo -e "\nexport CPKG_INSTALL=\"$cpkg_dir\"" >> ~/.bashrc
echo -e 'export PATH=$CPKG_INSTALL/bin:$PATH\n' >> ~/.bashrc
echo "Installed cpkg to $cpkg_dir and to PATH in ~/.bashrc.\nYou may need to run source ~/.bashrc."