-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-game.sh
executable file
·107 lines (92 loc) · 2.1 KB
/
build-game.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
#!/bin/sh
# Script builds some game packet.
# Needs to be invoked from game directory.
# ---- AUX FUNCTIONS ----
# $1: path to packet dir that contains debian/ dir
extract_ver() {
ls -1 $1 | grep .orig.tar.gz | sed -rn 's/.*_(.*)\.orig\.tar\.gz/\1/p'
}
# $1: path to packet dir that contains debian/ dir
extract_verd() {
cat $1/debian/changelog | head -1 | sed -rn 's/.*\((.*)\).*/\1/p'
}
# ---- VARIABLES ----
gn=$(ls -1 | grep orig.tar.gz | sed -rn 's/.*-(.*)_.*/\1/p')
ver=$(extract_ver .)
verd=$(extract_verd .) # +debian packaging ver
game_dir=instead-game-${gn}-$ver
game_orig_tar=instead-game-${gn}_$ver.orig.tar.gz
cur_dir=$(pwd)
home_dir=$(echo ~)
build_dir=../build_all
build_files="\
instead-game-${gn}_${verd}_all.deb \
instead-game-${gn}_${verd}_amd64.build \
instead-game-${gn}_${verd}_amd64.changes \
instead-game-${gn}_${verd}.debian.tar.gz \
instead-game-${gn}_${verd}.dsc"
# ---- FUNCTIONS ----
clean() {
echo "Cleaning build files..."
rm -rf $build_files
rm -rf $game_dir
echo "Cleaning build files [OK]"
}
rm_build() {
rm -rf "$build_dir"
}
prepare() {
echo "Preparing for building..."
tar -xzf $game_orig_tar
cp -R debian/ $game_dir
echo "Preparing for building [OK]"
}
build() {
echo "Start building deb..."
cd $game_dir
debuild --lintian-opts -i
res=$?
cd $cur_dir
if [ $res -eq 0 ]; then
echo "Building deb [OK]"
else
echo "Building deb [FAILED]" >&2
exit 1
fi
}
move() {
echo "Moving files to build dir..."
rm_build
mkdir "$build_dir"
for f in $build_files; do
mv $f "$build_dir"
done
cp -f instead-game-*.orig.tar.gz "$build_dir"
echo "Moving files to build dir [OK]"
}
# ---- ENTRY POINT ----
case "$1" in
"-c"|"--clean")
clean
;;
"-dc"|"--distclean")
clean
rm_build
;;
"-p"|"--prepare")
prepare
;;
"-b"|"--build")
build
;;
"-a"|"--all")
clean
prepare
build
move
clean
;;
*)
echo "Invalid arguments" >&2
exit 1
esac