diff --git a/drydocker/generic_obs.sh b/drydocker/generic_obs.sh index 9f842fa..95a918d 100644 --- a/drydocker/generic_obs.sh +++ b/drydocker/generic_obs.sh @@ -1,189 +1,193 @@ #!/bin/bash function obs_build_local { pushd /srv >&3 if [ -d "Kolab:Development/${PACKAGE}" ]; then rm -rf Kolab:Development/${PACKAGE} fi 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 >&3 short_rev=$(git rev-parse --short HEAD) long_rev=$(git rev-parse HEAD) branches=$(git branch --contains ${long_rev} | \ sed -r \ -e 's/^\* //g' \ -e 's/^ //g' | \ grep -E "^(master|${PACKAGE}|[a-z0-9-]+([0-9]+\.?))" | \ sort --version-sort -u ) echo "Branches that contain ${COMMIT}:" >&3 echo "${branches}" | sed -e 's/\s/\r\n/g' >&3 if [ ! -z "$(echo ${branches} | sed -e 's/\s/\r\n/g' | grep -E '^master$')" ]; then branch=master else branch=$(echo ${branches} | sed -e 's/\s/\r\n/g' | tail -n 1) fi echo "Branch is '${branch}'" >&3 latest_stable_branch=$(git branch -la | \ sed -r \ -e 's/^\* //g' \ -e 's/^ remotes\/origin\///g' \ -e '/^HEAD/d' | \ grep -E "^(${PACKAGE}|[a-z0-9-]+([0-9]+\.?))" | \ sort --version-sort -u | \ tail -n 1 ) echo "The latest stable branch is ${latest_stable_branch}" >&3 if [ "${branch}" == "master" ]; then master_version=$(echo ${latest_stable_branch} | \ sed -r -e 's/^.*([0-9]+(\.[0-9]+)+)$/\1/g' | \ awk -F. '{$NF+=1; OFS="."; print $0}' ) echo "This puts the version for master at ${master_version}" >&3 stable_version=0 tag_version=$(git tag -l | \ grep -E "${master_version}(\.[0-9]+)+$" | \ sed -r -e 's/^.*([0-9]\.([0-9]+(\.[0-9]+)+))$/\1/g' | \ sort --version-sort -u | \ tail -n 1 | \ awk -F. '{$NF+=1; OFS="."; print $0}' ) else master_version=0 stable_version=$(echo ${latest_stable_branch} | \ sed -r -e 's/^.*([0-9]+(\.[0-9]+)+)$/\1/g' ) echo "This puts the version for stable at ${stable_version}" >&3 tag_version=$(git tag -l | \ grep -E "${stable_version}(\.[0-9]+)+$" | \ sed -r -e 's/^.*([0-9]\.([0-9]+(\.[0-9]+)+))$/\1/g' | \ sort --version-sort -u | \ tail -n 1 | \ awk -F. '{$NF+=1; OFS="."; print $0}' ) fi new_version=$(echo -e "${master_version}\n${stable_version}\n${tag_version}" | \ sort --version-sort -u | \ tail -n 1 ) git archive \ --prefix=${PACKAGE}-${new_version}/ HEAD | \ gzip -c > \ /srv/Kolab:Development/${PACKAGE}/${PACKAGE}-${new_version}.tar.gz 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_7 \ ${PACKAGE}.spec >&3 2>&3 ; retval=$? popd >&3 popd >&3 return ${retval} } function obs_install_local { # Assume the locally built packages have a lower NEVRA. # # For packages with a higher NEVRA, this will simply result in # nothing. # # For packages that are not installed, this will simply result in # nothing. retval=$(_shell yum_downgrade) # It is OK if the downgrade fails. if [ ${retval} -ne 0 ]; then echo "yum downgrade failed, but that's OK" >&3 fi # Then install all the packages. retval=$(_shell yum_install) return ${retval} } function obs_checkin { + if [ ${TEST_OBS} -eq 0 ]; then + return + fi + pushd /srv/Kolab:Development/${PACKAGE}/ >&3 retval=$(_shell osc ar) if [ ${retval} -ne 0 ]; then return ${retval} fi retval=$(_shell osc ci -m "${PACKAGE}") if [ ${retval} -ne 0 ]; then return ${retval} fi popd } function yum_downgrade { yum -y downgrade \ /var/tmp/build-root/*/home/abuild/rpmbuild/RPMS/*/*.rpm ; \ return $? } function yum_install { yum -y install \ /var/tmp/build-root/*/home/abuild/rpmbuild/RPMS/*/*.rpm ; \ return $? }