#!/bin/sh set -eu #DEBUG=1 [ "$USER" = "aptuser" ] || SUDO="sudo -u aptuser" export REPREPRO_BASE_DIR="/srv/apt/repo" REPREPRO="flock $REPREPRO_BASE_DIR/db/.lock /usr/bin/reprepro -b $REPREPRO_BASE_DIR --morguedir $REPREPRO_BASE_DIR/morgue --verbose" DISTS="all" if [ "${DEBUG:-}" ]; then SUDO="echo" fi while getopts "d:" opt ; do case $opt in d) DISTS="$OPTARG" ;; *) exit 5 ;; esac done # shift away args shift $(($OPTIND - 1)) PKG="$1" [ "$DISTS" = "all" ] && DISTS="sid jessie wheezy squeeze wily trusty precise" NEWVERSION=$($REPREPRO -A source list sid-pgdg-testing "$PKG" | awk '{ print $3 }') if [ -z "$NEWVERSION" ]; then echo "ERROR: $PKG does not seem to be a source package" exit 1 fi INITIAL=$(echo $PKG | egrep -o '^(lib)?.') test -d /srv/apt/repo/pool/main/$INITIAL/$PKG/ BINARIES=$(ls /srv/apt/repo/pool/main/$INITIAL/$PKG/*deb | sed -e 's!.*/!!' -e 's/_.*//' | sort -u) OTHERBINARIES=$(echo "$BINARIES" | while read b; do if [ "$b" != "$PKG" ]; then echo "$b"; fi; done) OLDVERSION=$($REPREPRO -A source list sid-pgdg "$PKG" | awk '{ print $3 }') echo "Old status:" OLDLS=$($REPREPRO ls $PKG; for p in $OTHERBINARIES; do $REPREPRO ls $p; done) echo "$OLDLS" OLDLSPROD=$(echo "$OLDLS" | grep -v pgdg-testing | column -t) echo for DIST in $DISTS ; do ${SUDO:-} $REPREPRO copysrc $DIST-pgdg $DIST-pgdg-testing $PKG done echo echo "New status:" NEWLS=$($REPREPRO ls $PKG; for p in $OTHERBINARIES; do $REPREPRO ls $p; done) echo "$NEWLS" NEWLSPROD=$(echo "$NEWLS" | grep -v pgdg-testing | column -t) echo if [ -z "${DEBUG:-}" ] && [ "$OLDLSPROD" = "$NEWLSPROD" ]; then echo "No change in the repository, not sending mail" exit fi NEWSHORTVERSION=$(echo "$NEWVERSION" | sed -e 's/.*://') FROM="apt.postgresql.org repository " TO="PostgreSQL in Debian " if [ "$OLDVERSION" ]; then SOMEDEB=$(ls /srv/apt/repo/pool/main/$INITIAL/$PKG/*$NEWSHORTVERSION*deb | head -1) CHANGES=$(apt-listchanges -f text --which=changelogs --since=$OLDVERSION $SOMEDEB) CHANGESTEXT="Old version $OLDVERSION: $OLDLSPROD Changelog: $CHANGES" else CHANGESTEXT="This is the first version of this package in the repository." fi echo "Sending mail to $TO ..." TEXT="From: $FROM To: $TO Subject: $PKG updated to version $NEWVERSION The package $PKG was updated on apt.postgresql.org: New version $NEWVERSION: $NEWLSPROD $CHANGESTEXT The public mirrors serving apt.postgresql.org are synced hourly, the updated packages will be available there shortly. " echo "$TEXT" [ -z "${DEBUG:-}" ] && echo "$TEXT" | /usr/sbin/sendmail -t exit 0