blob: 8d4abf25cca6fc8872d5150b4664b4a89be8fe90 (
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
|
#!/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 "$@"
|