forked from xcat2/xcat-inventory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-ubuntu
executable file
·119 lines (105 loc) · 3.31 KB
/
build-ubuntu
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
#!/bin/bash
#
# Author: Yuan Bai ([email protected])
#
#
printusage()
{
printf "Usage: %s -c \n" $(basename $0) >&2
echo " -c : Build the xcat-inventory deb package"
}
# For the purpose of getting the distribution name
if [[ ! -f /etc/lsb-release ]]; then
echo "ERROR: Could not find /etc/lsb-release, is this script executed on a Ubuntu machine?"
exit 1
fi
. /etc/lsb-release
# Check the necessary packages before starting the build
declare -a packages=( "reprepro" "devscripts" "debhelper" "quilt" )
for package in ${packages[@]}; do
RC=`dpkg -l | grep $package >> /dev/null 2>&1; echo $?`
if [[ ${RC} != 0 ]]; then
echo "ERROR: Could not find $package, install using 'apt-get install $package' to continue"
exit 1
fi
done
# Supported distributions
dists="saucy trusty utopic xenial"
c_flag=$1
if [ -z "$c_flag" ];then
printusage
exit 2
fi
if [ "$c_flag" != "-c" ];then
printusage
exit 2
fi
# Find where this script is located to set some build variables
old_pwd=`pwd`
cd `dirname $0`
curdir=`pwd`
export HOME=/root
WGET_CMD="wget"
if [ ! -z ${LOG} ]; then
WGET_CMD="wget -o ${LOG}"
fi
if [ "$c_flag" ]
then
if [ -z "$REL" ]; then
t=${curdir%/src/xcat-core}
REL=`basename $t`
fi
if [ "$PROMOTE" != 1 ]; then
code_change=1
ver=`cat Version`
short_ver=`cat Version|cut -d. -f 1,2`
short_short_ver=`cat Version|cut -d. -f 1`
build_time=`date`
build_machine=`hostname`
commit_id=`git rev-parse --short HEAD`
commit_id_long=`git rev-parse HEAD`
echo "###############################"
echo "# Building xcat-inventory package #"
echo "###############################"
#the package type: local | snap | alpha
#the build introduce string
build_string="Snap_Build"
xcat_release="snap$(date '+%Y%m%d%H%M')"
pkg_version="${ver}-${xcat_release}"
packages="xcat-inventory"
target_archs=(all)
for file in $packages
do
file_low=`echo $file | tr '[A-Z]' '[a-z]'`
target_archs="all"
for target_arch in $target_archs
do
cd $file
CURDIR=$(pwd)
dch -v $pkg_version -b -c debian/changelog $build_string
if [ "$target_arch" = "all" ]; then
CURDIR=$(pwd)
cp ${CURDIR}/debian/control ${CURDIR}/debian/control.save.998
# Magic string used here
sed -i -e "s#>= 2.13-snap000000000000#= ${pkg_version}#g" ${CURDIR}/debian/control
dpkg-buildpackage -rfakeroot -uc -us
mv ${CURDIR}/debian/control.save.998 ${CURDIR}/debian/control
dh_testdir
dh_testroot
dh_clean -d
fi
rc=$?
if [ $rc -gt 0 ]; then
echo "Error: $file build package failed exit code $rc"
exit $rc
fi
rm -f debian/files
sed -i -e "s/* Snap_Build//g" debian/changelog
cd -
rm -f ${file_low}_*.tar.gz
rm -f ${file_low}_*.changes
rm -f ${file_low}_*.dsc
done
done
fi
fi