From a4fca1d52386924f25a18f6c4ed94e1a7bbac8e4 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Tue, 28 Apr 2015 12:25:30 +0100 Subject: recipetool: ensure git clone is standalone when extracting If -x is specified and the specified URI was a git repository, we need to ensure that the resulting clone is a sandalone and not one that has pointers into the temporary fetch location or DL_DIR (since the git fetcher does a local clone with -s). Split out the code from devtool that already does this for "devtool modify -x" and reuse that. (From OE-Core rev: fc47e8652ef32e7399f57c80593df90dc52d8b84) Signed-off-by: Paul Eggleton Signed-off-by: Richard Purdie --- scripts/lib/scriptutils.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'scripts/lib/scriptutils.py') diff --git a/scripts/lib/scriptutils.py b/scripts/lib/scriptutils.py index e7861268a5..fdf4b5d55d 100644 --- a/scripts/lib/scriptutils.py +++ b/scripts/lib/scriptutils.py @@ -58,3 +58,14 @@ def load_plugins(logger, plugins, pluginpath): if hasattr(plugin, 'plugin_init'): plugin.plugin_init(plugins) plugins.append(plugin) + +def git_convert_standalone_clone(repodir): + """If specified directory is a git repository, ensure it's a standalone clone""" + import bb.process + if os.path.exists(os.path.join(repodir, '.git')): + alternatesfile = os.path.join(repodir, '.git', 'objects', 'info', 'alternates') + if os.path.exists(alternatesfile): + # This will have been cloned with -s, so we need to convert it so none + # of the contents is shared + bb.process.run('git repack -a', cwd=repodir) + os.remove(alternatesfile) -- cgit v1.2.3-54-g00ecf