forked from pebcak/ingress-ice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·128 lines (104 loc) · 3.19 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
# Ingress ICE buildscript
NRML="$(tput sgr0)"
RED="$(tput setaf 1)"
BLUE="$(tput setaf 4)"
GREEN="$(tput setaf 2)"
DIR="`pwd`"
declare -A platforms=(
["ingress-ice-linux32"]="https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-i686.tar.bz2"
["ingress-ice-linux64"]="https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2"
["ingress-ice-armv6l"]="https://github.com/spfaffly/phantomjs-linux-armv6l/blob/master/phantomjs-2.0.1-development-linux-armv6l.tar.gz?raw=true"
["ingress-ice-osx"]="https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-macosx.zip"
["ingress-ice-win32"]="https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-windows.zip"
)
declare -A cmds=(
["ingress-ice-linux32"]="tar xvjf "
["ingress-ice-linux64"]="tar xvjf "
["ingress-ice-armv6l"]="tar xvzf "
["ingress-ice-osx"]="unzip "
["ingress-ice-win32"]="unzip "
)
declare -A pack=(
["ingress-ice-linux32"]="tar cvzf ingress-ice-linux32.tar.gz --owner=0 --group=0"
["ingress-ice-linux64"]="tar cvzf ingress-ice-linux64.tar.gz --owner=0 --group=0"
["ingress-ice-armv6l"]="tar cvzf ingress-ice-armv6l.tar.gz --owner=0 --group=0"
["ingress-ice-osx"]="zip -r ingress-ice-osx.zip"
["ingress-ice-win32"]="zip -r ingress-ice-win32.zip"
)
declare -A clean=(
["ingress-ice-linux32"]="ingress-ice.cmd reconfigure.cmd"
["ingress-ice-linux64"]="ingress-ice.cmd reconfigure.cmd"
["ingress-ice-armv6l"]="ingress-ice.cmd reconfigure.cmd"
["ingress-ice-osx"]="ingress-ice.cmd reconfigure.cmd"
["ingress-ice-win32"]="ingress-ice.sh"
)
TEMP_DIR="/tmp/ingress-ice"
say_red() {
echo -e "> $RED$1$NRML"
exit 1
}
say_blue() {
echo "> $BLUE$1$NRML"
}
say_green() {
echo "> $GREEN$1$NRML"
}
quit() {
echo -e ">$RED Operation cancelled by user.$NRML"
kill -- -$(ps -o pgid= $pokepid | grep -o '[0-9]*') >/dev/null
exit 2
}
remove() {
for i in $@; do
rm "$i" -rf
say_green "Deleted $i"
done
}
trap "quit" 2
[[ -d "$TEMP_DIR" ]] && rm -rf "$TEMP_DIR"
say_blue "Copying everything to a temporary directory..."
mkdir "$TEMP_DIR/original" -p
cp * "$TEMP_DIR/original" -R
say_blue "Removing development-related files..."
cd $TEMP_DIR/original
remove .git .gitattributes .gitignore CONTRIBUTING.md Dockerfile docker-ingress-ice.sh .editorconfig .dockerignore build.sh ingress-ice-* phantom-bin
cd ..
say_blue "Creating directories for different OS..."
for i in ${!platforms[@]}; do
cp original "$i" -R
say_green "Created $i"
done
say_blue "Downloading PhantomJS for each OS..."
mkdir phantom-bin && cd phantom-bin
for i in ${!platforms[@]}; do
[[ ! -d "$i" ]] && mkdir "$i"
cd "$i"
wget ${platforms[$i]} -O phntm
${cmds[$i]} phntm
say_green "Downloaded for $i"
find -regex ".\/phantom.*\/bin\/phantom.*" -exec mv {} "../../$i" \;
cd ..
done
cd ..
say_blue "Cleaning..."
for i in ${!clean[@]}; do
if [[ -d "$i" ]]; then
cd "$i"
rm -rf ${clean[$i]}
say_green "Found and removed ${clean[$i]}"
cd ..
fi
done
say_blue "Archiving Ingress ICE"
for i in ${!platforms[@]}; do
${pack[$i]} "$i"
say_green "Packed $i"
done
say_blue "Saving your archives..."
mv *.tar.gz $DIR
mv *.zip $DIR
cd $DIR
say_blue "You now have these builds:"
ls -l *.tar.gz *.zip
rm "$TEMP_DIR" -rf