makepkg: allow using GIT source URLs
Allow specifing GIT sources using the following syntax source=('<folder>::<repo>#<fragment>') This will download the git repo <repo> into <folder> (into $SRCDIR if set, otherwise $startdir). <repo> must start with "git", but non-git protocols are handled using (e.g.) "git+http://...". The <fragment> can be used to specify a branch, tag, or commit to build from. e.g. branch=maint. Checksum entries for git sources should be "SKIP". Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
57e06394dd
commit
91d119af1c
1 changed files with 85 additions and 0 deletions
|
@ -343,6 +343,88 @@ download_file() {
|
||||||
ln -s "$SRCDEST/$filename" "$srcdir/"
|
ln -s "$SRCDEST/$filename" "$srcdir/"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
download_git() {
|
||||||
|
local netfile=$1
|
||||||
|
|
||||||
|
local fragment=${netfile##*#}
|
||||||
|
if [[ $fragment = "$netfile" ]]; then
|
||||||
|
unset fragment
|
||||||
|
fi
|
||||||
|
|
||||||
|
local dir=${netfile%%::*}
|
||||||
|
local repo=${netfile##*/}
|
||||||
|
repo=${repo%%#*}
|
||||||
|
repo=${repo%%.git*}
|
||||||
|
|
||||||
|
if [[ $dir = "$netfile" ]]; then
|
||||||
|
dir="${repo}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -d "$startdir"/$dir ]]; then
|
||||||
|
dir="$SRCDEST"/$dir
|
||||||
|
else
|
||||||
|
dir="$startdir"/$dir
|
||||||
|
fi
|
||||||
|
|
||||||
|
local url=$(get_url "$netfile")
|
||||||
|
url=${url##*git+}
|
||||||
|
url=${url%%#*}
|
||||||
|
|
||||||
|
if [[ ! -d "$dir" ]]; then
|
||||||
|
msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "git"
|
||||||
|
if ! git clone --mirror "$url" "$dir"; then
|
||||||
|
error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "git"
|
||||||
|
plain "$(gettext "Aborting...")"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "git"
|
||||||
|
cd_safe "$dir"
|
||||||
|
if ! git fetch --all -p; then
|
||||||
|
# only warn on failure to allow offline builds
|
||||||
|
warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "git"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "git"
|
||||||
|
pushd "$srcdir" &>/dev/null
|
||||||
|
rm -rf "${dir##*/}"
|
||||||
|
|
||||||
|
if ! git clone "$dir"; then
|
||||||
|
error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git"
|
||||||
|
plain "$(gettext "Aborting...")"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd_safe "${dir##*/}"
|
||||||
|
|
||||||
|
local ref
|
||||||
|
if [[ -n $fragment ]]; then
|
||||||
|
case ${fragment%%=*} in
|
||||||
|
commit|tag)
|
||||||
|
ref=${fragment##*=}
|
||||||
|
;;
|
||||||
|
branch)
|
||||||
|
ref=origin/${fragment##*=}
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
error "$(gettext "Unrecognized reference: %s")" "${fragment}"
|
||||||
|
plain "$(gettext "Aborting...")"
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n $ref ]]; then
|
||||||
|
if ! git checkout -b makepkg $ref; then
|
||||||
|
error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git"
|
||||||
|
plain "$(gettext "Aborting...")"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
popd &>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
download_sources() {
|
download_sources() {
|
||||||
msg "$(gettext "Retrieving Sources...")"
|
msg "$(gettext "Retrieving Sources...")"
|
||||||
|
|
||||||
|
@ -359,6 +441,9 @@ download_sources() {
|
||||||
ftp|http|https|rsync|scp)
|
ftp|http|https|rsync|scp)
|
||||||
download_file "$netfile"
|
download_file "$netfile"
|
||||||
;;
|
;;
|
||||||
|
git*)
|
||||||
|
download_git "$netfile"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
error "$(gettext "Unknown download protocol: %s")" "$proto"
|
error "$(gettext "Unknown download protocol: %s")" "$proto"
|
||||||
plain "$(gettext "Aborting...")"
|
plain "$(gettext "Aborting...")"
|
||||||
|
|
Loading…
Add table
Reference in a new issue