#!/bin/bash
# Build IM pkgs
cmdname=$(basename $0)
usage="$cmdname [-d <topdir>] [-p] [-b] [-n] [spec files...]"
usage="$usage\nDefault build type is 'build-only'"
usage="$usage\n -d <topdir>: specify another top dir."
usage="$usage\n -p : source prep only."
usage="$usage\n -a : uninstall/build/install."
usage="$usage\n -n : NOT compress/copy to $HOME/packages\n"
# check /opt/jdsbld
if [ ! -d /opt/jdsbld ];then
echo "Need jds build tools in /opt/jdsbld"
exit 1
fi
export PATH=/usr/bin:/usr/sbin
source /opt/jdsbld/bin/env.sh
export PYTHON=/usr/bin/python2.6
while getopts pad:n option
do
case $option in
p) FLAGPREP=1;;
a) FLAGALL=1;;
d) TOPDIR="$OPTARG";;
n) NOTCPFLAG=1;;
?) printf "$usage" ; exit ;;
esac
done
shift $(expr $OPTIND - 1)
if [ X$TOPDIR = X ]; then
if echo $0 | egrep -s '^/'; then
TOPDIR=$(dirname $0)
else
TOPDIR="`pwd`/$(dirname $0)"
fi
fi
mkdir -p $TOPDIR/log
# set the http and ftp proxies if you are behind a firewall
# export http_proxy=
# export ftp_proxy=
if [ X$FLAGPREP = 'X1' ]; then
CMD='prep'
elif [ X$FLAGALL = 'X1' ]; then
CMD='build'
else
CMD='build-only'
fi
if [ -z $1 ]; then
SPECFILES="cmdassist.spec stardict.spec icu.spec idnkit.spec"
else
SPECFILES=$@
fi
G11NDIR=$(dirname $0)
for spec in $SPECFILES
do
case $spec in
cmdassist.spec )
cd $G11NDIR
cp cmdassist/COPYING cmdassist/cmdassist.copyright
VERSION=`egrep "Version:" cmdassist/cmdassist.spec | awk '{print $2}'`
mv cmdassist cmdassist-${VERSION}
/usr/bin/tar cf - cmdassist-${VERSION} | /usr/bin/gzip > cmdassist-${VERSION}.tar.gz
mv cmdassist-${VERSION}.tar.gz cmdassist-${VERSION}/
dir=cmdassist-${VERSION}
;;
icu.spec )
cd $G11NDIR/icu
/usr/bin/tar cf - old_libs | /usr/bin/gzip > old_libs.tar.gz
dir=icu
;;
idnkit.spec )
cd $G11NDIR/idn
/usr/bin/tar cf - sunothers | /usr/bin/gzip > sunothers.tar.gz
/usr/bin/tar cf - idnconv | /usr/bin/gzip > idnconv.tar.gz
dir=idn
;;
* )
dir=${spec%.spec}
;;
esac
SPECDIRS=$TOPDIR/$dir:$TOPDIR/include
PATCHDIRS=$TOPDIR/$dir/patches
SRCDIRS=$TOPDIR/$dir:$TOPDIR/SOURCES
PKGUNINSTALLARGS="uninstall-pkgs --specdirs=$SPECDIRS"
PKGBUILDARGS="$CMD --download --topdir=$TOPDIR --specdirs=$SPECDIRS "
PKGBUILDARGS="$PKGBUILDARGS --sourcedirs=$SRCDIRS --patchdirs=$PATCHDIRS"
PKGBUILDARGS="$PKGBUILDARGS --logdir=$TOPDIR/log"
if [ $CMD = 'build' ]; then
echo "pkgtool $PKGUNINSTALLARGS $spec"
pkgtool $PKGUNINSTALLARGS $spec
fi
echo "pkgtool $PKGBUILDARGS $spec"
pkgtool $PKGBUILDARGS $spec
done
# This is used for nightly build env
if [ X$NOTCPFLAG = X ]; then
( cd $TOPDIR/PKGS
# rm -f *.bz2
for pkg in `find . -type d -name "SUNW*" | cut -c3-`; do
tar cf - $pkg | bzip2 > $pkg.tar.bz2
done
)
fi