summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/lib/devtool/standard.py8
-rw-r--r--scripts/lib/recipetool/create.py2
-rw-r--r--scripts/lib/scriptutils.py11
3 files changed, 15 insertions, 6 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 6b5378176e..4dc175d117 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -23,6 +23,7 @@ import glob
23import tempfile 23import tempfile
24import logging 24import logging
25import argparse 25import argparse
26import scriptutils
26from devtool import exec_build_env_command, setup_tinfoil 27from devtool import exec_build_env_command, setup_tinfoil
27 28
28logger = logging.getLogger('devtool') 29logger = logging.getLogger('devtool')
@@ -236,12 +237,7 @@ def _extract_source(srctree, keep_temp, devbranch, d):
236 # Handle if S is set to a subdirectory of the source 237 # Handle if S is set to a subdirectory of the source
237 srcsubdir = os.path.join(workdir, os.path.relpath(srcsubdir, workdir).split(os.sep)[0]) 238 srcsubdir = os.path.join(workdir, os.path.relpath(srcsubdir, workdir).split(os.sep)[0])
238 239
239 if os.path.exists(os.path.join(srcsubdir, '.git')): 240 scriptutils.git_convert_standalone_clone(srcsubdir)
240 alternatesfile = os.path.join(srcsubdir, '.git', 'objects', 'info', 'alternates')
241 if os.path.exists(alternatesfile):
242 # This will have been cloned with -s, so we need to convert it to a full clone
243 bb.process.run('git repack -a', cwd=srcsubdir)
244 os.remove(alternatesfile)
245 241
246 patchdir = os.path.join(srcsubdir, 'patches') 242 patchdir = os.path.join(srcsubdir, 'patches')
247 haspatches = False 243 haspatches = False
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index 1d5bfd995c..0c413688c0 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -22,6 +22,7 @@ import glob
22import fnmatch 22import fnmatch
23import re 23import re
24import logging 24import logging
25import scriptutils
25 26
26logger = logging.getLogger('recipetool') 27logger = logging.getLogger('recipetool')
27 28
@@ -238,6 +239,7 @@ def create_recipe(args):
238 outlines.extend(lines_after) 239 outlines.extend(lines_after)
239 240
240 if args.extract_to: 241 if args.extract_to:
242 scriptutils.git_convert_standalone_clone(srctree)
241 shutil.move(srctree, args.extract_to) 243 shutil.move(srctree, args.extract_to)
242 logger.info('Source extracted to %s' % args.extract_to) 244 logger.info('Source extracted to %s' % args.extract_to)
243 245
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):
58 if hasattr(plugin, 'plugin_init'): 58 if hasattr(plugin, 'plugin_init'):
59 plugin.plugin_init(plugins) 59 plugin.plugin_init(plugins)
60 plugins.append(plugin) 60 plugins.append(plugin)
61
62def git_convert_standalone_clone(repodir):
63 """If specified directory is a git repository, ensure it's a standalone clone"""
64 import bb.process
65 if os.path.exists(os.path.join(repodir, '.git')):
66 alternatesfile = os.path.join(repodir, '.git', 'objects', 'info', 'alternates')
67 if os.path.exists(alternatesfile):
68 # This will have been cloned with -s, so we need to convert it so none
69 # of the contents is shared
70 bb.process.run('git repack -a', cwd=repodir)
71 os.remove(alternatesfile)