forked from xcat2/xcat-core
-
Notifications
You must be signed in to change notification settings - Fork 1
/
buildlocal.sh
executable file
·164 lines (131 loc) · 4.37 KB
/
buildlocal.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/sh
#######################################################################
#build script for local usage
#used for Linux/AIX/Ubuntu
#
###########################################################################
OSNAME=$(uname)
NAMEALL=$(uname -a)
for i in $*; do
# upper case the variable name
varstring=`echo "$i"|cut -d '=' -f 1|tr '[a-z]' '[A-Z]'`=`echo "$i"|cut -d '=' -f 2`
export $varstring
done
if [ -z "$CURDIR" ]; then
echo "get current directory!"
CURDIR=$(pwd)
fi
echo "CURDIR is $CURDIR"
echo "OSNAME is $OSNAME!"
echo "NAMEALL is $NAMEALL"
grep -i 'SUSE' /etc/issue
if [ $? -eq 0 ]; then
echo "This is a SUSE system!"
OS="SUSE";
fi
ls $CURDIR/makerpm
if [ $? -gt 0 ]; then
echo "Error:no repo exist, exit 1."
exit 1
fi
# Get a lock, so can not do 2 builds at once
exec 8>/var/lock/xcatbld.lock
if ! flock -n 8; then
echo "Can't get lock /var/lock/xcatbld.lock. Someone else must be doing a build right now. Exiting...."
exit 1
fi
#delete old package if there is
rm -rf $CURDIR/build/
cd $CURDIR
echo "==============================================="
echo $NAMEALL | egrep "Ubuntu"
#Check if it is an Ubuntu system
if [ $? -eq 0 ]; then
echo "This is an Ubuntu system"
pkg_type="snap"
build_string="Snap_Build"
cur_date=`date +%Y%m%d`
short_ver=`cat Version|cut -d. -f 1,2`
pkg_version="${short_ver}-${pkg_type}${cur_date}"
mkdir -p $CURDIR/build
for rpmname in xCAT-client xCAT-genesis-scripts perl-xCAT xCAT-server xCAT xCATsn xCAT-test xCAT-vlan; do
rpmname_low=`echo $rpmname | tr '[A-Z]' '[a-z]'`
echo "============================================"
echo "$rpmname_low"
cd $rpmname
dch -v $pkg_version -b -c debian/changelog $build_string
dpkg-buildpackage -uc -us
rc=$?
if [ $rc -gt 0 ]; then
echo "Error: $rpmname build package failed exit code $rc"
fi
cd -
mv ${rpmname_low}* $CURDIR/build
done
#delete all files except .deb file
find $CURDIR/build/* ! -name *.deb | xargs rm -f
else
#This is not an Ubuntu system
echo "This is an $OSNAME system"
if [ "$OS" = "SUSE" ]; then
rm -rf /usr/src/packages/RPMS/noarch/*
rm -rf /usr/src/packages/RPMS/x86_64/*
rm -rf /usr/src/packages/RPMS/ppc64/*
else
rm -rf /root/rpmbuild/RPMS/noarch/*
rm -rf /root/rpmbuild/RPMS/x86_64/*
rm -rf /root/rpmbuild/RPMS/ppc64/*
fi
mkdir -p $CURDIR/build/
#always build perl-xCAT
$CURDIR/makerpm perl-xCAT
# Build the rest of the noarch rpms
for rpmname in xCAT-client xCAT-server xCAT-IBMhpc xCAT-rmc xCAT-test xCAT-buildkit xCAT-vlan; do
if [ "$OSNAME" = "AIX" -a "$rpmname" = "xCAT-buildkit" ]; then continue; fi
$CURDIR/makerpm $rpmname
done
#build xCAT-genesis-scripts if it is x86_64 platform
ARCH=$(uname -p)
if [ "$ARCH" = "x86_64" ]; then
$CURDIR/makerpm xCAT-genesis-scripts x86_64
else
$CURDIR/makerpm xCAT-genesis-scripts ppc64
fi
# Build the xCAT and xCATsn rpms for all platforms
for rpmname in xCAT xCATsn; do
if [ "$OSNAME" = "AIX" ]; then
$CURDIR/makerpm $rpmname
if [ $? -ne 0 ]; then FAILEDRPMS="$FAILEDRPMS $rpmname"; fi
else
for arch in x86_64 ppc64 s390x; do
$CURDIR/makerpm $rpmname $arch
if [ $? -ne 0 ]; then FAILEDRPMS="$FAILEDRPMS $rpmname-$arch"; fi
done
fi
done
if [ "$OS" = "SUSE" ]; then
cp /usr/src/packages/RPMS/noarch/* $CURDIR/build/
cp /usr/src/packages/RPMS/x86_64/* $CURDIR/build/
cp /usr/src/packages/RPMS/ppc64/* $CURDIR/build/
else
cp /root/rpmbuild/RPMS/noarch/* $CURDIR/build/
cp /root/rpmbuild/RPMS/x86_64/* $CURDIR/build/
cp /root/rpmbuild/RPMS/ppc64/* $CURDIR/build/
fi
#begin to create repo for redhat platform
grep -i 'Red' /etc/*release*;
if [ "$OSNAME" != "AIX" -a $? -eq 0 ]; then
cat >$CURDIR/build/xcat-core.repo << EOF
[xcat-core]
name=xCAT 2 Core packages
baseurl=file://$CURDIR/build
enabled=1
gpgcheck=0
EOF
cp $CURDIR/build/xcat-core.repo /etc/yum.repos.d/
createrepo $CURDIR/build
else
rm -f /etc/zypp/repos.d/xcat-core.repo
zypper ar file://$CURDIR/build xcat-core
fi
fi