diff --git a/drydocker/generic_obs.sh b/drydocker/generic_obs.sh index 8a48278..50dbf11 100644 --- a/drydocker/generic_obs.sh +++ b/drydocker/generic_obs.sh @@ -1,105 +1,107 @@ #!/bin/bash function obs_build_local { - pushd /srv - osc co Kolab:Development/${PACKAGE} - pushd Kolab:Development/${PACKAGE} + pushd /srv >&3 + osc co Kolab:Development/${PACKAGE} >&3 + pushd Kolab:Development/${PACKAGE} >&3 # Remove all compressed content not debian.tar.gz find . \ -mindepth 1 \ -maxdepth 1 \ -type f \ -name "*.tar.gz" \ ! -name "debian.tar.gz" \ -delete # Remove _service file rm -rf _service # Obtain and copy in sources - pushd /srv/${PACKAGE}.git + pushd /srv/${PACKAGE}.git >&3 short_rev=$(git rev-parse --short HEAD) long_rev=$(git rev-parse HEAD) - echo "Branches that contain ${COMMIT}:" - git branch --contains ${long_rev} + echo "Branches that contain ${COMMIT}:" >&3 + git branch --contains ${long_rev} >&3 stable_branch=$(git branch --contains ${long_rev} | \ sed -r \ -e 's/^\* //g' \ -e 's/^ //g' | \ grep -E "^(master|${PACKAGE})" | \ sort --version-sort -u | \ tail -n 2 | \ head -n 1) - echo "We pick ${stable_branch}" + echo "We pick ${stable_branch}" >&3 latest_stable_branch=$(git branch -la | \ sed -r \ -e 's/^\* //g' \ -e 's/^ remotes\/origin\///g' \ -e '/^HEAD/d' | \ grep -E "^(master|${PACKAGE})" | \ sort --version-sort -u | \ tail -n 2 | \ head -n 1) - echo "The latest stable branch is ${latest_stable_branch}" + echo "The latest stable branch is ${latest_stable_branch}" >&3 master_version=$(echo ${latest_stable_branch} | \ awk -F. '{$NF+=1; OFS="."; print $0}') - echo "This puts the version for master at ${master_version}" + echo "This puts the version for master at ${master_version}" >&3 tag_version=$(git tag -l | \ grep -E "^${PACKAGE}-[0-9]+\.[0-9]+" | \ grep -E "^${stable_branch}" | \ sort --version-sort -u | \ tail -n 1 | \ awk -F. '{$NF+=1; OFS="."; print $0}') new_version=$(echo -e "${master_version}\n${tag_version}" | \ sort --version-sort -u | \ tail -n 1 | \ sed -r -e "s/(.*)-([0-9\.]+)$/\2/g") git archive \ --prefix=${PACKAGE}-${new_version}/ HEAD | \ gzip -c > \ /srv/Kolab:Development/${PACKAGE}/${PACKAGE}-${new_version}.tar.gz - popd + popd >&3 # Set .spec version sed -i -r \ -e "s/^Version: .*$/Version: ${new_version}/g" \ -e "s/^Release: .*$/Release: 0.$(date +'%Y%m%d').git${short_rev}%{?dist}/g" \ ${PACKAGE}.spec # Set .dsc and .changelog version sed -i -r \ -e "s/^Version: .*$/Version: ${new_version}~dev$(date +'%Y%m%d')-0~kolab1/g" \ -e "s/${PACKAGE}-([0-9\.]+)\.tar\.gz$/${PACKAGE}-${new_version}.tar.gz/g" \ ${PACKAGE}.dsc sed -i -r \ -e "1 s/\(.*\)/(${new_version}~dev$(date +'%Y%m%d')-0~kolab1)/g" \ debian.changelog # Echo this through stdin for the sub-command after a while, to # indicate trust. ( sleep 10; echo 2; ) | \ osc build \ --no-verify \ --disable-cpio-bulk-download \ --download-api-only \ --local-package \ CentOS_6 \ - ${PACKAGE}.spec || exit $? + ${PACKAGE}.spec >&3 2>&3 ; retval=$? - popd - popd + popd >&3 + popd >&3 + + return ${retval} }