Skip to content

Commit 1d29b4c

Browse files
committed
kbuild: deb-pkg: add KDEB_SOURCE_COMPRESS to specify source compression
Add KDEB_SOURCE_COMPRESS to specify the compression for the orig and debian tarballs. (cf. the existing KDEB_COMPRESS is used to specify the compression for binary packages.) Supported algorithms are gzip, bzip2, lzma, and xz, all of which are supported by dpkg-source. The current default is gzip. You can change it via the environment variable, for example, 'KDEB_SOURCE_COMPRESS=xz make deb-pkg'. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
1 parent 31f735c commit 1d29b4c

1 file changed

Lines changed: 27 additions & 8 deletions

File tree

scripts/Makefile.package

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,25 @@ check-git:
4141
false; \
4242
fi
4343

44-
git-config-tar.gz = -c tar.tar.gz.command="$(KGZIP)"
45-
git-config-tar.bz2 = -c tar.tar.bz2.command="$(KBZIP2)"
46-
git-config-tar.xz = -c tar.tar.xz.command="$(XZ)"
47-
git-config-tar.zst = -c tar.tar.zst.command="$(ZSTD)"
44+
git-config-tar.gz = -c tar.tar.gz.command="$(KGZIP)"
45+
git-config-tar.bz2 = -c tar.tar.bz2.command="$(KBZIP2)"
46+
git-config-tar.lzma = -c tar.tar.lzma.command="$(LZMA)"
47+
git-config-tar.xz = -c tar.tar.xz.command="$(XZ)"
48+
git-config-tar.zst = -c tar.tar.zst.command="$(ZSTD)"
4849

4950
quiet_cmd_archive = ARCHIVE $@
5051
cmd_archive = git -C $(srctree) $(git-config-tar$(suffix $@)) archive \
5152
--output=$$(realpath $@) --prefix=$(basename $@)/ $(archive-args)
5253

54+
suffix-gzip := .gz
55+
suffix-bzip2 := .bz2
56+
suffix-lzma := .lzma
57+
suffix-xz := .xz
58+
5359
# Linux source tarball
5460
# ---------------------------------------------------------------------------
5561

56-
linux-tarballs := $(addprefix linux, .tar.gz)
62+
linux-tarballs := $(addprefix linux, .tar.gz .tar.bz2 .tar.lzma .tar.xz)
5763

5864
targets += $(linux-tarballs)
5965
$(linux-tarballs): archive-args = $$(cat $<)
@@ -88,6 +94,19 @@ binrpm-pkg:
8894
# deb-pkg srcdeb-pkg bindeb-pkg
8995
# ---------------------------------------------------------------------------
9096

97+
KDEB_SOURCE_COMPRESS ?= gzip
98+
99+
supported-deb-source-compress := gzip bzip2 lzma xz
100+
101+
PHONY += linux.tar.unsupported-deb-src-compress
102+
linux.tar.unsupported-deb-src-compress:
103+
@echo "error: KDEB_SOURCE_COMPRESS=$(KDEB_SOURCE_COMPRESS) is not supported. The supported values are: $(supported-deb-source-compress)" >&2
104+
@false
105+
106+
debian-orig-suffix := \
107+
$(strip $(if $(filter $(supported-deb-source-compress), $(KDEB_SOURCE_COMPRESS)), \
108+
$(suffix-$(KDEB_SOURCE_COMPRESS)),.unsupported-deb-src-compress))
109+
91110
quiet_cmd_debianize = GEN $@
92111
cmd_debianize = $(srctree)/scripts/package/mkdebian $(mkdebian-opts)
93112

@@ -97,9 +116,9 @@ debian: FORCE
97116
PHONY += debian-orig
98117
debian-orig: private source = $(shell dpkg-parsechangelog -S Source)
99118
debian-orig: private version = $(shell dpkg-parsechangelog -S Version | sed 's/-[^-]*$$//')
100-
debian-orig: private orig-name = $(source)_$(version).orig.tar.gz
119+
debian-orig: private orig-name = $(source)_$(version).orig.tar$(debian-orig-suffix)
101120
debian-orig: mkdebian-opts = --need-source
102-
debian-orig: linux.tar.gz debian
121+
debian-orig: linux.tar$(debian-orig-suffix) debian
103122
$(Q)if [ "$(df --output=target .. 2>/dev/null)" = "$(df --output=target $< 2>/dev/null)" ]; then \
104123
ln -f $< ../$(orig-name); \
105124
else \
@@ -120,7 +139,7 @@ deb-pkg srcdeb-pkg bindeb-pkg:
120139
+$(strip dpkg-buildpackage \
121140
--build=$(build-type) --no-pre-clean --unsigned-changes \
122141
$(if $(findstring source, $(build-type)), \
123-
--unsigned-source) \
142+
--unsigned-source --compression=$(KDEB_SOURCE_COMPRESS)) \
124143
$(if $(findstring binary, $(build-type)), \
125144
-r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch), \
126145
--no-check-builddeps) \

0 commit comments

Comments
 (0)