Created
February 28, 2014 19:16
-
-
Save ehelms/9277760 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -xe | |
# Only Foreman itself is SCL | |
scl="nonscl" | |
[ ${project} = katello ] && scl="scl" | |
git config -f .git/config user.name Jenkins | |
git config -f .git/config user.email packaging@theforeman.org | |
# The spec file for the Katello deployment RPM is located under ./deploy and generates the katello rpm | |
# not to be confused with the gem | |
cd ./deploy | |
# Version this build after the current git revision | |
if [ x$gitrelease = xtrue ]; then | |
date=$(date +%Y%m%d%H%M) | |
gitrev=$(git rev-parse --short HEAD) | |
release="${date}git${gitrev}" | |
egrep -q "^Release:.*%" *.spec | |
sed -i "/^Release:/ s/%/.${release}%/" *.spec | |
if [ -e release ]; then | |
version=$(rpm -q --specfile --qf "%{VERSION}" *.spec) | |
git tag -m $version $version | |
# FIXME: no %changelog entry | |
else | |
EDITOR=/bin/cat tito tag --keep-version --auto-changelog-message="Automatic nightly build of ${gitrev}" | |
fi | |
else | |
if [ -e release ]; then | |
version=$gittag | |
else | |
git checkout -b build $gittag | |
EDITOR=/bin/cat tito tag --keep-version --no-auto-changelog | |
fi | |
fi | |
# Work out build options for this OS | |
if [ ${os##rhel} != ${os} ]; then | |
dist=${os##rh} # rhel6 => el6 | |
osscl="scl" # RHEL is SCL'd | |
elif [ ${os##fedora} != ${os} ]; then | |
dist="fc${os##fedora}" # fedora18 => fc18 | |
osscl="nonscl" # no SCL | |
else | |
echo "unknown OS: $os" | |
exit 1 | |
fi | |
# Only projects marked "scl" on SCL OSes should be SCL | |
scltag="" | |
args="" | |
if [ $osscl = scl ]; then | |
if [ $scl = scl ]; then | |
args="--scl=ruby193" | |
else | |
scltag="-nonscl" | |
fi | |
fi | |
fullkojitag=katello-${kojitag}${scltag}-${os} | |
# Skip an OS if the build target doesn't exist | |
# This can happen when we stop building nightlies but still need to build stable releases | |
if [ x$(koji -c ~/.koji/katello-config list-targets --quiet --name=$fullkojitag) = x ]; then | |
echo cannot find build target $fullkojitag | |
echo SKIPPING BUILD | |
exit 0 | |
fi | |
# Build it! | |
BUILDLOG=$(mktemp) | |
if [ -e release ]; then | |
./release $version .${dist} > $BUILDLOG | |
else | |
tito build --offline --srpm --dist=.${dist} $args > $BUILDLOG | |
fi | |
srpm=$(grep Wrote $BUILDLOG | tail -n1 | sed "s/^Wrote: //g") | |
[ -e $srpm ] | |
trap "rm -f $srpm $BUILDLOG" EXIT | |
scratcharg="--scratch" | |
[ x$scratch = xfalse ] && scratcharg="" | |
koji -c ~/.koji/katello-config build --wait ${scratcharg} $fullkojitag $srpm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment