2009-12-05 20:55:00 +00:00
# The shell is commented out so that it will run in bash on linux and ksh on aix
# !/bin/bash
# Build and upload the xcat-core code, on either linux or aix.
2009-02-23 21:03:18 +00:00
2009-11-06 16:11:05 +00:00
# Getting Started:
# - Check out the xcat-core svn repository (either the trunk or a branch) into
# a dir called <rel>/src/xcat-core, where <rel> is the same as the release dir it will be
# uploaded to in sourceforge (e.g. devel, or 2.3).
# - You probably also 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
2009-11-06 16:38:13 +00:00
# at https://sourceforge.net/account/ssh
2009-12-05 20:55:00 +00:00
# - On Linux: make sure createrepo is installed on the build machine
# - On AIX: Install openssl and openssh installp pkgs and run updtvpkg. Install from http://www.perzl.org/aix/
# apr, apr-util, bash, bzip2, db4, expat, gdbm, gettext, glib2, gmp, info, libidn, neon, openssl (won't
# conflict with the installp version), pcre, perl-DBD-SQLite, perl-DBI, popt, python, readline, rsynce, sqlite,
# subversion, unixODBC, wget, zlib.
2009-11-06 19:26:12 +00:00
# - Run this script from the local svn repository you just created. It will create the other
# directories that are needed.
2009-02-23 21:03:18 +00:00
2009-07-31 20:36:29 +00:00
# Usage: buildcore.sh [attr=value attr=value ...]
# PROMOTE=1 - if the attribute "PROMOTE" is specified, means an official dot release.
2009-02-26 21:48:23 +00:00
# Otherwise, and snap build is assumed.
2009-07-31 20:36:29 +00:00
# UP=0 or UP=1 - override the default upload behavior
# SVNUP=<filename> - control which rpms get built by specifying a coresvnup file
2009-02-26 21:48:23 +00:00
2009-02-23 21:03:18 +00:00
# you can change this if you need to
UPLOADUSER = bp-sawyers
2009-12-05 20:55:00 +00:00
OSNAME = $( uname)
if [ " $OSNAME " = "AIX" ] ; then
GSA = http://pokgsa.ibm.com/projects/x/xcat/build/linux
fi
2009-11-06 20:53:22 +00:00
2009-04-07 00:43:03 +00:00
set -x
2009-07-31 20:36:29 +00:00
2009-11-06 16:11:05 +00:00
# Process cmd line variable assignments, assigning each attr=val pair to a variable of same name
2009-07-31 20:36:29 +00:00
for i in $* ; do
2009-12-05 20:55:00 +00:00
#declare `echo $i|cut -d '=' -f 1`=`echo $i|cut -d '=' -f 2`
export $i
2009-07-31 20:36:29 +00:00
done
2009-12-07 14:40:27 +00:00
if [ " $OSNAME " != "AIX" ] ; then
export HOME = /root # This is so rpm and gpg will know home, even in sudo
fi
2008-03-04 18:10:05 +00:00
cd ` dirname $0 `
2009-05-08 16:31:57 +00:00
# Strip the /src/xcat-core from the end of the dir to get the next dir up and use as the release
CURDIR = ` pwd `
2009-12-05 20:55:00 +00:00
#D=${CURDIR/\/src\/xcat-core/}
D = ${ CURDIR %/src/xcat-core }
2009-05-08 16:31:57 +00:00
REL = ` basename $D `
2009-10-08 20:17:51 +00:00
XCATCORE = "xcat-core"
2009-12-01 15:53:44 +00:00
svn up Version
2009-01-28 15:42:14 +00:00
VER = ` cat Version`
2009-12-23 11:54:00 +00:00
SHORTVER = ` cat Version| cut -d. -f 1,2`
2009-07-31 20:36:29 +00:00
if [ " $PROMOTE " = 1 ] ; then
2009-04-07 00:43:03 +00:00
CORE = "xcat-core"
2009-12-05 20:55:00 +00:00
if [ " $OSNAME " = "AIX" ] ; then
TARNAME = core-aix-$VER .tar.gz
else
TARNAME = xcat-core-$VER .tar.bz2
fi
2009-04-07 00:43:03 +00:00
else
CORE = "core-snap"
2009-12-05 20:55:00 +00:00
if [ " $OSNAME " = "AIX" ] ; then
TARNAME = core-aix-snap.tar.gz
else
TARNAME = core-rpms-snap.tar.bz2
fi
2009-04-07 00:43:03 +00:00
fi
2009-10-08 20:17:51 +00:00
DESTDIR = ../../$XCATCORE
2009-11-06 16:11:05 +00:00
SRCD = core-snap-srpms
2009-04-07 00:43:03 +00:00
2009-04-17 14:25:21 +00:00
2009-07-31 20:36:29 +00:00
if [ " $PROMOTE " != 1 ] ; then # very long if statement to not do builds if we are promoting
2009-04-07 00:43:03 +00:00
mkdir -p $DESTDIR
2009-11-06 16:11:05 +00:00
SRCDIR = ../../$SRCD
2009-04-07 00:43:03 +00:00
mkdir -p $SRCDIR
2008-03-04 18:10:05 +00:00
GREP = grep
2009-12-05 20:55:00 +00:00
# currently aix builds ppc rpms, but it should build noarch
if [ " $OSNAME " = "AIX" ] ; then
NOARCH = ppc
else
NOARCH = noarch
fi
2008-03-04 18:10:05 +00:00
UPLOAD = 0
2009-12-05 20:55:00 +00:00
if [ " $OSNAME " = "AIX" ] ; then
source = /opt/freeware/src/packages
2008-03-04 18:10:05 +00:00
else
2009-12-05 20:55:00 +00:00
if [ -f /etc/redhat-release ] ; then
source = "/usr/src/redhat"
else
source = "/usr/src/packages"
fi
2008-03-04 18:10:05 +00:00
fi
2009-11-06 16:11:05 +00:00
# If they have not given us a premade update file, do an svn update and capture the results
2009-05-08 15:09:15 +00:00
if [ -z " $SVNUP " ] ; then
SVNUP = ../coresvnup
svn up > $SVNUP
2009-05-11 14:35:46 +00:00
fi
2009-11-06 16:11:05 +00:00
2009-12-23 11:09:48 +00:00
# If anything has changed, we should always rebuild perl-xCAT
if ! $GREP 'At revision' $SVNUP ; then # Use to be: $GREP perl-xCAT $SVNUP; then
UPLOAD = 1
./makeperlxcatrpm
rm -f $DESTDIR /perl-xCAT*rpm
rm -f $SRCDIR /perl-xCAT*rpm
mv $source /RPMS/$NOARCH /perl-xCAT-$VER *rpm $DESTDIR /
mv $source /SRPMS/perl-xCAT-$VER *rpm $SRCDIR /
fi
if [ " $OSNAME " = "AIX" ] ; then
2010-01-11 23:25:00 +00:00
# For the 1st one we overwrite, not append
echo " rpm -Uvh perl-xCAT- $SHORTVER *rpm " > $DESTDIR /instxcat
2009-05-08 15:09:15 +00:00
fi
2009-01-28 15:42:14 +00:00
2009-05-08 15:09:15 +00:00
if $GREP xCAT-client $SVNUP ; then
2008-03-04 18:10:05 +00:00
UPLOAD = 1
./makeclientrpm
rm -f $DESTDIR /xCAT-client*rpm
rm -f $SRCDIR /xCAT-client*rpm
2009-12-05 20:55:00 +00:00
mv $source /RPMS/$NOARCH /xCAT-client-$VER *rpm $DESTDIR /
mv $source /SRPMS/xCAT-client-$VER *rpm $SRCDIR /
fi
if [ " $OSNAME " = "AIX" ] ; then
2010-01-11 23:25:00 +00:00
echo " rpm -Uvh xCAT-client- $SHORTVER *rpm " >> $DESTDIR /instxcat
2008-03-04 18:10:05 +00:00
fi
2009-12-05 20:55:00 +00:00
2009-11-06 16:11:05 +00:00
if $GREP xCAT-UI $SVNUP ; then
2009-01-26 14:25:00 +00:00
UPLOAD = 1
2009-12-16 15:27:33 +00:00
rm -f $DESTDIR /xCAT-UI*rpm
rm -f $SRCDIR /xCAT-UI*rpm
2009-11-06 16:11:05 +00:00
./makeuirpm
2009-12-07 14:40:27 +00:00
mv $source /RPMS/noarch/xCAT-UI-$VER *rpm $DESTDIR
2009-12-05 20:55:00 +00:00
mv $source /SRPMS/xCAT-UI-$VER *rpm $SRCDIR
2008-03-04 18:10:05 +00:00
fi
2010-01-04 15:41:28 +00:00
# Do not automatically install xCAT-UI on AIX
#if [ "$OSNAME" = "AIX" ]; then
2010-01-11 23:25:00 +00:00
# echo "rpm -Uvh xCAT-UI-$SHORTVER*rpm" >> $DESTDIR/instxcat
2010-01-04 15:41:28 +00:00
#fi
2009-12-05 20:55:00 +00:00
2010-03-18 00:45:38 +00:00
# Not quite ready to ship this yet...
#if $GREP xCAT-IBMhpc $SVNUP; then
# UPLOAD=1
# rm -f $DESTDIR/xCAT-IBMhpc*rpm
# rm -f $SRCDIR/xCAT-IBMhpc*rpm
# ./makehpcrpm
# mv $source/RPMS/noarch/xCAT-IBMhpc-$VER*rpm $DESTDIR
# mv $source/SRPMS/xCAT-IBMhpc-$VER*rpm $SRCDIR
#fi
# Do not automatically install xCAT-IBMhpc on AIX
#if [ "$OSNAME" = "AIX" ]; then
# echo "rpm -Uvh xCAT-IBMhpc-$SHORTVER*rpm" >> $DESTDIR/instxcat
#fi
2009-05-08 15:09:15 +00:00
if $GREP xCAT-server $SVNUP ; then
2008-03-04 18:10:05 +00:00
UPLOAD = 1
./makeserverrpm
rm -f $DESTDIR /xCAT-server*rpm
rm -f $SRCDIR /xCAT-server*rpm
2009-12-05 20:55:00 +00:00
mv $source /RPMS/$NOARCH /xCAT-server-$VER *rpm $DESTDIR
mv $source /SRPMS/xCAT-server-$VER *rpm $SRCDIR
fi
if [ " $OSNAME " = "AIX" ] ; then
2010-01-11 23:25:00 +00:00
echo " rpm -Uvh --nodeps xCAT-server- $SHORTVER *rpm " >> $DESTDIR /instxcat
2008-03-04 18:10:05 +00:00
fi
2009-12-05 20:55:00 +00:00
2009-05-08 15:09:15 +00:00
if $GREP xCAT-rmc $SVNUP ; then
2009-03-09 12:42:55 +00:00
UPLOAD = 1
./makermcrpm
rm -f $DESTDIR /xCAT-rmc*rpm
rm -f $SRCDIR /xCAT-rmc*rpm
2009-12-05 20:55:00 +00:00
mv $source /RPMS/$NOARCH /xCAT-rmc-$VER *rpm $DESTDIR
mv $source /SRPMS/xCAT-rmc-$VER *rpm $SRCDIR
2009-03-09 12:42:55 +00:00
fi
2009-12-24 12:57:56 +00:00
# Note: not putting xCAT-rmc into instxcat for aix here, because it has to be installed
# after xCAT.
2009-12-05 20:55:00 +00:00
if [ " $OSNAME " != "AIX" ] ; then
if $GREP xCAT-nbroot $SVNUP ; then
UPLOAD = 1
./makenbrootrpm x86_64
./makenbrootrpm ppc64
./makenbrootrpm x86
rm -f $DESTDIR /xCAT-nbroot-core*rpm
rm -f $SRCDIR /xCAT-nbroot-core*rpm
mv $source /RPMS/noarch/xCAT-nbroot-core-*rpm $DESTDIR
mv $source /SRPMS/xCAT-nbroot-core-*rpm $SRCDIR
fi
fi
2010-02-08 19:48:57 +00:00
if $GREP -E '^[UAD] +xCATsn/' $SVNUP ; then
UPLOAD = 1
rm -f $DESTDIR /xCATsn-$SHORTVER *rpm
rm -f $SRCDIR /xCATsn-$SHORTVER *rpm
if [ " $OSNAME " = "AIX" ] ; then
./makexcatsnrpm
mv $source /RPMS/*/xCATsn-$VER *rpm $DESTDIR
mv $source /SRPMS/xCATsn-$VER *rpm $SRCDIR
else
2009-12-05 20:55:00 +00:00
./makexcatsnrpm x86_64
mv $source /RPMS/*/xCATsn-$VER *rpm $DESTDIR
mv $source /SRPMS/xCATsn-$VER *rpm $SRCDIR
./makexcatsnrpm i386
mv $source /RPMS/*/xCATsn-$VER *rpm $DESTDIR
./makexcatsnrpm ppc64
mv $source /RPMS/*/xCATsn-$VER *rpm $DESTDIR
./makexcatsnrpm s390x
mv $source /RPMS/*/xCATsn-$VER *rpm $DESTDIR
fi
2008-03-18 20:02:53 +00:00
fi
2009-12-05 20:55:00 +00:00
2009-05-08 15:09:15 +00:00
if $GREP -E '^[UAD] +xCAT/' $SVNUP ; then
2008-03-04 18:10:05 +00:00
UPLOAD = 1
2009-12-23 11:54:00 +00:00
rm -f $DESTDIR /xCAT-$SHORTVER *rpm
rm -f $SRCDIR /xCAT-$SHORTVER *rpm
2009-12-05 20:55:00 +00:00
if [ " $OSNAME " = "AIX" ] ; then
./makexcatrpm
mv $source /RPMS/*/xCAT-$VER *rpm $DESTDIR
mv $source /SRPMS/xCAT-$VER *rpm $SRCDIR
else
./makexcatrpm x86_64
mv $source /RPMS/*/xCAT-$VER *rpm $DESTDIR
mv $source /SRPMS/xCAT-$VER *rpm $SRCDIR
./makexcatrpm i386
mv $source /RPMS/*/xCAT-$VER *rpm $DESTDIR
./makexcatrpm ppc64
mv $source /RPMS/*/xCAT-$VER *rpm $DESTDIR
./makexcatrpm s390x
mv $source /RPMS/*/xCAT-$VER *rpm $DESTDIR
fi
fi
if [ " $OSNAME " = "AIX" ] ; then
2010-01-11 23:25:00 +00:00
echo " rpm -Uvh xCAT- $SHORTVER *rpm " >> $DESTDIR /instxcat
echo " rpm -Uvh xCAT-rmc- $SHORTVER *rpm " >> $DESTDIR /instxcat
2009-12-05 20:55:00 +00:00
# add the service node bundle files
cp xCATaixSN.bnd xCATaixSN2.bnd xCATaixSSH.bnd xCATaixSSL.bnd $DESTDIR /
2008-03-04 18:10:05 +00:00
fi
2009-02-26 21:48:23 +00:00
2009-11-12 14:35:24 +00:00
# Decide if anything was built or not
2009-11-13 23:09:13 +00:00
if [ $UPLOAD = = 0 -a " $UP " != 1 ] ; then
2009-11-12 14:35:24 +00:00
echo "Nothing new detected"
exit 0;
2008-03-04 18:10:05 +00:00
fi
2009-11-12 14:35:24 +00:00
#else we will continue
2009-02-26 21:48:23 +00:00
# Prepare the RPMs for pkging and upload
2009-12-05 20:55:00 +00:00
2009-11-06 20:53:22 +00:00
# get gpg keys in place
2009-12-05 20:55:00 +00:00
if [ " $OSNAME " != "AIX" ] ; then
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
wget -P $HOME /.gnupg $GSA /keys/$i
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 Jarrod Johnson' >> $MACROS
fi
build-utils/rpmsign.exp $DESTDIR /*rpm
build-utils/rpmsign.exp $SRCDIR /*rpm
createrepo $DESTDIR
createrepo $SRCDIR
rm -f $SRCDIR /repodata/repomd.xml.asc
rm -f $DESTDIR /repodata/repomd.xml.asc
gpg -a --detach-sign $DESTDIR /repodata/repomd.xml
gpg -a --detach-sign $SRCDIR /repodata/repomd.xml
if [ ! -f $DESTDIR /repodata/repomd.xml.key ] ; then
wget -P $DESTDIR /repodata $GSA /keys/repomd.xml.key
fi
if [ ! -f $SRCDIR /repodata/repomd.xml.key ] ; then
wget -P $SRCDIR /repodata $GSA /keys/repomd.xml.key
2009-11-06 20:53:22 +00:00
fi
2009-11-06 20:08:25 +00:00
fi
2009-12-05 20:55:00 +00:00
2009-11-06 16:11:05 +00:00
# make everything have a group of xcat, so anyone can manage them once they get on SF
2009-12-05 20:55:00 +00:00
if [ " $OSNAME " = "AIX" ] ; then
mkgroup xcat 2>/dev/null
chmod +x $DESTDIR /instxcat
else
groupadd -f xcat
fi
2009-02-23 21:03:18 +00:00
chgrp -R xcat $DESTDIR
chmod -R g+w $DESTDIR
2009-11-06 16:11:05 +00:00
chgrp -R xcat $SRCDIR
chmod -R g+w $SRCDIR
2009-04-07 00:43:03 +00:00
fi # end of very long if-not-promote
2009-04-17 14:25:21 +00:00
cd $DESTDIR
2009-12-05 20:55:00 +00:00
if [ " $OSNAME " != "AIX" ] ; then
# Modify the repo file to point to either xcat-core or core-snap
# Always recreate it, in case the whole dir was copied from devel to 2.x
cat >xCAT-core.repo << EOF
2009-11-06 16:38:13 +00:00
[ xcat-2-core]
name = xCAT 2 Core packages
baseurl = http://xcat.sourceforge.net/yum/$REL /$CORE
enabled = 1
gpgcheck = 1
gpgkey = http://xcat.sourceforge.net/yum/$REL /$CORE /repodata/repomd.xml.key
EOF
2009-12-05 20:55:00 +00:00
# Create the mklocalrepo script
cat >mklocalrepo.sh << 'EOF2'
2009-11-13 23:09:13 +00:00
#!/bin/sh
cd ` dirname $0 `
REPOFILE = ` basename xCAT-*.repo`
sed -e 's|baseurl=.*|baseurl=file://' ` pwd ` '|' $REPOFILE | sed -e 's|gpgkey=.*|gpgkey=file://' ` pwd ` '/repodata/repomd.xml.key|' > /etc/yum.repos.d/$REPOFILE
cd -
EOF2
2010-03-19 16:54:56 +00:00
chmod 775 mklocalrepo.sh
fi # not AIX
2009-04-17 14:25:21 +00:00
# Build the tarball
2009-05-08 15:09:15 +00:00
cd ..
2009-12-05 20:55:00 +00:00
if [ " $OSNAME " = "AIX" ] ; then
tar -hcvf ${ TARNAME %.gz } $XCATCORE
rm -f $TARNAME
gzip ${ TARNAME %.gz }
else
tar -hjcvf $TARNAME $XCATCORE
fi
2009-04-07 00:43:03 +00:00
chgrp xcat $TARNAME
chmod g+w $TARNAME
2009-02-26 21:48:23 +00:00
2009-11-12 14:35:24 +00:00
# Decide whether to upload or not
if [ -n " $UP " ] && [ " $UP " = = 0 ] ; then
exit 0;
fi
#else we will continue
2009-07-31 20:36:29 +00:00
# Upload the individual RPMs to sourceforge
2009-12-05 20:55:00 +00:00
if [ " $OSNAME " = "AIX" ] ; then
YUM = aix
else
YUM = yum
fi
2009-10-08 20:17:51 +00:00
if [ ! -e core-snap ] ; then
ln -s xcat-core core-snap
fi
2009-12-05 20:55:00 +00:00
while ! rsync -urLv --delete $CORE $UPLOADUSER ,xcat@web.sourceforge.net:htdocs/$YUM /$REL /
2009-07-31 20:36:29 +00:00
do : ; done
2009-11-06 16:11:05 +00:00
# Upload the individual source RPMs to sourceforge
2009-12-05 20:55:00 +00:00
while ! rsync -urLv --delete $SRCD $UPLOADUSER ,xcat@web.sourceforge.net:htdocs/$YUM /$REL /
2009-11-06 16:11:05 +00:00
do : ; done
2009-07-31 20:36:29 +00:00
# Upload the tarball to sourceforge
if [ " $PROMOTE " = 1 -a " $REL " != "devel" ] ; then
2009-04-16 20:01:54 +00:00
# upload tarball to FRS area
2009-07-23 15:58:16 +00:00
#scp $TARNAME $UPLOADUSER@web.sourceforge.net:uploads/
2009-12-05 20:55:00 +00:00
while ! rsync -v $TARNAME $UPLOADUSER ,xcat@web.sourceforge.net:/home/frs/project/x/xc/xcat/xcat/$REL .x_$OSNAME /
2009-08-13 19:07:34 +00:00
do : ; done
2009-02-26 21:48:23 +00:00
else
2009-12-05 20:55:00 +00:00
while ! rsync -v $TARNAME $UPLOADUSER ,xcat@web.sourceforge.net:htdocs/$YUM /$REL /
2009-07-31 20:36:29 +00:00
do : ; done
2009-02-26 21:48:23 +00:00
fi
2009-06-12 15:49:27 +00:00
# Extract and upload the man pages in html format
2009-12-05 20:55:00 +00:00
if [ " $OSNAME " != "AIX" -a " $REL " = "devel" -a " $PROMOTE " != 1 ] ; then
2009-06-12 15:49:27 +00:00
mkdir -p man
cd man
rm -rf opt
2009-12-05 20:55:00 +00:00
rpm2cpio ../$XCATCORE /xCAT-client-*.$NOARCH .rpm | cpio -id '*.html'
rpm2cpio ../$XCATCORE /perl-xCAT-*.$NOARCH .rpm | cpio -id '*.html'
2009-10-13 20:50:23 +00:00
while ! rsync -rv opt/xcat/share/doc/man1 opt/xcat/share/doc/man3 opt/xcat/share/doc/man5 opt/xcat/share/doc/man8 $UPLOADUSER ,xcat@web.sourceforge.net:htdocs/
2009-07-31 20:36:29 +00:00
do : ; done
2009-06-12 15:49:27 +00:00
cd ..
fi