-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_deb
executable file
·81 lines (63 loc) · 1.33 KB
/
build_deb
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
#!/bin/bash
set -e
NOCOLOR='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
LIGHTGRAY='\033[0;37m'
DARKGRAY='\033[1;30m'
LIGHTRED='\033[1;31m'
LIGHTGREEN='\033[1;32m'
YELLOW='\033[1;33m'
LIGHTBLUE='\033[1;34m'
LIGHTPURPLE='\033[1;35m'
LIGHTCYAN='\033[1;36m'
WHITE='\033[1;37m'
green()
{
echo -e "${LIGHTGREEN}$*${NOCOLOR}"
}
info()
{
echo -e "${CYAN}$*${NOCOLOR}"
}
warn()
{
echo -e "${ORANGE}$*${NOCOLOR}"
}
err()
{
echo -e "${LIGHTRED}$*${NOCOLOR}"
}
pkgname=$1
pkgversion=$2
image_src=$3
workdir="/work"
cd $workdir || exit
git config --global --add safe.directory $workdir
if [ -z "$pkgversion" ]
then
err "Version not specified"
exit 1
fi
cd /work/$pkgname
#replace - with ~ for debian compliance
pkgversion="${pkgversion/-/'~'}"
sed -i "s/VERSION = 1.2.3/VERSION = $pkgversion/g" debian/rules
sed -i "s/1.2.3/$pkgversion/g" debian/changelog
sed -i "s/VERSION?=.*$/VERSION?=$pkgversion/g" Makefile
if [ -n "$image_src" ]
then
sed -i "s|IMAGE_SRC?=.*$|IMAGE_SRC?=$image_src|g" Makefile
fi
pkg_name=$(grep "Package: " debian/control | sed 's/Package: //')
apt-get build-dep -y .
dpkg-buildpackage -us -uc -b
lintian ../"${pkg_name}"_*.deb
make clean
mkdir -p $workdir/pkg
mv ../"${pkg_name}"_*.deb $workdir/pkg
green "Build with success!"