diff mbox series

[RFC/upstream:linux,3/5] kbuild: snap-pkg: build in-place to achieve incremental builds

Message ID 20230228094949.2660702-4-masahiro.yamada@canonical.com
State New
Headers show
Series kbuild: snap-pkg: make 'make snap-pkg' comple on Ubuntu 20.04 | expand

Commit Message

Masahiro Yamada Feb. 28, 2023, 9:49 a.m. UTC
Currently, the source tree is passed as a tarball, but it is very slow,
and there is no reason to do so. Use the local source-type to skip the
tarball creation.

The kernel is built in snap/parts/kerenl/build, which does not reuse
the objects in the tree. Make parts/kernel/build a symlink to the top
of objtree. This is a trick to build in-place.

There is no need to replicate the entire tree to parts/kernel/src
since we build the kernel in-place. Just let it copy an empty directory.

Signed-off-by: Masahiro Yamada <masahiro.yamada@canonical.com>
---
 scripts/Makefile.package           |  6 ++----
 scripts/package/snapcraft.template | 11 +++++++++--
 2 files changed, 11 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/scripts/Makefile.package b/scripts/Makefile.package
index 037d42db0b55..0b99e4aaead1 100644
--- a/scripts/Makefile.package
+++ b/scripts/Makefile.package
@@ -136,12 +136,10 @@  PHONY += snap-pkg
 snap-pkg:
 	rm -rf $(objtree)/snap
 	mkdir $(objtree)/snap
-	$(MAKE) clean
-	$(call cmd,src_tar,$(KERNELPATH))
-	sed "s@KERNELRELEASE@$$(echo $(KERNELRELEASE) | cut -b -32)@; \
-		s@SRCTREE@$(shell realpath $(KERNELPATH).tar.gz)@" \
+	sed "s@KERNELRELEASE@$$(echo $(KERNELRELEASE) | cut -b -32)@" \
 		$(srctree)/scripts/package/snapcraft.template > \
 		$(objtree)/snap/snapcraft.yaml
+	mkdir -p snap/dummy
 	cd $(objtree)/snap && \
 	SNAPCRAFT_BUILD_ENVIRONMENT=host snapcraft --target-arch=$(UTS_MACHINE)
 
diff --git a/scripts/package/snapcraft.template b/scripts/package/snapcraft.template
index 9835bf4c3194..fd91ac9c2ca3 100644
--- a/scripts/package/snapcraft.template
+++ b/scripts/package/snapcraft.template
@@ -10,6 +10,13 @@  build-base: core18
 parts:
   kernel:
     plugin: kernel
-    source: SRCTREE
-    source-type: tar
+    source: dummy
+    source-type: local
     kernel-with-firmware: false
+    override-build: |
+      # build in-place
+      cd ..
+      rm -rf build
+      ln -s ../../.. build
+      cd build
+      snapcraftctl build