summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/lib/oeqa/selftest/devtool.py33
-rw-r--r--scripts/lib/devtool/standard.py7
2 files changed, 40 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py
index f147f248b3..932d6b9ec2 100644
--- a/meta/lib/oeqa/selftest/devtool.py
+++ b/meta/lib/oeqa/selftest/devtool.py
@@ -227,6 +227,39 @@ class DevtoolTests(oeSelfTest):
227 matches = glob.glob(stampprefix + '*') 227 matches = glob.glob(stampprefix + '*')
228 self.assertFalse(matches, 'Stamp files exist for recipe mdadm that should have been cleaned') 228 self.assertFalse(matches, 'Stamp files exist for recipe mdadm that should have been cleaned')
229 229
230 def test_devtool_modify_git(self):
231 # Check preconditions
232 workspacedir = os.path.join(self.builddir, 'workspace')
233 self.assertTrue(not os.path.exists(workspacedir), 'This test cannot be run with a workspace directory under the build directory')
234 testrecipe = 'mkelfimage'
235 src_uri = get_bb_var('SRC_URI', testrecipe)
236 self.assertIn('git://', src_uri, 'This test expects the %s recipe to be a git recipe' % testrecipe)
237 # Clean up anything in the workdir/sysroot/sstate cache
238 bitbake('%s -c cleansstate' % testrecipe)
239 # Try modifying a recipe
240 tempdir = tempfile.mkdtemp(prefix='devtoolqa')
241 self.track_for_cleanup(tempdir)
242 self.track_for_cleanup(workspacedir)
243 self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
244 self.add_command_to_tearDown('bitbake -c clean %s' % testrecipe)
245 result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir))
246 self.assertTrue(os.path.exists(os.path.join(tempdir, 'Makefile')), 'Extracted source could not be found')
247 self.assertTrue(os.path.isdir(os.path.join(tempdir, '.git')), 'git repository for external source tree not found')
248 self.assertTrue(os.path.exists(os.path.join(workspacedir, 'conf', 'layer.conf')), 'Workspace directory not created')
249 matches = glob.glob(os.path.join(workspacedir, 'appends', 'mkelfimage_*.bbappend'))
250 self.assertTrue(matches, 'bbappend not created')
251 # Test devtool status
252 result = runCmd('devtool status')
253 self.assertIn(testrecipe, result.output)
254 self.assertIn(tempdir, result.output)
255 # Check git repo
256 result = runCmd('git status --porcelain', cwd=tempdir)
257 self.assertEqual(result.output.strip(), "", 'Created git repo is not clean')
258 result = runCmd('git symbolic-ref HEAD', cwd=tempdir)
259 self.assertEqual(result.output.strip(), "refs/heads/devtool", 'Wrong branch in git repo')
260 # Try building
261 bitbake(testrecipe)
262
230 def test_devtool_update_recipe(self): 263 def test_devtool_update_recipe(self):
231 # Check preconditions 264 # Check preconditions
232 workspacedir = os.path.join(self.builddir, 'workspace') 265 workspacedir = os.path.join(self.builddir, 'workspace')
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index bf18aae686..cabf3feaf3 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -202,6 +202,13 @@ def _extract_source(srctree, keep_temp, devbranch, d):
202 # Handle if S is set to a subdirectory of the source 202 # Handle if S is set to a subdirectory of the source
203 srcsubdir = os.path.join(workdir, os.path.relpath(srcsubdir, workdir).split(os.sep)[0]) 203 srcsubdir = os.path.join(workdir, os.path.relpath(srcsubdir, workdir).split(os.sep)[0])
204 204
205 if os.path.exists(os.path.join(srcsubdir, '.git')):
206 alternatesfile = os.path.join(srcsubdir, '.git', 'objects', 'info', 'alternates')
207 if os.path.exists(alternatesfile):
208 # This will have been cloned with -s, so we need to convert it to a full clone
209 bb.process.run('git repack -a', cwd=srcsubdir)
210 os.remove(alternatesfile)
211
205 patchdir = os.path.join(srcsubdir, 'patches') 212 patchdir = os.path.join(srcsubdir, 'patches')
206 haspatches = False 213 haspatches = False
207 if os.path.exists(patchdir): 214 if os.path.exists(patchdir):