From e231e9b9675aff4cc201d03cdc7479e0d2dc1639 Mon Sep 17 00:00:00 2001 From: insleker Date: Fri, 22 May 2026 18:58:53 +0800 Subject: [PATCH] feat: basic linux kbuild tree recipe implement --- recipes/linux-kbuild-tree/.gitignore | 3 +++ recipes/linux-kbuild-tree/conanfile.py | 20 ++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 recipes/linux-kbuild-tree/.gitignore diff --git a/recipes/linux-kbuild-tree/.gitignore b/recipes/linux-kbuild-tree/.gitignore new file mode 100644 index 0000000..fc6de81 --- /dev/null +++ b/recipes/linux-kbuild-tree/.gitignore @@ -0,0 +1,3 @@ +/build/ +/linux/ +*.txt diff --git a/recipes/linux-kbuild-tree/conanfile.py b/recipes/linux-kbuild-tree/conanfile.py index 2c6962d..d630276 100644 --- a/recipes/linux-kbuild-tree/conanfile.py +++ b/recipes/linux-kbuild-tree/conanfile.py @@ -29,6 +29,10 @@ class LinuxKbuildTreeConan(ConanFile): exports_sources = "configs/*" + def layout(self): + self.folders.build = "build" + self.folders.generators = os.path.join(self.folders.build, "generators") + def package_id(self): arch = self.conf.get("user.kernel:arch", default=None) if arch: @@ -61,8 +65,8 @@ class LinuxKbuildTreeConan(ConanFile): def source(self): self.run( "git clone --depth=1 " - f"--branch {shlex.quote(self._source_ref)} " - f"{shlex.quote(str(self.options.url))} linux" + f"--branch {shlex.quote(self._linux_ref_from_version())} " + "https://github.com/torvalds/linux.git linux" ) def build(self): @@ -73,7 +77,7 @@ class LinuxKbuildTreeConan(ConanFile): make_jobs = f" -j{jobs}" if jobs else "" make_base = ( - f"make -C {shlex.quote(linux)}{make_jobs} " + f"make --no-print-directory -C {shlex.quote(linux)}{make_jobs} " f"ARCH={shlex.quote(str(arch))} " f"CROSS_COMPILE={shlex.quote(str(cross_compile))}" ) @@ -97,7 +101,7 @@ class LinuxKbuildTreeConan(ConanFile): "\n".join( [ f"url={self.options.url}", - f"ref={self.version}", + f"ref={self._linux_ref_from_version()}", f"git_commit={git_commit}", f"kernelrelease={kernelrelease}", f"arch={arch}", @@ -130,6 +134,14 @@ class LinuxKbuildTreeConan(ConanFile): self.conf_info.define("user.kernel:arch", self._kernel_arch) self.conf_info.define("user.kernel:cross_compile", self._cross_compile or "") + def _linux_ref_from_version(self): + # Upstream Linux tags base releases as v6.8, while the kernel release + # and Conan package version are commonly represented as 6.8.0. + version_parts = str(self.version).split(".") + if len(version_parts) == 3 and version_parts[2] == "0": + return f"v{version_parts[0]}.{version_parts[1]}" + return f"v{self.version}" + @property def _kernel_arch(self): arch = self.conf.get("user.kernel:arch", default=None)