-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
deb.sh
executable file
·131 lines (107 loc) · 2.5 KB
/
deb.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
129
130
131
#!/bin/bash
#
# This script generate debian package for Leosac.
#
#
# SUBROUTINES
#
# Unused function
function die()
{
if [ -z $1 ]; then
echo "No return value..."
exit 42;
fi
echo $2
rm -rf $TMP_DIR
exit $1
}
function clone()
{
git clone $1
pushd leosac
git checkout $2;
git submodule init;
git submodule update;
popd
}
usage()
{
cat <<EOF
Usage: $0 [-h] [-u GIT REPO ] [-b GIT BRANCH ]
OPTIONS:
-h Show this message and quit
-u Full url to a Leosac git repo. If undefined default git repo will be used.
-b Git branch name to checkout
-v A version to force set. If undefined, the version is extracted from the root CMakeLists.txt
EOF
}
#
# BEGIN MAIN PROGRAM
#
# Set default values
url="https://github.com/leosac/leosac.git"
branch="develop"
while getopts "hu:b:" OPTION
do
case $OPTION in
h)
usage
exit 0
;;
u)
url="$OPTARG"
;;
b)
branch="$OPTARG"
;;
v)
VERSION="$OPTARG"
;;
*)
usage
exit 50
;;
esac
done
# Check to see if this script has access to all the commands it needs
for CMD in cp debuild egrep git grep mk-build-deps mv sudo tar; do
type $CMD 2>&1 > /dev/null
if [ $? -ne 0 ]; then
echo
echo "ERROR: The script cannot find the required command \"${CMD}\"."
echo
exit 99
fi
done
TMP_DIR=$(mktemp -d)
cd $TMP_DIR
echo $TMP_DIR
clone $url $branch
if [ -z ${VERSION+x} ] ; then
MAJOR=`grep "DLEOSAC_VERSION_MAJOR=" leosac/CMakeLists.txt | egrep -o '([0-9]+)'`
MINOR=`grep "DLEOSAC_VERSION_MINOR=" leosac/CMakeLists.txt | egrep -o '([0-9]+)'`
PATCH=`grep "DLEOSAC_VERSION_PATCH=" leosac/CMakeLists.txt | egrep -o '([0-9]+)'`
VERSION=${MAJOR}.${MINOR}.${PATCH}
fi
name="leosac_${VERSION}"
mv leosac $name
tar czf leosac_${VERSION}.orig.tar.gz $name
cd $name
#copy existing pkg/debian directory (maintained in repos, with patches)
cp -R pkg/debian .
# Auto-install build dependencies using the debian control file
sudo mk-build-deps -ir -t "apt-get -o Debug::pkgProblemResolver=yes \
--no-install-recommends --no-upgrade -y" \
./debian/control
if [ -z ${DEB_BUILD_OPTIONS} ] ; then
export DEB_BUILD_OPTIONS="parallel=3"
fi
debuild -b -us -uc
RESULT="$?"
if [ "$RESULT" == "0" ]; then
echo
echo "The build succeeded."
echo "Debian package files can be found here: ${TMP_DIR}"
echo
fi