-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.sh
executable file
·52 lines (36 loc) · 1.31 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
#!/bin/bash
distro=$(awk -F= '$1 == "ID_LIKE" { print $2 }' /etc/*-release)
if ! [ -x "$(command -v cargo)" ]; then
echo 'Error: rust compiler is not installed.' >&2
echo 'installing rust compiler..'
#curls the rust compiler
curl https://sh.rustup.rs -sSf | sh -s -- -y
. $HOME/.cargo/env
fi
[ ! -d ~/.punch ] && \
mkdir -p ~/.punch/trash && mkdir ~/.punch/bin && echo "~/.punch created in home"
cargo build --release \
&& echo "succefully compiled"
mv ./target/release/punch ~/.punch/bin/
if ! command -V punch &> /dev/null
then
{
printf 'export PATH=$PATH:~/.punch/bin/' >> ~/.zshrc \
&& printf 'export PATH=$PATH:~/.punch/bin/' >> ~/.bashrc \
&& . ~/.zshrc \
&& . ~/.bashrc
}||{
printf 'export PATH=$PATH:~/.punch/bin/' >> ~/.bashrc \
&& . ~/.bashrc
}||{
printf 'export PATH=$PATH:~/.punch/bin/' >> ~/.zshrc \
&& . ~/.zshhrc
}||{
echo "failed: if you are on debian cc build essentials must be installed, run :" \
\
&& echo 'sudo apt update && sudo apt upgrade && sudo apt-get install build-essential' \
\
&& echo 'after running, try building again'
}
fi
echo "build complete-- type: punch -h"