summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>2024-02-19 02:28:28 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-02-19 16:03:22 +0000
commit24433ce8f9e091f04a18d2753347f32fb0860999 (patch)
tree8581c0bbf911ca6bfd6c182dc1367e3373291e5f
parent1e6565402f93848796cb5f19154b6eb6866d6110 (diff)
downloadpoky-24433ce8f9e091f04a18d2753347f32fb0860999.tar.gz
lib/oe/patch: Make extractPatches() not extract ignored commits
If a commit is marked with "%% ignore" it means it is used by devtool to keep track of changes to the source code that are not the result of running do_patch(). These changes need to actually be ignored when extracting the patches as they typically make no sense as actual patches in a recipe. This also adds a new test for oe-selftest that verifies that there are no patches generated from ignored commits. (From OE-Core rev: c3d43de7e54189bf09fbe8e87ddb976e42ebf531) Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta-selftest/recipes-extended/sysdig/sysdig-selftest/0055-Add-cstdint-for-uintXX_t-types.patch38
-rw-r--r--meta-selftest/recipes-extended/sysdig/sysdig-selftest/0099-cmake-Pass-PROBE_NAME-via-CFLAGS.patch29
-rw-r--r--meta-selftest/recipes-extended/sysdig/sysdig-selftest_0.28.0.bb66
-rw-r--r--meta/lib/oe/patch.py16
-rw-r--r--meta/lib/oeqa/selftest/cases/devtool.py46
5 files changed, 187 insertions, 8 deletions
diff --git a/meta-selftest/recipes-extended/sysdig/sysdig-selftest/0055-Add-cstdint-for-uintXX_t-types.patch b/meta-selftest/recipes-extended/sysdig/sysdig-selftest/0055-Add-cstdint-for-uintXX_t-types.patch
new file mode 100644
index 0000000000..e564958dad
--- /dev/null
+++ b/meta-selftest/recipes-extended/sysdig/sysdig-selftest/0055-Add-cstdint-for-uintXX_t-types.patch
@@ -0,0 +1,38 @@
1From 3d076ea588eb3c7f334133b4c31172a14beadf5b Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Thu, 2 Feb 2023 20:18:27 -0800
4Subject: [PATCH] Add <cstdint> for uintXX_t types
5
6gcc 13 moved some includes around and as a result <cstdint> is no
7longer transitively included [1]. Explicitly include it
8for uintXX_t.
9
10[1] https://gcc.gnu.org/gcc-13/porting_to.html#header-dep-changes
11
12Upstream-Status: Submitted [https://github.com/falcosecurity/libs/pull/862]
13Signed-off-by: Khem Raj <raj.khem@gmail.com>
14---
15 userspace/libsinsp/filter/parser.h | 1 +
16 userspace/libsinsp/filter_value.h | 1 +
17 2 files changed, 2 insertions(+)
18
19--- a/userspace/libsinsp/filter/parser.h
20+++ b/userspace/libsinsp/filter/parser.h
21@@ -18,6 +18,7 @@ limitations under the License.
22 #pragma once
23
24 #include "ast.h"
25+#include <cstdint>
26
27 //
28 // Context-free Grammar for Sinsp Filters
29--- a/userspace/libsinsp/filter_value.h
30+++ b/userspace/libsinsp/filter_value.h
31@@ -18,6 +18,7 @@ limitations under the License.
32 #pragma once
33
34 #include <string.h>
35+#include <cstdint>
36 #include <utility>
37
38 // Used for CO_IN/CO_PMATCH filterchecks using PT_CHARBUFs to allow
diff --git a/meta-selftest/recipes-extended/sysdig/sysdig-selftest/0099-cmake-Pass-PROBE_NAME-via-CFLAGS.patch b/meta-selftest/recipes-extended/sysdig/sysdig-selftest/0099-cmake-Pass-PROBE_NAME-via-CFLAGS.patch
new file mode 100644
index 0000000000..903ccdf36a
--- /dev/null
+++ b/meta-selftest/recipes-extended/sysdig/sysdig-selftest/0099-cmake-Pass-PROBE_NAME-via-CFLAGS.patch
@@ -0,0 +1,29 @@
1From ed8969a233adb6bf701de96d0fd0570e5ddcc787 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Mon, 21 Mar 2022 19:35:48 -0700
4Subject: [PATCH] cmake: Pass PROBE_NAME via CFLAGS
5
6This helps compliation of driver code where its calling modprobe on the
7given kernel module via system() API
8
9Upstream-Status: Pending
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11---
12 CMakeLists.txt | 1 +
13 1 file changed, 1 insertion(+)
14
15diff --git a/CMakeLists.txt b/CMakeLists.txt
16index 7dceb7ae..e156c36f 100644
17--- a/CMakeLists.txt
18+++ b/CMakeLists.txt
19@@ -149,6 +149,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux")
20 if(NOT DEFINED PROBE_NAME)
21 set(PROBE_NAME "scap")
22 endif()
23+ add_definitions(-DPROBE_NAME="${PROBE_NAME}")
24
25 set(DRIVERS_REPO "https://download.sysdig.com/scap-drivers")
26
27--
282.35.1
29
diff --git a/meta-selftest/recipes-extended/sysdig/sysdig-selftest_0.28.0.bb b/meta-selftest/recipes-extended/sysdig/sysdig-selftest_0.28.0.bb
new file mode 100644
index 0000000000..2ce85fe451
--- /dev/null
+++ b/meta-selftest/recipes-extended/sysdig/sysdig-selftest_0.28.0.bb
@@ -0,0 +1,66 @@
1SUMMARY = "A New System Troubleshooting Tool Built for the Way You Work"
2DESCRIPTION = "Sysdig is open source, system-level exploration: capture \
3system state and activity from a running Linux instance, then save, \
4filter and analyze."
5HOMEPAGE = "http://www.sysdig.org/"
6LICENSE = "Apache-2.0 & (MIT | GPL-2.0-only)"
7LIC_FILES_CHKSUM = "file://COPYING;md5=f8fee3d59797546cffab04f3b88b2d44"
8
9inherit cmake pkgconfig
10
11#OECMAKE_GENERATOR = "Unix Makefiles"
12JIT ?= "jit"
13JIT:mipsarchn32 = ""
14JIT:mipsarchn64 = ""
15JIT:riscv64 = ""
16JIT:riscv32 = ""
17JIT:powerpc = ""
18JIT:powerpc64le = ""
19JIT:powerpc64 = ""
20
21#DEPENDS += "libb64 lua${JIT} zlib c-ares grpc-native grpc curl ncurses jsoncpp \
22# tbb jq openssl elfutils protobuf protobuf-native jq-native valijson"
23RDEPENDS:${PN} = "bash"
24
25SRC_URI = "git://github.com/draios/sysdig.git;branch=dev;protocol=https;name=sysdig \
26 git://github.com/falcosecurity/libs;protocol=https;branch=master;name=falco;subdir=git/falcosecurity-libs \
27 file://0055-Add-cstdint-for-uintXX_t-types.patch;patchdir=./falcosecurity-libs \
28 file://0099-cmake-Pass-PROBE_NAME-via-CFLAGS.patch \
29 "
30SRCREV_sysdig = "4fb6288275f567f63515df0ff0a6518043ecfa9b"
31SRCREV_falco= "caa0e4d0044fdaaebab086592a97f0c7f32aeaa9"
32
33SRCREV_FORMAT = "sysdig_falco"
34
35S = "${WORKDIR}/git"
36
37EXTRA_OECMAKE = "\
38 -DBUILD_DRIVER=OFF \
39 -DMINIMAL_BUILD=ON \
40 -DUSE_BUNDLED_DEPS=OFF \
41 -DCREATE_TEST_TARGETS=OFF \
42 -DDIR_ETC=${sysconfdir} \
43 -DLUA_INCLUDE_DIR=${STAGING_INCDIR}/luajit-2.1 \
44 -DFALCOSECURITY_LIBS_SOURCE_DIR=${S}/falcosecurity-libs \
45 -DVALIJSON_INCLUDE=${STAGING_INCDIR}/valijson \
46"
47
48#CMAKE_VERBOSE = "VERBOSE=1"
49
50FILES:${PN} += " \
51 ${DIR_ETC}/* \
52 ${datadir}/zsh/* \
53 ${prefix}/src/* \
54"
55# Use getaddrinfo_a is a GNU extension in libsinsp
56# It should be fixed in sysdig, until then disable
57# on musl
58# Something like this https://code.videolan.org/ePirat/vlc/-/commit/01fd9fe4c7f6c5558f7345f38abf0152e17853ab is needed to fix it
59COMPATIBLE_HOST:libc-musl = "null"
60COMPATIBLE_HOST:mips = "null"
61COMPATIBLE_HOST:riscv64 = "null"
62COMPATIBLE_HOST:riscv32 = "null"
63COMPATIBLE_HOST:powerpc = "null"
64COMPATIBLE_HOST:powerpc64le = "null"
65
66EXCLUDE_FROM_WORLD = "1"
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index d5ad4f3dc1..70cdb1d9c0 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -474,9 +474,9 @@ class GitApplyTree(PatchTree):
474 out = runcmd(["sh", "-c", " ".join(shellcmd)], os.path.join(tree, name)) 474 out = runcmd(["sh", "-c", " ".join(shellcmd)], os.path.join(tree, name))
475 if out: 475 if out:
476 for srcfile in out.split(): 476 for srcfile in out.split():
477 outfile = os.path.basename(srcfile)
477 for encoding in ['utf-8', 'latin-1']: 478 for encoding in ['utf-8', 'latin-1']:
478 patchlines = [] 479 patchlines = []
479 outfile = None
480 try: 480 try:
481 with open(srcfile, 'r', encoding=encoding, newline='') as f: 481 with open(srcfile, 'r', encoding=encoding, newline='') as f:
482 for line in f: 482 for line in f:
@@ -484,7 +484,8 @@ class GitApplyTree(PatchTree):
484 outfile = line.split()[-1].strip() 484 outfile = line.split()[-1].strip()
485 continue 485 continue
486 if line.startswith(GitApplyTree.ignore_commit_prefix): 486 if line.startswith(GitApplyTree.ignore_commit_prefix):
487 continue 487 outfile = None
488 break
488 patchlines.append(line) 489 patchlines.append(line)
489 except UnicodeDecodeError: 490 except UnicodeDecodeError:
490 continue 491 continue
@@ -492,12 +493,11 @@ class GitApplyTree(PatchTree):
492 else: 493 else:
493 raise PatchError('Unable to find a character encoding to decode %s' % srcfile) 494 raise PatchError('Unable to find a character encoding to decode %s' % srcfile)
494 495
495 if not outfile: 496 if outfile:
496 outfile = os.path.basename(srcfile) 497 bb.utils.mkdirhier(os.path.join(outdir, name))
497 bb.utils.mkdirhier(os.path.join(outdir, name)) 498 with open(os.path.join(outdir, name, outfile), 'w') as of:
498 with open(os.path.join(outdir, name, outfile), 'w') as of: 499 for line in patchlines:
499 for line in patchlines: 500 of.write(line)
500 of.write(line)
501 finally: 501 finally:
502 shutil.rmtree(tempdir) 502 shutil.rmtree(tempdir)
503 503
diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py
index d76b974fbb..c4dcdb4550 100644
--- a/meta/lib/oeqa/selftest/cases/devtool.py
+++ b/meta/lib/oeqa/selftest/cases/devtool.py
@@ -2228,6 +2228,52 @@ class DevtoolUpgradeTests(DevtoolBase):
2228 if files: 2228 if files:
2229 self.fail('Unexpected file(s) copied next to bbappend: %s' % ', '.join(files)) 2229 self.fail('Unexpected file(s) copied next to bbappend: %s' % ', '.join(files))
2230 2230
2231 def test_devtool_finish_update_patch(self):
2232 # This test uses a modified version of the sysdig recipe from meta-oe.
2233 # - The patches have been renamed.
2234 # - The dependencies are commented out since the recipe is not being
2235 # built.
2236 #
2237 # The sysdig recipe is interesting in that it fetches two different Git
2238 # repositories, and there are patches for both. This leads to that
2239 # devtool will create ignore commits as it uses Git submodules to keep
2240 # track of the second repository.
2241 #
2242 # This test will verify that the ignored commits actually are ignored
2243 # when a commit in between is modified. It will also verify that the
2244 # updated patch keeps its original name.
2245
2246 # Check preconditions
2247 self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory')
2248 # Try modifying a recipe
2249 self.track_for_cleanup(self.workspacedir)
2250 recipe = 'sysdig-selftest'
2251 recipefile = get_bb_var('FILE', recipe)
2252 recipedir = os.path.dirname(recipefile)
2253 result = runCmd('git status --porcelain .', cwd=recipedir)
2254 if result.output.strip():
2255 self.fail('Recipe directory for %s contains uncommitted changes' % recipe)
2256 tempdir = tempfile.mkdtemp(prefix='devtoolqa')
2257 self.track_for_cleanup(tempdir)
2258 self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
2259 result = runCmd('devtool modify %s %s' % (recipe, tempdir))
2260 self.add_command_to_tearDown('cd %s; rm %s/*; git checkout %s %s' % (recipedir, recipe, recipe, os.path.basename(recipefile)))
2261 self.assertExists(os.path.join(tempdir, 'CMakeLists.txt'), 'Extracted source could not be found')
2262 # Make a change to one of the existing commits
2263 result = runCmd('echo "# A comment " >> CMakeLists.txt', cwd=tempdir)
2264 result = runCmd('git status --porcelain', cwd=tempdir)
2265 self.assertIn('M CMakeLists.txt', result.output)
2266 result = runCmd('git commit --fixup HEAD^ CMakeLists.txt', cwd=tempdir)
2267 result = runCmd('git show -s --format=%s', cwd=tempdir)
2268 self.assertIn('fixup! cmake: Pass PROBE_NAME via CFLAGS', result.output)
2269 result = runCmd('GIT_SEQUENCE_EDITOR=true git rebase -i --autosquash devtool-base', cwd=tempdir)
2270 result = runCmd('devtool finish %s meta-selftest' % recipe)
2271 result = runCmd('devtool status')
2272 self.assertNotIn(recipe, result.output, 'Recipe should have been reset by finish but wasn\'t')
2273 self.assertNotExists(os.path.join(self.workspacedir, 'recipes', recipe), 'Recipe directory should not exist after finish')
2274 expected_status = [(' M', '.*/0099-cmake-Pass-PROBE_NAME-via-CFLAGS.patch$')]
2275 self._check_repo_status(recipedir, expected_status)
2276
2231 def test_devtool_rename(self): 2277 def test_devtool_rename(self):
2232 # Check preconditions 2278 # Check preconditions
2233 self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory') 2279 self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory')