2013-11-04 12:12:20 +00:00
|
|
|
#!/bin/bash -ex
|
|
|
|
|
2014-04-28 12:06:03 +00:00
|
|
|
resultdir="/var/lib/mock/fedora-rawhide-x86_64/result"
|
2013-11-04 12:12:20 +00:00
|
|
|
|
2014-04-28 12:06:03 +00:00
|
|
|
# download spec file
|
2014-05-02 06:37:58 +00:00
|
|
|
curl 'http://pkgs.fedoraproject.org/cgit/xmvn.git/plain/xmvn.spec?id=jenkins' > xmvn.spec
|
2013-11-04 12:12:20 +00:00
|
|
|
|
2014-04-28 12:06:03 +00:00
|
|
|
# create directories
|
|
|
|
repo=RPM/latest/
|
|
|
|
[[ ! -d ${repo} ]] && mkdir -p ${repo}
|
2013-11-04 12:12:20 +00:00
|
|
|
|
2014-04-28 12:06:03 +00:00
|
|
|
# update version and release tag in spec file
|
|
|
|
version=$(sed -n '/<version>/{s/.*>\(.*\)<.*/\1/;s/-SNAPSHOT$//;p;q}' pom.xml)
|
|
|
|
release=$(git describe --match="[^(jenkins)].*" --tags | sed 's/[^-]*-/0./;s/-/./;s/g/git/')
|
|
|
|
sed -i "s/^Version:\s\+[0-9.]*$/Version: ${version}/" xmvn.spec
|
|
|
|
sed -i "s/^Release:\s\+[0-9.]*%{?dist}$/Release: ${release}/" xmvn.spec
|
|
|
|
|
|
|
|
# make tarball
|
2014-04-28 12:15:57 +00:00
|
|
|
git archive -v --prefix=xmvn-${version}/ HEAD | xz > xmvn-${version}.tar.xz
|
2014-04-28 12:06:03 +00:00
|
|
|
|
|
|
|
# print root.log and build.log in case of failure
|
|
|
|
trap "cat ${resultdir}/root.log | tail -30; cat ${resultdir}/build.log || :" 0
|
|
|
|
|
|
|
|
# crate srpm
|
2013-11-04 12:12:20 +00:00
|
|
|
rm -f SRPMS/*
|
|
|
|
rpmbuild -bs --clean --define "_topdir `pwd`" --define "_sourcedir `pwd`" xmvn.spec
|
|
|
|
|
2014-04-28 12:06:03 +00:00
|
|
|
# build RPM with custom mock config
|
|
|
|
rm -Rf ${resultdir}/*
|
2013-11-04 12:12:20 +00:00
|
|
|
mock -r fedora-rawhide-x86_64 SRPMS/*.src.rpm
|
|
|
|
|
2014-04-28 12:06:03 +00:00
|
|
|
# remove unneeded stuff
|
|
|
|
rm -f xmvn-*.tar.xz
|
2013-11-04 12:12:20 +00:00
|
|
|
|
2014-04-28 12:06:03 +00:00
|
|
|
last_bn=`grep "Build number" ${repo}/info.log | awk '{ print $3 }'`
|
|
|
|
if [ -n "${last_bn}" ]; then
|
|
|
|
mkdir -p RPM/${last_bn}
|
|
|
|
mv ${repo}/* RPM/${last_bn}
|
2013-11-04 12:12:20 +00:00
|
|
|
|
2014-04-28 12:06:03 +00:00
|
|
|
# we only want keep RPMs from last 10 builds
|
|
|
|
blist=`find ./RPM/ -maxdepth 1 -name "[0-9]*"`
|
|
|
|
for bn in $blist; do
|
|
|
|
if [ `basename $bn` -lt `expr $last_bn - 10` ]; then
|
|
|
|
rm -Rf $bn
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
2013-11-04 12:12:20 +00:00
|
|
|
|
2014-04-28 12:06:03 +00:00
|
|
|
# copy resulting RPMs to RPM/latest
|
|
|
|
cp ${resultdir}/* ${repo}
|
2013-11-04 12:12:20 +00:00
|
|
|
|
2014-04-28 12:06:03 +00:00
|
|
|
tail -n 50 ${resultdir}/build.log
|
2013-11-04 12:12:20 +00:00
|
|
|
|
2014-04-28 12:06:03 +00:00
|
|
|
createrepo ${repo}
|
2013-11-04 12:12:20 +00:00
|
|
|
|
2014-04-28 12:06:03 +00:00
|
|
|
# store current build number into the file
|
|
|
|
echo "Build number: $BUILD_NUMBER" >> ${repo}/info.log
|
2013-11-04 12:12:20 +00:00
|
|
|
|