diff options
author | Aki <please@ignore.pl> | 2023-12-28 14:32:06 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2023-12-28 14:32:06 +0100 |
commit | a690ee5ab819ef03176194b044a6854b2a07e1ab (patch) | |
tree | 54e93f202385dc9c4a56a14d71f44e5b0f2e85f1 /mirror.sh | |
parent | 939ac08827a035b0f144219ea2f3a6c0646e1b5f (diff) | |
download | mirror-a690ee5ab819ef03176194b044a6854b2a07e1ab.zip mirror-a690ee5ab819ef03176194b044a6854b2a07e1ab.tar.gz mirror-a690ee5ab819ef03176194b044a6854b2a07e1ab.tar.bz2 |
A non-zero exit status will be returned on one or more failure
Tool will now use date-based versioning scheme: '%Y%m%d.N', where N will
get incremented if multiple releases happen during a day. This is not done
automatically currently.
Some additional smaller changes were done to support exit status and
versioning.
Diffstat (limited to 'mirror.sh')
-rw-r--r-- | mirror.sh | 38 |
1 files changed, 35 insertions, 3 deletions
@@ -1,4 +1,16 @@ #!/bin/sh +_version() { + echo "@VERSION@" + exit 0 +} + + +_usage() { + echo "Usage: $0 [-v] [list]" + exit 1 +} >&2 + + _path() { local path="$(url %h%p $1)" case "${path}" in @@ -11,14 +23,34 @@ _path() { _update() { local repo="$1" local path="$(_path ${repo})" - test -d "${path}" || git clone -q --mirror "${repo}" "${path}" - git -C "${path}" fetch -q && echo "Updated ${path}" || echo "Failed to update ${path}" + test -d "${path}" || git clone -q --mirror "${repo}" "${path}" || return 1 # TODO: Check if remotes are the same? + if git -C "${path}" fetch -q; then + echo "Updated ${path}" + else + echo "Failed to update ${path}" >&2 + return 1 + fi } +while getopts :v opt; do + case ${opt} in + v) _version;; + ?) _usage;; + esac +done +shift $(( ${OPTIND} - 1 )) list="${1:-repositories.list}" test -f "${list}" || exit 1 +pids= while read repo; do _update "${repo}" & + pids="${pids} $!" done <"${list}" -wait +failed=0 +for pid in ${pids}; do + if ! wait ${pid}; then + failed=1 + fi +done +exit ${failed} |