-
Notifications
You must be signed in to change notification settings - Fork 172
/
build-python-deb
executable file
·91 lines (84 loc) · 2.49 KB
/
build-python-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
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
#
# Author: Yuan Bai (bybai@cn.ibm.com)
#
#
printusage()
{
echo "Usage : build-python-deb xcat-openbmc-py"
}
# 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 commands before starting the build
for cmd in dch dpkg-buildpackage
do
if ! type "$cmd" >/dev/null 2>&1
then
echo "ERROR: Required command, $package, not found." >&2
exit 1
fi
done
# Supported distributions
pkg_name=$1
if [ "$pkg_name" != "xcat-openbmc-py" ]; then
printusage
exit 1
fi
# Find where this script is located to set some build variables
old_pwd=`pwd`
cd `dirname $0`
curdir=`pwd`
if [ -z "$REL" ]; then
t=${curdir%/src/xcat-core}
REL=`basename $t`
fi
if [ "$PROMOTE" != 1 ]; then
ver=`cat Version`
echo "###############################"
echo "# Building xcat-openbmc-py 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-openbmc-py"
for file in $packages
do
file_low="${file,,}"
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
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
rm -f debian/xcat-openbmc-py.debhelper.log
rm -f debian/xcat-openbmc-py.substvars
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