FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 06-26-2012, 10:58 PM
Allan McRae
 
Default 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>
---
scripts/makepkg.sh.in | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++ +
1 file changed, 85 insertions(+)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 985bbbd..2b29759 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -341,6 +341,88 @@ download_file() {
ln -s "$SRCDEST/$filename" "$srcdir/"
}

+download_git() {
+ local netfile=$1
+
+ local fragment=${netfile##*#}
+ if [[ $fragment = "$netfile" ]]; then
+ unset fragment
+ fi
+
+ local folder=${netfile%%::*}
+ local repo=${netfile##*/}
+ repo=${repo%%#*}
+ repo=${repo%%.git*}
+
+ if [[ $folder = "$netfile" ]]; then
+ folder="${repo}"
+ fi
+
+ if [[ ! -d "$startdir"/$folder && -d "$SRCDEST"/$folder ]]; then
+ folder="$SRCDEST"/$folder
+ else
+ folder="$startdir"/$folder
+ fi
+
+ local url=$(get_url "$netfile")
+ url=${url##*git+}
+ url=${url%%#*}
+
+ if [[ ! -d $folder ]]; then
+ msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "git"
+ if ! git clone --mirror "$url" "$folder"; 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 "$folder"
+ 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 ${folder##*/}
+
+ if ! git clone $folder; then
+ error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git"
+ plain "$(gettext "Aborting...")"
+ exit 1
+ fi
+
+ cd_safe ${folder##*/}
+
+ 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() {
msg "$(gettext "Retrieving Sources...")"

@@ -357,6 +439,9 @@ download_sources() {
ftp|http|https|rsync|scp)
download_file "$netfile"
;;
+ git*)
+ download_git "$netfile"
+ ;;
*)
error "$(gettext "Unknown download protocol: %s")" "$proto"
plain "$(gettext "Aborting...")"
--
1.7.11.1
 
Old 06-27-2012, 12:14 AM
Dave Reisner
 
Default makepkg: allow using GIT source URLs

On Wed, Jun 27, 2012 at 08:58:12AM +1000, Allan McRae wrote:
> 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>
> ---
> scripts/makepkg.sh.in | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++ +
> 1 file changed, 85 insertions(+)
>
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index 985bbbd..2b29759 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -341,6 +341,88 @@ download_file() {
> ln -s "$SRCDEST/$filename" "$srcdir/"
> }
>
> +download_git() {
> + local netfile=$1
> +
> + local fragment=${netfile##*#}
> + if [[ $fragment = "$netfile" ]]; then
> + unset fragment
> + fi
> +
> + local folder=${netfile%%::*}

This makes my OCD twitch -- dir instead of folder?

> + local repo=${netfile##*/}
> + repo=${repo%%#*}
> + repo=${repo%%.git*}
> +
> + if [[ $folder = "$netfile" ]]; then
> + folder="${repo}"
> + fi
> +
> + if [[ ! -d "$startdir"/$folder && -d "$SRCDEST"/$folder ]]; then
> + folder="$SRCDEST"/$folder
> + else
> + folder="$startdir"/$folder
> + fi

None of the quoting in this block is strictly necessary.

> +
> + local url=$(get_url "$netfile")
> + url=${url##*git+}
> + url=${url%%#*}
> +
> + if [[ ! -d $folder ]]; then
> + msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "git"
> + if ! git clone --mirror "$url" "$folder"; 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 "$folder"
> + 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 ${folder##*/}
> +
> + if ! git clone $folder; then

Your spare quotes from above can go here.

> + error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git"
> + plain "$(gettext "Aborting...")"
> + exit 1
> + fi
> +
> + cd_safe ${folder##*/}

Quotes here too, please.

> +
> + local ref
> + if [[ -n $fragment ]]; then
> + case $fragment in
> + commit=*|tag*)

tag=* rather than tag* ? You might want to trim $fragment right in the
switch to avoid all the glob matching, i.e.

case ${fragmen%%=*} in
commit|tag)
....
branch)
....

> + 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

Is that branch name really intentional here? Why not name it the same as
$ref?

> + 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() {
> msg "$(gettext "Retrieving Sources...")"
>
> @@ -357,6 +439,9 @@ download_sources() {
> ftp|http|https|rsync|scp)
> download_file "$nethe tfile"
> ;;
> + git*)
> + download_git "$netfile"
> + ;;
> *)
> error "$(gettext "Unknown download protocol: %s")" "$proto"
> plain "$(gettext "Aborting...")"
> --
> 1.7.11.1
>
>
 
Old 06-27-2012, 08:54 AM
Thomas Bächler
 
Default makepkg: allow using GIT source URLs

Am 27.06.2012 00:58, schrieb Allan McRae:
> + if [[ ! -d "$startdir"/$folder && -d "$SRCDEST"/$folder ]]; then
> + folder="$SRCDEST"/$folder
> + else
> + folder="$startdir"/$folder
> + fi

I don't understand this logic: Does this mean that you put the git clone
to $startdir/$folder by default? If $SRCDEST is set, I would always
expect it to go to $SRCDEST.
 
Old 06-27-2012, 09:14 AM
Allan McRae
 
Default makepkg: allow using GIT source URLs

On 27/06/12 18:54, Thomas Bächler wrote:
> Am 27.06.2012 00:58, schrieb Allan McRae:
>> + if [[ ! -d "$startdir"/$folder && -d "$SRCDEST"/$folder ]]; then
>> + folder="$SRCDEST"/$folder
>> + else
>> + folder="$startdir"/$folder
>> + fi
>
> I don't understand this logic: Does this mean that you put the git clone
> to $startdir/$folder by default? If $SRCDEST is set, I would always
> expect it to go to $SRCDEST.
>

Yeah, that was an oversight there - and probably completely broken. But
it is entirely fixed in patch 09/11.

Allan
 
Old 06-27-2012, 09:49 AM
Thomas Bächler
 
Default makepkg: allow using GIT source URLs

Am 27.06.2012 11:14, schrieb Allan McRae:
> On 27/06/12 18:54, Thomas Bächler wrote:
>> Am 27.06.2012 00:58, schrieb Allan McRae:
>>> + if [[ ! -d "$startdir"/$folder && -d "$SRCDEST"/$folder ]]; then
>>> + folder="$SRCDEST"/$folder
>>> + else
>>> + folder="$startdir"/$folder
>>> + fi
>>
>> I don't understand this logic: Does this mean that you put the git clone
>> to $startdir/$folder by default? If $SRCDEST is set, I would always
>> expect it to go to $SRCDEST.
>>
>
> Yeah, that was an oversight there - and probably completely broken. But
> it is entirely fixed in patch 09/11.

Didn't see that, but yeah, seems to make more sense there.
 

Thread Tools




All times are GMT. The time now is 09:19 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org