* [PATCH] bitbake: layerindex: allow clones to be shallow
@ 2020-02-18 13:55 Jan-Simon Moeller
2020-02-18 22:06 ` Mark Hatle
0 siblings, 1 reply; 2+ messages in thread
From: Jan-Simon Moeller @ 2020-02-18 13:55 UTC (permalink / raw)
To: bitbake-devel
When bitbake-layers fetch-layerindex clones the repositories, these are
full clones. Allow the user to specify '-s' and do shallow clones
instead for faster downloads.
Signed-off-by: Jan-Simon Moeller <dl9pf@gmx.de>
---
lib/bblayers/layerindex.py | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/lib/bblayers/layerindex.py b/lib/bblayers/layerindex.py
index aa3b682d..95b67a66 100644
--- a/lib/bblayers/layerindex.py
+++ b/lib/bblayers/layerindex.py
@@ -24,7 +24,7 @@ class LayerIndexPlugin(ActionPlugin):
This class inherits ActionPlugin to get do_add_layer.
"""
- def get_fetch_layer(self, fetchdir, url, subdir, fetch_layer, branch):
+ def get_fetch_layer(self, fetchdir, url, subdir, fetch_layer, branch, shallow=False):
layername = self.get_layer_name(url)
if os.path.splitext(layername)[1] == '.git':
layername = os.path.splitext(layername)[0]
@@ -32,10 +32,12 @@ class LayerIndexPlugin(ActionPlugin):
layerdir = os.path.join(repodir, subdir)
if not os.path.exists(repodir):
if fetch_layer:
- cmd = ['git', 'clone', '-b' , branch, url, repodir]
- if not branch:
- # Branch really shouldn't be empty, but use the repo default if it is
- cmd = ['git', 'clone', url, repodir]
+ cmd = ['git', 'clone']
+ if shallow:
+ cmd.extend(['--depth', '1'])
+ if branch:
+ cmd.extend(['-b' , branch])
+ cmd.extend([url, repodir])
result = subprocess.call(cmd)
if result:
logger.error("Failed to download %s (%s)" % (url, branch))
@@ -176,7 +178,8 @@ class LayerIndexPlugin(ActionPlugin):
layerBranch.layer.vcs_url,
layerBranch.vcs_subdir,
not args.show_only,
- layerBranch.actual_branch)
+ layerBranch.actual_branch,
+ args.shallow)
if not name:
# Error already shown
return 1
@@ -209,6 +212,7 @@ class LayerIndexPlugin(ActionPlugin):
parser_layerindex_fetch = self.add_command(sp, 'layerindex-fetch', self.do_layerindex_fetch, parserecipes=False)
parser_layerindex_fetch.add_argument('-n', '--show-only', help='show dependencies and do nothing else', action='store_true')
parser_layerindex_fetch.add_argument('-b', '--branch', help='branch name to fetch')
+ parser_layerindex_fetch.add_argument('-s', '--shallow', help='do only shallow clones (--depth=1)', action='store_true')
parser_layerindex_fetch.add_argument('-i', '--ignore', help='assume the specified layers do not need to be fetched/added (separate multiple layers with commas, no spaces)', metavar='LAYER')
parser_layerindex_fetch.add_argument('layername', nargs='+', help='layer to fetch')
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] bitbake: layerindex: allow clones to be shallow
2020-02-18 13:55 [PATCH] bitbake: layerindex: allow clones to be shallow Jan-Simon Moeller
@ 2020-02-18 22:06 ` Mark Hatle
0 siblings, 0 replies; 2+ messages in thread
From: Mark Hatle @ 2020-02-18 22:06 UTC (permalink / raw)
To: bitbake-devel
Ack, this looks fine.
It would be nice (in the future) to have a way to specify an optional depth,
that could be passed through the system. But as implemented it's fine.
--Mark
On 2/18/20 7:55 AM, Jan-Simon Moeller wrote:
> When bitbake-layers fetch-layerindex clones the repositories, these are
> full clones. Allow the user to specify '-s' and do shallow clones
> instead for faster downloads.
>
> Signed-off-by: Jan-Simon Moeller <dl9pf@gmx.de>
> ---
> lib/bblayers/layerindex.py | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/lib/bblayers/layerindex.py b/lib/bblayers/layerindex.py
> index aa3b682d..95b67a66 100644
> --- a/lib/bblayers/layerindex.py
> +++ b/lib/bblayers/layerindex.py
> @@ -24,7 +24,7 @@ class LayerIndexPlugin(ActionPlugin):
> This class inherits ActionPlugin to get do_add_layer.
> """
>
> - def get_fetch_layer(self, fetchdir, url, subdir, fetch_layer, branch):
> + def get_fetch_layer(self, fetchdir, url, subdir, fetch_layer, branch, shallow=False):
> layername = self.get_layer_name(url)
> if os.path.splitext(layername)[1] == '.git':
> layername = os.path.splitext(layername)[0]
> @@ -32,10 +32,12 @@ class LayerIndexPlugin(ActionPlugin):
> layerdir = os.path.join(repodir, subdir)
> if not os.path.exists(repodir):
> if fetch_layer:
> - cmd = ['git', 'clone', '-b' , branch, url, repodir]
> - if not branch:
> - # Branch really shouldn't be empty, but use the repo default if it is
> - cmd = ['git', 'clone', url, repodir]
> + cmd = ['git', 'clone']
> + if shallow:
> + cmd.extend(['--depth', '1'])
> + if branch:
> + cmd.extend(['-b' , branch])
> + cmd.extend([url, repodir])
> result = subprocess.call(cmd)
> if result:
> logger.error("Failed to download %s (%s)" % (url, branch))
> @@ -176,7 +178,8 @@ class LayerIndexPlugin(ActionPlugin):
> layerBranch.layer.vcs_url,
> layerBranch.vcs_subdir,
> not args.show_only,
> - layerBranch.actual_branch)
> + layerBranch.actual_branch,
> + args.shallow)
> if not name:
> # Error already shown
> return 1
> @@ -209,6 +212,7 @@ class LayerIndexPlugin(ActionPlugin):
> parser_layerindex_fetch = self.add_command(sp, 'layerindex-fetch', self.do_layerindex_fetch, parserecipes=False)
> parser_layerindex_fetch.add_argument('-n', '--show-only', help='show dependencies and do nothing else', action='store_true')
> parser_layerindex_fetch.add_argument('-b', '--branch', help='branch name to fetch')
> + parser_layerindex_fetch.add_argument('-s', '--shallow', help='do only shallow clones (--depth=1)', action='store_true')
> parser_layerindex_fetch.add_argument('-i', '--ignore', help='assume the specified layers do not need to be fetched/added (separate multiple layers with commas, no spaces)', metavar='LAYER')
> parser_layerindex_fetch.add_argument('layername', nargs='+', help='layer to fetch')
>
> --
> 2.11.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-02-18 22:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-18 13:55 [PATCH] bitbake: layerindex: allow clones to be shallow Jan-Simon Moeller
2020-02-18 22:06 ` Mark Hatle
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.