summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2014-06-29 22:36:22 +1000
committerAllan McRae <allan@archlinux.org>2014-08-04 14:23:56 +1000
commit7e87614665f667cc550acab3626ab6ad655541c7 (patch)
tree2162cd5fd9d1dc06636feb1ebc5baeee946d321f /scripts
parentfbb0945bfb6a9535dc42a120466b44c0b39c915d (diff)
downloadpacman-7e87614665f667cc550acab3626ab6ad655541c7.tar.xz
makepkg: ensure vcs download tool are installed when required
Add an array VCSCLIENTS to makepkg.conf that matches vcs source protocols to the package containing the software needed for handling the source. Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/makepkg.sh.in70
1 files changed, 70 insertions, 0 deletions
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index f9e816fa..48e19899 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -2402,6 +2402,71 @@ check_pkgver() {
return $ret
}
+get_vcsclient() {
+ local proto=${1%%+*}
+
+ local i
+ for i in "${VCSCLIENTS[@]}"; do
+ local handler="${i%%::*}"
+ if [[ $proto = "$handler" ]]; then
+ local client="${i##*::}"
+ break
+ fi
+ done
+
+ # if we didn't find an client, return an error
+ if [[ -z $client ]]; then
+ error "$(gettext "Unknown download protocol: %s")" "$proto"
+ plain "$(gettext "Aborting...")"
+ exit 1 # $E_CONFIG_ERROR
+ fi
+
+ printf "%s\n" "$client"
+}
+
+check_vcs_software() {
+ local ret=0
+
+ if (( SOURCEONLY == 1 )); then
+ # we will not download VCS sources
+ return $ret
+ fi
+
+ if [[ -z $PACMAN_PATH ]]; then
+ warning "$(gettext "Cannot find the %s binary needed to check VCS source requirements.")" "$PACMAN"
+ return $ret
+ fi
+
+ for netfile in ${source[@]}; do
+ local proto=$(get_protocol "$netfile")
+
+ case $proto in
+ bzr*|git*|hg*|svn*)
+ if ! type -p ${proto%%+*} > /dev/null; then
+ local client
+ client=$(get_vcsclient "$proto") || exit $?
+ # ensure specified program is installed
+ local uninstalled
+ uninstalled="$(set +E; check_deps $client)" || exit 1
+ # if not installed, check presence in depends or makedepends
+ if [[ -n "$uninstalled" ]] && (( ! NODEPS )); then
+ if ! in_array "$client" ${depends[@]} ${makedepends[@]}; then
+ error "$(gettext "Cannot find the %s package needed to handle %s sources.")" \
+ "$client" "${proto%%+*}"
+ ret=1
+ fi
+ fi
+ fi
+ ;;
+ *)
+ # non VCS source
+ ;;
+ esac
+ done
+
+ return $ret
+}
+
check_software() {
# check for needed software
local ret=0
@@ -2493,6 +2558,11 @@ check_software() {
fi
fi
+ # tools to download vcs sources
+ if ! check_vcs_software; then
+ ret=1
+ fi
+
return $ret
}