#!/bin/bash # No way I try to deal with a crippled sh just for POSIX foo. # Copyright (C) 2009-2016 Joerg Jaspert # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; version 2. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # exit on errors set -e # A pipeline's return status is the value of the last (rightmost) # command to exit with a non-zero status, or zero if all commands exit # successfully. set -o pipefail # make sure to only use defined variables set -u # ERR traps should be inherited from functions too. (And command # substitutions and subshells and whatnot, but for us the functions is # the important part here) set -E # If the extglob shell option is enabled using the shopt builtin, # several extended pattern matching operators are recognized. We use # it for the POSSIBLEARGS and the first case ${ARGS} matching. shopt -s extglob # And use one locale, no matter what the caller has set export LANG=C.UTF-8 export LC_ALL=C.UTF-8 # If run from crontab, CONFIGDIR will point to the correct dir # where we find the vars file configdir=${configdir:-"/srv/ftp-master.debian.org/dak/config/debian"} # import the general variable set. (This will overwrite configdir, but # it is expected to have the same value) export SCRIPTVARS=${configdir}/vars . "${SCRIPTVARS}" . "${configdir}/dinstall.functions" umask 022 # Get rid of tempfiles at the end trap cleanup EXIT TERM HUP INT QUIT function usage() { echo "Fun with a pointrelease" echo "Takes two args, suite and version" echo "Default for suite is jessie, version defaults to last plus one" } # Arguments, we like while getopts ":hs:v:" OPTION; do case ${OPTION} in s) # suite suitename="${OPTARG}" ;; x) # version version="${OPTARG}" ;; h) # help usage exit 0 ;; ?) echo "Unknown option ${OPTION} given, try -h" exit 42 ;; esac done # Set some variables suitename=${suitename:-"jessie"} suite=$(psql -qAtc "SELECT suite_name FROM suite WHERE codename='${suitename}'") oldrev=$(psql -qAtc "SELECT version FROM suite WHERE codename='${suitename}'") version=${version:-$(( ${oldrev##*.} + 1 ))} PROGRAM="pointrelease_${suitename}" # Set some variables case "${suite}" in stable) pusuite=proposed-updates ;; oldstable) pusuite=oldstable-proposed-updates ;; *) pusuite=INVALID ;; esac # set DEBUG if you want to see a little more logs DEBUG=${DEBUG:-0} # common functions are "outsourced" . "${configdir}/common" # Timestamp when we started NOW=$(date "+%Y.%m.%d-%H:%M:%S") log "Point release for ${suite} (${suitename}); old version: ${oldrev}, new: ${newrev}" log "Updates come from ${pusuite}" log "Preparing" pg_timestamp pre_${suite}_${newrev} cd ~ mkdir -p ${suitename}_${newrev} cd ${suitename}_${newrev} dak control-suite -l ${pusuite} > ${pusuite}.list dak control-suite -l ${suite} > ${suite}.list echo "Is there anything to skip in this release? If so, please enter source package names, whitespace seperated, if not just hit enter" read -e -p "Source packages: " skiplist if [[ -n ${skiplist} ]]; then mv ${pusuite}.list ${pusuite}.list.ori grep -vFf <(dak ls -f heidi -S -s ${pusuite} ${skip}) ${pusuite}.list.ori > ${pusuite}.list fi log "Creating changelog" tmpfile=$(mktemp -p "${TMPDIR}" changelog.XXXXXX) dak make-changelog -s ${pusuite} -b ${suite} | cat - ${ftpdir}/dists/${suite}/ChangeLog > ${tmpfile} chmod 0644 ${tmpfile} mv ${tmpfile} ${ftpdir}/dists/${suite}/ChangeLog if [[ -n ${skiplist} ]]; then echo "Please edit to remove the changelogs for the skipped packages" $EDITOR ${ftpdir}/dists/${suite}/ChangeLog rm -f ${ftpdir}/dists/${suite}/ChangeLog~ fi dak control-suite --add ${suite} < ${pusuite}.list dak control-suite --remove ${pusuite} < ${pusuite}.list log "Cleaning changelogs from proposed-updates" pumorguedir="${base}/morgue/queues/$(date +%Y/%m)" mkdir -p "${pumorguedir}" cd ${ftpdir}/dists/${pusuite} mv -t "${pumorguedir}" -n -- *.changes if [[ -n ${skiplist} ]]; then for pack in ${skiplist}; do mv -t "${ftpdir}/dists/${pusuite}" ${pumorguedir}/${pack}*.changes done fi log "Checking for r0 additions and propups" cd ~/${suitename}_${newrev} if [[ -f /srv/release.debian.org/www/${suitename}/${newrev%%.*}/${newrev}/${suitename}-r0-additions.cs ]]; then cp /srv/release.debian.org/www/${suitename}/${newrev%%.*}/${newrev}/${suitename}-r0-additions.cs . dak control-suite --add ${suitename}-r0 < ${suitename}-r0-additions.cs fi if [[ -f /srv/release.debian.org/www/${suitename}/${newrev%%.*}/${newrev}/propups.unstable ]]; then cp /srv/release.debian.org/www/${suitename}/${newrev%%.*}/${newrev}/propups.unstable . dak control-suite --force --add unstable > Release.gpg gpg --no-default-keyring --keyring /usr/share/keyrings/debian-archive-keyring.gpg --trust-model=always --verify Release.gpg Release break else echo -n "." sleep 10 continue fi done echo "Done. Is a mirrorpush needed? Or just one to the cd-builder?" read -e -p "Mirrorpush? no/cd/yes" -i "cd" mirrorpush case ${mirrorpush} in no) : ;; yes) $configdir/cronscript mirror ;; cd) mirror mirrorpush-release ;; *) echo "Sod off" ;; esac