forked from xcat2/xcat-inventory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-ubuntu
executable file
·120 lines (107 loc) · 3.33 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
120
#!/bin/bash
#
# Author: Yuan Bai (bybai@cn.ibm.com)
#
#
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
VERSION=$(git describe --long --tags|cut -d- -f 1 | tail -c +2)
NUMCOMMITS=$(git describe --long --tags|cut -d- -f 2)
if [ "$NUMCOMMITS" != "$VERSION" ]; then
VERSION=$VERSION
fi
echo $VERSION > Version
if [ "$c_flag" ]
then
if [ -z "$REL" ]; then
t=${curdir%/src/xcat-core}
REL=`basename $t`
fi
if [ "$PROMOTE" != 1 ]; then
build_machine=`hostname`
commit_id_long=`git rev-parse HEAD`
echo "###################################"
echo "# Building xcat-inventory package #"
echo "###################################"
#the build introduce string
build_string="xcat-inventory Build"
pkg_version="${VERSION}-c${NUMCOMMITS}"
VERINFO="${VERSION} (git commit $commit_id_long)"
echo "VERINFO $VERINFO"
packages="xcat-inventory"
cp -f $curdir/xcat-inventory/xcclient/inventory/shell.py /tmp/
sed -i s/\#VERSION_SUBSTITUTE\#/"$VERINFO"/g $curdir/xcat-inventory/xcclient/inventory/shell.py
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)
dpkg-buildpackage -rfakeroot -uc -us
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/* Build//g" debian/changelog
cd -
rm -f ${file_low}_*.tar.gz
rm -f ${file_low}_*.changes
rm -f ${file_low}_*.dsc
done
done
if [ -f /tmp/shell.py ]; then
cp -f /tmp/shell.py $curdir/xcat-inventory/xcclient/inventory/shell.py
rm -f /tmp/shell.py
fi
fi
fi