Since commit 05e96e96a315 ("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.
Unified · Split
| @@ -57,16 +57,23 @@ check-git: · 56 unmodified lines | ||
| 57 | 57 | false; \ |
| 58 | 58 | fi |
| 59 | 59 | |
| 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 | + | |
| 60 | 65 | quiet_cmd_archive = ARCHIVE $@ |
| 61 | − cmd_archive = git -C $(srctree) archive \ | |
| 66 | + cmd_archive = git -C $(srctree) $(git-config-tar$(suffix $@)) archive \ | |
| 62 | 67 | --output=$$(realpath $@) --prefix=$(basename $@)/ $(archive-args) |
| 63 | 68 | |
| 64 | 69 | # Linux source tarball |
| 65 | 70 | # --------------------------------------------------------------------------- |
| 66 | 71 | |
| 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 | |
| 70 | 77 | $(call if_changed,archive) |
| 71 | 78 | |
| 72 | 79 | # rpm-pkg |
| @@ -186,9 +193,12 @@ perf-archive-args = --add-file=$$(realpath $(word 2, $^)) \ · 113 unmodified lines | ||
| 186 | 193 | --add-file=$$(realpath $(word 3, $^)) \ |
| 187 | 194 | $$(cat $(word 2, $^))^{tree} $$(cat $<) |
| 188 | 195 | |
| 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 | |
| 192 | 202 | $(call if_changed,archive) |
| 193 | 203 | |
| 194 | 204 | PHONY += perf-tar-src-pkg |