-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.sh
executable file
·62 lines (51 loc) · 1.15 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
#!/bin/sh
set -e
DIR="$(cd "$(dirname "${0}")" && pwd)"
usage() { echo "Usage: ${0} -c <codename> -p <package>" 1>&2; exit 1; }
exitIfRoot() {
if [ "$(id -u)" -eq "0" ]; then
echo "Don't execute this script as root user!"
exit 1
fi
}
exitIfRoot
while getopts "c:p:" o; do
case "${o}" in
c)
CODENAME=${OPTARG}
;;
p)
PACKAGE=${OPTARG}
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
if [ -z "${CODENAME}" ]; then
usage
fi
if [ -z "${PACKAGE}" ]; then
usage
fi
DIR_PACKAGE="${DIR}/packages/${CODENAME}/${PACKAGE}"
cd "${DIR_PACKAGE}"
rm -rf tmp/ && mkdir tmp/ && cd tmp/
. "${DIR_PACKAGE}/setup.sh"
cp -r "${DIR_PACKAGE}/debian" ./debian
sudo mk-build-deps --install --remove debian/control
dpkg-buildpackage -us -uc
cd "${DIR_PACKAGE}"
mkdir -p pkg/
mv tmp/*.deb pkg/
rm -rf tmp/
find pkg/ -name '*.deb' -ctime +30 -delete
if ! (sudo dpkg -i "${DIR_PACKAGE}/pkg/"*.deb); then
sudo apt-get install -f
fi
PATH_TEST="${DIR_PACKAGE}/debian/tests/run-tests"
if (test -e "${PATH_TEST}"); then
echo "Now executing tests..."
"${PATH_TEST}"
fi