diff --git a/drydocker/generic_obs.sh b/drydocker/generic_obs.sh index 3b96008..40dae9e 100644 --- a/drydocker/generic_obs.sh +++ b/drydocker/generic_obs.sh @@ -1,177 +1,182 @@ #!/bin/bash source /srv/stick.git/drydocker/generic_functions.sh function obs_build_local { if [ ! -f "/root/.oscrc" ]; then echo "SKIPPED: No ~/.oscrc." >&3 return fi # Figure out the version for the commit new_version=$(version_for_commit) # Figure out the OBS project for the version osc_project=$(project_for_package_version CentOS_7 ${new_version}) pushd /srv >&3 if [ -d "${osc_project}/${PACKAGE}" ]; then rm -rf ${osc_project}/${PACKAGE} fi osc co ${osc_project}/${PACKAGE} >&3 pushd ${osc_project}/${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 echo "Going with new version: '${new_version}'" >&3 set -x + echo "About to create /srv/${osc_project}/${PACKAGE}/${PACKAGE}-${new_version}.tar.gz" >&3 + if [ ! -f "${PACKAGE}-${new_version}.tar.gz" ]; then git archive \ --prefix=${PACKAGE}-${new_version}/ HEAD | \ gzip -c > \ /srv/${osc_project}/${PACKAGE}/${PACKAGE}-${new_version}.tar.gz else cp ${PACKAGE}-${new_version}.tar.gz \ /srv/${osc_project}/${PACKAGE}/${PACKAGE}-${new_version}.tar.gz fi + echo "Creating /srv/${osc_project}/${PACKAGE}/${PACKAGE}-${new_version}.tar.gz completed" >&3 + ls -l /srv/${osc_project}/${PACKAGE}/ >&3 + popd >&3 # Set .spec version sed -i -r \ -e "s/^Version:(\s*).*$/Version:\1${new_version}/g" \ -e "s/^Release:(\s*).*$/Release:\10.$(date +'%Y%m%d').git${short_rev}%{?dist}/g" \ ${PACKAGE}.spec # Set .dsc and .changelog version sed -i -r \ -e "s/^Version:(.*).*$/Version:\1${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 set - -x # Echo this through stdin for the sub-command after a while, to # indicate trust. ( sleep 10; echo 2; case ${osc_project} in Kolab:3.4*) sleep 10; echo 2; ;; esac; ) | \ 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 { if [ ! -f "/root/.oscrc" ]; then echo "SKIPPED: No ~/.oscrc." >&3 return fi # 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 [ ! -f "/root/.oscrc" ]; then echo "SKIPPED: No ~/.oscrc." >&3 return fi if [ ${TEST_OBS} -eq 0 ]; then echo "SKIPPED: osc_checkin (disabled)" >&3 return fi # Also do not check in code if the difference between HEAD and # master is more than 0. pushd /srv/${PACKAGE}.git num_behind=$(git format-patch ${COMMIT}..master | wc -l) if [ ${num_behind} -gt 0 ]; then echo "SKIPPED: osc_checkin (behind master)" >&3 return fi popd # Figure out the version for the commit new_version=$(version_for_commit) # Figure out the OBS project for the version osc_project=$(project_for_package_version CentOS_7 ${new_version}) pushd /srv/${osc_project}/${PACKAGE}/ >&3 retval=$(_shell osc ar) if [ ${retval} -ne 0 ]; then return ${retval} fi retval=$(_shell osc ci -m "${PACKAGE}@${COMMIT}-$(date +'%Y-%m-%d')") 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 $? }