Skip to contentSkip to conversation

builddeb: make deb building more flexible

PATCH In review [email protected] 1 participant 7 messages May 25, 2021 – Jun 28, 2021 Kbuild

lore
Share & tools
lore
#0 lore raw

v2 cover builddeb: make deb building more flexible

From: Bastian Germann <[email protected]>

Building Debian packages via the [bin]deb-pkg make targets has some shortcomings. These targets do not allow for packing a Debian source package independently from actually building the binary package.

This series improves that process by making it possible to rebuild the packages without errors via dpkg-buildpackage, by separating source package creation from binary package building, and by making the dbg package build optional.

Changelog v2:
* Drop "use standard format for copyright file" (equivalent available)
* Enable parallel builds (via ordered make target dependencies)
* Include previously excluded top-level files in tarball
* Other minor suggestions by Masahiro

Bastian Germann (5):
builddeb: ignore or export files for clean pkg build
builddeb: set CC on cross build to prefixed gcc
builddeb: clean generated package content
builddeb: introduce profile excluding the dbg pkg
kbuild: introduce srcdeb-pkg target

 scripts/Makefile.package | 11 +++++++++--
 scripts/package/mkdebian | 13 ++++++++++++-
 2 files changed, 21 insertions(+), 3 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH v2 1/5 builddeb: ignore or export files for clean pkg build

From: Bastian Germann <[email protected]>

scripts/Makefile.package's TAR_CONTENT lists the files to include in orig tarballs while the deb-pkg make target only ignores .git. This results in the other top-level files ending up in the .diff.gz.

Extend the TAR_CONTENT with the git-controlled top-level files.

Let dpkg-source ignore .git with the default diff-ignore and list dynamically generated files that are not cleaned in extend-diff-ignore. Use the debian/source/options in order to have those always available on building the package.

---
 scripts/Makefile.package | 5 +++--
 scripts/package/mkdebian | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)
scripts/Makefile.package +3 -2
index b74c65284fb2..360ce0ae2fa1 100644
@@ -28,8 +28,9 @@ KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE))
 KDEB_SOURCENAME ?= linux-upstream
 KBUILD_PKG_ROOTCMD ?="fakeroot -u"
 export KDEB_SOURCENAME
-# Include only those top-level files that are needed by make, plus the GPL copy
 TAR_CONTENT := $(KBUILD_ALLDIRS) .config .scmversion Makefile \
+               .clang-format .cocciconfig .get_maintainer.ignore \
+               .gitignore .mailmap CREDITS MAINTAINERS README \
                Kbuild Kconfig COPYING $(wildcard localversion*)
 MKSPEC     := $(srctree)/scripts/package/mkspec
 
@@ -75,7 +76,7 @@ deb-pkg:
 	$(call cmd,src_tar,$(KDEB_SOURCENAME))
 	origversion=$$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$$//');\
 		mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz
-	+dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -i.git -us -uc
+	+dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -us -uc
 
 PHONY += bindeb-pkg
 bindeb-pkg:
scripts/package/mkdebian +2 -0
index 60a2a63a5e90..b317d26e2bbf 100755
@@ -134,6 +134,8 @@ fi
 
 mkdir -p debian/source/
 echo "1.0" > debian/source/format
+echo diff-ignore > debian/source/options
+echo 'extend-diff-ignore = ".config.old|.version|.*include/generated.*|scripts/mod/.*"' >> debian/source/options
 
 echo $debarch > debian/arch
 extra_build_depends=", $(if_enabled_echo CONFIG_UNWINDER_ORC libelf-dev:native)"
Signature · 1 line
2.30.2
#2 lore raw

PATCH v2 2/5 builddeb: set CC on cross build to prefixed gcc

In reply to [email protected]

From: Bastian Germann <[email protected]>

Building the generated package with CC unset will fail for cross compilation. Detect that and set CC to a sane default prefixed by dpkg-architecture's DEB_HOST_GNU_TYPE variable.

---
 scripts/package/mkdebian | 8 ++++++++
 1 file changed, 8 insertions(+)
scripts/package/mkdebian +8 -0
index b317d26e2bbf..449e284a449c 100755
@@ -223,6 +223,14 @@ fi
 cat <<EOF > debian/rules
 #!$(command -v $MAKE) -f
 
+include /usr/share/dpkg/architecture.mk
+
+ifneq (\$(DEB_BUILD_GNU_TYPE),\$(DEB_HOST_GNU_TYPE))
+ifeq (\$(origin CC),default)
+CC := \$(DEB_HOST_GNU_TYPE)-gcc
+endif
+endif
+
 srctree ?= .
 
 build-indep:
Signature · 1 line
2.30.2
#3 lore raw

PATCH v2 3/5 builddeb: clean generated package content

In reply to [email protected]

From: Bastian Germann <[email protected]>

For each binary Debian package, a directory with the package name is created in the debian directory. Correct the generated file matches in the package's clean target, which were renamed without adjusting the target.

Fixes 1694e94e4f46 ("builddeb: match temporary directory name to the package name")
---
 scripts/package/mkdebian | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/package/mkdebian +1 -1
index 449e284a449c..9470581d8c75 100755
@@ -246,7 +246,7 @@ binary-arch: build-arch
 	KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile intdeb-pkg
 
 clean:
-	rm -rf debian/*tmp debian/files
+	rm -rf debian/files debian/linux-*
 	\$(MAKE) clean
 
 binary: binary-arch
Signature · 1 line
2.30.2
#4 lore raw

PATCH v2 4/5 builddeb: introduce profile excluding the dbg pkg

In reply to [email protected]

From: Bastian Germann <[email protected]>

Enabling CONFIG_DEBUG_INFO implies building the binary linux-image-*-dbg. As this increases package build time significantly, one might want to exclude it from being built.

Add a pkg.$sourcename.nodbg build profile for that package so it can be excluded via e.g.: make DPKG_FLAGS="-P=pkg.linux-upstream.nodbg" deb-pkg

---
 scripts/package/mkdebian | 1 +
 1 file changed, 1 insertion(+)
scripts/package/mkdebian +1 -0
index 9470581d8c75..2e95966fe4dd 100755
@@ -212,6 +212,7 @@ if is_enabled CONFIG_DEBUG_INFO; then
 cat <<EOF >> debian/control
 
 Package: linux-image-$version-dbg
+Build-Profiles: <!pkg.$sourcename.nodbg>
 Section: debug
 Architecture: $debarch
 Description: Linux kernel debugging symbols for $version
Signature · 1 line
2.30.2
#5 lore raw

PATCH v2 5/5 kbuild: introduce srcdeb-pkg target

In reply to [email protected]

From: Bastian Germann <[email protected]>

A Debian source package can be generated only in combination with building it afterwards. Introduce a target srcdeb-pkg that generates the source package without building it (adding dpkg-buildpackage's -S flag).

Make the former deb-pkg run both srcdeb-pkg and bindeb-pkg to retain its behavior.

---
 scripts/Makefile.package | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
scripts/Makefile.package +7 -1
index 360ce0ae2fa1..dd347355c95e 100644
@@ -71,12 +71,17 @@ binrpm-pkg:
 
 PHONY += deb-pkg
 deb-pkg:
+	$(MAKE) srcdeb-pkg
+	$(MAKE) bindeb-pkg
+
+PHONY += srcdeb-pkg
+srcdeb-pkg:
 	$(MAKE) clean
 	$(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
 	$(call cmd,src_tar,$(KDEB_SOURCENAME))
 	origversion=$$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$$//');\
 		mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz
-	+dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -us -uc
+	+dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -S -us -uc
 
 PHONY += bindeb-pkg
 bindeb-pkg:
@@ -146,6 +151,7 @@ help:
 	@echo '  rpm-pkg             - Build both source and binary RPM kernel packages'
 	@echo '  binrpm-pkg          - Build only the binary kernel RPM package'
 	@echo '  deb-pkg             - Build both source and binary deb kernel packages'
+	@echo '  srcdeb-pkg          - Build only the source kernel deb package'
 	@echo '  bindeb-pkg          - Build only the binary kernel deb package'
 	@echo '  snap-pkg            - Build only the binary kernel snap package'
 	@echo '                        (will connect to external hosts)'
Signature · 1 line
2.30.2
#6 lore raw
In reply to [email protected]

Am 26.05.21 um 01:01 schrieb [email protected]:

Quoted 24 lines

From: Bastian Germann <[email protected]>

Building Debian packages via the [bin]deb-pkg make targets has some shortcomings. These targets do not allow for packing a Debian source package independently from actually building the binary package.

This series improves that process by making it possible to rebuild the packages without errors via dpkg-buildpackage, by separating source package creation from binary package building, and by making the dbg package build optional.

Changelog v2:
* Drop "use standard format for copyright file" (equivalent available)
* Enable parallel builds (via ordered make target dependencies)
* Include previously excluded top-level files in tarball
* Other minor suggestions by Masahiro

Bastian Germann (5):
builddeb: ignore or export files for clean pkg build
builddeb: set CC on cross build to prefixed gcc
builddeb: clean generated package content
builddeb: introduce profile excluding the dbg pkg
kbuild: introduce srcdeb-pkg target

Quoted 3 lines
  scripts/Makefile.package | 11 +++++++++--
  scripts/package/mkdebian | 13 ++++++++++++-
  2 files changed, 21 insertions(+), 3 deletions(-)

Gentle ping after a month without reply.