blob: 76763c184a1b9cf4e44c454c1bcf999f04fb4931 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#!/bin/bash
# Copyright © 2014 Luke Shumaker <lukeshu@sbcglobal.net>
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
# as published by Sam Hocevar. See the COPYING file for more details.
# Depends on the 'gitget' and 'libremessages' commands. On Parabola
# GNU/Linux-libre, those are the 'gitget' and 'librelib' packages,
# respectively.
#
# For other systems, the both live at:
# https://projects.parabolagnulinux.org/packages/libretools.git/
set -o pipefail
set -e
. libremessages
config-get() {
[[ $# == 1 ]] || panic
git config --file "$conf_file" --get "$1"
}
list-repos() {
[[ $# == 0 ]] || panic
git config --file "$conf_file" --list | cut -s -d. -f2 | sort -u
}
mirror-repo() {
[[ $# == 1 ]] || panic
repo=$1
canonical_path="$(config-get "repo.${repo}.canonical")"
local_path="$(config-get "repo.${repo}.local")"
description="$(config-get "repo.${repo}.description" || printf 'mirror of %s' "${canonical_path}")"
gitget -f -n "$repo" bare "$canonical_path" "$local_path"
printf '%s\n' "$description" > "$local_path/description.tmp"
mv -- "$local_path/description.tmp" "$local_path/description"
}
usage() {
print 'Usage %s CONFIG-FILE' "${0##*/}"
}
main() {
if [[ $# != 1 ]]; then
usage
exit
fi
declare -g conf_file="$1"
while read -r repo; do mirror-repo "$repo"; done < <(list-repos)
}
main "$@"
|