fixed bug 7025560, the latest pkgtool/pkgbuild does not support ${VAR} to get the definitions inside spec file.
#!/bin/bash
# Build IM pkgs
usage="$(basename $0) [-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
date
IPS_VENDORVER=0.${L10N_BUILDNUM:-"155"}
PUBLISHER=${L10N_PUBLISHER:-"l10n-nightly"}
rm -f /tmp/.build_env.$$
[ -z "$PKGDEST" ] || echo "export PKGDEST=$PKGDEST" >> /tmp/.build_env.$$
[ -z "$IPS_VENDORVER" ] || echo "export IPS_VENDORVER=$IPS_VENDORVER" >> /tmp/.build_env.$$
[ -z "$PUBLISHER" ] || echo "export PUBLISHER=$PUBLISHER" >> /tmp/.build_env.$$
[ -z "$DOWNLOADS" ] || echo "export DOWNLOADS=$DOWNLOADS" >> /tmp/.build_env.$$
source /opt/jdsbld/bin/env.sh
. /tmp/.build_env.$$
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
MACH="${MACH:-`uname -p`}"
BLDDIR="$TOPDIR/build.$MACH"
mkdir -p $BLDDIR/log
# set the http and ftp proxies if you are behind a firewall
# export http_proxy=
# export ftp_proxy=
if [ -z $1 ]; then
SPECFILES="cmdassist.spec icu.spec idnkit.spec"
else
SPECFILES=$@
fi
if [ X$FLAGPREP = 'X1' ]; then
CMD='prep'
elif [ X$FLAGALL = 'X1' ]; then
CMD='build'
else
CMD='build-only'
fi
# Explicitly specifying location to enable to use pkgtool (pkgbuild)
# not yet in jdsbld.
PKGTOOL="/opt/pkgbuild/bin/pkgtool"
# IPS repos are created in $PKGDEST if defined in environment,
# otherwise in $BLDDIR (build.$MACH).
IPS_REPODIR="${PKGDEST:-$BLDDIR}/repo.spec"
SRC_IPS_REPODIR="${PKGDEST:-$BLDDIR}/repoS.spec"
export PKGBUILD_IPS_SERVER="file://$IPS_REPODIR/"
export PKGBUILD_SRC_IPS_SERVER="file://$SRC_IPS_REPODIR/"
rm -rf "$IPS_REPODIR"
pkgrepo create --version 3 "$PKGBUILD_IPS_SERVER"
pkgrepo set -s "$PKGBUILD_IPS_SERVER" publisher/prefix=${PUBLISHER}
rm -rf "$SRC_IPS_REPODIR"
pkgrepo create --version 3 "$PKGBUILD_SRC_IPS_SERVER"
pkgrepo set -s "$PKGBUILD_SRC_IPS_SERVER" publisher/prefix=${PUBLISHER}
for spec in $SPECFILES
do
case $spec in
cmdassist.spec )
cd $TOPDIR
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 $TOPDIR/icu
/usr/bin/tar cf - old_libs | /usr/bin/gzip > old_libs.tar.gz
dir=icu
;;
idnkit.spec )
cd $TOPDIR/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
PKGUNINSTALLARGS="uninstall-pkgs --nonotify --specdirs=$SPECDIRS"
PKGBUILDARGS="$CMD --nonotify --download --topdir=$BLDDIR --specdirs=$SPECDIRS "
PKGBUILDARGS="$PKGBUILDARGS --sourcedirs=$SRCDIRS --patchdirs=$PATCHDIRS"
PKGBUILDARGS="$PKGBUILDARGS --logdir=$BLDDIR/log"
PKGBUILDARGS="$PKGBUILDARGS --pkgformat=ips"
PKGBUILDARGS="$PKGBUILDARGS --halt-on-errors"
[[ -z "$DOWNLOADS" ]] || PKGBUILDARGS+=" --tar=$DOWNLOADS"
if [ $CMD = 'build' ]; then
echo "pkgtool $PKGUNINSTALLARGS $spec"
$PKGTOOL $PKGUNINSTALLARGS $spec
fi
echo "$PKGTOOL $PKGBUILDARGS --define \"ipsvendorver $IPS_VENDORVER\" $spec"
$PKGTOOL $PKGBUILDARGS --define "ipsvendorver $IPS_VENDORVER" $spec || exit 1
# tentative workaround: should eliminate the previous mv instead,
# after verifying that directory name does not affect build result
if [ "$spec" = "cmdassist.spec" ]
then
mv "$dir" cmdassist
fi
done
date