Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v2 12/13] download: git: introduce cache feature
Date: Mon, 5 Feb 2018 14:46:47 +0100	[thread overview]
Message-ID: <20180205144647.5be8d385@windsurf> (raw)
In-Reply-To: <20171025201003.16105-13-ps.report@gmx.net>

Hello,

On issue below.

On Wed, 25 Oct 2017 22:10:02 +0200, Peter Seiderer wrote:

> diff --git a/support/download/git b/support/download/git
> index 58a2c6ad9d..5d09cc0d7a 100755
> --- a/support/download/git
> +++ b/support/download/git
> @@ -39,28 +39,34 @@ _git() {
>      eval ${GIT} "${@}"
>  }
>  
> -# Try a shallow clone, since it is faster than a full clone - but that only
> -# works if the version is a ref (tag or branch). Before trying to do a shallow
> -# clone we check if ${cset} is in the list provided by git ls-remote. If not
> -# we fall back on a full clone.
> -#
> -# Messages for the type of clone used are provided to ease debugging in case of
> -# problems
> -git_done=0
> -if [ -n "$(_git ls-remote "'${uri}'" "'${cset}'" 2>&1)" ]; then
> -    printf "Doing shallow clone\n"
> -    if _git clone ${verbose} "${@}" --depth 1 -b "'${cset}'" "'${uri}'" "'${basename}'"; then
> -        git_done=1
> -    else
> -        printf "Shallow clone failed, falling back to doing a full clone\n"
> +# We want to check if a cache of the git clone of this repo already exists.
> +git_cache="${BR2_DL_DIR}/${basename%%-*}/git"
> +
> +# If the cache directory already exists, don't try to clone.
> +if [ ! -d "${git_cache}" ]; then
> +    # Try a shallow clone, since it is faster than a full clone - but that
> +    # only works if the versionis a ref (tag or branch). Before trying to do a
> +    # shallow clone we check if ${cset} is in the list provided by git
> +    # ls-remote. If not we fall back on a full clone.
> +    #
> +    # Messages for the type of clone used are provided to ease debugging in
> +    # case of problems
> +    git_done=0
> +    if [ -n "$(_git ls-remote "'${uri}'" "'${cset}'" 2>&1)" ]; then
> +        printf "Doing shallow clone\n"
> +        if _git clone ${verbose} "${@}" --depth 1 -b "'${cset}'" "'${uri}'" "'${git_cache}'"; then
> +            git_done=1
> +        else
> +            printf "Shallow clone failed, falling back to doing a full clone\n"
> +        fi
> +    fi
> +    if [ ${git_done} -eq 0 ]; then
> +        printf "Doing full clone\n"
> +        _git clone ${verbose} "${@}" "'${uri}'" "'${git_cache}'"
>      fi
> -fi
> -if [ ${git_done} -eq 0 ]; then
> -    printf "Doing full clone\n"
> -    _git clone ${verbose} "${@}" "'${uri}'" "'${basename}'"
>  fi

This looks all good, except that the rest of the script does:

if ! _git fetch origin "'${cset}:${cset}'" >/dev/null 2>&1; then
    printf "Could not fetch special ref '%s'; assuming it is not special.\n" "${cset}"
fi

And "origin" will be the first remote from which the Git cache was
started, but not necessarily the current Git repository that we should
pull from. This "origin" should be changed to ${uri} it seems.

This is not a problem today because we always clone, so origin is
always ${uri}. But with Git caching, it is no longer the case.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com

  reply	other threads:[~2018-02-05 13:46 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-25 20:09 [Buildroot] [PATCH v2 00/13] New DL_DIR organisation; git cache feature Peter Seiderer
2017-10-25 20:09 ` [Buildroot] [PATCH v2 01/13] pkg-{download, generic}: remove source-check Peter Seiderer
2018-01-08 20:22   ` Yann E. MORIN
2018-01-08 20:28   ` Thomas Petazzoni
2018-01-10 12:04     ` Thomas De Schampheleire
2018-01-10 12:41       ` Thomas Petazzoni
2018-01-10 12:51         ` Thomas De Schampheleire
2018-01-10 18:18       ` Yann E. MORIN
2017-10-25 20:09 ` [Buildroot] [PATCH v2 02/13] core/pkg-download: change all helpers to use common options Peter Seiderer
2018-02-05 15:34   ` Luca Ceresoli
2017-10-25 20:09 ` [Buildroot] [PATCH v2 03/13] download: put most of the infra in dl-wrapper Peter Seiderer
2018-02-05 15:34   ` Luca Ceresoli
2017-10-25 20:09 ` [Buildroot] [PATCH v2 04/13] packages: use new $($PKG)_DL_DIR) variable Peter Seiderer
2017-10-25 20:09 ` [Buildroot] [PATCH v2 05/13] pkg-{download, generic}: use new $($(PKG)_DL_DIR) Peter Seiderer
2017-10-25 20:09 ` [Buildroot] [PATCH v2 06/13] support/download: make sure the download folder is created Peter Seiderer
2017-10-25 20:09 ` [Buildroot] [PATCH v2 07/13] pkg-generic: add a subdirectory to the DL_DIR Peter Seiderer
2017-10-25 20:09 ` [Buildroot] [PATCH v2 08/13] pkg-download: support new subdir for mirrors Peter Seiderer
2017-10-25 20:09 ` [Buildroot] [PATCH v2 09/13] pkg-generic: introduce _SAME_SOURCE_AS Peter Seiderer
2017-10-25 20:10 ` [Buildroot] [PATCH v2 10/13] help/manual: update help about the new $(LIBFOO_DL_DIR) Peter Seiderer
2017-10-25 20:10 ` [Buildroot] [PATCH v2 11/13] download: add flock call before dl-wrapper Peter Seiderer
2017-10-25 20:10 ` [Buildroot] [PATCH v2 12/13] download: git: introduce cache feature Peter Seiderer
2018-02-05 13:46   ` Thomas Petazzoni [this message]
2017-10-25 20:10 ` [Buildroot] [PATCH v2 13/13] WIP: support package with '-' Peter Seiderer
2018-02-05 13:33   ` Thomas Petazzoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180205144647.5be8d385@windsurf \
    --to=thomas.petazzoni@bootlin.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox