forked from xcat2/xcat-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuilddep.sh
executable file
·273 lines (238 loc) · 8.3 KB
/
builddep.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# The shell is commented out so that it will run in bash on linux and ksh on aix
# !/bin/sh
# Package up all the xCAT open source dependencies, setting up yum repos and
# also tar it all up. This assumes that individual rpms have already been built for
# all relevant architectures from the src & spec files in svn.
# When running this script to package xcat-dep:
# - You need to install gsa-client on the build machine.
# - You probably want to put root's pub key from the build machine onto sourceforge for
# the upload user listed below, so you don't have to keep entering pw's. You can do this
# at https://sourceforge.net/account/ssh
# - Also make sure createrepo is installed on the build machine
# Usage: builddep.sh [attr=value attr=value ...]
# DESTDIR=<dir> - the dir to place the dep tarball in. The default is ../../../xcat-dep, relative
# to where this script is located.
# UP=0 or UP=1 - override the default upload behavior
# FRSYUM=0 - put the directory of individual rpms in the project web area instead of the FRS area.
# VERBOSE=1 - to see lots of verbose output
# you can change this if you need to
UPLOADUSER=litingt
FRS=/home/frs/project/x/xc/xcat
OSNAME=$(uname)
# Process cmd line variable assignments, assigning each attr=val pair to a variable of same name
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 [ "$VERBOSE" = "1" -o "$VERBOSE" = "yes" ]; then
set -x
VERBOSEMODE=1
fi
if [ "$OSNAME" == "AIX" ]; then
GSA=/gsa/pokgsa/projects/x/xcat/build/aix/xcat-dep
else
GSA=/gsa/pokgsa/projects/x/xcat/build/linux/xcat-dep
export HOME=/root # This is so rpm and gpg will know home, even in sudo
fi
# this is needed only when we are transitioning the yum over to frs
YUMREPOURL1="http://xcat.sourceforge.net/yum"
YUMREPOURL2="https://sourceforge.net/projects/xcat/files/yum"
if [ "$FRSYUM" != 0 ]; then
YUMDIR=$FRS
YUMREPOURL="$YUMREPOURL2"
else
YUMDIR=htdocs
YUMREPOURL="$YUMREPOURL1"
fi
if [ -n "$VERBOSEMODE" ]; then
GREP=grep
else
GREP="grep -q"
fi
if [ ! -d $GSA ]; then
echo "builddep: It appears that you do not have gsa installed to access the xcat-dep pkgs."
exit 1;
fi
cd `dirname $0`
XCATCOREDIR=`/bin/pwd`
if [ -z "$DESTDIR" ]; then
DESTDIR=../../../xcat-dep
fi
# Sync from the GSA master copy of the dep rpms
mkdir -p $DESTDIR/xcat-dep
echo "Syncing RPMs from $GSA/ to $DESTDIR/xcat-dep ..."
rsync -ilrtpu --delete $GSA/ $DESTDIR/xcat-dep
cd $DESTDIR/xcat-dep
if [ "$OSNAME" != "AIX" ]; then
# Get gpg keys in place
mkdir -p $HOME/.gnupg
for i in pubring.gpg secring.gpg trustdb.gpg; do
if [ ! -f $HOME/.gnupg/$i ] || [ `wc -c $HOME/.gnupg/$i|cut -f 1 -d' '` == 0 ]; then
rm -f $HOME/.gnupg/$i
cp $GSA/../keys/$i $HOME/.gnupg
chmod 600 $HOME/.gnupg/$i
fi
done
# Tell rpm to use gpg to sign
MACROS=$HOME/.rpmmacros
if ! $GREP -q '%_signature gpg' $MACROS 2>/dev/null; then
echo '%_signature gpg' >> $MACROS
fi
if ! $GREP -q '%_gpg_name' $MACROS 2>/dev/null; then
echo '%_gpg_name xCAT Security Key' >> $MACROS
fi
# Sign the rpms that are not already signed. The "standard input reopened" warnings are normal.
echo "Signing RPMs..."
$XCATCOREDIR/build-utils/rpmsign.exp `find . -type f -name '*.rpm'` | grep -v -E '(already contains identical signature|was already signed|rpm --quiet --resign|WARNING: standard input reopened)'
# Create the repodata dirs
echo "Creating repodata directories..."
for i in `find -mindepth 2 -maxdepth 2 -type d `; do
if [ -n "$VERBOSEMODE" ]; then
createrepo --checksum sha $i # specifying checksum so the repo will work on rhel5
else
createrepo --checksum sha $i >/dev/null
fi
rm -f $i/repodata/repomd.xml.asc
gpg -a --detach-sign $i/repodata/repomd.xml
if [ ! -f $i/repodata/repomd.xml.key ]; then
cp $GSA/../keys/repomd.xml.key $i/repodata
fi
done
# Modify xCAT-dep.repo files to point to the correct place
if [ "$FRSYUM" != 0 ]; then
newurl="$YUMREPOURL2"
oldurl="$YUMREPOURL1"
else
newurl="$YUMREPOURL1"
oldurl="$YUMREPOURL2"
fi
sed -i -e "s|=$oldurl|=$newurl|g" `find . -name "xCAT-dep.repo" `
fi
if [ "$OSNAME" == "AIX" ]; then
# Build the instoss file ------------------------------------------
cat >instoss << 'EOF'
#!/bin/ksh
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
# xCAT on AIX - prerequisite install script
cd `dirname $0`
PERLVER=`perl -v|grep 'This is perl'|cut -d' ' -f 4`
if [ "$PERLVER" == "v5.8.2" ]; then
OSVER='5.3'
elif [ "$PERLVER" == "v5.8.8" ]; then
OSVER='6.1'
aixver=`lslpp -lc|grep 'bos.rte:'|head -1|cut -d: -f3`
if [[ $aixver < '6.1.9.0' ]]; then
AIX61Y=0
else
AIX61Y=1
fi
elif [ "$PERLVER" == "v5.10.1" ]; then
OSVER='7.1'
aixver=`lslpp -lc|grep 'bos.rte:'|head -1|cut -d: -f3`
if [[ $aixver < '7.1.3.0' ]]; then
AIX71L=0
else
AIX71L=1
fi
else
echo "Error: the perl version of '$PERLVER' is not one that instoss understands. Exiting..."
exit 2
fi
cd $OSVER
# Have to install rpms 1 at a time, since some may be already installed.
# The only interdependency between the dep rpms so far is that net-snmp requires bash, and
# pyodbc requires unixODBC. (The bash dependency is taken care of automatically because it
# comes earlier in the alphabet.)
# first run /usr/sbin/updtvpkg to make sure any installp software is
# registered with RPM.
echo "Running updtvpkg. This could take a few minutes."
/usr/sbin/updtvpkg
echo "updtvpkg has completed."
# unixODBC is required by pyodbc, so install it first
rpm -Uvh unixODBC*
# Now install the bulk of the rpms, one at a time, in case some are already installed
for i in `ls *.rpm|grep -v -E '^tcl-|^tk-|^expect-|^unixODBC-|^xCAT-UI-deps|^perl-DBD-DB2Lite|^net-snmp'`; do
if [ "$i" == "perl-Net-DNS-0.66-1.aix5.3.ppc.rpm" ]; then
opts="--nodeps"
else
opts=""
fi
# On 7.1L and 6.1Y we need a newer version of perl-Net_SSLeay.pm
if [[ $AIX71L -eq 1 || $AIX61Y -eq 1 ]]; then
if [[ $i == perl-Net_SSLeay.pm-1.30-* ]]; then continue; fi # skip the old rpm
else
if [[ $i == perl-Net_SSLeay.pm-1.55-* ]]; then continue; fi # skip the new rpm
fi
echo rpm -Uvh $opts $i
rpm -Uvh $opts $i
done
# Have to upgrade all of the net-snmp rpms together because they depend on each other.
# Also, they require bash, so do it after the loop, rather than before
rpm -Uvh net-snmp*
EOF
# end of instoss file content ---------------------------------------------
chmod +x instoss
fi
# Get the permissions and group correct
if [ "$OSNAME" == "AIX" ]; then
SYSGRP=system
else
SYSGRP=root
fi
chgrp -R -h $SYSGRP *
chmod -R g+w *
# Build the tarball
#VER=`cat $XCATCOREDIR/Version`
cd ..
if [ -n "$VERBOSEMODE" ]; then
verbosetar="-v"
else
verbosetar=""
fi
if [ "$OSNAME" == "AIX" ]; then
DFNAME=dep-aix-`date +%Y%m%d%H%M`.tar.gz
echo "Creating $DFNAME ..."
tar $verbosetar -cf ${DFNAME%.gz} xcat-dep
rm -f $DFNAME
gzip ${DFNAME%.gz}
else
DFNAME=xcat-dep-`date +%Y%m%d%H%M`.tar.bz2
echo "Creating $DFNAME ..."
tar $verbosetar -jcf $DFNAME xcat-dep
fi
#cd xcat-dep <-- now we want to stay above xcat-dep, so we can rsync the whole dir
if [ "$UP" == 0 ]; then
exit 0;
fi
if [ "$OSNAME" == "AIX" ]; then
YUM=aix
FRSDIR='2.x_AIX'
else
YUM=yum
FRSDIR='2.x_Linux'
fi
# Upload the dir structure to SF yum area. Currently we do not have it preserving permissions
# because that gives errors when different users try to do it.
i=0
if [ "$FRSYUM" != 0 ]; then
links="-L" # FRS does not support rsyncing sym links
else
links="-l"
fi
echo "Uploading RPMs from xcat-dep to $YUMDIR/$YUM/ ..."
while [ $((i+=1)) -le 5 ] && ! rsync $links -ruv --delete xcat-dep $UPLOADUSER,[email protected]:$YUMDIR/$YUM/
do : ; done
# Upload the tarball to the SF FRS Area
i=0
echo "Uploading $DFNAME to $FRS/xcat-dep/$FRSDIR/ ..."
while [ $((i+=1)) -le 5 ] && ! rsync -v $DFNAME $UPLOADUSER,[email protected]:$FRS/xcat-dep/$FRSDIR/
do : ; done
# Upload the README to the SF FRS Area
cd xcat-dep
# add a comment to indicate the latest xcat-dep tar ball name
sed "6 iThe latest xcat-dep tar ball is ${DFNAME}" -i README
i=0
echo "Uploading README to $FRS/xcat-dep/$FRSDIR/ ..."
while [ $((i+=1)) -le 5 ] && ! rsync -v README $UPLOADUSER,[email protected]:$FRS/xcat-dep/$FRSDIR/
do : ; done