#!/bin/sh set -eu #DEBUG=1 # read pgapt config for dir in . .. /srv/apt; do test -f $dir/pgapt.conf || continue . $dir/pgapt.conf break done [ "$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" COMPONENT="main" if [ "${DEBUG:-}" ]; then SUDO="echo" fi while getopts "c:d:efq" opt ; do case $opt in c) COMPONENT="$OPTARG" ;; # check this component to determine if packages exists d) DISTS="$OPTARG" ;; # promote these dists only e) REPREPRO="$REPREPRO --export=never" ;; # skip "reprepro export" f) FORCE="force" ;; # ignore server packages component mismatch q) QUIET="quiet" ;; # don't send announcement mail *) exit 5 ;; esac done # shift away args shift $(($OPTIND - 1)) PKG="$1" [ "$DISTS" = "all" ] && DISTS="$PG_SUPPORTED_DISTS" set -- $DISTS FIRST_DIST="$1" # server packages: test .deb files for correct components if [ -z "${FORCE:-}" ]; then case $PKG in postgresql-?.?|postgresql-??) for DIST in $DISTS; do /srv/apt/repo/bin/validate-component \ /srv/apt/repo/dists/$DIST-pgdg-testing/*/binary-*/Packages done ;; esac fi NEWVERSION=$($REPREPRO -A source list $FIRST_DIST-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 | grep -Eo '^(lib)?.') POOLDIR="/srv/apt/repo/pool/$COMPONENT/$INITIAL/$PKG" if ! test -d $POOLDIR; then echo "$POOLDIR is missing (did you mean promote -c NN ?)" exit 1 fi BINARIES=$(ls $POOLDIR/*deb | sed -e 's!.*/!!' -e 's/_.*//' | sort -u) OTHERBINARIES=$(echo "$BINARIES" | while read b; do if [ "$b" != "$PKG" ]; then echo "$b"; fi; done) if [ -z "${QUIET:-}" ]; then OLDVERSION=$($REPREPRO -A source list $FIRST_DIST-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 -e pgdg-testing -e pgdg-snapshot | sed -e 's/ */ /g' | column -t -s '|' -o '|') echo fi for DIST in $DISTS ; do ${SUDO:-} $REPREPRO copysrc $DIST-pgdg $DIST-pgdg-testing $PKG done [ "${QUIET:-}" ] && exit echo echo "New status:" NEWLS=$($REPREPRO ls $PKG; for p in $OTHERBINARIES; do $REPREPRO ls $p; done) echo "$NEWLS" NEWLSPROD=$(echo "$NEWLS" | grep -v -e pgdg-testing -e pgdg-snapshot | sed -e 's/ */ /g' | column -t -s '|' -o '|') echo if [ -z "${DEBUG:-}" ] && [ "$OLDLSPROD" = "$NEWLSPROD" ]; then echo "No change in the repository, not sending mail" exit fi NEWSHORTVERSION=$(echo "$NEWVERSION" | sed -e 's/.*://') if [ "$OLDVERSION" ]; then SOMEDEB=$(ls $POOLDIR/*$NEWSHORTVERSION*deb | head -1) CHANGES=$(LANGUAGE= LANG=C.UTF-8 apt-listchanges -f text --which=both --since=$OLDVERSION $SOMEDEB | grep -Fv 'Reading changelogs...') CHANGESTEXT="$CHANGES" else CHANGESTEXT="This is the first version of this package in the repository." fi echo "Sending mail to $MAILING_LIST ..." TEXT="From: $MAIL_FROM To: $MAILING_LIST Reply-To: $MAILING_LIST Subject: $PKG updated to version $NEWVERSION The package $PKG was updated on apt.postgresql.org. $CHANGESTEXT New version $NEWVERSION: $NEWLSPROD 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