Skip to content

Commit

Permalink
Prettifying the build script a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
excieve authored and buger committed Aug 4, 2017
1 parent 7769f8a commit 84b0086
Showing 1 changed file with 44 additions and 25 deletions.
69 changes: 44 additions & 25 deletions utils/dist_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ export SOURCEBIN=tyk
export CLIBIN=tyk-cli

declare -A ARCHTGZDIRS
ARCHTGZDIRS[i386]=$SOURCEBINPATH/build/i386/tgz/tyk.linux.i386-$VERSION
ARCHTGZDIRS[amd64]=$SOURCEBINPATH/build/amd64/tgz/tyk.linux.amd64-$VERSION
ARCHTGZDIRS[arm64]=$SOURCEBINPATH/build/arm/tgz/tyk.linux.arm64-$VERSION
ARCHTGZDIRS=(
[i386]=$SOURCEBINPATH/build/i386/tgz/tyk.linux.i386-$VERSION
[amd64]=$SOURCEBINPATH/build/amd64/tgz/tyk.linux.amd64-$VERSION
[arm64]=$SOURCEBINPATH/build/arm/tgz/tyk.linux.arm64-$VERSION
)

cliDIR=$ORGDIR/tyk-cli
cliTmpDir=$SOURCEBINPATH/temp/cli
Expand Down Expand Up @@ -106,25 +108,42 @@ do
tar -pczf ${ARCHTGZDIRS[$arch]}/../tyk-linux-$arch-$VERSION.tar.gz tyk.linux.$arch-$VERSION/
done

if [ $BUILDPKGS == "1" ]; then
CONFIGFILES=(--config-files /opt/tyk-gateway/apps --config-files /opt/tyk-gateway/templates --config-files /opt/tyk-gateway/middleware --config-files /opt/tyk-gateway/event_handlers --config-files /opt/tyk-gateway/js --config-files /opt/tyk-gateway/policies --config-files /opt/tyk-gateway/tyk.conf)
FPMCOMMON=(--name tyk-gateway --description "$DESCRIPTION" -v $VERSION --vendor "Tyk Technologies Ltd" -m "<info@tyk.io>" --url "https://tyk.io" -s dir)

for arch in ${!ARCHTGZDIRS[@]}
do
archDir=${ARCHTGZDIRS[$arch]}
cd $archDir/
echo "Removing old $arch packages"
rm -f *.deb
rm -f *.rpm

echo "Creating DEB Package for $arch"
fpm "${FPMCOMMON[@]}" --after-install $archDir/install/post_install.sh --after-remove $archDir/install/post_remove.sh -a $arch -t deb "${CONFIGFILES[@]}" ./=/opt/tyk-gateway
echo "Creating RPM Package for $arch"
fpm "${FPMCOMMON[@]}" -x **/*.deb --after-install $archDir/install/post_install.sh --after-remove $archDir/install/post_remove.sh -a $arch -t rpm "${CONFIGFILES[@]}" ./=/opt/tyk-gateway

rpmName="tyk-gateway-$VERSION-1.${arch/amd64/x86_64}.rpm"
echo "Signing $arch RPM"
$BUILDTOOLSDIR/rpm-sign.exp $archDir/$rpmName
done
fi
# Nothing more to do if we're not going to build packages
[ $BUILDPKGS != "1" ] && exit 0

CONFIGFILES=(
--config-files /opt/tyk-gateway/apps
--config-files /opt/tyk-gateway/templates
--config-files /opt/tyk-gateway/middleware
--config-files /opt/tyk-gateway/event_handlers
--config-files /opt/tyk-gateway/js
--config-files /opt/tyk-gateway/policies
--config-files /opt/tyk-gateway/tyk.conf
)
FPMCOMMON=(
--name tyk-gateway
--description "$DESCRIPTION"
-v $VERSION
--vendor "Tyk Technologies Ltd"
-m "<info@tyk.io>"
--url "https://tyk.io"
-s dir
)

for arch in ${!ARCHTGZDIRS[@]}
do
archDir=${ARCHTGZDIRS[$arch]}
cd $archDir/
echo "Removing old $arch packages"
rm -f *.deb
rm -f *.rpm

echo "Creating DEB Package for $arch"
fpm "${FPMCOMMON[@]}" --after-install $archDir/install/post_install.sh --after-remove $archDir/install/post_remove.sh -a $arch -t deb "${CONFIGFILES[@]}" ./=/opt/tyk-gateway
echo "Creating RPM Package for $arch"
fpm "${FPMCOMMON[@]}" -x **/*.deb --after-install $archDir/install/post_install.sh --after-remove $archDir/install/post_remove.sh -a $arch -t rpm "${CONFIGFILES[@]}" ./=/opt/tyk-gateway

rpmName="tyk-gateway-$VERSION-1.${arch/amd64/x86_64}.rpm"
echo "Signing $arch RPM"
$BUILDTOOLSDIR/rpm-sign.exp $archDir/$rpmName
done

0 comments on commit 84b0086

Please sign in to comment.