Skip to content

Commit f8d94c4

Browse files
committed
kbuild: do not create intermediate *.tar for source tarballs
Since commit 05e96e9 ("kbuild: use git-archive for source package creation"), a source tarball is created in two steps; create *.tar file then compress it. I split the compression as a separate rule because I just thought 'git archive' supported only gzip. For other compression algorithms, I could pipe the two commands: $ git archive HEAD | xz > linux.tar.xz I read git-archive(1) carefully, and I realized GIT had provided a more elegant way: $ git -c tar.tar.xz.command=xz archive -o linux.tar.xz HEAD This commit uses 'tar.tar.*.command' configuration to specify the compression backend so we can compress a source tarball on-the-fly. GIT commit 767cf4579f0e ("archive: implement configurable tar filters") is more than a decade old, so it should be available on almost all build environments. Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]>
1 parent f6d8283 commit f8d94c4

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

scripts/Makefile.package

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,23 @@ check-git:
5757
false; \
5858
fi
5959

60+
git-config-tar.gz = -c tar.tar.gz.command="$(KGZIP)"
61+
git-config-tar.bz2 = -c tar.tar.bz2.command="$(KBZIP2)"
62+
git-config-tar.xz = -c tar.tar.xz.command="$(XZ)"
63+
git-config-tar.zst = -c tar.tar.zst.command="$(ZSTD)"
64+
6065
quiet_cmd_archive = ARCHIVE $@
61-
cmd_archive = git -C $(srctree) archive \
66+
cmd_archive = git -C $(srctree) $(git-config-tar$(suffix $@)) archive \
6267
--output=$$(realpath $@) --prefix=$(basename $@)/ $(archive-args)
6368

6469
# Linux source tarball
6570
# ---------------------------------------------------------------------------
6671

67-
targets += linux.tar
68-
linux.tar: archive-args = $$(cat $<)
69-
linux.tar: .tmp_HEAD FORCE
72+
linux-tarballs := $(addprefix linux, .tar.gz)
73+
74+
targets += $(linux-tarballs)
75+
$(linux-tarballs): archive-args = $$(cat $<)
76+
$(linux-tarballs): .tmp_HEAD FORCE
7077
$(call if_changed,archive)
7178

7279
# rpm-pkg
@@ -186,9 +193,12 @@ perf-archive-args = --add-file=$$(realpath $(word 2, $^)) \
186193
--add-file=$$(realpath $(word 3, $^)) \
187194
$$(cat $(word 2, $^))^{tree} $$(cat $<)
188195

189-
targets += perf-$(KERNELVERSION).tar
190-
perf-$(KERNELVERSION).tar: archive-args = $(perf-archive-args)
191-
perf-$(KERNELVERSION).tar: tools/perf/MANIFEST .tmp_perf/HEAD .tmp_perf/PERF-VERSION-FILE FORCE
196+
197+
perf-tarballs := $(addprefix perf-$(KERNELVERSION), .tar .tar.gz .tar.bz2 .tar.xz .tar.zst)
198+
199+
targets += $(perf-tarballs)
200+
$(perf-tarballs): archive-args = $(perf-archive-args)
201+
$(perf-tarballs): tools/perf/MANIFEST .tmp_perf/HEAD .tmp_perf/PERF-VERSION-FILE FORCE
192202
$(call if_changed,archive)
193203

194204
PHONY += perf-tar-src-pkg

0 commit comments

Comments
 (0)