Skip to content

Commit 71aaa5e

Browse files
committed
backports: bindeb-pkg: from: linux.git
Reference: v5.2.21 Signed-off-by: Robert Nelson <[email protected]>
1 parent c0d5a87 commit 71aaa5e

File tree

6 files changed

+447
-423
lines changed

6 files changed

+447
-423
lines changed

scripts/package/Makefile

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
12
# Makefile for the different targets used to generate full packages of a kernel
23
# It uses the generic clean infrastructure of kbuild
34

@@ -24,6 +25,7 @@
2425
# Remove hyphens since they have special meaning in RPM filenames
2526
KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE))
2627
KDEB_SOURCENAME ?= linux-$(KERNELRELEASE)
28+
KBUILD_PKG_ROOTCMD ?="fakeroot -u"
2729
export KDEB_SOURCENAME
2830
# Include only those top-level files that are needed by make, plus the GPL copy
2931
TAR_CONTENT := $(KBUILD_ALLDIRS) .config .scmversion Makefile \
@@ -33,9 +35,12 @@ MKSPEC := $(srctree)/scripts/package/mkspec
3335
quiet_cmd_src_tar = TAR $(2).tar.gz
3436
cmd_src_tar = \
3537
if test "$(objtree)" != "$(srctree)"; then \
36-
echo "Building source tarball is not possible outside the"; \
37-
echo "kernel source tree. Don't set KBUILD_OUTPUT, or use the"; \
38-
echo "binrpm-pkg or bindeb-pkg target instead."; \
38+
echo >&2; \
39+
echo >&2 " ERROR:"; \
40+
echo >&2 " Building source tarball is not possible outside the"; \
41+
echo >&2 " kernel source tree. Don't set KBUILD_OUTPUT, or use the"; \
42+
echo >&2 " binrpm-pkg or bindeb-pkg target instead."; \
43+
echo >&2; \
3944
false; \
4045
fi ; \
4146
$(srctree)/scripts/setlocalversion --save-scmversion; \
@@ -45,60 +50,61 @@ rm -f $(objtree)/.scmversion
4550

4651
# rpm-pkg
4752
# ---------------------------------------------------------------------------
48-
rpm-pkg rpm: FORCE
53+
rpm-pkg: FORCE
4954
$(MAKE) clean
5055
$(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
5156
$(call cmd,src_tar,$(KERNELPATH),kernel.spec)
52-
+rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz
57+
+rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz \
58+
--define='_smp_mflags %{nil}'
5359

5460
# binrpm-pkg
5561
# ---------------------------------------------------------------------------
5662
binrpm-pkg: FORCE
57-
$(MAKE) KBUILD_SRC=
63+
$(MAKE) -f $(srctree)/Makefile
5864
$(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
5965
+rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
6066
$(UTS_MACHINE) -bb $(objtree)/binkernel.spec
6167

6268
clean-files += $(objtree)/*.spec
6369

64-
# Deb target
65-
# ---------------------------------------------------------------------------
66-
quiet_cmd_builddeb = BUILDDEB
67-
cmd_builddeb = set -e; \
68-
test `id -u` = 0 || \
69-
test -n "$(KBUILD_PKG_ROOTCMD)" || { \
70-
which fakeroot >/dev/null 2>&1 && \
71-
KBUILD_PKG_ROOTCMD="fakeroot -u"; \
72-
} || { \
73-
echo; \
74-
echo "builddeb must be run as root (or using fakeroot)."; \
75-
echo "KBUILD_PKG_ROOTCMD is unset and fakeroot not found."; \
76-
echo "Try setting KBUILD_PKG_ROOTCMD to a command to acquire"; \
77-
echo "root privileges (e.g., 'fakeroot -u' or 'sudo')."; \
78-
false; \
79-
} && \
80-
\
81-
$$KBUILD_PKG_ROOTCMD $(CONFIG_SHELL) \
82-
$(srctree)/scripts/package/builddeb $@
83-
8470
deb-pkg: FORCE
8571
$(MAKE) clean
72+
$(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
8673
$(call cmd,src_tar,$(KDEB_SOURCENAME))
87-
$(MAKE) KBUILD_SRC=
88-
+$(call cmd,builddeb)
74+
origversion=$$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$$//');\
75+
mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz
76+
+dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -i.git -us -uc
8977

9078
bindeb-pkg: FORCE
91-
$(MAKE) KBUILD_SRC=
92-
+$(call cmd,builddeb)
79+
$(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
80+
+dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -b -nc -uc
81+
82+
intdeb-pkg: FORCE
83+
+$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb
9384

9485
clean-dirs += $(objtree)/debian/
9586

87+
# snap-pkg
88+
# ---------------------------------------------------------------------------
89+
snap-pkg: FORCE
90+
rm -rf $(objtree)/snap
91+
mkdir $(objtree)/snap
92+
$(MAKE) clean
93+
$(call cmd,src_tar,$(KERNELPATH))
94+
sed "s@KERNELRELEASE@$(KERNELRELEASE)@; \
95+
s@SRCTREE@$(shell realpath $(KERNELPATH).tar.gz)@" \
96+
$(srctree)/scripts/package/snapcraft.template > \
97+
$(objtree)/snap/snapcraft.yaml
98+
cd $(objtree)/snap && \
99+
snapcraft --target-arch=$(UTS_MACHINE)
100+
101+
clean-dirs += $(objtree)/snap/
96102

97103
# tarball targets
98104
# ---------------------------------------------------------------------------
99105
tar%pkg: FORCE
100-
$(MAKE) KBUILD_SRC=
101-
$(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@
106+
$(MAKE) -f $(srctree)/Makefile
107+
+$(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@
102108

103109
clean-dirs += $(objtree)/tar-install/
104110

@@ -137,6 +143,7 @@ help: FORCE
137143
@echo ' binrpm-pkg - Build only the binary kernel RPM package'
138144
@echo ' deb-pkg - Build both source and binary deb kernel packages'
139145
@echo ' bindeb-pkg - Build only the binary kernel deb package'
146+
@echo ' snap-pkg - Build only the binary kernel snap package (will connect to external hosts)'
140147
@echo ' tar-pkg - Build the kernel as an uncompressed tarball'
141148
@echo ' targz-pkg - Build the kernel as a gzip compressed tarball'
142149
@echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'

0 commit comments

Comments
 (0)