makepkg: add hg url support
Supported fragments are branch, revision and tag. Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
d51902c978
commit
7e4aa9e524
2 changed files with 71 additions and 5 deletions
|
@ -405,8 +405,8 @@ Using VCS Sources[[VCS]]
|
||||||
------------------------
|
------------------------
|
||||||
Building a developmental version of a package using sources from a version control
|
Building a developmental version of a package using sources from a version control
|
||||||
system (VCS) is enabled by specifying the source in the form
|
system (VCS) is enabled by specifying the source in the form
|
||||||
`source=('folder::url#fragment')`. Currently makepkg supports the `git` and `svn`
|
`source=('folder::url#fragment')`. Currently makepkg supports the `git`, `hg` and
|
||||||
protocols.
|
`svn` protocols.
|
||||||
|
|
||||||
The source URL is divided into three components:
|
The source URL is divided into three components:
|
||||||
|
|
||||||
|
@ -430,6 +430,9 @@ The source URL is divided into three components:
|
||||||
*git*;;
|
*git*;;
|
||||||
branch, commit, tag
|
branch, commit, tag
|
||||||
|
|
||||||
|
*hg*;;
|
||||||
|
branch, revision, tag
|
||||||
|
|
||||||
*svn*;;
|
*svn*;;
|
||||||
revision
|
revision
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,7 @@ get_filepath() {
|
||||||
local proto="$(get_protocol "$1")"
|
local proto="$(get_protocol "$1")"
|
||||||
|
|
||||||
case $proto in
|
case $proto in
|
||||||
git*|svn*)
|
git*|hg*|svn*)
|
||||||
if [[ -d "$startdir/$file" ]]; then
|
if [[ -d "$startdir/$file" ]]; then
|
||||||
file="$startdir/$file"
|
file="$startdir/$file"
|
||||||
elif [[ -d "$SRCDEST/$file" ]]; then
|
elif [[ -d "$SRCDEST/$file" ]]; then
|
||||||
|
@ -235,7 +235,7 @@ get_filename() {
|
||||||
local proto=$(get_protocol "$netfile")
|
local proto=$(get_protocol "$netfile")
|
||||||
|
|
||||||
case $proto in
|
case $proto in
|
||||||
git*|svn*)
|
git*|hg*|svn*)
|
||||||
filename=${netfile##*/}
|
filename=${netfile##*/}
|
||||||
filename=${filename%%#*}
|
filename=${filename%%#*}
|
||||||
# fall-through
|
# fall-through
|
||||||
|
@ -450,6 +450,66 @@ download_git() {
|
||||||
popd &>/dev/null
|
popd &>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
download_hg() {
|
||||||
|
local netfile=$1
|
||||||
|
|
||||||
|
local fragment=${netfile##*#}
|
||||||
|
if [[ $fragment = "$netfile" ]]; then
|
||||||
|
unset fragment
|
||||||
|
fi
|
||||||
|
|
||||||
|
local dir=$(get_filepath "$netfile")
|
||||||
|
[[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
|
||||||
|
|
||||||
|
local repo=${netfile##*/}
|
||||||
|
repo=${repo%%#*}
|
||||||
|
|
||||||
|
local url=$(get_url "$netfile")
|
||||||
|
url=${url##*hg+}
|
||||||
|
url=${url%%#*}
|
||||||
|
|
||||||
|
if [[ ! -d "$dir" ]]; then
|
||||||
|
msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "hg"
|
||||||
|
if ! hg clone "$url" "$dir"; then
|
||||||
|
error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "hg"
|
||||||
|
plain "$(gettext "Aborting...")"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
elif (( ! HOLDVER )); then
|
||||||
|
msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "hg"
|
||||||
|
cd_safe "$dir"
|
||||||
|
if ! hg pull -u; then
|
||||||
|
# only warn on failure to allow offline builds
|
||||||
|
warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "hg"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "hg"
|
||||||
|
pushd "$srcdir" &>/dev/null
|
||||||
|
rm -rf "${dir##*/}"
|
||||||
|
|
||||||
|
local ref
|
||||||
|
if [[ -n $fragment ]]; then
|
||||||
|
case ${fragment%%=*} in
|
||||||
|
branch|revision|tag)
|
||||||
|
ref=('-u' "${fragment##*=}")
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
error "$(gettext "Unrecognized reference: %s")" "${fragment}"
|
||||||
|
plain "$(gettext "Aborting...")"
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! hg clone "${ref[@]}" "$dir" "${dir##*/}"; then
|
||||||
|
error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "hg"
|
||||||
|
plain "$(gettext "Aborting...")"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
popd &>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
download_svn() {
|
download_svn() {
|
||||||
local netfile=$1
|
local netfile=$1
|
||||||
|
|
||||||
|
@ -535,6 +595,9 @@ download_sources() {
|
||||||
git*)
|
git*)
|
||||||
(( GET_VCS )) && download_git "$netfile"
|
(( GET_VCS )) && download_git "$netfile"
|
||||||
;;
|
;;
|
||||||
|
hg*)
|
||||||
|
(( GET_VCS )) && download_hg "$netfile"
|
||||||
|
;;
|
||||||
svn*)
|
svn*)
|
||||||
(( GET_VCS )) && download_svn "$netfile"
|
(( GET_VCS )) && download_svn "$netfile"
|
||||||
;;
|
;;
|
||||||
|
@ -909,7 +972,7 @@ generate_checksums() {
|
||||||
proto="$(get_protocol "$netfile")"
|
proto="$(get_protocol "$netfile")"
|
||||||
|
|
||||||
case $proto in
|
case $proto in
|
||||||
git*|svn*)
|
git*|hg*|svn*)
|
||||||
sum="SKIP"
|
sum="SKIP"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
Loading…
Add table
Reference in a new issue