linux/scripts/package
Masahiro Yamada ed79c34d3c kbuild: deb-pkg: support DEB_BUILD_OPTIONS=parallel=N in debian/rules
'make srcdeb-pkg' generates a source package, which you can build
later by using dpkg-buildpackage.

In older dpkg versions, 'dpkg-buildpackage --jobs=N' sets not only
DEB_BUILD_OPTIONS but also MAKEFLAGS. Hence, passing -j or --jobs
to dpkg-buildpackage was enough for kicking the parallel execution.

The behavior was changed by commit 1d0ea9b2ba3f ("dpkg-buildpackage:
Change -j, --jobs semantics to non-force mode") of dpkg project. [1]

Since then, 'dpkg-buildpackage --jobs=N' sets only DEB_BUILD_OPTIONS,
which is not parsed by the current debian/rules. To build the package
in parallel, you need to pass the alternative --jobs-force option or
set the MAKEFLAGS environment variable.

Debian policy [2] suggests the following code snippet for debian/rules.

  ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
      NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
      MAKEFLAGS += -j$(NUMJOBS)
  endif

I tweaked the code to filter out parallel=1 and passed --jobs=1 to
dpkg-buildpackage from scripts/Makefile.package. It is needed to force
'make deb-pkg' without the -j option to run in serial. Please note that
dpkg-buildpackage sets parallel=<nproc> in DEB_BUILD_OPTIONS by default
(that is, --jobs=auto is the default) and --jobs=1 is needed to restore
the serial execution. When dpkg-buildpackage is invoked from Kbuild,
the number of jobs is inherited from the top level Makefile. Passing
--jobs=1 to dpkg-buildpackage allows debian/rules to skip parsing
DEB_BUILD_OPTIONS.

[1] 1d0ea9b2ba
[2] https://www.debian.org/doc/debian-policy/ch-source.html#s-debianrules-options

Reported-by: Bastian Germann <bage@linutronix.de>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2023-08-29 22:29:35 +09:00
..
debian kbuild: deb-pkg: support DEB_BUILD_OPTIONS=parallel=N in debian/rules 2023-08-29 22:29:35 +09:00
builddeb kbuild: refactor kernel-devel RPM package and linux-headers Deb package 2023-07-25 00:59:32 +09:00
buildtar kbuild: tar-pkg: use tar rules in scripts/Makefile.package 2023-02-26 15:23:30 +09:00
deb-build-option kbuild: deb-pkg: set CROSS_COMPILE only when undefined 2023-03-15 15:15:07 +09:00
gen-diff-patch kbuild: give up untracked files for source package builds 2023-04-11 08:58:45 +09:00
install-extmod-build kbuild: refactor kernel-devel RPM package and linux-headers Deb package 2023-07-25 00:59:32 +09:00
kernel.spec kbuild: rpm-pkg: split out the body of spec file 2023-07-25 00:59:33 +09:00
mkdebian kbuild: deb-pkg: split debian/rules 2023-08-08 01:08:54 +09:00
mkspec kbuild: rpm-pkg: refactor *rpm-pkg targets 2023-07-25 00:59:33 +09:00
snapcraft.template scripts/package: snap-pkg target 2017-12-13 00:00:18 +09:00