linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] scripts/package/Makefile: make revision update a function
@ 2017-08-16 11:08 riku.voipio
  2017-08-16 11:08 ` [PATCH 2/2] scripts/package/builddeb: split generating packaging and build riku.voipio
  2017-09-07 17:04 ` [PATCH 1/2] scripts/package/Makefile: make revision update a function Masahiro Yamada
  0 siblings, 2 replies; 11+ messages in thread
From: riku.voipio @ 2017-08-16 11:08 UTC (permalink / raw)
  To: linux-kbuild, mmarek; +Cc: yamada.masahiro, debian-kernel, Riku Voipio

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

The updated deb-pkg and bindeb-pkg will use the same snippet,
so make it reusable.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 scripts/package/Makefile | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index 71b4a8af9d4d..9867638896ad 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -44,14 +44,18 @@ tar -cz $(RCS_TAR_IGNORE) -f $(2).tar.gz \
 	$(addprefix $(2)/,$(TAR_CONTENT) $(3)); \
 rm -f $(2) $(objtree)/.scmversion
 
+quiet_cmd_updateversion = UPDATEVERSION
+      cmd_updateversion = \
+	$(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version; \
+	mv -f $(objtree)/.tmp_version $(objtree)/.version
+
 # rpm-pkg
 # ---------------------------------------------------------------------------
 rpm-pkg rpm: FORCE
 	$(MAKE) clean
 	$(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
 	$(call cmd,src_tar,$(KERNELPATH),kernel.spec)
-	$(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
-	mv -f $(objtree)/.tmp_version $(objtree)/.version
+	$(call cmd,updateversion)
 	rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz
 	rm $(KERNELPATH).tar.gz kernel.spec
 
@@ -60,9 +64,7 @@ rpm-pkg rpm: FORCE
 binrpm-pkg: FORCE
 	$(MAKE) KBUILD_SRC=
 	$(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
-	$(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
-	mv -f $(objtree)/.tmp_version $(objtree)/.version
-
+	$(call cmd,updateversion)
 	rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
 		$(UTS_MACHINE) -bb $(objtree)/binkernel.spec
 	rm binkernel.spec
-- 
2.11.0


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

* [PATCH 2/2] scripts/package/builddeb: split generating packaging and build
  2017-08-16 11:08 [PATCH 1/2] scripts/package/Makefile: make revision update a function riku.voipio
@ 2017-08-16 11:08 ` riku.voipio
  2017-08-17  0:24   ` Jim Davis
  2017-09-20  9:04   ` Masahiro Yamada
  2017-09-07 17:04 ` [PATCH 1/2] scripts/package/Makefile: make revision update a function Masahiro Yamada
  1 sibling, 2 replies; 11+ messages in thread
From: riku.voipio @ 2017-08-16 11:08 UTC (permalink / raw)
  To: linux-kbuild, mmarek; +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 and 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 handrulled 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>
---
 scripts/package/Makefile |  14 ++-
 scripts/package/builddeb | 233 +----------------------------------------------
 scripts/package/mkdebian | 209 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 221 insertions(+), 235 deletions(-)
 create mode 100755 scripts/package/mkdebian

diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index 9867638896ad..176158c9b7da 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -92,12 +92,18 @@ quiet_cmd_builddeb = BUILDDEB
 deb-pkg: FORCE
 	$(MAKE) clean
 	$(call cmd,src_tar,$(KDEB_SOURCENAME))
-	$(MAKE) KBUILD_SRC=
-	+$(call cmd,builddeb)
+	$(call cmd,updateversion)
+	mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$(KERNELRELEASE).orig.tar.gz
+	$(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
+	dpkg-buildpackage -r"fakeroot -u" -a$$(cat debian/arch) -i.git
 
 bindeb-pkg: FORCE
-	$(MAKE) KBUILD_SRC=
-	+$(call cmd,builddeb)
+	$(call cmd,updateversion)
+	$(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
+	dpkg-buildpackage -r"fakeroot -u" -a$$(cat debian/arch) -b
+
+intdeb-pkg: FORCE
+	$(call cmd,builddeb)
 
 clean-dirs += $(objtree)/debian/
 
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index aad67000e4dd..584404f7a473 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
+version=$KDEB_VERSION
 tmpdir="$objtree/debian/tmp"
 fwdir="$objtree/debian/fwtmp"
 kernel_headers_dir="$objtree/debian/hdrtmp"
@@ -101,9 +45,6 @@ fwpackagename=linux-firmware-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
@@ -215,106 +156,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
-Suggests: $fwpackagename
-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"
@@ -335,43 +176,13 @@ 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
-
 # Do we have firmware? Move it out of the way and build it into a package.
 if [ -e "$tmpdir/lib/firmware" ]; then
 	mv "$tmpdir/lib/firmware"/* "$fwdir/lib/firmware/$version/"
 	rmdir "$tmpdir/lib/firmware"
-
-	cat <<EOF >> debian/control
-
-Package: $fwpackagename
-Architecture: all
-Description: Linux kernel firmware, version $version
- This package contains firmware from the Linux kernel, version $version.
-EOF
-
 	create_package "$fwpackagename" "$fwdir"
 fi
 
-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"
@@ -390,47 +201,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 > ../${sourcename}_${packageversion}_${debarch}.changes
-else
-	dpkg-genchanges -b > ../${sourcename}_${packageversion}_${debarch}.changes
-fi
-
 exit 0
diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
new file mode 100755
index 000000000000..75fc95a9bb21
--- /dev/null
+++ b/scripts/package/mkdebian
@@ -0,0 +1,209 @@
+#!/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
+revision=$(cat .version)
+if [ -n "$KDEB_PKGVERSION" ]; then
+	packageversion=$KDEB_PKGVERSION
+else
+	packageversion=$version-$revision
+fi
+sourcename=$KDEB_SOURCENAME
+packagename=linux-image-$version
+fwpackagename=linux-firmware-image-$version
+kernel_headers_packagename=linux-headers-$version
+libc_headers_packagename=linux-libc-dev
+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/
+
+# 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
+
+
+# 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
+Suggests: $fwpackagename
+Architecture: $debarch
+Description: Linux kernel, version $version
+ This package contains the Linux kernel, modules and corresponding other
+ files, version: $version.
+
+Package: $fwpackagename
+Architecture: all
+Description: Linux kernel firmware, version $version
+ This package contains firmware from the Linux kernel, 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: $libc_headers_packagename
+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
+
+echo $debarch > debian/arch
+env > debian/env
+
+cat <<EOF > debian/rules
+#!/usr/bin/make -f
+
+ifneq (,\$(filter parallel=%,\$(DEB_BUILD_OPTIONS)))
+    NUMJOBS = \$(patsubst parallel=%,%,\$(filter parallel=%,\$(DEB_BUILD_OPTIONS)))
+    MAKEFLAGS += -j\$(NUMJOBS)
+endif
+
+build:
+	\$(MAKE) ARCH=${ARCH}
+
+binary-arch:
+	\$(MAKE) KDEB_VERSION=${version} ARCH=${ARCH} intdeb-pkg
+
+clean:
+	rm -rf debian/*tmp debian/files
+	mv debian/ debian.backup # debian/ might be cleaned away
+	\$(MAKE) clean
+	mv debian.backup debian
+
+binary-arch: build
+binary: binary-arch
+EOF
+
+exit 0
-- 
2.11.0


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

* Re: [PATCH 2/2] scripts/package/builddeb: split generating packaging and build
  2017-08-16 11:08 ` [PATCH 2/2] scripts/package/builddeb: split generating packaging and build riku.voipio
@ 2017-08-17  0:24   ` Jim Davis
  2017-08-17  7:45     ` Riku Voipio
  2017-09-20  9:04   ` Masahiro Yamada
  1 sibling, 1 reply; 11+ messages in thread
From: Jim Davis @ 2017-08-17  0:24 UTC (permalink / raw)
  To: Riku Voipio; +Cc: linux-kbuild, Michal Marek, Masahiro Yamada, debian-kernel

On Wed, Aug 16, 2017 at 4:08 AM,  <riku.voipio@linaro.org> wrote:
>
> deb-pkg and bindeb-pkg removing need for handrulled source/changes

handrolled?

A quick test on a Ubuntu 16.04 vm with these patches applied on top of
4.13-rc5 generated a few warnings that didn't appear before:

dpkg-architecture: warning: specified GNU system type i686-linux-gnu
does not match CC system type x86_64-linux-gnu, try setting a correct
CC environment variable
dpkg-buildpackage: warning: debian/rules is not executable; fixing that
make[3]: warning: jobserver unavailable: using -j1.  Add '+' to parent
make rule.
make[3]: warning: jobserver unavailable: using -j1.  Add '+' to parent
make rule.
make[3]: warning: jobserver unavailable: using -j1.  Add '+' to parent
make rule.
dpkg-genchanges: warning: package linux-firmware-image-4.13.0-rc5+ in
control file but not in files list
dpkg-genchanges: warning: package linux-image-4.13.0-rc5+-dbg in
control file but not in files list

I think that first warning is from running "make allnoconfig
bindeb-pkg", and allnoconfig sets CONFIG_X86_32=y

-- 
Jim

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

* Re: [PATCH 2/2] scripts/package/builddeb: split generating packaging and build
  2017-08-17  0:24   ` Jim Davis
@ 2017-08-17  7:45     ` Riku Voipio
  0 siblings, 0 replies; 11+ messages in thread
From: Riku Voipio @ 2017-08-17  7:45 UTC (permalink / raw)
  To: Jim Davis; +Cc: linux-kbuild, Michal Marek, Masahiro Yamada, debian-kernel

Hi Jim,

Thanks for testing.

On 17 August 2017 at 03:24, Jim Davis <jim.epost@gmail.com> wrote:
> On Wed, Aug 16, 2017 at 4:08 AM,  <riku.voipio@linaro.org> wrote:
>>
>> deb-pkg and bindeb-pkg removing need for handrulled source/changes
>
> handrolled?
>
> A quick test on a Ubuntu 16.04 vm with these patches applied on top of
> 4.13-rc5 generated a few warnings that didn't appear before:

Before investing too much energy polishing, I'd like to know that
people find the approach reasonable. So in fact this patch was
intended more as an RFC.

> dpkg-architecture: warning: specified GNU system type i686-linux-gnu
> does not match CC system type x86_64-linux-gnu, try setting a correct
> CC environment variable
> dpkg-buildpackage: warning: debian/rules is not executable; fixing that
> make[3]: warning: jobserver unavailable: using -j1.  Add '+' to parent
> make rule.
> make[3]: warning: jobserver unavailable: using -j1.  Add '+' to parent
> make rule.
> make[3]: warning: jobserver unavailable: using -j1.  Add '+' to parent
> make rule.
> dpkg-genchanges: warning: package linux-firmware-image-4.13.0-rc5+ in
> control file but not in files list
> dpkg-genchanges: warning: package linux-image-4.13.0-rc5+-dbg in
> control file but not in files list

The last warning is becaues mkdebian make debian/control inone go.
With a little bit of added complexity we can only add the packages
that the builddeb script will generate. But then we have to keep the
logic in mkdebian and builddeb in sync.

Riku

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

* Re: [PATCH 1/2] scripts/package/Makefile: make revision update a function
  2017-08-16 11:08 [PATCH 1/2] scripts/package/Makefile: make revision update a function riku.voipio
  2017-08-16 11:08 ` [PATCH 2/2] scripts/package/builddeb: split generating packaging and build riku.voipio
@ 2017-09-07 17:04 ` Masahiro Yamada
  2017-09-08 15:40   ` Masahiro Yamada
  1 sibling, 1 reply; 11+ messages in thread
From: Masahiro Yamada @ 2017-09-07 17:04 UTC (permalink / raw)
  To: Riku Voipio; +Cc: Linux Kbuild mailing list, Michal Marek, debian-kernel

Hi Riku,


2017-08-16 20:08 GMT+09:00  <riku.voipio@linaro.org>:
> From: Riku Voipio <riku.voipio@linaro.org>
>
> The updated deb-pkg and bindeb-pkg will use the same snippet,
> so make it reusable.
>
> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
> ---
>  scripts/package/Makefile | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/scripts/package/Makefile b/scripts/package/Makefile
> index 71b4a8af9d4d..9867638896ad 100644
> --- a/scripts/package/Makefile
> +++ b/scripts/package/Makefile
> @@ -44,14 +44,18 @@ tar -cz $(RCS_TAR_IGNORE) -f $(2).tar.gz \
>         $(addprefix $(2)/,$(TAR_CONTENT) $(3)); \
>  rm -f $(2) $(objtree)/.scmversion
>
> +quiet_cmd_updateversion = UPDATEVERSION
> +      cmd_updateversion = \
> +       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version; \
> +       mv -f $(objtree)/.tmp_version $(objtree)/.version
> +
>  # rpm-pkg
>  # ---------------------------------------------------------------------------
>  rpm-pkg rpm: FORCE
>         $(MAKE) clean
>         $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
>         $(call cmd,src_tar,$(KERNELPATH),kernel.spec)
> -       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
> -       mv -f $(objtree)/.tmp_version $(objtree)/.version
> +       $(call cmd,updateversion)
>         rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz
>         rm $(KERNELPATH).tar.gz kernel.spec
>
> @@ -60,9 +64,7 @@ rpm-pkg rpm: FORCE
>  binrpm-pkg: FORCE
>         $(MAKE) KBUILD_SRC=
>         $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
> -       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
> -       mv -f $(objtree)/.tmp_version $(objtree)/.version
> -
> +       $(call cmd,updateversion)
>         rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
>                 $(UTS_MACHINE) -bb $(objtree)/binkernel.spec
>         rm binkernel.spec



scripts/mkversion is pretty small.
I think scripts/mkversion can also update .version

For example,




if [ ! -f .version ]
then
    version=1
else
    version=$(expr 0$(cat .version) + 1)
fi

echo $version > .version
echo $version




Then, remove the duplicated code from the Makefile.




-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH 1/2] scripts/package/Makefile: make revision update a function
  2017-09-07 17:04 ` [PATCH 1/2] scripts/package/Makefile: make revision update a function Masahiro Yamada
@ 2017-09-08 15:40   ` Masahiro Yamada
  2017-09-11 10:48     ` Riku Voipio
  0 siblings, 1 reply; 11+ messages in thread
From: Masahiro Yamada @ 2017-09-08 15:40 UTC (permalink / raw)
  To: Riku Voipio; +Cc: Linux Kbuild mailing list, Michal Marek, debian-kernel

2017-09-08 2:04 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:
> Hi Riku,
>
>
> 2017-08-16 20:08 GMT+09:00  <riku.voipio@linaro.org>:
>> From: Riku Voipio <riku.voipio@linaro.org>
>>
>> The updated deb-pkg and bindeb-pkg will use the same snippet,
>> so make it reusable.
>>
>> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
>> ---
>>  scripts/package/Makefile | 12 +++++++-----
>>  1 file changed, 7 insertions(+), 5 deletions(-)
>>
>> diff --git a/scripts/package/Makefile b/scripts/package/Makefile
>> index 71b4a8af9d4d..9867638896ad 100644
>> --- a/scripts/package/Makefile
>> +++ b/scripts/package/Makefile
>> @@ -44,14 +44,18 @@ tar -cz $(RCS_TAR_IGNORE) -f $(2).tar.gz \
>>         $(addprefix $(2)/,$(TAR_CONTENT) $(3)); \
>>  rm -f $(2) $(objtree)/.scmversion
>>
>> +quiet_cmd_updateversion = UPDATEVERSION
>> +      cmd_updateversion = \
>> +       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version; \
>> +       mv -f $(objtree)/.tmp_version $(objtree)/.version
>> +
>>  # rpm-pkg
>>  # ---------------------------------------------------------------------------
>>  rpm-pkg rpm: FORCE
>>         $(MAKE) clean
>>         $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
>>         $(call cmd,src_tar,$(KERNELPATH),kernel.spec)
>> -       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
>> -       mv -f $(objtree)/.tmp_version $(objtree)/.version
>> +       $(call cmd,updateversion)
>>         rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz
>>         rm $(KERNELPATH).tar.gz kernel.spec
>>
>> @@ -60,9 +64,7 @@ rpm-pkg rpm: FORCE
>>  binrpm-pkg: FORCE
>>         $(MAKE) KBUILD_SRC=
>>         $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
>> -       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
>> -       mv -f $(objtree)/.tmp_version $(objtree)/.version
>> -
>> +       $(call cmd,updateversion)
>>         rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
>>                 $(UTS_MACHINE) -bb $(objtree)/binkernel.spec
>>         rm binkernel.spec
>
>
>
> scripts/mkversion is pretty small.
> I think scripts/mkversion can also update .version
>
> For example,
>
>
>
>
> if [ ! -f .version ]
> then
>     version=1
> else
>     version=$(expr 0$(cat .version) + 1)
> fi
>
> echo $version > .version
> echo $version
>
>
>
>
> Then, remove the duplicated code from the Makefile.



Sorry, please let me think about this carefully.

We have simliar code in
scripts/link-vmlinux.sh and scripts/mkversion





-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH 1/2] scripts/package/Makefile: make revision update a function
  2017-09-08 15:40   ` Masahiro Yamada
@ 2017-09-11 10:48     ` Riku Voipio
  2017-09-14 11:23       ` Masahiro Yamada
  0 siblings, 1 reply; 11+ messages in thread
From: Riku Voipio @ 2017-09-11 10:48 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: Linux Kbuild mailing list, Michal Marek, debian-kernel

On 8 September 2017 at 18:40, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> 2017-09-08 2:04 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:
>> Hi Riku,
>>
>>
>> 2017-08-16 20:08 GMT+09:00  <riku.voipio@linaro.org>:
>>> From: Riku Voipio <riku.voipio@linaro.org>
>>>
>>> The updated deb-pkg and bindeb-pkg will use the same snippet,
>>> so make it reusable.
>>>
>>> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
>>> ---
>>>  scripts/package/Makefile | 12 +++++++-----
>>>  1 file changed, 7 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/scripts/package/Makefile b/scripts/package/Makefile
>>> index 71b4a8af9d4d..9867638896ad 100644
>>> --- a/scripts/package/Makefile
>>> +++ b/scripts/package/Makefile
>>> @@ -44,14 +44,18 @@ tar -cz $(RCS_TAR_IGNORE) -f $(2).tar.gz \
>>>         $(addprefix $(2)/,$(TAR_CONTENT) $(3)); \
>>>  rm -f $(2) $(objtree)/.scmversion
>>>
>>> +quiet_cmd_updateversion = UPDATEVERSION
>>> +      cmd_updateversion = \
>>> +       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version; \
>>> +       mv -f $(objtree)/.tmp_version $(objtree)/.version
>>> +
>>>  # rpm-pkg
>>>  # ---------------------------------------------------------------------------
>>>  rpm-pkg rpm: FORCE
>>>         $(MAKE) clean
>>>         $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
>>>         $(call cmd,src_tar,$(KERNELPATH),kernel.spec)
>>> -       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
>>> -       mv -f $(objtree)/.tmp_version $(objtree)/.version
>>> +       $(call cmd,updateversion)
>>>         rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz
>>>         rm $(KERNELPATH).tar.gz kernel.spec
>>>
>>> @@ -60,9 +64,7 @@ rpm-pkg rpm: FORCE
>>>  binrpm-pkg: FORCE
>>>         $(MAKE) KBUILD_SRC=
>>>         $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
>>> -       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
>>> -       mv -f $(objtree)/.tmp_version $(objtree)/.version
>>> -
>>> +       $(call cmd,updateversion)
>>>         rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
>>>                 $(UTS_MACHINE) -bb $(objtree)/binkernel.spec
>>>         rm binkernel.spec
>>
>>
>>
>> scripts/mkversion is pretty small.
>> I think scripts/mkversion can also update .version
>>
>> For example,
>>
>>
>>
>>
>> if [ ! -f .version ]
>> then
>>     version=1
>> else
>>     version=$(expr 0$(cat .version) + 1)
>> fi
>>
>> echo $version > .version
>> echo $version
>>
>>
>>
>>
>> Then, remove the duplicated code from the Makefile.
>
>
>
> Sorry, please let me think about this carefully.
>
> We have simliar code in
> scripts/link-vmlinux.sh and scripts/mkversion

Oh. Looking deeper, running "make binrpm" twice in a row incrediments
the .version with two. I think we can leave updating version to
link-mklinux and drop updating .version from
scripts/packaging/Makefile. The actual use of mkversion is then to
predict the next version, and we can stop using .version directly in
builddeb since the build will outdate it.

Riku

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

* Re: [PATCH 1/2] scripts/package/Makefile: make revision update a function
  2017-09-11 10:48     ` Riku Voipio
@ 2017-09-14 11:23       ` Masahiro Yamada
  0 siblings, 0 replies; 11+ messages in thread
From: Masahiro Yamada @ 2017-09-14 11:23 UTC (permalink / raw)
  To: Riku Voipio; +Cc: Linux Kbuild mailing list, Michal Marek, debian-kernel

2017-09-11 19:48 GMT+09:00 Riku Voipio <riku.voipio@linaro.org>:
> On 8 September 2017 at 18:40, Masahiro Yamada
> <yamada.masahiro@socionext.com> wrote:
>> 2017-09-08 2:04 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:
>>> Hi Riku,
>>>
>>>
>>> 2017-08-16 20:08 GMT+09:00  <riku.voipio@linaro.org>:
>>>> From: Riku Voipio <riku.voipio@linaro.org>
>>>>
>>>> The updated deb-pkg and bindeb-pkg will use the same snippet,
>>>> so make it reusable.
>>>>
>>>> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
>>>> ---
>>>>  scripts/package/Makefile | 12 +++++++-----
>>>>  1 file changed, 7 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/scripts/package/Makefile b/scripts/package/Makefile
>>>> index 71b4a8af9d4d..9867638896ad 100644
>>>> --- a/scripts/package/Makefile
>>>> +++ b/scripts/package/Makefile
>>>> @@ -44,14 +44,18 @@ tar -cz $(RCS_TAR_IGNORE) -f $(2).tar.gz \
>>>>         $(addprefix $(2)/,$(TAR_CONTENT) $(3)); \
>>>>  rm -f $(2) $(objtree)/.scmversion
>>>>
>>>> +quiet_cmd_updateversion = UPDATEVERSION
>>>> +      cmd_updateversion = \
>>>> +       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version; \
>>>> +       mv -f $(objtree)/.tmp_version $(objtree)/.version
>>>> +
>>>>  # rpm-pkg
>>>>  # ---------------------------------------------------------------------------
>>>>  rpm-pkg rpm: FORCE
>>>>         $(MAKE) clean
>>>>         $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
>>>>         $(call cmd,src_tar,$(KERNELPATH),kernel.spec)
>>>> -       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
>>>> -       mv -f $(objtree)/.tmp_version $(objtree)/.version
>>>> +       $(call cmd,updateversion)
>>>>         rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz
>>>>         rm $(KERNELPATH).tar.gz kernel.spec
>>>>
>>>> @@ -60,9 +64,7 @@ rpm-pkg rpm: FORCE
>>>>  binrpm-pkg: FORCE
>>>>         $(MAKE) KBUILD_SRC=
>>>>         $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
>>>> -       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
>>>> -       mv -f $(objtree)/.tmp_version $(objtree)/.version
>>>> -
>>>> +       $(call cmd,updateversion)
>>>>         rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
>>>>                 $(UTS_MACHINE) -bb $(objtree)/binkernel.spec
>>>>         rm binkernel.spec
>>>
>>>
>>>
>>> scripts/mkversion is pretty small.
>>> I think scripts/mkversion can also update .version
>>>
>>> For example,
>>>
>>>
>>>
>>>
>>> if [ ! -f .version ]
>>> then
>>>     version=1
>>> else
>>>     version=$(expr 0$(cat .version) + 1)
>>> fi
>>>
>>> echo $version > .version
>>> echo $version
>>>
>>>
>>>
>>>
>>> Then, remove the duplicated code from the Makefile.
>>
>>
>>
>> Sorry, please let me think about this carefully.
>>
>> We have simliar code in
>> scripts/link-vmlinux.sh and scripts/mkversion
>
> Oh. Looking deeper, running "make binrpm" twice in a row incrediments
> the .version with two. I think we can leave updating version to
> link-mklinux and drop updating .version from
> scripts/packaging/Makefile. The actual use of mkversion is then to
> predict the next version, and we can stop using .version directly in
> builddeb since the build will outdate it.
>

Even worse, the spec file claims a different number from
the one embedded in the kernel image
(for both rpm-pkg and binrpm-pkg).

I sent a patch.  Seems working as far as I tested.





-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH 2/2] scripts/package/builddeb: split generating packaging and build
  2017-08-16 11:08 ` [PATCH 2/2] scripts/package/builddeb: split generating packaging and build riku.voipio
  2017-08-17  0:24   ` Jim Davis
@ 2017-09-20  9:04   ` Masahiro Yamada
  2017-09-20 10:35     ` Riku Voipio
  1 sibling, 1 reply; 11+ messages in thread
From: Masahiro Yamada @ 2017-09-20  9:04 UTC (permalink / raw)
  To: Riku Voipio
  Cc: Linux Kbuild mailing list, Michal Marek, debian-kernel,
	Ben Hutchings, Jim Davis

Hi Riku,


2017-08-16 20:08 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 and 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 handrulled 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 late reply, and thanks for working on this!

In my opinion, this seems the right direction.

A few comments below.

(Please note I am not a debian developer.
If I am suggesting wrong, please correct me.)


>  scripts/package/Makefile |  14 ++-
>  scripts/package/builddeb | 233 +----------------------------------------------
>  scripts/package/mkdebian | 209 ++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 221 insertions(+), 235 deletions(-)
>  create mode 100755 scripts/package/mkdebian
>
> diff --git a/scripts/package/Makefile b/scripts/package/Makefile
> index 9867638896ad..176158c9b7da 100644
> --- a/scripts/package/Makefile
> +++ b/scripts/package/Makefile
> @@ -92,12 +92,18 @@ quiet_cmd_builddeb = BUILDDEB
>  deb-pkg: FORCE
>         $(MAKE) clean
>         $(call cmd,src_tar,$(KDEB_SOURCENAME))
> -       $(MAKE) KBUILD_SRC=
> -       +$(call cmd,builddeb)
> +       $(call cmd,updateversion)
> +       mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$(KERNELRELEASE).orig.tar.gz
> +       $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
> +       dpkg-buildpackage -r"fakeroot -u" -a$$(cat debian/arch) -i.git


This tries to sign the source package and .changes file by default.

Maybe, "-us -uc" options reasonable for easier use?




>  bindeb-pkg: FORCE
> -       $(MAKE) KBUILD_SRC=
> -       +$(call cmd,builddeb)
> +       $(call cmd,updateversion)
> +       $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
> +       dpkg-buildpackage -r"fakeroot -u" -a$$(cat debian/arch) -b

IIUC, the whole of dpkg-buildpackage process is run under "fakeroot -u".
Correct?

It will internally invokes "make intdeb-pkg",
then $(call cmd,builddeb) calls "fakeroot -u" recursively,
this seems redundant to me.

Maybe,

     dpkg-buildpackage -r"$(KBUILD_PKG_ROOTCMD)" -a$$(cat debian/arch) -b

makes more sense?





> +
> +cat <<EOF > debian/rules
> +#!/usr/bin/make -f
> +
> +ifneq (,\$(filter parallel=%,\$(DEB_BUILD_OPTIONS)))
> +    NUMJOBS = \$(patsubst parallel=%,%,\$(filter parallel=%,\$(DEB_BUILD_OPTIONS)))
> +    MAKEFLAGS += -j\$(NUMJOBS)
> +endif
> +
> +build:
> +       \$(MAKE) ARCH=${ARCH}
> +
> +binary-arch:
> +       \$(MAKE) KDEB_VERSION=${version} ARCH=${ARCH} intdeb-pkg


Hmm, instead of recursive make,
is it possible to run scripts/package/debuild directly here?

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


The biggest change in the behavior is, "make bindeb-pkg" did not
previously "make clean",
but now does it.

If "make bindeb-pkg" is run in a row, all objects are cleaned every time.

Is it reasonable to skip "$(MAKE) clean" for bindeb-pkg?





-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH 2/2] scripts/package/builddeb: split generating packaging and build
  2017-09-20  9:04   ` Masahiro Yamada
@ 2017-09-20 10:35     ` Riku Voipio
  2017-09-22  4:26       ` Masahiro Yamada
  0 siblings, 1 reply; 11+ messages in thread
From: Riku Voipio @ 2017-09-20 10:35 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Linux Kbuild mailing list, Michal Marek, debian-kernel,
	Ben Hutchings, Jim Davis

On 20 September 2017 at 12:04, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> Hi Riku,
>
>
> 2017-08-16 20:08 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 and 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 handrulled 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 late reply, and thanks for working on this!
>
> In my opinion, this seems the right direction.
>
> A few comments below.
>
> (Please note I am not a debian developer.
> If I am suggesting wrong, please correct me.)
>
>
>>  scripts/package/Makefile |  14 ++-
>>  scripts/package/builddeb | 233 +----------------------------------------------
>>  scripts/package/mkdebian | 209 ++++++++++++++++++++++++++++++++++++++++++
>>  3 files changed, 221 insertions(+), 235 deletions(-)
>>  create mode 100755 scripts/package/mkdebian
>>
>> diff --git a/scripts/package/Makefile b/scripts/package/Makefile
>> index 9867638896ad..176158c9b7da 100644
>> --- a/scripts/package/Makefile
>> +++ b/scripts/package/Makefile
>> @@ -92,12 +92,18 @@ quiet_cmd_builddeb = BUILDDEB
>>  deb-pkg: FORCE
>>         $(MAKE) clean
>>         $(call cmd,src_tar,$(KDEB_SOURCENAME))
>> -       $(MAKE) KBUILD_SRC=
>> -       +$(call cmd,builddeb)
>> +       $(call cmd,updateversion)
>> +       mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$(KERNELRELEASE).orig.tar.gz
>> +       $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
>> +       dpkg-buildpackage -r"fakeroot -u" -a$$(cat debian/arch) -i.git

> This tries to sign the source package and .changes file by default.

> Maybe, "-us -uc" options reasonable for easier use?

I don't really mind signing, but otoh the old targets didn't ask for
signing so perhaps we should keep the behaviour that way.

>>  bindeb-pkg: FORCE
>> -       $(MAKE) KBUILD_SRC=
>> -       +$(call cmd,builddeb)
>> +       $(call cmd,updateversion)
>> +       $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
>> +       dpkg-buildpackage -r"fakeroot -u" -a$$(cat debian/arch) -b
>
> IIUC, the whole of dpkg-buildpackage process is run under "fakeroot -u".
> Correct?

No, dpkg-buildpackage will call -rfakeroot only for binary-arch targets

> It will internally invokes "make intdeb-pkg",
> then $(call cmd,builddeb) calls "fakeroot -u" recursively,
> this seems redundant to me.

it wont, since it's checks if if = 0 - which will be true under. But
all this can be indeed removed
if we can call builddeb directly as discussed below.

> Maybe,
>
>      dpkg-buildpackage -r"$(KBUILD_PKG_ROOTCMD)" -a$$(cat debian/arch) -b
>
> makes more sense?

>> +
>> +cat <<EOF > debian/rules
>> +#!/usr/bin/make -f
>> +
>> +ifneq (,\$(filter parallel=%,\$(DEB_BUILD_OPTIONS)))
>> +    NUMJOBS = \$(patsubst parallel=%,%,\$(filter parallel=%,\$(DEB_BUILD_OPTIONS)))
>> +    MAKEFLAGS += -j\$(NUMJOBS)
>> +endif
>> +
>> +build:
>> +       \$(MAKE) ARCH=${ARCH}
>> +
>> +binary-arch:
>> +       \$(MAKE) KDEB_VERSION=${version} ARCH=${ARCH} intdeb-pkg
>
>
> Hmm, instead of recursive make,
> is it possible to run scripts/package/debuild directly here?

I though it's not possible because I need variables from kernel make.
Now that I check, I see only  $KCONFIG_CONFIG which I think we can
assume to be .config. Also some ARCH and SRCARCH variables which are
hardcoded anyways in mkdebian. I'll try.

>> +
>> +clean:
>> +       rm -rf debian/*tmp debian/files
>> +       mv debian/ debian.backup # debian/ might be cleaned away
>> +       \$(MAKE) clean
>
>
> The biggest change in the behavior is, "make bindeb-pkg" did not
> previously "make clean",
> but now does it.
>
> If "make bindeb-pkg" is run in a row, all objects are cleaned every time.
>
> Is it reasonable to skip "$(MAKE) clean" for bindeb-pkg?

dpkg-buildpackage -nc should do that. I'll add it.

>
>
>
>
> --
> Best Regards
> Masahiro Yamada

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

* Re: [PATCH 2/2] scripts/package/builddeb: split generating packaging and build
  2017-09-20 10:35     ` Riku Voipio
@ 2017-09-22  4:26       ` Masahiro Yamada
  0 siblings, 0 replies; 11+ messages in thread
From: Masahiro Yamada @ 2017-09-22  4:26 UTC (permalink / raw)
  To: Riku Voipio
  Cc: Linux Kbuild mailing list, Michal Marek, debian-kernel,
	Ben Hutchings, Jim Davis

Hi Riku


2017-09-20 19:35 GMT+09:00 Riku Voipio <riku.voipio@linaro.org>:

>>>  bindeb-pkg: FORCE
>>> -       $(MAKE) KBUILD_SRC=
>>> -       +$(call cmd,builddeb)
>>> +       $(call cmd,updateversion)
>>> +       $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
>>> +       dpkg-buildpackage -r"fakeroot -u" -a$$(cat debian/arch) -b
>>
>> IIUC, the whole of dpkg-buildpackage process is run under "fakeroot -u".
>> Correct?
>
> No, dpkg-buildpackage will call -rfakeroot only for binary-arch targets


You are right.
I tested this and seems to work so.


>> It will internally invokes "make intdeb-pkg",
>> then $(call cmd,builddeb) calls "fakeroot -u" recursively,
>> this seems redundant to me.
>
> it wont, since it's checks if if = 0 - which will be true under. But
> all this can be indeed removed
> if we can call builddeb directly as discussed below.


Right.
I missed that id -u is already 0 in this case.



>> Maybe,
>>
>>      dpkg-buildpackage -r"$(KBUILD_PKG_ROOTCMD)" -a$$(cat debian/arch) -b
>>
>> makes more sense?
>
>>> +
>>> +cat <<EOF > debian/rules
>>> +#!/usr/bin/make -f
>>> +
>>> +ifneq (,\$(filter parallel=%,\$(DEB_BUILD_OPTIONS)))
>>> +    NUMJOBS = \$(patsubst parallel=%,%,\$(filter parallel=%,\$(DEB_BUILD_OPTIONS)))
>>> +    MAKEFLAGS += -j\$(NUMJOBS)
>>> +endif
>>> +
>>> +build:
>>> +       \$(MAKE) ARCH=${ARCH}
>>> +
>>> +binary-arch:
>>> +       \$(MAKE) KDEB_VERSION=${version} ARCH=${ARCH} intdeb-pkg
>>
>>
>> Hmm, instead of recursive make,
>> is it possible to run scripts/package/debuild directly here?
>
> I though it's not possible because I need variables from kernel make.
> Now that I check, I see only  $KCONFIG_CONFIG which I think we can
> assume to be .config. Also some ARCH and SRCARCH variables which are
> hardcoded anyways in mkdebian. I'll try.


Most of the variables are exported from the top-level Makefile.

KCONFIG_CONFIG  ?= .config
export KCONFIG_CONFIG

....

export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC


So, I think you can refer $KCONFIG_CONFIG from scripts/package/debuild.
(I have not tested it, though...)




-- 
Best Regards
Masahiro Yamada

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

end of thread, other threads:[~2017-09-22  4:27 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-16 11:08 [PATCH 1/2] scripts/package/Makefile: make revision update a function riku.voipio
2017-08-16 11:08 ` [PATCH 2/2] scripts/package/builddeb: split generating packaging and build riku.voipio
2017-08-17  0:24   ` Jim Davis
2017-08-17  7:45     ` Riku Voipio
2017-09-20  9:04   ` Masahiro Yamada
2017-09-20 10:35     ` Riku Voipio
2017-09-22  4:26       ` Masahiro Yamada
2017-09-07 17:04 ` [PATCH 1/2] scripts/package/Makefile: make revision update a function Masahiro Yamada
2017-09-08 15:40   ` Masahiro Yamada
2017-09-11 10:48     ` Riku Voipio
2017-09-14 11:23       ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).