github.com/Tyktechnologies/tyk@v2.9.5+incompatible/bin/integration_build.sh (about) 1 #!/bin/bash 2 3 set -ex 4 5 : ${SIGNKEY:="12B5D62C28F57592D1575BD51ED14C59E37DAC20"} 6 : ${BUILDPKGS:="1"} 7 : ${ARCH:=amd64} 8 : ${PKG_PREFIX:=tyk} 9 if [ $BUILDPKGS == "1" ]; then 10 echo Configuring gpg-agent-config to accept a passphrase 11 mkdir ~/.gnupg && chmod 700 ~/.gnupg 12 cat >> ~/.gnupg/gpg-agent.conf <<EOF 13 allow-preset-passphrase 14 debug-level expert 15 log-file /tmp/gpg-agent.log 16 EOF 17 gpg-connect-agent reloadagent /bye 18 19 echo "Importing signing key" 20 gpg --list-keys | grep -w $SIGNKEY && echo "Key exists" || gpg --batch --import $BUILDTOOLSDIR/tyk.io.signing.key 21 bash $BUILDTOOLSDIR/unlock-agent.sh $SIGNKEY 22 fi 23 24 DESCRIPTION="Tyk Open Source API Gateway written in Go" 25 26 bdir=build 27 echo "Creating build dir: $bdir" 28 29 mkdir -p ${bdir}/apps \ 30 ${bdir}/js \ 31 ${bdir}/middleware \ 32 ${bdir}/middleware/python \ 33 ${bdir}/middleware/lua \ 34 ${bdir}/event_handlers \ 35 ${bdir}/event_handlers/sample \ 36 ${bdir}/templates \ 37 ${bdir}/policies \ 38 ${bdir}/utils \ 39 ${bdir}/install 40 41 cp apps/app_sample.json ${bdir}/apps 42 cp templates/*.json ${bdir}/templates 43 cp -R install/* ${bdir}/install 44 cp middleware/*.js ${bdir}/middleware 45 cp event_handlers/sample/*.js ${bdir}/event_handlers/sample 46 cp policies/*.json ${bdir}/policies 47 cp tyk.conf.example ${bdir} 48 cp tyk.conf.example ${bdir}/tyk.conf 49 cp -R coprocess ${bdir} 50 51 echo "Building Tyk binaries" 52 go get && go build -tags 'goplugin' 53 mv tyk ${bdir} 54 55 echo "Making tarball" 56 tar -C $bdir -pczf ${PKG_PREFIX}-${ARCH}-${VERSION}.tar.gz . 57 58 # Nothing more to do if we're not going to build packages 59 [ $BUILDPKGS != "1" ] && exit 0 60 61 CONFIGFILES=( 62 --config-files /opt/${PKG_PREFIX}/apps 63 --config-files /opt/${PKG_PREFIX}/templates 64 --config-files /opt/${PKG_PREFIX}/middleware 65 --config-files /opt/${PKG_PREFIX}/event_handlers 66 --config-files /opt/${PKG_PREFIX}/js 67 --config-files /opt/${PKG_PREFIX}/policies 68 --config-files /opt/${PKG_PREFIX}/tyk.conf 69 ) 70 FPMCOMMON=( 71 --name "$PKGNAME" 72 --description "$DESCRIPTION" 73 -v $VERSION 74 --vendor "Tyk Technologies Ltd" 75 -m "<info@tyk.io>" 76 --url "https://tyk.io" 77 -s dir 78 --before-install $TEMPLATEDIR/install/before_install.sh 79 --after-install $TEMPLATEDIR/install/post_install.sh 80 --after-remove $TEMPLATEDIR/install/post_remove.sh 81 ) 82 [ -z $PKGCONFLICTS ] || FPMCOMMON+=( --conflicts $PKGCONFLICTS ) 83 FPMRPM=( 84 --before-upgrade $TEMPLATEDIR/install/post_remove.sh 85 --after-upgrade $TEMPLATEDIR/install/post_install.sh 86 ) 87 88 cd $bdir 89 echo "Creating DEB Package for $ARCH" 90 fpm "${FPMCOMMON[@]}" -a $ARCH -t deb "${CONFIGFILES[@]}" ./=/opt/${PKG_PREFIX} 91 echo "Creating RPM Package for $ARCH" 92 fpm "${FPMCOMMON[@]}" "${FPMRPM[@]}" -a $ARCH -t rpm "${CONFIGFILES[@]}" ./=/opt/${PKG_PREFIX} 93 94 if [ $BUILDPKGS == "1" ]; then 95 echo "Signing $ARCH RPM" 96 rpm --define "%_gpg_name Team Tyk (package signing) <team@tyk.io>" \ 97 --define "%__gpg /usr/bin/gpg" \ 98 --addsign *.rpm || (cat /tmp/gpg-agent.log; exit 1) 99 echo "Signing $ARCH DEB" 100 dpkg-sig --sign builder -k $SIGNKEY $i || (cat /tmp/gpg-agent.log; exit 1) 101 fi