diff options
author | Erich Eckner <git@eckner.net> | 2021-03-30 10:15:23 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2021-03-30 10:15:23 +0200 |
commit | e22433d581ffd666267e26a859fb307f3b9d8e3c (patch) | |
tree | c598373203675262f49c0ccb80c99462254aac0d | |
parent | 3c61534b8f2f022b47913a87001b6a602d79b8c5 (diff) | |
download | archlinuxewe-e22433d581ffd666267e26a859fb307f3b9d8e3c.tar.xz |
update-sources: cleanup
-rwxr-xr-x | update-sources | 58 |
1 files changed, 41 insertions, 17 deletions
diff --git a/update-sources b/update-sources index 77bbba31b..8cae06165 100755 --- a/update-sources +++ b/update-sources @@ -1,19 +1,43 @@ #!/bin/bash -srcDir="${HOME}/packageSources" - -[ -d "${srcDir}" ] || exit 0 - -find "${srcDir}" \ - -mindepth 2 \ - -maxdepth 2 \ - -name HEAD \ - -printf '%h\n' \ -| parallel -j 0 -l 1 git -C {} fetch --all -p - -find "${srcDir}" \ - -mindepth 2 \ - -maxdepth 2 \ - -type d \ - -name .svn \ - -execdir svn update \; +if [ $# -eq 0 ]; then + + srcDir=$( + readlink -e "${HOME}/packageSources" + ) + + [ -d "${srcDir}" ] || exit 0 + + find "${srcDir}" \ + -type d \ + -exec sh -c 'test -f "{}/HEAD"' \; \ + -printf 'git: %p\n' \ + -prune , \ + -type d \ + -exec sh -c 'test -d "{}/.svn"' \; \ + -printf 'svn: %p\n' \ + -prune \ + | parallel -j 0 -l 1 "$0" + +elif [ $# -eq 1 ]; then + + case "${1%%: *}" in + 'git') + git -C "${1#*: }" fetch --all -p + ;; + 'svn') + cd "${1#*: }" + svn update + ;; + *) + >&2 printf '%s: unknown VCS "%s"\n' "$0" "${1%%: *}" + exit 1 + ;; + esac + +else + + >&2 printf '%s: too many arguments\n' "$0" + exit 1 + +fi |