diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-05-01 22:36:50 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-05-21 12:08:04 +0100 |
commit | 6d77296d83f87ea7f6ca0363a947d3eac721459b (patch) | |
tree | bdd4f17e69cffdcc39e20e43a917938736482e45 /meta | |
parent | d6ae8d2004f8ac3aab4571e0077d406b2d19b542 (diff) | |
download | poky-6d77296d83f87ea7f6ca0363a947d3eac721459b.tar.gz |
devtool: Drop oe-local-files and simplify
The only real reason for oe-local-files was to support S = WORKDIR. With changes to
drop support for that, it makes sense to simplify devtool and to try and make both
the code and the processes/workflows simpler.
This patch drops support for S = WORKDIR, removes oe-local-files and then updates
the test cases to match this new situation.
At the code level, we assume we can always now track code changes using git and
that things committed into git are handled as patches (as before) but delta against
HEAD is saved as specific file level changes to the recipe.
One test is disabled as it is no longer approproate. It is being keped until we can
make WORKDIR != UNPACKDIR at which point it should be revisited.
(From OE-Core rev: ce8190c519052fed10b5233697b69a75868db45a)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/classes-recipe/kernel-yocto.bbclass | 2 | ||||
-rw-r--r-- | meta/classes/devtool-source.bbclass | 74 | ||||
-rw-r--r-- | meta/lib/oeqa/selftest/cases/devtool.py | 38 |
3 files changed, 27 insertions, 87 deletions
diff --git a/meta/classes-recipe/kernel-yocto.bbclass b/meta/classes-recipe/kernel-yocto.bbclass index c4ed3f1ca2..e8ff7311c3 100644 --- a/meta/classes-recipe/kernel-yocto.bbclass +++ b/meta/classes-recipe/kernel-yocto.bbclass | |||
@@ -234,8 +234,6 @@ do_kernel_metadata() { | |||
234 | for f in ${feat_dirs}; do | 234 | for f in ${feat_dirs}; do |
235 | if [ -d "${UNPACKDIR}/$f/kernel-meta" ]; then | 235 | if [ -d "${UNPACKDIR}/$f/kernel-meta" ]; then |
236 | includes="$includes -I${UNPACKDIR}/$f/kernel-meta" | 236 | includes="$includes -I${UNPACKDIR}/$f/kernel-meta" |
237 | elif [ -d "${UNPACKDIR}/../oe-local-files/$f" ]; then | ||
238 | includes="$includes -I${UNPACKDIR}/../oe-local-files/$f" | ||
239 | elif [ -d "${UNPACKDIR}/$f" ]; then | 237 | elif [ -d "${UNPACKDIR}/$f" ]; then |
240 | includes="$includes -I${UNPACKDIR}/$f" | 238 | includes="$includes -I${UNPACKDIR}/$f" |
241 | fi | 239 | fi |
diff --git a/meta/classes/devtool-source.bbclass b/meta/classes/devtool-source.bbclass index 4158c20c7e..3e24800dcb 100644 --- a/meta/classes/devtool-source.bbclass +++ b/meta/classes/devtool-source.bbclass | |||
@@ -26,8 +26,6 @@ | |||
26 | 26 | ||
27 | 27 | ||
28 | DEVTOOL_TEMPDIR ?= "" | 28 | DEVTOOL_TEMPDIR ?= "" |
29 | DEVTOOL_PATCH_SRCDIR = "${DEVTOOL_TEMPDIR}/patchworkdir" | ||
30 | |||
31 | 29 | ||
32 | python() { | 30 | python() { |
33 | tempdir = d.getVar('DEVTOOL_TEMPDIR') | 31 | tempdir = d.getVar('DEVTOOL_TEMPDIR') |
@@ -60,7 +58,6 @@ python() { | |||
60 | else: | 58 | else: |
61 | unpacktask = 'do_unpack' | 59 | unpacktask = 'do_unpack' |
62 | d.appendVarFlag(unpacktask, 'postfuncs', ' devtool_post_unpack') | 60 | d.appendVarFlag(unpacktask, 'postfuncs', ' devtool_post_unpack') |
63 | d.prependVarFlag('do_patch', 'prefuncs', ' devtool_pre_patch') | ||
64 | d.appendVarFlag('do_patch', 'postfuncs', ' devtool_post_patch') | 61 | d.appendVarFlag('do_patch', 'postfuncs', ' devtool_post_patch') |
65 | 62 | ||
66 | # NOTE: in order for the patch stuff to be fully functional, | 63 | # NOTE: in order for the patch stuff to be fully functional, |
@@ -79,67 +76,23 @@ python devtool_post_unpack() { | |||
79 | 76 | ||
80 | tempdir = d.getVar('DEVTOOL_TEMPDIR') | 77 | tempdir = d.getVar('DEVTOOL_TEMPDIR') |
81 | workdir = d.getVar('WORKDIR') | 78 | workdir = d.getVar('WORKDIR') |
79 | unpackdir = d.getVar('UNPACKDIR') | ||
82 | srcsubdir = d.getVar('S') | 80 | srcsubdir = d.getVar('S') |
83 | 81 | ||
84 | def _move_file(src, dst): | 82 | # Add locally copied files to gitignore as we add back to the metadata directly |
85 | """Move a file. Creates all the directory components of destination path.""" | ||
86 | dst_d = os.path.dirname(dst) | ||
87 | if dst_d: | ||
88 | bb.utils.mkdirhier(dst_d) | ||
89 | shutil.move(src, dst) | ||
90 | |||
91 | def _ls_tree(directory): | ||
92 | """Recursive listing of files in a directory""" | ||
93 | ret = [] | ||
94 | for root, dirs, files in os.walk(directory): | ||
95 | ret.extend([os.path.relpath(os.path.join(root, fname), directory) for | ||
96 | fname in files]) | ||
97 | return ret | ||
98 | |||
99 | is_kernel_yocto = bb.data.inherits_class('kernel-yocto', d) | ||
100 | # Move local source files into separate subdir | ||
101 | recipe_patches = [os.path.basename(patch) for patch in | ||
102 | oe.recipeutils.get_recipe_patches(d)] | ||
103 | local_files = oe.recipeutils.get_recipe_local_files(d) | 83 | local_files = oe.recipeutils.get_recipe_local_files(d) |
104 | |||
105 | if is_kernel_yocto: | ||
106 | for key in [f for f in local_files if f.endswith('scc')]: | ||
107 | with open(local_files[key], 'r') as sccfile: | ||
108 | for l in sccfile: | ||
109 | line = l.split() | ||
110 | if line and line[0] in ('kconf', 'patch'): | ||
111 | cfg = os.path.join(os.path.dirname(local_files[key]), line[-1]) | ||
112 | if cfg not in local_files.values(): | ||
113 | local_files[line[-1]] = cfg | ||
114 | shutil.copy2(cfg, workdir) | ||
115 | |||
116 | # Ignore local files with subdir={BP} | ||
117 | srcabspath = os.path.abspath(srcsubdir) | 84 | srcabspath = os.path.abspath(srcsubdir) |
118 | local_files = [fname for fname in local_files if | 85 | local_files = [fname for fname in local_files if |
119 | os.path.exists(os.path.join(workdir, fname)) and | 86 | os.path.exists(os.path.join(unpackdir, fname)) and |
120 | (srcabspath == workdir or not | 87 | srcabspath == unpackdir] |
121 | os.path.join(workdir, fname).startswith(srcabspath + | ||
122 | os.sep))] | ||
123 | if local_files: | 88 | if local_files: |
124 | for fname in local_files: | 89 | with open(os.path.join(tempdir, '.gitignore'), 'a+') as f: |
125 | _move_file(os.path.join(workdir, fname), | 90 | f.write('# Ignore local files, by default. Remove following lines' |
126 | os.path.join(tempdir, 'oe-local-files', fname)) | 91 | 'if you want to commit the directory to Git\n') |
127 | with open(os.path.join(tempdir, 'oe-local-files', '.gitignore'), | 92 | for fname in local_files: |
128 | 'w') as f: | 93 | f.write('%s\n' % fname) |
129 | f.write('# Ignore local files, by default. Remove this file ' | 94 | |
130 | 'if you want to commit the directory to Git\n*\n') | 95 | if os.path.dirname(srcsubdir) != workdir: |
131 | |||
132 | if srcsubdir == workdir: | ||
133 | # Find non-patch non-local sources that were "unpacked" to srctree | ||
134 | # directory | ||
135 | src_files = [fname for fname in _ls_tree(workdir) if | ||
136 | os.path.basename(fname) not in recipe_patches] | ||
137 | srcsubdir = d.getVar('DEVTOOL_PATCH_SRCDIR') | ||
138 | # Move source files to S | ||
139 | for path in src_files: | ||
140 | _move_file(os.path.join(workdir, path), | ||
141 | os.path.join(srcsubdir, path)) | ||
142 | elif os.path.dirname(srcsubdir) != workdir: | ||
143 | # Handle if S is set to a subdirectory of the source | 96 | # Handle if S is set to a subdirectory of the source |
144 | srcsubdir = os.path.join(workdir, os.path.relpath(srcsubdir, workdir).split(os.sep)[0]) | 97 | srcsubdir = os.path.join(workdir, os.path.relpath(srcsubdir, workdir).split(os.sep)[0]) |
145 | 98 | ||
@@ -164,11 +117,6 @@ python devtool_post_unpack() { | |||
164 | f.write(srcsubdir) | 117 | f.write(srcsubdir) |
165 | } | 118 | } |
166 | 119 | ||
167 | python devtool_pre_patch() { | ||
168 | if d.getVar('S') == d.getVar('WORKDIR'): | ||
169 | d.setVar('S', '${DEVTOOL_PATCH_SRCDIR}') | ||
170 | } | ||
171 | |||
172 | python devtool_post_patch() { | 120 | python devtool_post_patch() { |
173 | import shutil | 121 | import shutil |
174 | tempdir = d.getVar('DEVTOOL_TEMPDIR') | 122 | tempdir = d.getVar('DEVTOOL_TEMPDIR') |
diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py index 8ce1c65a38..c8bf7d9e44 100644 --- a/meta/lib/oeqa/selftest/cases/devtool.py +++ b/meta/lib/oeqa/selftest/cases/devtool.py | |||
@@ -879,13 +879,8 @@ class DevtoolModifyTests(DevtoolBase): | |||
879 | self.add_command_to_tearDown('bitbake -c clean %s' % testrecipe) | 879 | self.add_command_to_tearDown('bitbake -c clean %s' % testrecipe) |
880 | self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') | 880 | self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') |
881 | result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) | 881 | result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) |
882 | srcfile = os.path.join(tempdir, 'oe-local-files/share/dot.bashrc') | 882 | srcfile = os.path.join(tempdir, 'share/dot.bashrc') |
883 | srclink = os.path.join(tempdir, 'share/dot.bashrc') | ||
884 | self.assertExists(srcfile, 'Extracted source could not be found') | 883 | self.assertExists(srcfile, 'Extracted source could not be found') |
885 | if os.path.islink(srclink) and os.path.exists(srclink) and os.path.samefile(srcfile, srclink): | ||
886 | correct_symlink = True | ||
887 | self.assertTrue(correct_symlink, 'Source symlink to oe-local-files is broken') | ||
888 | |||
889 | matches = glob.glob(os.path.join(self.workspacedir, 'appends', '%s_*.bbappend' % testrecipe)) | 884 | matches = glob.glob(os.path.join(self.workspacedir, 'appends', '%s_*.bbappend' % testrecipe)) |
890 | self.assertTrue(matches, 'bbappend not created') | 885 | self.assertTrue(matches, 'bbappend not created') |
891 | # Test devtool status | 886 | # Test devtool status |
@@ -1278,7 +1273,7 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1278 | with open(bbappendfile, 'r') as f: | 1273 | with open(bbappendfile, 'r') as f: |
1279 | self.assertEqual(expectedlines, f.readlines()) | 1274 | self.assertEqual(expectedlines, f.readlines()) |
1280 | # Drop new commit and check patch gets deleted | 1275 | # Drop new commit and check patch gets deleted |
1281 | result = runCmd('git reset HEAD^', cwd=tempsrcdir) | 1276 | result = runCmd('git reset HEAD^ --hard', cwd=tempsrcdir) |
1282 | result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir)) | 1277 | result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir)) |
1283 | self.assertNotExists(patchfile, 'Patch file not deleted') | 1278 | self.assertNotExists(patchfile, 'Patch file not deleted') |
1284 | expectedlines2 = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n', | 1279 | expectedlines2 = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n', |
@@ -1287,6 +1282,7 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1287 | self.assertEqual(expectedlines2, f.readlines()) | 1282 | self.assertEqual(expectedlines2, f.readlines()) |
1288 | # Put commit back and check we can run it if layer isn't in bblayers.conf | 1283 | # Put commit back and check we can run it if layer isn't in bblayers.conf |
1289 | os.remove(bbappendfile) | 1284 | os.remove(bbappendfile) |
1285 | result = runCmd("sed 's!\\(#define VERSION\\W*\"[^\"]*\\)\"!\\1-custom\"!' -i ReadMe.c", cwd=tempsrcdir) | ||
1290 | result = runCmd('git commit -a -m "Add our custom version"', cwd=tempsrcdir) | 1286 | result = runCmd('git commit -a -m "Add our custom version"', cwd=tempsrcdir) |
1291 | result = runCmd('bitbake-layers remove-layer %s' % templayerdir, cwd=self.builddir) | 1287 | result = runCmd('bitbake-layers remove-layer %s' % templayerdir, cwd=self.builddir) |
1292 | result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir)) | 1288 | result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir)) |
@@ -1361,7 +1357,7 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1361 | with open(bbappendfile, 'r') as f: | 1357 | with open(bbappendfile, 'r') as f: |
1362 | self.assertEqual(expectedlines, set(f.readlines())) | 1358 | self.assertEqual(expectedlines, set(f.readlines())) |
1363 | # Drop new commit and check SRCREV changes | 1359 | # Drop new commit and check SRCREV changes |
1364 | result = runCmd('git reset HEAD^', cwd=tempsrcdir) | 1360 | result = runCmd('git reset HEAD^ --hard', cwd=tempsrcdir) |
1365 | result = runCmd('devtool update-recipe -m srcrev %s -a %s' % (testrecipe, templayerdir)) | 1361 | result = runCmd('devtool update-recipe -m srcrev %s -a %s' % (testrecipe, templayerdir)) |
1366 | self.assertNotExists(os.path.join(appenddir, testrecipe), 'Patch directory should not be created') | 1362 | self.assertNotExists(os.path.join(appenddir, testrecipe), 'Patch directory should not be created') |
1367 | result = runCmd('git rev-parse HEAD', cwd=tempsrcdir) | 1363 | result = runCmd('git rev-parse HEAD', cwd=tempsrcdir) |
@@ -1373,6 +1369,7 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1373 | self.assertEqual(expectedlines, set(f.readlines())) | 1369 | self.assertEqual(expectedlines, set(f.readlines())) |
1374 | # Put commit back and check we can run it if layer isn't in bblayers.conf | 1370 | # Put commit back and check we can run it if layer isn't in bblayers.conf |
1375 | os.remove(bbappendfile) | 1371 | os.remove(bbappendfile) |
1372 | result = runCmd('echo "# Additional line" >> Makefile.am', cwd=tempsrcdir) | ||
1376 | result = runCmd('git commit -a -m "Change the Makefile"', cwd=tempsrcdir) | 1373 | result = runCmd('git commit -a -m "Change the Makefile"', cwd=tempsrcdir) |
1377 | result = runCmd('bitbake-layers remove-layer %s' % templayerdir, cwd=self.builddir) | 1374 | result = runCmd('bitbake-layers remove-layer %s' % templayerdir, cwd=self.builddir) |
1378 | result = runCmd('devtool update-recipe -m srcrev %s -a %s' % (testrecipe, templayerdir)) | 1375 | result = runCmd('devtool update-recipe -m srcrev %s -a %s' % (testrecipe, templayerdir)) |
@@ -1404,11 +1401,12 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1404 | # Try building just to ensure we haven't broken that | 1401 | # Try building just to ensure we haven't broken that |
1405 | bitbake("%s" % testrecipe) | 1402 | bitbake("%s" % testrecipe) |
1406 | # Edit / commit local source | 1403 | # Edit / commit local source |
1407 | runCmd('echo "/* Foobar */" >> oe-local-files/makedevs.c', cwd=tempdir) | 1404 | runCmd('echo "/* Foobar */" >> makedevs.c', cwd=tempdir) |
1408 | runCmd('echo "Foo" > oe-local-files/new-local', cwd=tempdir) | 1405 | runCmd('echo "Foo" > new-local', cwd=tempdir) |
1409 | runCmd('echo "Bar" > new-file', cwd=tempdir) | 1406 | runCmd('echo "Bar" > new-file', cwd=tempdir) |
1410 | runCmd('git add new-file', cwd=tempdir) | 1407 | runCmd('git add new-file', cwd=tempdir) |
1411 | runCmd('git commit -m "Add new file"', cwd=tempdir) | 1408 | runCmd('git commit -m "Add new file"', cwd=tempdir) |
1409 | runCmd('git add new-local', cwd=tempdir) | ||
1412 | runCmd('devtool update-recipe %s' % testrecipe) | 1410 | runCmd('devtool update-recipe %s' % testrecipe) |
1413 | expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)), | 1411 | expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)), |
1414 | (' M', '.*/makedevs/makedevs.c$'), | 1412 | (' M', '.*/makedevs/makedevs.c$'), |
@@ -1434,8 +1432,8 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1434 | self.assertExists(local_file, 'File makedevs.c not created') | 1432 | self.assertExists(local_file, 'File makedevs.c not created') |
1435 | self.assertExists(patchfile, 'File new_local not created') | 1433 | self.assertExists(patchfile, 'File new_local not created') |
1436 | 1434 | ||
1437 | def test_devtool_update_recipe_local_files_2(self): | 1435 | def _test_devtool_update_recipe_local_files_2(self): |
1438 | """Check local source files support when oe-local-files is in Git""" | 1436 | """Check local source files support when editing local files in Git""" |
1439 | testrecipe = 'devtool-test-local' | 1437 | testrecipe = 'devtool-test-local' |
1440 | recipefile = get_bb_var('FILE', testrecipe) | 1438 | recipefile = get_bb_var('FILE', testrecipe) |
1441 | recipedir = os.path.dirname(recipefile) | 1439 | recipedir = os.path.dirname(recipefile) |
@@ -1450,17 +1448,13 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1450 | result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) | 1448 | result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) |
1451 | # Check git repo | 1449 | # Check git repo |
1452 | self._check_src_repo(tempdir) | 1450 | self._check_src_repo(tempdir) |
1453 | # Add oe-local-files to Git | ||
1454 | runCmd('rm oe-local-files/.gitignore', cwd=tempdir) | ||
1455 | runCmd('git add oe-local-files', cwd=tempdir) | ||
1456 | runCmd('git commit -m "Add local sources"', cwd=tempdir) | ||
1457 | # Edit / commit local sources | 1451 | # Edit / commit local sources |
1458 | runCmd('echo "# Foobar" >> oe-local-files/file1', cwd=tempdir) | 1452 | runCmd('echo "# Foobar" >> file1', cwd=tempdir) |
1459 | runCmd('git commit -am "Edit existing file"', cwd=tempdir) | 1453 | runCmd('git commit -am "Edit existing file"', cwd=tempdir) |
1460 | runCmd('git rm oe-local-files/file2', cwd=tempdir) | 1454 | runCmd('git rm file2', cwd=tempdir) |
1461 | runCmd('git commit -m"Remove file"', cwd=tempdir) | 1455 | runCmd('git commit -m"Remove file"', cwd=tempdir) |
1462 | runCmd('echo "Foo" > oe-local-files/new-local', cwd=tempdir) | 1456 | runCmd('echo "Foo" > new-local', cwd=tempdir) |
1463 | runCmd('git add oe-local-files/new-local', cwd=tempdir) | 1457 | runCmd('git add new-local', cwd=tempdir) |
1464 | runCmd('git commit -m "Add new local file"', cwd=tempdir) | 1458 | runCmd('git commit -m "Add new local file"', cwd=tempdir) |
1465 | runCmd('echo "Gar" > new-file', cwd=tempdir) | 1459 | runCmd('echo "Gar" > new-file', cwd=tempdir) |
1466 | runCmd('git add new-file', cwd=tempdir) | 1460 | runCmd('git add new-file', cwd=tempdir) |
@@ -1469,7 +1463,7 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1469 | os.path.dirname(recipefile)) | 1463 | os.path.dirname(recipefile)) |
1470 | # Checkout unmodified file to working copy -> devtool should still pick | 1464 | # Checkout unmodified file to working copy -> devtool should still pick |
1471 | # the modified version from HEAD | 1465 | # the modified version from HEAD |
1472 | runCmd('git checkout HEAD^ -- oe-local-files/file1', cwd=tempdir) | 1466 | runCmd('git checkout HEAD^ -- file1', cwd=tempdir) |
1473 | runCmd('devtool update-recipe %s' % testrecipe) | 1467 | runCmd('devtool update-recipe %s' % testrecipe) |
1474 | expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)), | 1468 | expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)), |
1475 | (' M', '.*/file1$'), | 1469 | (' M', '.*/file1$'), |
@@ -1544,7 +1538,7 @@ class DevtoolUpdateTests(DevtoolBase): | |||
1544 | # (don't bother with cleaning the recipe on teardown, we won't be building it) | 1538 | # (don't bother with cleaning the recipe on teardown, we won't be building it) |
1545 | result = runCmd('devtool modify %s' % testrecipe) | 1539 | result = runCmd('devtool modify %s' % testrecipe) |
1546 | # Modify one file | 1540 | # Modify one file |
1547 | runCmd('echo "Another line" >> file2', cwd=os.path.join(self.workspacedir, 'sources', testrecipe, 'oe-local-files')) | 1541 | runCmd('echo "Another line" >> file2', cwd=os.path.join(self.workspacedir, 'sources', testrecipe)) |
1548 | self.add_command_to_tearDown('cd %s; rm %s/*; git checkout %s %s' % (os.path.dirname(recipefile), testrecipe, testrecipe, os.path.basename(recipefile))) | 1542 | self.add_command_to_tearDown('cd %s; rm %s/*; git checkout %s %s' % (os.path.dirname(recipefile), testrecipe, testrecipe, os.path.basename(recipefile))) |
1549 | result = runCmd('devtool update-recipe %s' % testrecipe) | 1543 | result = runCmd('devtool update-recipe %s' % testrecipe) |
1550 | expected_status = [(' M', '.*/%s/file2$' % testrecipe)] | 1544 | expected_status = [(' M', '.*/%s/file2$' % testrecipe)] |