From 21a59991ce0cd9a0b54b135305e3fcf880f2aaf1 Mon Sep 17 00:00:00 2001 From: Jim Davis Date: Mon, 8 Jun 2015 13:19:08 -0700 Subject: scripts/package/Makefile: rpmbuild is needed for rpm targets Before rpm release 4.1, in 2002, either the rpm command or the rpmbuild command could be used in the rpm-pkg or binrpm-pkg targets, and the Makefile chose the rpm command if the rpmbuild command wasn't found. After release 4.1, however, the rpm command could no longer be used in place of the rpmbuild command. As the rpmbuild command is not installed by default, this can lead to failures with the rpm-pkg and binrpm-pkg targets: rpm --define "_builddir ." --target \ x86_64 -bb ./binkernel.spec rpm --target: unknown option scripts/package/Makefile:60: recipe for target 'binrpm-pkg' failed Change the Makefile to use rpmbuild unconditionally to avoid this. Signed-off-by: Jim Davis Signed-off-by: Michal Marek --- scripts/package/Makefile | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'scripts/package/Makefile') diff --git a/scripts/package/Makefile b/scripts/package/Makefile index 99ca6e76eb0a..8b11d5adec7f 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile @@ -21,10 +21,6 @@ # Note that the rpm-pkg target cannot be used with KBUILD_OUTPUT, # but the binrpm-pkg target can; for some reason O= gets ignored. -# Do we have rpmbuild, otherwise fall back to the older rpm -RPM := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ - else echo rpm; fi) - # Remove hyphens since they have special meaning in RPM filenames KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE)) # Include only those top-level files that are needed by make, plus the GPL copy @@ -51,7 +47,7 @@ rpm-pkg rpm: FORCE rm -f $(objtree)/.scmversion $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version mv -f $(objtree)/.tmp_version $(objtree)/.version - $(RPM) $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz + rpmbuild --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz rm $(KERNELPATH).tar.gz kernel.spec # binrpm-pkg @@ -62,7 +58,7 @@ binrpm-pkg: FORCE $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version mv -f $(objtree)/.tmp_version $(objtree)/.version - $(RPM) $(RPMOPTS) --define "_builddir $(objtree)" --target \ + rpmbuild --define "_builddir $(objtree)" --target \ $(UTS_MACHINE) -bb $(objtree)/binkernel.spec rm binkernel.spec -- cgit v1.2.3-59-g8ed1b From 26803821463c4e76322559b3dfb0c6b0fcc8aee8 Mon Sep 17 00:00:00 2001 From: Riku Voipio Date: Wed, 2 Sep 2015 12:57:08 +0300 Subject: package/Makefile: move source tar creation to a function Split source tarball creation from rpm-pkg target so it can be used from deb-pkg target as well. As added bonus, we can now pretty print TAR the name of tarball created in quiet mode This patch prepares the groundwork for deb-pkg source package adding bit. Signed-off-by: Riku Voipio Signed-off-by: Michal Marek --- scripts/package/Makefile | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'scripts/package/Makefile') diff --git a/scripts/package/Makefile b/scripts/package/Makefile index 8b11d5adec7f..297e75684738 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile @@ -24,27 +24,30 @@ # Remove hyphens since they have special meaning in RPM filenames KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE)) # Include only those top-level files that are needed by make, plus the GPL copy -TAR_CONTENT := $(KBUILD_ALLDIRS) kernel.spec .config .scmversion Makefile \ +TAR_CONTENT := $(KBUILD_ALLDIRS) .config .scmversion Makefile \ Kbuild Kconfig COPYING $(wildcard localversion*) -TAR_CONTENT := $(addprefix $(KERNELPATH)/,$(TAR_CONTENT)) MKSPEC := $(srctree)/scripts/package/mkspec +quiet_cmd_src_tar = TAR $(2).tar.gz + cmd_src_tar = \ +if test "$(objtree)" != "$(srctree)"; then \ + echo "Building source tarball is not possible outside the"; \ + echo "kernel source tree. Don't set KBUILD_OUTPUT, or use the"; \ + echo "binrpm-pkg or bindeb-pkg target instead."; \ + false; \ +fi ; \ +$(srctree)/scripts/setlocalversion --save-scmversion; \ +ln -sf $(srctree) $(2); \ +tar -cz $(RCS_TAR_IGNORE) -f $(2).tar.gz \ + $(addprefix $(2)/,$(TAR_CONTENT) $(3)); \ +rm -f $(2) $(objtree)/.scmversion + # rpm-pkg # --------------------------------------------------------------------------- rpm-pkg rpm: FORCE - @if test "$(objtree)" != "$(srctree)"; then \ - echo "Building source + binary RPM is not possible outside the"; \ - echo "kernel source tree. Don't set KBUILD_OUTPUT, or use the"; \ - echo "binrpm-pkg target instead."; \ - false; \ - fi $(MAKE) clean - ln -sf $(srctree) $(KERNELPATH) $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec - $(CONFIG_SHELL) $(srctree)/scripts/setlocalversion --save-scmversion - tar -cz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(TAR_CONTENT) - rm $(KERNELPATH) - rm -f $(objtree)/.scmversion + $(call cmd,src_tar,$(KERNELPATH),kernel.spec) $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version mv -f $(objtree)/.tmp_version $(objtree)/.version rpmbuild --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz -- cgit v1.2.3-59-g8ed1b From 3716001bcb7f5822382ac1f2f54226b87312cc6b Mon Sep 17 00:00:00 2001 From: Riku Voipio Date: Wed, 2 Sep 2015 12:57:24 +0300 Subject: deb-pkg: add source package Make deb-pkg build both source and binary package like make rpm-pkg does. For people who only need binary kernel package, there is now bindeb-pkg target, same target also used to build the .deb files if built from the source package using dpkg-buildpackage. Generated source package will build the same kernel .config than what was available for make deb-pkg. The name of the source package can be set with KDEB_SOURCENAME enviroment variable. The source package is useful for GPL compliance, or for feeding to a automated debian package builder. Cc: Chris J Arges Reviewed-by: maximilian attems Reviewed-by: Ben Hutchings Signed-off-by: Riku Voipio Signed-off-by: Michal Marek --- scripts/package/Makefile | 17 +++++++++++++---- scripts/package/builddeb | 38 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 6 deletions(-) (limited to 'scripts/package/Makefile') diff --git a/scripts/package/Makefile b/scripts/package/Makefile index 297e75684738..1aca224e8597 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile @@ -23,6 +23,8 @@ # Remove hyphens since they have special meaning in RPM filenames KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE)) +KDEB_SOURCENAME ?= linux-$(KERNELRELEASE) +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 \ Kbuild Kconfig COPYING $(wildcard localversion*) @@ -83,11 +85,17 @@ quiet_cmd_builddeb = BUILDDEB } && \ \ $$KBUILD_PKG_ROOTCMD $(CONFIG_SHELL) \ - $(srctree)/scripts/package/builddeb + $(srctree)/scripts/package/builddeb $@ deb-pkg: FORCE + $(MAKE) clean + $(call cmd,src_tar,$(KDEB_SOURCENAME)) + $(MAKE) KBUILD_SRC= + +$(call cmd,builddeb) + +bindeb-pkg: FORCE $(MAKE) KBUILD_SRC= - $(call cmd,builddeb) + +$(call cmd,builddeb) clean-dirs += $(objtree)/debian/ @@ -132,8 +140,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 0c18cfd93287..0cd46e129920 100755 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -79,6 +79,7 @@ if [ -n "$KDEB_PKGVERSION" ]; then else packageversion=$version-$revision fi +sourcename=$KDEB_SOURCENAME tmpdir="$objtree/debian/tmp" fwdir="$objtree/debian/fwtmp" kernel_headers_dir="$objtree/debian/hdrtmp" @@ -238,7 +239,7 @@ fi # Generate a simple changelog template cat < debian/changelog -linux-upstream ($packageversion) $distribution; urgency=low +$sourcename ($packageversion) $distribution; urgency=low * Custom built Linux kernel. @@ -265,12 +266,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 " + # Generate a control file cat < debian/control -Source: linux-upstream +Source: $sourcename Section: kernel Priority: optional Maintainer: $maintainer +Build-Depends: $build_depends Standards-Version: 3.8.4 Homepage: http://www.kernel.org/ EOF @@ -391,4 +396,33 @@ EOF create_package "$dbg_packagename" "$dbg_dir" fi +if [ "x$1" = "xdeb-pkg" ] +then + cat < debian/rules +#!/usr/bin/make -f + +build: + \$(MAKE) + +binary-arch: + \$(MAKE) KDEB_SOURCENAME=${sourcename} KDEB_PKGVERSION=${packageversion} bindeb-pkg + +clean: + rm -rf debian/*tmp + 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 -- cgit v1.2.3-59-g8ed1b