#!/bin/sh

#  This script packages the AIX RPM dependencies
#    - it should be run in the ../xcat/xcat-core/trunk directory
#    - it puts everything in a aix-dep-snap subdirectory
#
# to upload deps gz file to FRS SourceForge location
#scp ./dep-aix-200909241259.tar.gz nott,xcat@web.sourceforge.net:/home/frs/project/x/xc/xcat/xcat-dep/2.x_AIX/

BLDTOP=`pwd`
RPMDIR=$BLDTOP/aix-dep-snap
VER=`cat $BLDTOP/Version`
DATE=`date +"%Y%m%d%H%M"`
#SNAP="snap$DATE"
SNAP="$DATE"

if [ -d $RPMDIR ]
then
  # clean it up
  rm -f $RPMDIR/instoss
  rm -f $RPMDIR/instmysql
  rm -f $RPMDIR/README
  rm -f $RPMDIR/*.rpm
  rm -f $RPMDIR/*.bnd
  rm -f $RPMDIR/flist
  rm -f $RPMDIR/flist2
  rm -f $RPMDIR/*.gz
else
  mkdir -p $RPMDIR
fi

cd $RPMDIR

# build tar.gz for default required RPMs and a second tar.gz for mysql

# create a simple install script
echo "#!/bin/sh" > $RPMDIR/instoss
echo "# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html" >> $RPMDIR/instoss
echo "# xCAT on AIX - prerequisite install script" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/perl-DBI-1.55-1.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh perl-DBI-1.55-1.aix5.3.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/bash-3.2-1.aix5.2.ppc.rpm $RPMDIR/
echo "rpm -Uvh bash-3.2-1.aix5.2.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/perl-DBD-SQLite-1.13-1.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh perl-DBD-SQLite-1.13-1.aix5.3.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/popt-1.7-2.aix5.1.ppc.rpm $RPMDIR/
echo "rpm -Uvh popt-1.7-2.aix5.1.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/rsync-3.0.6-1.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh rsync-3.0.6-1.aix5.3.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/wget-1.9.1-1.aix5.1.ppc.rpm $RPMDIR/
echo "rpm -Uvh wget-1.9.1-1.aix5.1.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/libxml2-2.6.21-4.aix5.2.ppc.rpm $RPMDIR/
echo "rpm -Uvh libxml2-2.6.21-4.aix5.2.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/curl-7.19.6-1ssl.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh curl-7.19.6-1ssl.aix5.3.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/expat-2.0.1-2.aix5.1.ppc.rpm $RPMDIR/
echo "rpm -Uvh expat-2.0.1-2.aix5.1.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/conserver-8.1.16-2.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh conserver-8.1.16-2.aix5.3.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/perl-Expect-1.21-1.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh perl-Expect-1.21-1.aix5.3.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/perl-IO-Tty-1.07-1.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh perl-IO-Tty-1.07-1.aix5.3.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/perl-IO-Stty-.02-1.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh perl-IO-Stty-.02-1.aix5.3.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/perl-IO-Socket-SSL-1.06-1.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh perl-IO-Socket-SSL-1.06-1.aix5.3.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/perl-Net_SSLeay.pm-1.30-1.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh perl-Net_SSLeay.pm-1.30-1.aix5.3.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/perl-Digest-SHA1-2.11-1.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh perl-Digest-SHA1-2.11-1.aix5.3.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/perl-Digest-SHA-5.48-1.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh perl-Digest-SHA-5.48-1.aix5.3.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/perl-Digest-HMAC-1.01-1.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh perl-Digest-HMAC-1.01-1.aix5.3.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/perl-Net-DNS-0.66-1.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh --nodeps perl-Net-DNS-0.66-1.aix5.3.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/perl-Net-IP-1.25-1.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh perl-Net-IP-1.25-1.aix5.3.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/perl-Digest-MD5-2.36-1.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh perl-Digest-MD5-2.36-1.aix5.3.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/fping-2.4b2_to-1.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh fping-2.4b2_to-1.aix5.3.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/openslp-xcat-1.2.1-1.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh openslp-xcat-1.2.1-1.aix5.3.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/perl-Crypt-SSLeay-0.57-1.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh perl-Crypt-SSLeay-0.57-1.aix5.3.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/perl-Net-Telnet-3.03-1.2.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh perl-Net-Telnet-3.03-1.2.aix5.3.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/net-snmp-5.4.2.1-1.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh net-snmp-5.4.2.1-1.aix5.3.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/net-snmp-devel-5.4.2.1-1.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh net-snmp-devel-5.4.2.1-1.aix5.3.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/net-snmp-perl-5.4.2.1-1.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh net-snmp-perl-5.4.2.1-1.aix5.3.ppc.rpm" >> $RPMDIR/instoss

cp /opt/freeware/src/packages/RPMS/ppc/unixODBC-2.2.15-32bit.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh unixODBC-2.2.15-32bit.aix5.3.ppc.rpm" >> $RPMDIR/instoss

# get the OSS README file
cp ./../../../xcat-dep/trunk/AIX/README $RPMDIR/

# make the default required RPM tar.gz file
ls *.rpm > $RPMDIR/flist
echo "README" >> $RPMDIR/flist
echo "instoss" >> $RPMDIR/flist

chmod 664 $RPMDIR/*
chmod +x $RPMDIR/instoss

chgrp xcat *
chmod g+w *

tar -cvf $RPMDIR/dep-aix-$SNAP.tar -L $RPMDIR/flist
gzip $RPMDIR/dep-aix-$SNAP.tar

# make a second tar.gz for mysql packages
cp /opt/freeware/src/packages/RPMS/ppc/perl-DBD-mysql-4.007-1.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh perl-DBD-mysql-4.007-1.aix5.3.ppc.rpm" >> $RPMDIR/instmysql
echo "perl-DBD-mysql-4.007-1.aix5.3.ppc.rpm" > $RPMDIR/flist2

cp /opt/freeware/src/packages/RPMS/ppc/xcat-mysql-5.1-37.aix5.3.ppc.rpm $RPMDIR/
echo "rpm -Uvh xcat-mysql-5.1-37.aix5.3.ppc.rpm" >> $RPMDIR/instmysql
echo "xcat-mysql-5.1-37.aix5.3.ppc.rpm" >> $RPMDIR/flist2

cp /opt/freeware/src/packages/RPMS/ppc/mysql-connector-odbc-3.51.27-32bit.aix5.3.ppc.rpm $RPMDIR/
echo "mysql-connector-odbc-3.51.27-32bit.aix5.3.ppc.rpm" >> $RPMDIR/flist2


chmod +x $RPMDIR/instmysql
echo "instmysql" >> $RPMDIR/flist2
echo "README" >> $RPMDIR/flist2

chgrp xcat *
chmod g+w *

tar -cvf $RPMDIR/xcat-mysql-$SNAP.tar -L $RPMDIR/flist2
gzip $RPMDIR/xcat-mysql-$SNAP.tar


# create xcat-web-dep tar ball
cp /xcat-web-dep.tar.gz $RPMDIR/

# get the PHP5 readme file
#cd ./../../../xcat-dep/trunk/AIX/php5/
#cp README $RPMDIR/web-dep.README
# make a third tar.gz for xcat-web-dep package
#cp *.rpm $RPMDIR/
#ls *.rpm > $RPMDIR/flist3
#cd $RPMDIR
#cp /opt/freeware/src/packages/RPMS/ppc/php-5.2.6-0.aix5.3.ppc.rpm $RPMDIR/
#echo "rpm -Uvh php-5.2.6-0.aix5.3.ppc.rpm" >> $RPMDIR/instwebdep
#echo "php-5.2.6-0.aix5.3.ppc.rpm" >> $RPMDIR/flist3

#chmod +x $RPMDIR/instwebdep
#echo "instwebdep" >> $RPMDIR/flist3
#echo "web-dep.README" >> $RPMDIR/flist3
#tar -cvf $RPMDIR/xcat-web-dep-$SNAP.tar -L $RPMDIR/flist3
#gzip $RPMDIR/xcat-web-dep-$SNAP.tar

cd $RPMDIR

chgrp xcat *
chmod g+w *

exit 0;
