All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] scripts/package/builddeb: split generating packaging and build
@ 2018-02-21 10:10 riku.voipio
  2018-03-27  9:07 ` Masahiro Yamada
  0 siblings, 1 reply; 8+ messages in thread
From: riku.voipio @ 2018-02-21 10:10 UTC (permalink / raw)
  To: linux-kbuild; +Cc: yamada.masahiro, debian-kernel, Riku Voipio

From: Riku Voipio <riku.voipio@linaro.org>

Move debian/ directory generation out of builddeb to a new script,
mkdebian. The package build commands are kept in builddeb, which
is now an internal command called from debian/rules.

With these changes in place, we can now use dpkg-buildpackage from
deb-pkg and bindeb-pkg removing need for handrolled source/changes
generation.

This patch is based on the criticism of the current state of builddeb
discussed on:

https://patchwork.kernel.org/patch/9656403/

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
changes since v3:
- removed hack from make clean target
- updated copyright year
- verified works with make 4.2
changes since v2:
- revert back to intdeb-pkg target
- fix parellel builds from deb-pkg targets
- drop unneccesary -us flag from bindeb-pkg target
changes since v1:
- use scripts/package/builddeb directly instead of
  using a internal intdeb-pkg target
- as consequence remove cmd_builddeb
- use KBUILD_PKG_ROOTCMD instead of hardcoded fakeroot -u
- don't clean tree in bindeb-pkg target
- fix source tarball version
- rebase on kbuild/next: no more firmware package
 scripts/package/Makefile |  34 +++-----
 scripts/package/builddeb | 221 +----------------------------------------------
 scripts/package/mkdebian | 189 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 200 insertions(+), 244 deletions(-)
 create mode 100755 scripts/package/mkdebian

diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index 9fbcf5ed0ca7..19ce0217f67e 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -24,6 +24,7 @@
 # Remove hyphens since they have special meaning in RPM filenames
 KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE))
 KDEB_SOURCENAME ?= linux-$(KERNELRELEASE)
+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 \
@@ -66,35 +67,20 @@ binrpm-pkg: FORCE
 
 clean-files += $(objtree)/*.spec
 
-# Deb target
-# ---------------------------------------------------------------------------
-quiet_cmd_builddeb = BUILDDEB
-      cmd_builddeb = set -e; \
-	test `id -u` = 0 || \
-	test -n "$(KBUILD_PKG_ROOTCMD)" || { \
-		which fakeroot >/dev/null 2>&1 && \
-		KBUILD_PKG_ROOTCMD="fakeroot -u"; \
-	} || { \
-		echo; \
-		echo "builddeb must be run as root (or using fakeroot)."; \
-		echo "KBUILD_PKG_ROOTCMD is unset and fakeroot not found."; \
-		echo "Try setting KBUILD_PKG_ROOTCMD to a command to acquire"; \
-		echo "root privileges (e.g., 'fakeroot -u' or 'sudo')."; \
-		false; \
-	} && \
-	\
-	$$KBUILD_PKG_ROOTCMD $(CONFIG_SHELL) \
-		$(srctree)/scripts/package/builddeb $@
-
 deb-pkg: FORCE
 	$(MAKE) clean
+	$(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
 	$(call cmd,src_tar,$(KDEB_SOURCENAME))
-	$(MAKE) KBUILD_SRC=
-	+$(call cmd,builddeb)
+	origversion=$$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$$//');\
+		mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz
+	+dpkg-buildpackage -j1 -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) -i.git -us -uc
 
 bindeb-pkg: FORCE
-	$(MAKE) KBUILD_SRC=
-	+$(call cmd,builddeb)
+	$(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
+	+dpkg-buildpackage -j1 -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) -b -nc -uc
+
+intdeb-pkg: FORCE
+	+$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb
 
 clean-dirs += $(objtree)/debian/
 
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index b4f0f2b3f8d2..9dd31f5d5395 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -30,67 +30,11 @@ create_package() {
 	chmod -R a+rX "$pdir"
 
 	# Create the package
-	dpkg-gencontrol $forcearch -Vkernel:debarch="${debarch}" -p$pname -P"$pdir"
+	dpkg-gencontrol -p$pname -P"$pdir"
 	dpkg --build "$pdir" ..
 }
 
-set_debarch() {
-	# Attempt to find the correct Debian architecture
-	case "$UTS_MACHINE" in
-	i386|ia64|alpha)
-		debarch="$UTS_MACHINE" ;;
-	x86_64)
-		debarch=amd64 ;;
-	sparc*)
-		debarch=sparc ;;
-	s390*)
-		debarch=s390$(grep -q CONFIG_64BIT=y $KCONFIG_CONFIG && echo x || true) ;;
-	ppc*)
-		debarch=$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo ppc64el || echo powerpc) ;;
-	parisc*)
-		debarch=hppa ;;
-	mips*)
-		debarch=mips$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo el || true) ;;
-	aarch64|arm64)
-		debarch=arm64 ;;
-	arm*)
-		if grep -q CONFIG_AEABI=y $KCONFIG_CONFIG; then
-		    if grep -q CONFIG_VFP=y $KCONFIG_CONFIG; then
-			debarch=armhf
-		    else
-			debarch=armel
-		    fi
-		else
-		    debarch=arm
-		fi
-		;;
-	*)
-		debarch=$(dpkg --print-architecture)
-		echo "" >&2
-		echo "** ** **  WARNING  ** ** **" >&2
-		echo "" >&2
-		echo "Your architecture doesn't have its equivalent" >&2
-		echo "Debian userspace architecture defined!" >&2
-		echo "Falling back to using your current userspace instead!" >&2
-		echo "Please add support for $UTS_MACHINE to ${0} ..." >&2
-		echo "" >&2
-	esac
-	if [ -n "$KBUILD_DEBARCH" ] ; then
-		debarch="$KBUILD_DEBARCH"
-	fi
-	forcearch="-DArchitecture=$debarch"
-
-}
-
-# Some variables and settings used throughout the script
 version=$KERNELRELEASE
-revision=$(cat .version)
-if [ -n "$KDEB_PKGVERSION" ]; then
-	packageversion=$KDEB_PKGVERSION
-else
-	packageversion=$version-$revision
-fi
-sourcename=$KDEB_SOURCENAME
 tmpdir="$objtree/debian/tmp"
 kernel_headers_dir="$objtree/debian/hdrtmp"
 libc_headers_dir="$objtree/debian/headertmp"
@@ -99,9 +43,6 @@ packagename=linux-image-$version
 kernel_headers_packagename=linux-headers-$version
 libc_headers_packagename=linux-libc-dev
 dbg_packagename=$packagename-dbg
-debarch=
-forcearch=
-set_debarch
 
 if [ "$ARCH" = "um" ] ; then
 	packagename=user-mode-linux-$version
@@ -212,105 +153,6 @@ EOF
 	chmod 755 "$tmpdir/DEBIAN/$script"
 done
 
-# Try to determine maintainer and email values
-if [ -n "$DEBEMAIL" ]; then
-       email=$DEBEMAIL
-elif [ -n "$EMAIL" ]; then
-       email=$EMAIL
-else
-       email=$(id -nu)@$(hostname -f 2>/dev/null || hostname)
-fi
-if [ -n "$DEBFULLNAME" ]; then
-       name=$DEBFULLNAME
-elif [ -n "$NAME" ]; then
-       name=$NAME
-else
-       name="Anonymous"
-fi
-maintainer="$name <$email>"
-
-# Try to determine distribution
-if [ -n "$KDEB_CHANGELOG_DIST" ]; then
-        distribution=$KDEB_CHANGELOG_DIST
-# In some cases lsb_release returns the codename as n/a, which breaks dpkg-parsechangelog
-elif distribution=$(lsb_release -cs 2>/dev/null) && [ -n "$distribution" ] && [ "$distribution" != "n/a" ]; then
-        : # nothing to do in this case
-else
-        distribution="unstable"
-        echo >&2 "Using default distribution of 'unstable' in the changelog"
-        echo >&2 "Install lsb-release or set \$KDEB_CHANGELOG_DIST explicitly"
-fi
-
-# Generate a simple changelog template
-cat <<EOF > debian/changelog
-$sourcename ($packageversion) $distribution; urgency=low
-
-  * Custom built Linux kernel.
-
- -- $maintainer  $(date -R)
-EOF
-
-# Generate copyright file
-cat <<EOF > debian/copyright
-This is a packacked upstream version of the Linux kernel.
-
-The sources may be found at most Linux archive sites, including:
-https://www.kernel.org/pub/linux/kernel
-
-Copyright: 1991 - 2017 Linus Torvalds and others.
-
-The git repository for mainline kernel development is at:
-git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; version 2 dated June, 1991.
-
-On Debian GNU/Linux systems, the complete text of the GNU General Public
-License version 2 can be found in \`/usr/share/common-licenses/GPL-2'.
-EOF
-
-
-build_depends="bc, kmod, cpio "
-
-# Generate a control file
-cat <<EOF > debian/control
-Source: $sourcename
-Section: kernel
-Priority: optional
-Maintainer: $maintainer
-Build-Depends: $build_depends
-Homepage: http://www.kernel.org/
-EOF
-
-if [ "$ARCH" = "um" ]; then
-	cat <<EOF >> debian/control
-
-Package: $packagename
-Architecture: any
-Description: User Mode Linux kernel, version $version
- User-mode Linux is a port of the Linux kernel to its own system call
- interface.  It provides a kind of virtual machine, which runs Linux
- as a user process under another Linux kernel.  This is useful for
- kernel development, sandboxes, jails, experimentation, and
- many other things.
- .
- This package contains the Linux kernel, modules and corresponding other
- files, version: $version.
-EOF
-
-else
-	cat <<EOF >> debian/control
-
-Package: $packagename
-Architecture: any
-Description: Linux kernel, version $version
- This package contains the Linux kernel, modules and corresponding other
- files, version: $version.
-EOF
-
-fi
-
 # Build kernel header package
 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl) > "$objtree/debian/hdrsrcfiles"
 (cd $srctree; find arch/*/include include scripts -type f) >> "$objtree/debian/hdrsrcfiles"
@@ -331,27 +173,6 @@ mkdir -p "$destdir"
 ln -sf "/usr/src/linux-headers-$version" "$kernel_headers_dir/lib/modules/$version/build"
 rm -f "$objtree/debian/hdrsrcfiles" "$objtree/debian/hdrobjfiles"
 
-cat <<EOF >> debian/control
-
-Package: $kernel_headers_packagename
-Architecture: any
-Description: Linux kernel headers for $KERNELRELEASE on \${kernel:debarch}
- This package provides kernel header files for $KERNELRELEASE on \${kernel:debarch}
- .
- This is useful for people who need to build external modules
-EOF
-
-cat <<EOF >> debian/control
-
-Package: $libc_headers_packagename
-Section: devel
-Provides: linux-kernel-headers
-Architecture: any
-Description: Linux support headers for userspace development
- This package provides userspaces headers from the Linux kernel.  These headers
- are used by the installed headers for GNU glibc and other system libraries.
-EOF
-
 if [ "$ARCH" != "um" ]; then
 	create_package "$kernel_headers_packagename" "$kernel_headers_dir"
 	create_package "$libc_headers_packagename" "$libc_headers_dir"
@@ -370,47 +191,7 @@ if [ -n "$BUILD_DEBUG" ] ; then
 	ln -s ../lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/boot/vmlinux-$version
 	# kdump-tools
 	ln -s lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/vmlinux-$version
-
-	cat <<EOF >> debian/control
-
-Package: $dbg_packagename
-Section: debug
-Architecture: any
-Description: Linux kernel debugging symbols for $version
- This package will come in handy if you need to debug the kernel. It provides
- all the necessary debug symbols for the kernel and its modules.
-EOF
-
 	create_package "$dbg_packagename" "$dbg_dir"
 fi
 
-if [ "x$1" = "xdeb-pkg" ]
-then
-    cat <<EOF > debian/rules
-#!/usr/bin/make -f
-
-build:
-	\$(MAKE)
-
-binary-arch:
-	\$(MAKE) KDEB_SOURCENAME=${sourcename} KDEB_PKGVERSION=${packageversion} bindeb-pkg
-
-clean:
-	rm -rf debian/*tmp debian/files
-	mv debian/ debian.backup # debian/ might be cleaned away
-	\$(MAKE) clean
-	mv debian.backup debian
-
-binary: binary-arch
-EOF
-	mv ${sourcename}.tar.gz ../${sourcename}_${version}.orig.tar.gz
-	tar caf ../${sourcename}_${packageversion}.debian.tar.gz debian/{copyright,rules,changelog,control}
-	dpkg-source -cdebian/control -ldebian/changelog --format="3.0 (custom)" --target-format="3.0 (quilt)" \
-		-b / ../${sourcename}_${version}.orig.tar.gz  ../${sourcename}_${packageversion}.debian.tar.gz
-	mv ${sourcename}_${packageversion}*dsc ..
-	dpkg-genchanges -Vkernel:debarch="${debarch}" > ../${sourcename}_${packageversion}_${debarch}.changes
-else
-	dpkg-genchanges -b -Vkernel:debarch="${debarch}" > ../${sourcename}_${packageversion}_${debarch}.changes
-fi
-
 exit 0
diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
new file mode 100755
index 000000000000..794477698455
--- /dev/null
+++ b/scripts/package/mkdebian
@@ -0,0 +1,189 @@
+#!/bin/sh
+#
+# Copyright 2003 Wichert Akkerman <wichert@wiggy.net>
+#
+# Simple script to generate a debian/ directory for a Linux kernel.
+
+set -e
+
+set_debarch() {
+	# Attempt to find the correct Debian architecture
+	case "$UTS_MACHINE" in
+	i386|ia64|alpha)
+		debarch="$UTS_MACHINE" ;;
+	x86_64)
+		debarch=amd64 ;;
+	sparc*)
+		debarch=sparc ;;
+	s390*)
+		debarch=s390$(grep -q CONFIG_64BIT=y $KCONFIG_CONFIG && echo x || true) ;;
+	ppc*)
+		debarch=$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo ppc64el || echo powerpc) ;;
+	parisc*)
+		debarch=hppa ;;
+	mips*)
+		debarch=mips$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo el || true) ;;
+	aarch64|arm64)
+		debarch=arm64 ;;
+	arm*)
+		if grep -q CONFIG_AEABI=y $KCONFIG_CONFIG; then
+		    if grep -q CONFIG_VFP=y $KCONFIG_CONFIG; then
+			debarch=armhf
+		    else
+			debarch=armel
+		    fi
+		else
+		    debarch=arm
+		fi
+		;;
+	*)
+		debarch=$(dpkg --print-architecture)
+		echo "" >&2
+		echo "** ** **  WARNING  ** ** **" >&2
+		echo "" >&2
+		echo "Your architecture doesn't have its equivalent" >&2
+		echo "Debian userspace architecture defined!" >&2
+		echo "Falling back to using your current userspace instead!" >&2
+		echo "Please add support for $UTS_MACHINE to ${0} ..." >&2
+		echo "" >&2
+	esac
+	if [ -n "$KBUILD_DEBARCH" ] ; then
+		debarch="$KBUILD_DEBARCH"
+	fi
+}
+
+# Some variables and settings used throughout the script
+version=$KERNELRELEASE
+if [ -n "$KDEB_PKGVERSION" ]; then
+	packageversion=$KDEB_PKGVERSION
+else
+	revision=$(cat .version 2>/dev/null||echo 1)
+	packageversion=$version-$revision
+fi
+sourcename=$KDEB_SOURCENAME
+packagename=linux-image-$version
+kernel_headers_packagename=linux-headers-$version
+dbg_packagename=$packagename-dbg
+debarch=
+set_debarch
+
+if [ "$ARCH" = "um" ] ; then
+	packagename=user-mode-linux-$version
+fi
+
+# Try to determine maintainer and email values
+if [ -n "$DEBEMAIL" ]; then
+       email=$DEBEMAIL
+elif [ -n "$EMAIL" ]; then
+       email=$EMAIL
+else
+       email=$(id -nu)@$(hostname -f 2>/dev/null || hostname)
+fi
+if [ -n "$DEBFULLNAME" ]; then
+       name=$DEBFULLNAME
+elif [ -n "$NAME" ]; then
+       name=$NAME
+else
+       name="Anonymous"
+fi
+maintainer="$name <$email>"
+
+# Try to determine distribution
+if [ -n "$KDEB_CHANGELOG_DIST" ]; then
+        distribution=$KDEB_CHANGELOG_DIST
+# In some cases lsb_release returns the codename as n/a, which breaks dpkg-parsechangelog
+elif distribution=$(lsb_release -cs 2>/dev/null) && [ -n "$distribution" ] && [ "$distribution" != "n/a" ]; then
+        : # nothing to do in this case
+else
+        distribution="unstable"
+        echo >&2 "Using default distribution of 'unstable' in the changelog"
+        echo >&2 "Install lsb-release or set \$KDEB_CHANGELOG_DIST explicitly"
+fi
+
+mkdir -p debian/
+echo $debarch > debian/arch
+
+# Generate a simple changelog template
+cat <<EOF > debian/changelog
+$sourcename ($packageversion) $distribution; urgency=low
+
+  * Custom built Linux kernel.
+
+ -- $maintainer  $(date -R)
+EOF
+
+# Generate copyright file
+cat <<EOF > debian/copyright
+This is a packacked upstream version of the Linux kernel.
+
+The sources may be found at most Linux archive sites, including:
+https://www.kernel.org/pub/linux/kernel
+
+Copyright: 1991 - 2018 Linus Torvalds and others.
+
+The git repository for mainline kernel development is at:
+git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; version 2 dated June, 1991.
+
+On Debian GNU/Linux systems, the complete text of the GNU General Public
+License version 2 can be found in \`/usr/share/common-licenses/GPL-2'.
+EOF
+
+# Generate a control file
+cat <<EOF > debian/control
+Source: $sourcename
+Section: kernel
+Priority: optional
+Maintainer: $maintainer
+Build-Depends: bc, kmod, cpio
+Homepage: http://www.kernel.org/
+
+Package: $packagename
+Architecture: $debarch
+Description: Linux kernel, version $version
+ This package contains the Linux kernel, modules and corresponding other
+ files, version: $version.
+
+Package: $kernel_headers_packagename
+Architecture: $debarch
+Description: Linux kernel headers for $version on $debarch
+ This package provides kernel header files for $version on $debarch
+ .
+ This is useful for people who need to build external modules
+
+Package: linux-libc-dev
+Section: devel
+Provides: linux-kernel-headers
+Architecture: $debarch
+Description: Linux support headers for userspace development
+ This package provides userspaces headers from the Linux kernel.  These headers
+ are used by the installed headers for GNU glibc and other system libraries.
+
+Package: $dbg_packagename
+Section: debug
+Architecture: $debarch
+Description: Linux kernel debugging symbols for $version
+ This package will come in handy if you need to debug the kernel. It provides
+ all the necessary debug symbols for the kernel and its modules.
+EOF
+
+cat <<EOF > debian/rules
+#!/usr/bin/make -f
+
+build:
+	\$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} KBUILD_SRC=
+
+binary-arch:
+	\$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} KBUILD_SRC= intdeb-pkg
+
+clean:
+	rm -rf debian/*tmp debian/files
+	\$(MAKE) clean
+
+binary: binary-arch
+EOF
+
+exit 0
-- 
2.15.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] scripts/package/builddeb: split generating packaging and build
  2018-02-21 10:10 [PATCH v4] scripts/package/builddeb: split generating packaging and build riku.voipio
@ 2018-03-27  9:07 ` Masahiro Yamada
       [not found]   ` <CAAqcGHkvKssjFmG0ebz5uBeO_PGeov5_C6MutW65ONp5riFwRg@mail.gmail.com>
  0 siblings, 1 reply; 8+ messages in thread
From: Masahiro Yamada @ 2018-03-27  9:07 UTC (permalink / raw)
  To: Riku Voipio; +Cc: Linux Kbuild mailing list, debian-kernel

Hi Riku,


2018-02-21 19:10 GMT+09:00  <riku.voipio@linaro.org>:
> From: Riku Voipio <riku.voipio@linaro.org>
>
> Move debian/ directory generation out of builddeb to a new script,
> mkdebian. The package build commands are kept in builddeb, which
> is now an internal command called from debian/rules.
>
> With these changes in place, we can now use dpkg-buildpackage from
> deb-pkg and bindeb-pkg removing need for handrolled source/changes
> generation.
>
> This patch is based on the criticism of the current state of builddeb
> discussed on:
>
> https://patchwork.kernel.org/patch/9656403/
>
> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
> ---

Sorry for the delay.


> changes since v3:
> - removed hack from make clean target
> - updated copyright year
> - verified works with make 4.2


I have to say the same comment as in v3.

This patch does not work for me if I use Make 4.2 or newer.


I compared v3 and v4, and the diff is just below:

diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
index a151646..7944776 100755
--- a/scripts/package/mkdebian
+++ b/scripts/package/mkdebian
@@ -119,7 +119,7 @@ This is a packacked upstream version of the Linux kernel.
 The sources may be found at most Linux archive sites, including:
 https://www.kernel.org/pub/linux/kernel

-Copyright: 1991 - 2017 Linus Torvalds and others.
+Copyright: 1991 - 2018 Linus Torvalds and others.

 The git repository for mainline kernel development is at:
 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
@@ -181,9 +181,7 @@ binary-arch:

 clean:
        rm -rf debian/*tmp debian/files
-       mv debian/ debian.backup # debian/ might be cleaned away
        \$(MAKE) clean
-       mv debian.backup debian

 binary: binary-arch
 EOF




I still see the fork bomb problem on my machine, like the same as before.
It is curious you mention this is working on your machine.


So, something is different between your build machine and mine.

Perhaps, dpkg-buildpackage version?


I use Ubuntu 16.04 LTS.

My version:

$ dpkg-buildpackage --version
Debian dpkg-buildpackage version 1.18.4.

This is free software; see the GNU General Public License version 2 or
later for copying conditions. There is NO warranty.




Could you apply the following patch to get the log?


diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index 19ce021..849058e 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -68,6 +68,7 @@ binrpm-pkg: FORCE
 clean-files += $(objtree)/*.spec

 deb-pkg: FORCE
+       echo MAKEFLAGS for deb-pkg: $(MAKEFLAGS) > deb_pkg_log.txt
        $(MAKE) clean
        $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
        $(call cmd,src_tar,$(KDEB_SOURCENAME))
diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
index 7944776..158b121 100755
--- a/scripts/package/mkdebian
+++ b/scripts/package/mkdebian
@@ -174,6 +174,7 @@ cat <<EOF > debian/rules
 #!/usr/bin/make -f

 build:
+       echo MAKEFLAGS for mkdebian internal: \$(MAKEFLAGS) >> deb_pkg_log.txt
        \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} KBUILD_SRC=

 binary-arch:



Run the following:

$ make -s tinyconfig
$ make -j8 deb-pkg


Then, can you provide the content of deb_pkg_log.txt, please?


If I use GNU Make 4.0

$ cat deb_pkg_log.txt
MAKEFLAGS for deb-pkg: rR -I/home/masahiro/ref/linux -j
--jobserver-fds=3,4 --no-print-directory -- obj=scripts/package
MAKEFLAGS for mkdebian internal: rR -I/home/masahiro/ref/linux -j
--jobserver-fds=3,4 --no-print-directory -- obj=scripts/package



If I use GNU Make 4.2

$ cat deb_pkg_log.txt
MAKEFLAGS for deb-pkg: rR -I/home/masahiro/ref/linux -j8
--jobserver-auth=3,4 --no-print-directory -- obj=scripts/package
MAKEFLAGS for mkdebian internal: rR -I/home/masahiro/ref/linux -j
--jobserver-fds=5,6 --no-print-directory -- obj=scripts/package






-- 
Best Regards
Masahiro Yamada

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Fwd: [PATCH v4] scripts/package/builddeb: split generating packaging and build
       [not found]   ` <CAAqcGHkvKssjFmG0ebz5uBeO_PGeov5_C6MutW65ONp5riFwRg@mail.gmail.com>
@ 2018-03-27 13:28     ` Riku Voipio
  2018-03-27 15:23       ` Masahiro Yamada
  0 siblings, 1 reply; 8+ messages in thread
From: Riku Voipio @ 2018-03-27 13:28 UTC (permalink / raw)
  To: Masahiro Yamada, Linux Kbuild mailing list, debian-kernel

resend, sorry forgot the mailing lists from last post.

Hi Masahiro,

On 27 March 2018 at 12:07, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> 2018-02-21 19:10 GMT+09:00  <riku.voipio@linaro.org>:
>> From: Riku Voipio <riku.voipio@linaro.org>
>>
>> Move debian/ directory generation out of builddeb to a new script,
>> mkdebian. The package build commands are kept in builddeb, which
>> is now an internal command called from debian/rules.
>>
>> With these changes in place, we can now use dpkg-buildpackage from
>> deb-pkg and bindeb-pkg removing need for handrolled source/changes
>> generation.
>>
>> This patch is based on the criticism of the current state of builddeb
>> discussed on:
>>
>> https://patchwork.kernel.org/patch/9656403/
>>
>> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
>> ---
>
> Sorry for the delay.
>
>
>> changes since v3:
>> - removed hack from make clean target
>> - updated copyright year
>> - verified works with make 4.2
>
>
> I have to say the same comment as in v3.
>
> This patch does not work for me if I use Make 4.2 or newer.
>
>
> I compared v3 and v4, and the diff is just below:
>
> diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
> index a151646..7944776 100755
> --- a/scripts/package/mkdebian
> +++ b/scripts/package/mkdebian
> @@ -119,7 +119,7 @@ This is a packacked upstream version of the Linux kernel.
>  The sources may be found at most Linux archive sites, including:
>  https://www.kernel.org/pub/linux/kernel
>
> -Copyright: 1991 - 2017 Linus Torvalds and others.
> +Copyright: 1991 - 2018 Linus Torvalds and others.
>
>  The git repository for mainline kernel development is at:
>  git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> @@ -181,9 +181,7 @@ binary-arch:
>
>  clean:
>         rm -rf debian/*tmp debian/files
> -       mv debian/ debian.backup # debian/ might be cleaned away
>         \$(MAKE) clean
> -       mv debian.backup debian
>
>  binary: binary-arch
>  EOF
>
>
>
>
> I still see the fork bomb problem on my machine, like the same as before.
> It is curious you mention this is working on your machine.
>
>
> So, something is different between your build machine and mine.
>
> Perhaps, dpkg-buildpackage version?
>
> I use Ubuntu 16.04 LTS.
>
> My version:
>
> $ dpkg-buildpackage --version
> Debian dpkg-buildpackage version 1.18.4.
>
> This is free software; see the GNU General Public License version 2 or
> later for copying conditions. There is NO warranty.
>
>
>
>
> Could you apply the following patch to get the log?
>
>
> diff --git a/scripts/package/Makefile b/scripts/package/Makefile
> index 19ce021..849058e 100644
> --- a/scripts/package/Makefile
> +++ b/scripts/package/Makefile
> @@ -68,6 +68,7 @@ binrpm-pkg: FORCE
>  clean-files += $(objtree)/*.spec
>
>  deb-pkg: FORCE
> +       echo MAKEFLAGS for deb-pkg: $(MAKEFLAGS) > deb_pkg_log.txt
>         $(MAKE) clean
>         $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
>         $(call cmd,src_tar,$(KDEB_SOURCENAME))
> diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
> index 7944776..158b121 100755
> --- a/scripts/package/mkdebian
> +++ b/scripts/package/mkdebian
> @@ -174,6 +174,7 @@ cat <<EOF > debian/rules
>  #!/usr/bin/make -f
>
>  build:
> +       echo MAKEFLAGS for mkdebian internal: \$(MAKEFLAGS) >> deb_pkg_log.txt
>         \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} KBUILD_SRC=
>
>  binary-arch:
>
>
>
> Run the following:
>
> $ make -s tinyconfig
> $ make -j8 deb-pkg
>
>
> Then, can you provide the content of deb_pkg_log.txt, please?

I tested again with:

With debian testing:

$ dpkg-buildpackage --version
Debian dpkg-buildpackage version 1.19.0.5.
$ make --version
GNU Make 4.2.1

MAKEFLAGS for deb-pkg: rR -I/home/voipio/linaro/linux -j8
--jobserver-auth=3,4 --no-print-directory -- obj=scripts/package
MAKEFLAGS for mkdebian internal: rR -I/home/voipio/linaro/linux -j8
--jobserver-auth=3,4 --no-print-directory -- obj=scripts/package

And using container for Ubuntu 16.04:

docker run  --rm -v (pwd):/work  -it ubuntu:16.04 /bin/bash
apt-get update; apt-get install build-essential bc kmod bison flex cpio
Debian dpkg-buildpackage version 1.18.4.
GNU Make 4.1

MAKEFLAGS for deb-pkg: rR -I/work -j --jobserver-fds=3,4
--no-print-directory -- obj=scripts/package
MAKEFLAGS for mkdebian internal: rR -I/work -j --jobserver-fds=3,4
--no-print-directory -- obj=scripts/package

And finally with old ubuntu 16.04 dpkg and make 4.2.1 from debian
installed into container:

MAKEFLAGS for deb-pkg: rR -I/work -j8 --jobserver-auth=3,4
--no-print-directory -- obj=scripts/package
MAKEFLAGS for mkdebian internal: rR -I/work -j8 --jobserver-auth=3,4
--no-print-directory -- obj=scripts/package

> If I use GNU Make 4.0
>
> $ cat deb_pkg_log.txt
> MAKEFLAGS for deb-pkg: rR -I/home/masahiro/ref/linux -j
> --jobserver-fds=3,4 --no-print-directory -- obj=scripts/package
> MAKEFLAGS for mkdebian internal: rR -I/home/masahiro/ref/linux -j
> --jobserver-fds=3,4 --no-print-directory -- obj=scripts/package
>
>
>
> If I use GNU Make 4.2
>
> $ cat deb_pkg_log.txt
> MAKEFLAGS for deb-pkg: rR -I/home/masahiro/ref/linux -j8
> --jobserver-auth=3,4 --no-print-directory -- obj=scripts/package
> MAKEFLAGS for mkdebian internal: rR -I/home/masahiro/ref/linux -j
> --jobserver-fds=5,6 --no-print-directory -- obj=scripts/package

I'll make a wild guess, and "outside" make is your 4.2 build while the
intdeb-pkg ends up calling the make 4.0 that comes with your ubuntu?
observe the --jobserver-auth vs ---jobsserver-fds arguments.


Riku

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] scripts/package/builddeb: split generating packaging and build
  2018-03-27 13:28     ` Fwd: " Riku Voipio
@ 2018-03-27 15:23       ` Masahiro Yamada
  2018-03-28  8:58         ` Riku Voipio
  0 siblings, 1 reply; 8+ messages in thread
From: Masahiro Yamada @ 2018-03-27 15:23 UTC (permalink / raw)
  To: Riku Voipio; +Cc: Linux Kbuild mailing list, debian-kernel

Riku,

2018-03-27 22:28 GMT+09:00 Riku Voipio <riku.voipio@linaro.org>:

>> If I use GNU Make 4.2
>>
>> $ cat deb_pkg_log.txt
>> MAKEFLAGS for deb-pkg: rR -I/home/masahiro/ref/linux -j8
>> --jobserver-auth=3,4 --no-print-directory -- obj=scripts/package
>> MAKEFLAGS for mkdebian internal: rR -I/home/masahiro/ref/linux -j
>> --jobserver-fds=5,6 --no-print-directory -- obj=scripts/package
>
> I'll make a wild guess, and "outside" make is your 4.2 build while the
> intdeb-pkg ends up calling the make 4.0 that comes with your ubuntu?
> observe the --jobserver-auth vs ---jobsserver-fds arguments.
>

Ah, you are right!


Probably this

>
> -if [ "x$1" = "xdeb-pkg" ]
> -then
> -    cat <<EOF > debian/rules
> -#!/usr/bin/make -f
> -
> -build:
> -       \$(MAKE)



I installed Make 4.2 into /home/masahiro/bin/,
but /usr/bin/make is still distro-bundled older Make.

/home/masahiro/bin is listed before /usr/bin in my PATH environment,

So, if I type "make" from the command line, /home/masahiro/bin/make is chosen.
Then, the outer Makefile is executed by Make 4.2.

But, due to the shebang '#!/usr/bin/make -f'
debian/rules is executed by older Make.


Due to the incompatibility of MAKEFLAGS, Make went insane.

Hmm, do you have an idea for solution?

I would be possible to forcibly overwrite MAKEFLAGS, but
IMHO, it is kind of strange to run dpkg-buildpackage
from Makefile.




-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] scripts/package/builddeb: split generating packaging and build
  2018-03-27 15:23       ` Masahiro Yamada
@ 2018-03-28  8:58         ` Riku Voipio
  2018-03-29  0:20           ` Ben Hutchings
  2018-04-05  4:37           ` Masahiro Yamada
  0 siblings, 2 replies; 8+ messages in thread
From: Riku Voipio @ 2018-03-28  8:58 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: Linux Kbuild mailing list, debian-kernel

On 27 March 2018 at 18:23, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> Riku,
>
> 2018-03-27 22:28 GMT+09:00 Riku Voipio <riku.voipio@linaro.org>:
>
>>> If I use GNU Make 4.2
>>>
>>> $ cat deb_pkg_log.txt
>>> MAKEFLAGS for deb-pkg: rR -I/home/masahiro/ref/linux -j8
>>> --jobserver-auth=3,4 --no-print-directory -- obj=scripts/package
>>> MAKEFLAGS for mkdebian internal: rR -I/home/masahiro/ref/linux -j
>>> --jobserver-fds=5,6 --no-print-directory -- obj=scripts/package
>>
>> I'll make a wild guess, and "outside" make is your 4.2 build while the
>> intdeb-pkg ends up calling the make 4.0 that comes with your ubuntu?
>> observe the --jobserver-auth vs ---jobsserver-fds arguments.
>>
>
> Ah, you are right!
>
>
> Probably this
>
>>
>> -if [ "x$1" = "xdeb-pkg" ]
>> -then
>> -    cat <<EOF > debian/rules
>> -#!/usr/bin/make -f

This is actually mandated in Debian policy:

https://www.debian.org/doc/debian-policy/#main-building-script-debian-rules

> So, if I type "make" from the command line, /home/masahiro/bin/make is chosen.
> Then, the outer Makefile is executed by Make 4.2.
>
> But, due to the shebang '#!/usr/bin/make -f'
> debian/rules is executed by older Make.
>
> Due to the incompatibility of MAKEFLAGS, Make went insane.
>
> Hmm, do you have an idea for solution?

One option:

+++ b/scripts/package/mkdebian
cat <<EOF > debian/rules
-#!/usr/bin/make -f
#!$(which $MAKE)  -f

This will let people build with whatever make they please, with the
price that the resulting source package will not build elsewhere.

Option 2 is to error out if "which $MAKE" != /usr/bin/make

> I would be possible to forcibly overwrite MAKEFLAGS

I think one goal is to keep deb-pkg simple, and fudging MAKEFLAGS
would go against that goal.

Riku

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] scripts/package/builddeb: split generating packaging and build
  2018-03-28  8:58         ` Riku Voipio
@ 2018-03-29  0:20           ` Ben Hutchings
  2018-03-29  7:36             ` Riku Voipio
  2018-04-05  4:37           ` Masahiro Yamada
  1 sibling, 1 reply; 8+ messages in thread
From: Ben Hutchings @ 2018-03-29  0:20 UTC (permalink / raw)
  To: Riku Voipio, Masahiro Yamada; +Cc: Linux Kbuild mailing list, debian-kernel

[-- Attachment #1: Type: text/plain, Size: 395 bytes --]

On Wed, 2018-03-28 at 11:58 +0300, Riku Voipio wrote:
[...]
> One option:
> 
> +++ b/scripts/package/mkdebian
> cat <<EOF > debian/rules
> -#!/usr/bin/make -f
> #!$(which $MAKE)  -f
[..]

Shebang lines are interpreted by the kernel, not by a shell.  So you
can't do anything clever like that.

Ben.

-- 
Ben Hutchings
Who are all these weirdos? - David Bowie, on joining IRC


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] scripts/package/builddeb: split generating packaging and build
  2018-03-29  0:20           ` Ben Hutchings
@ 2018-03-29  7:36             ` Riku Voipio
  0 siblings, 0 replies; 8+ messages in thread
From: Riku Voipio @ 2018-03-29  7:36 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: Masahiro Yamada, Linux Kbuild mailing list, debian-kernel

On 29 March 2018 at 03:20, Ben Hutchings <ben@decadent.org.uk> wrote:
> On Wed, 2018-03-28 at 11:58 +0300, Riku Voipio wrote:
> [...]
>> One option:
>>
>> +++ b/scripts/package/mkdebian
>> cat <<EOF > debian/rules
>> -#!/usr/bin/make -f
>> #!$(which $MAKE)  -f
> [..]
>
> Shebang lines are interpreted by the kernel, not by a shell.  So you
> can't do anything clever like that.

Look more closely ;) Shell expands the variables into the herefile. So
if make is picked from a nonstandard location, the debian/rules
shebang becomes #!/home/masahiro/bin/make -f

As I said the price of this hack is that if use make from non-standard
location, the source package won't build anywhere else. Then again,
you probably shouldn't use non-standard tools when building source
packages for others to consume.

Riku

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] scripts/package/builddeb: split generating packaging and build
  2018-03-28  8:58         ` Riku Voipio
  2018-03-29  0:20           ` Ben Hutchings
@ 2018-04-05  4:37           ` Masahiro Yamada
  1 sibling, 0 replies; 8+ messages in thread
From: Masahiro Yamada @ 2018-04-05  4:37 UTC (permalink / raw)
  To: Riku Voipio; +Cc: Linux Kbuild mailing list, debian-kernel

2018-03-28 17:58 GMT+09:00 Riku Voipio <riku.voipio@linaro.org>:
> On 27 March 2018 at 18:23, Masahiro Yamada
> <yamada.masahiro@socionext.com> wrote:
>> Riku,
>>
>> 2018-03-27 22:28 GMT+09:00 Riku Voipio <riku.voipio@linaro.org>:
>>
>>>> If I use GNU Make 4.2
>>>>
>>>> $ cat deb_pkg_log.txt
>>>> MAKEFLAGS for deb-pkg: rR -I/home/masahiro/ref/linux -j8
>>>> --jobserver-auth=3,4 --no-print-directory -- obj=scripts/package
>>>> MAKEFLAGS for mkdebian internal: rR -I/home/masahiro/ref/linux -j
>>>> --jobserver-fds=5,6 --no-print-directory -- obj=scripts/package
>>>
>>> I'll make a wild guess, and "outside" make is your 4.2 build while the
>>> intdeb-pkg ends up calling the make 4.0 that comes with your ubuntu?
>>> observe the --jobserver-auth vs ---jobsserver-fds arguments.
>>>
>>
>> Ah, you are right!
>>
>>
>> Probably this
>>
>>>
>>> -if [ "x$1" = "xdeb-pkg" ]
>>> -then
>>> -    cat <<EOF > debian/rules
>>> -#!/usr/bin/make -f
>
> This is actually mandated in Debian policy:
>
> https://www.debian.org/doc/debian-policy/#main-building-script-debian-rules
>
>> So, if I type "make" from the command line, /home/masahiro/bin/make is chosen.
>> Then, the outer Makefile is executed by Make 4.2.
>>
>> But, due to the shebang '#!/usr/bin/make -f'
>> debian/rules is executed by older Make.
>>
>> Due to the incompatibility of MAKEFLAGS, Make went insane.
>>
>> Hmm, do you have an idea for solution?
>
> One option:
>
> +++ b/scripts/package/mkdebian
> cat <<EOF > debian/rules
> -#!/usr/bin/make -f
> #!$(which $MAKE)  -f
>
> This will let people build with whatever make they please, with the
> price that the resulting source package will not build elsewhere.


I prefer this idea.


Just a nit:

Maybe is 'command -v' more portable than 'which'?

Bjørn Forsman stated so in the following:
https://lkml.org/lkml/2018/3/11/196



Now the parallel building works nicely.
So, I think '-j1' for dpkg-buildpackage is unnecessary.



> Option 2 is to error out if "which $MAKE" != /usr/bin/make
>
>> I would be possible to forcibly overwrite MAKEFLAGS
>
> I think one goal is to keep deb-pkg simple, and fudging MAKEFLAGS
> would go against that goal.

I agree.
Please forget my comment.





-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-04-05  4:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-21 10:10 [PATCH v4] scripts/package/builddeb: split generating packaging and build riku.voipio
2018-03-27  9:07 ` Masahiro Yamada
     [not found]   ` <CAAqcGHkvKssjFmG0ebz5uBeO_PGeov5_C6MutW65ONp5riFwRg@mail.gmail.com>
2018-03-27 13:28     ` Fwd: " Riku Voipio
2018-03-27 15:23       ` Masahiro Yamada
2018-03-28  8:58         ` Riku Voipio
2018-03-29  0:20           ` Ben Hutchings
2018-03-29  7:36             ` Riku Voipio
2018-04-05  4:37           ` Masahiro Yamada

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.