#! /usr/bin/env bash # Publish build2 to build2.org/cppget.org (and brep.cppget.org). # # Usage: publish [] # usage="$0 []" owd=`pwd` trap "{ cd $owd; exit 1; }" ERR set -o errtrace # Trap in functions. function info () { echo "$*" 1>&2; } function error () { info "$*"; exit 1; } v=`sed -e 's/^\(.*\)\.\(.*\)\..*$/\1.\2/' build2-toolchain/version` if [ -z "$v" ]; then error "unable to extract version from `cat build2-toolchain/version`" fi d="build2-$v" if [ ! -d "$d" ]; then error "distribution directory $d does not exist" fi function sync () { info "build2.org:" rsync -v -rlpt -c --copy-unsafe-links --prune-empty-dirs --delete-after $* \ $d/ build2.org:/var/www/download.build2.org/public/$v/ info "cppget.org:" cppget.org/publish cppget.org/repository/1/ cppget.org:/var/bpkg/1/ $* info "brep.cppget.org:" cppget.org/publish cppget.org/repository/1/ brep.cppget.org:/var/bpkg/1/ $* } sync --dry-run $* r= while [ -z "$r" ]; do read -r -p "Continue? [yes/no]: " r case "$r" in yes) ;; no) exit 0 ;; *) r= ;; esac done sync --progress $*