#!/bin/bash -e . /usr/bin/libremessages main() { [[ $# != 1 ]] && { usage; return 1; } local source=$1 local url="$(pbs-plumb-config get "source.$source.url")" local cachedir="$(pbs-plumb-config get core.cachedir)" [[ -d "${cachedir}" ]] || mkdir -p "${cachedir}" if [[ ! -d "${cachedir}/${source}.git" ]]; then cd "${cachedir}" msg "$(gettext "Cloning %s")" "${cachedir}/${source}.git" if ! git clone --mirror "$url" "$source.git"; then error "$(gettext "Failed to download source %s")" "$source" exit 1 fi else cd "${cachedir}/${source}.git" # Make sure we are fetching the right repo if [[ "$url" != "$(git config --get remote.origin.url)" ]] ; then error "$(gettext "%s is not a clone of %s")" "$source" "$url" plain "$(gettext "Aborting...")" exit 1 fi msg "$(gettext "Updating %s")" "${cachedir}/${source}.git" if ! git fetch --all -p; then error "$(gettext "Failed to update source %s")" "$source" exit 1 fi fi } main "$@"