diff mbox

[2/2] deb-pkg: add source package

Message ID 1432804275-13187-3-git-send-email-riku.voipio@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Riku Voipio May 28, 2015, 9:11 a.m. UTC
From: Riku Voipio <riku.voipio@linaro.org>

By passing BUILD_SOURCE=y variable, make deb-pkg builds a debian source
package. It will generate a minimal debian/rules file that calls back
to make deb-pkg. Generated source package will build the same kernel
.config than what was available for make deb-pkg.

The source package is useful for gpl compliance, or for feeding to a
automated debian package builder.

v2, address Maximilians comments

- Isolate from my other patches, so it can be merged easier
- Separate bindeb-pkg target for building just binary debs
- Build source package in deb-pkg target to match rpm-pkg target

Cc: maximilian attems <maks@stro.at>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 scripts/package/Makefile | 11 ++++++++---
 scripts/package/builddeb | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 3 deletions(-)

Comments

Ben Hutchings May 31, 2015, 1:14 a.m. UTC | #1
On Thu, 2015-05-28 at 12:11 +0300, riku.voipio@linaro.org wrote:
> From: Riku Voipio <riku.voipio@linaro.org>
> 
> By passing BUILD_SOURCE=y variable, make deb-pkg builds a debian source
> package. It will generate a minimal debian/rules file that calls back
> to make deb-pkg. Generated source package will build the same kernel
> .config than what was available for make deb-pkg.
> 
> The source package is useful for gpl compliance, or for feeding to a
> automated debian package builder.
> 
> v2, address Maximilians comments
> 
> - Isolate from my other patches, so it can be merged easier
> - Separate bindeb-pkg target for building just binary debs
> - Build source package in deb-pkg target to match rpm-pkg target
[...]
> --- a/scripts/package/builddeb
> +++ b/scripts/package/builddeb
> @@ -265,12 +265,16 @@ 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, python "

Why python?

>  # Generate a control file
>  cat <<EOF > debian/control
>  Source: linux-upstream
>  Section: kernel
>  Priority: optional
>  Maintainer: $maintainer
> +Build-Depends: $build_depends
>  Standards-Version: 3.8.4
>  Homepage: http://www.kernel.org/
>  EOF
> @@ -391,4 +395,33 @@ EOF
>  	create_package "$dbg_packagename" "$dbg_dir"
>  fi
>  
> +if [ "x$1" = "xdeb-pkg" ]
> +then
> +    cat <<EOF > debian/rules
> +#!/usr/bin/make -f
> +
> +build:
> +	cp debian/config .config
> +	\$(MAKE) oldconfig
> +
> +binary-arch:
> +	\$(MAKE) KDEB_PKGVERSION=${packageversion} deb-pkg

This should invoke the bindeb-pkg target.

> +clean:
> +	\$(MAKE) clean
> +
> +binary: binary-arch
> +EOF
> +
> +	(cd $KBUILD_SRC; git archive --prefix=linux-upstream-${version}/ HEAD)|gzip -9 > ../linux-upstream_${version}.orig.tar.gz

Not xz?  (Which would add a build-dependency, of course.)

Ben.

> +	cp $KCONFIG_CONFIG debian/config
> +	tar caf ../linux-upstream_${packageversion}.debian.tar.gz debian/{config,copyright,rules,changelog,control}
> +	dpkg-source -cdebian/control -ldebian/changelog --format="3.0 (custom)" --target-format="3.0 (quilt)" \
> +		-b / ../linux-upstream_${version}.orig.tar.gz  ../linux-upstream_${packageversion}.debian.tar.gz
> +	mv linux-upstream_${packageversion}*dsc ..
> +	dpkg-genchanges > ../linux-upstream_${packageversion}_${debarch}.changes
> +else
> +	dpkg-genchanges -b > ../linux-upstream_${packageversion}_${debarch}.changes
> +fi
> +
>  exit 0
Riku Voipio June 1, 2015, 8:35 a.m. UTC | #2
On 31 May 2015 at 04:14, Ben Hutchings <ben@decadent.org.uk> wrote:
> On Thu, 2015-05-28 at 12:11 +0300, riku.voipio@linaro.org wrote:
>> From: Riku Voipio <riku.voipio@linaro.org>
>>
>> By passing BUILD_SOURCE=y variable, make deb-pkg builds a debian source
>> package. It will generate a minimal debian/rules file that calls back
>> to make deb-pkg. Generated source package will build the same kernel
>> .config than what was available for make deb-pkg.
>>
>> The source package is useful for gpl compliance, or for feeding to a
>> automated debian package builder.
>>
>> v2, address Maximilians comments
>>
>> - Isolate from my other patches, so it can be merged easier
>> - Separate bindeb-pkg target for building just binary debs
>> - Build source package in deb-pkg target to match rpm-pkg target
> [...]
>> --- a/scripts/package/builddeb
>> +++ b/scripts/package/builddeb
>> @@ -265,12 +265,16 @@ 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, python "

> Why python?

I recall seeing python called sometimes in kernel build, and it's
alsoin debian kernel build-depends. However, a quick git grep suggests
this would be ia64 only.

>>  # Generate a control file
>>  cat <<EOF > debian/control
>>  Source: linux-upstream
>>  Section: kernel
>>  Priority: optional
>>  Maintainer: $maintainer
>> +Build-Depends: $build_depends
>>  Standards-Version: 3.8.4
>>  Homepage: http://www.kernel.org/
>>  EOF
>> @@ -391,4 +395,33 @@ EOF
>>       create_package "$dbg_packagename" "$dbg_dir"
>>  fi
>>
>> +if [ "x$1" = "xdeb-pkg" ]
>> +then
>> +    cat <<EOF > debian/rules
>> +#!/usr/bin/make -f
>> +
>> +build:
>> +     cp debian/config .config
>> +     \$(MAKE) oldconfig
>> +
>> +binary-arch:
>> +     \$(MAKE) KDEB_PKGVERSION=${packageversion} deb-pkg
>
> This should invoke the bindeb-pkg target.

good catch, will fix.

>> +clean:
>> +     \$(MAKE) clean
>> +
>> +binary: binary-arch
>> +EOF
>> +
>> +     (cd $KBUILD_SRC; git archive --prefix=linux-upstream-${version}/ HEAD)|gzip -9 > ../linux-upstream_${version}.orig.tar.gz

> Not xz?  (Which would add a build-dependency, of course.)

I tried to keep this as universally usable as possible. Can we assume
xz installed these days? In debian/ubuntu yes, but do we want to cater
users of other distributions as well?

> Ben.
>
>> +     cp $KCONFIG_CONFIG debian/config
>> +     tar caf ../linux-upstream_${packageversion}.debian.tar.gz debian/{config,copyright,rules,changelog,control}
>> +     dpkg-source -cdebian/control -ldebian/changelog --format="3.0 (custom)" --target-format="3.0 (quilt)" \
>> +             -b / ../linux-upstream_${version}.orig.tar.gz  ../linux-upstream_${packageversion}.debian.tar.gz
>> +     mv linux-upstream_${packageversion}*dsc ..
>> +     dpkg-genchanges > ../linux-upstream_${packageversion}_${debarch}.changes
>> +else
>> +     dpkg-genchanges -b > ../linux-upstream_${packageversion}_${debarch}.changes
>> +fi
>> +
>>  exit 0
>
> --
> Ben Hutchings
> Reality is just a crutch for people who can't handle science fiction.
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ben Hutchings June 1, 2015, 12:03 p.m. UTC | #3
On Mon, 2015-06-01 at 11:35 +0300, Riku Voipio wrote:
> On 31 May 2015 at 04:14, Ben Hutchings <ben@decadent.org.uk> wrote:
> > On Thu, 2015-05-28 at 12:11 +0300, riku.voipio@linaro.org wrote:
> >> From: Riku Voipio <riku.voipio@linaro.org>
> >>
> >> By passing BUILD_SOURCE=y variable, make deb-pkg builds a debian source
> >> package. It will generate a minimal debian/rules file that calls back
> >> to make deb-pkg. Generated source package will build the same kernel
> >> .config than what was available for make deb-pkg.
> >>
> >> The source package is useful for gpl compliance, or for feeding to a
> >> automated debian package builder.
> >>
> >> v2, address Maximilians comments
> >>
> >> - Isolate from my other patches, so it can be merged easier
> >> - Separate bindeb-pkg target for building just binary debs
> >> - Build source package in deb-pkg target to match rpm-pkg target
> > [...]
> >> --- a/scripts/package/builddeb
> >> +++ b/scripts/package/builddeb
> >> @@ -265,12 +265,16 @@ 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, python "
> 
> > Why python?
> 
> I recall seeing python called sometimes in kernel build, and it's
> alsoin debian kernel build-depends. However, a quick git grep suggests
> this would be ia64 only.

Yes, the Debian source package has a bunch of Python scripts but not
upstream.

[...]
> >> +clean:
> >> +     \$(MAKE) clean
> >> +
> >> +binary: binary-arch
> >> +EOF
> >> +
> >> +     (cd $KBUILD_SRC; git archive --prefix=linux-upstream-${version}/ HEAD)|gzip -9 > ../linux-upstream_${version}.orig.tar.gz
> 
> > Not xz?  (Which would add a build-dependency, of course.)
> 
> I tried to keep this as universally usable as possible. Can we assume
> xz installed these days? In debian/ubuntu yes, but do we want to cater
> users of other distributions as well?

It would be surprising to have dpkg and not xz.  dpkg doesn't depend on
the xz command any more but it does use liblzma.

Still, I accept that gzip may make this slightly more portable.

Ben.
Yves-Alexis Perez June 9, 2015, 7:26 a.m. UTC | #4
On jeu., 2015-05-28 at 12:11 +0300, Riku Voipio wrote:
> +       dpkg-genchanges > ../linux-upstream_${packageversion}_
> ${debarch}.changes
> +else
> +       dpkg-genchanges -b > ../linux-upstream_${packageversion}_
> ${debarch}.changes

${debarch} seems empty here when using make deb-pkg, not too sure why
(I'm building using KBUILD_OUTPUT, not sure if it's related).

Regards,
Riku Voipio June 10, 2015, 10:04 a.m. UTC | #5
On 9 June 2015 at 10:26, Yves-Alexis Perez <corsac@debian.org> wrote:
> On jeu., 2015-05-28 at 12:11 +0300, Riku Voipio wrote:
>> +       dpkg-genchanges > ../linux-upstream_${packageversion}_
>> ${debarch}.changes
>> +else
>> +       dpkg-genchanges -b > ../linux-upstream_${packageversion}_
>> ${debarch}.changes
>
> ${debarch} seems empty here when using make deb-pkg, not too sure why
> (I'm building using KBUILD_OUTPUT, not sure if it's related).

Hi Yves,

You are missing the patch already qued that is sets the debarch variable:

https://kernel.googlesource.com/pub/scm/linux/kernel/git/mmarek/kbuild/+/dca0c0246fb739bccdd19ff2bfd0f02ccffdb07c

Riku
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index 99ca6e7..7ec4dcc 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -84,12 +84,16 @@  quiet_cmd_builddeb = BUILDDEB
 	} && \
 	\
 	$$KBUILD_PKG_ROOTCMD $(CONFIG_SHELL) \
-		$(srctree)/scripts/package/builddeb
+		$(srctree)/scripts/package/builddeb $@
 
 deb-pkg: FORCE
 	$(MAKE) KBUILD_SRC=
 	$(call cmd,builddeb)
 
+bindeb-pkg: FORCE
+	$(MAKE) KBUILD_SRC=
+	$(call cmd,builddeb)
+
 clean-dirs += $(objtree)/debian/
 
 
@@ -133,8 +137,9 @@  perf-%pkg: FORCE
 # ---------------------------------------------------------------------------
 help: FORCE
 	@echo '  rpm-pkg             - Build both source and binary RPM kernel packages'
-	@echo '  binrpm-pkg          - Build only the binary kernel package'
-	@echo '  deb-pkg             - Build the kernel as a deb package'
+	@echo '  binrpm-pkg          - Build only the binary kernel RPM package'
+	@echo '  deb-pkg             - Build both source and binary deb kernel packages'
+	@echo '  bindeb-pkg          - Build only the binary kernel deb package'
 	@echo '  tar-pkg             - Build the kernel as an uncompressed tarball'
 	@echo '  targz-pkg           - Build the kernel as a gzip compressed tarball'
 	@echo '  tarbz2-pkg          - Build the kernel as a bzip2 compressed tarball'
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 0ccd7ee..1872d03 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -265,12 +265,16 @@  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, python "
+
 # Generate a control file
 cat <<EOF > debian/control
 Source: linux-upstream
 Section: kernel
 Priority: optional
 Maintainer: $maintainer
+Build-Depends: $build_depends
 Standards-Version: 3.8.4
 Homepage: http://www.kernel.org/
 EOF
@@ -391,4 +395,33 @@  EOF
 	create_package "$dbg_packagename" "$dbg_dir"
 fi
 
+if [ "x$1" = "xdeb-pkg" ]
+then
+    cat <<EOF > debian/rules
+#!/usr/bin/make -f
+
+build:
+	cp debian/config .config
+	\$(MAKE) oldconfig
+
+binary-arch:
+	\$(MAKE) KDEB_PKGVERSION=${packageversion} deb-pkg
+
+clean:
+	\$(MAKE) clean
+
+binary: binary-arch
+EOF
+
+	(cd $KBUILD_SRC; git archive --prefix=linux-upstream-${version}/ HEAD)|gzip -9 > ../linux-upstream_${version}.orig.tar.gz
+	cp $KCONFIG_CONFIG debian/config
+	tar caf ../linux-upstream_${packageversion}.debian.tar.gz debian/{config,copyright,rules,changelog,control}
+	dpkg-source -cdebian/control -ldebian/changelog --format="3.0 (custom)" --target-format="3.0 (quilt)" \
+		-b / ../linux-upstream_${version}.orig.tar.gz  ../linux-upstream_${packageversion}.debian.tar.gz
+	mv linux-upstream_${packageversion}*dsc ..
+	dpkg-genchanges > ../linux-upstream_${packageversion}_${debarch}.changes
+else
+	dpkg-genchanges -b > ../linux-upstream_${packageversion}_${debarch}.changes
+fi
+
 exit 0