History

kbuild: make perf-tar*-src-pkg work without relying on git

Currently, perf-tar*-src-pkg only uses 'git archive', but it is better to make it work without relying on git. The file, HEAD, which saves the commit hash, will be included in the tarball only when the source tree is managed by git. The git tree is more precisely checked; it has been copied from scripts/setlocalversion.

Masahiro Yamada committed 3 years ago

Commit e0ca1671 parent e7853991 file · +64 −33Browse files

Unified · Split

scripts/Makefile.package+64−33
@@ -50,10 +50,25 @@ quiet_cmd_tar = TAR $@ · 49 unmodified lines
50 50
51tar-rootdir := $(srctree)51tar-rootdir := $(srctree)
52 52
53%.tar:
54 $(call cmd,tar)
55
53%.tar.gz: private tar-compress-opt := -I $(KGZIP)56%.tar.gz: private tar-compress-opt := -I $(KGZIP)
54%.tar.gz:57%.tar.gz:
55 $(call cmd,tar)58 $(call cmd,tar)
56 59
60%.tar.bz2: private tar-compress-opt := -I $(KBZIP2)
61%.tar.bz2:
62 $(call cmd,tar)
63
64%.tar.xz: private tar-compress-opt := -I $(XZ)
65%.tar.xz:
66 $(call cmd,tar)
67
68%.tar.zst: private tar-compress-opt := -I $(ZSTD)
69%.tar.zst:
70 $(call cmd,tar)
71
57# Linux source tarball72# Linux source tarball
58# ---------------------------------------------------------------------------73# ---------------------------------------------------------------------------
59 74
@@ -138,36 +153,52 @@ $(tar-pkgs): · 78 unmodified lines
138 $(MAKE) -f $(srctree)/Makefile153 $(MAKE) -f $(srctree)/Makefile
139 +$(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@154 +$(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@
140 155
141# perf-pkg - generate a source tarball with perf source156# perf-tar*-src-pkg - generate a source tarball with perf source
142# ---------------------------------------------------------------------------157# ---------------------------------------------------------------------------
143 158
144perf-tar=perf-$(KERNELVERSION)159perf-tar-src-pkg-tarball = perf-$(KERNELVERSION).$(1)
145 160perf-tar-src-pkg-phony = perf-$(subst .,,$(1))-src-pkg
146quiet_cmd_perf_tar = TAR161
147 cmd_perf_tar = \162quiet_cmd_stage_perf_src = STAGE $@
148git --git-dir=$(srctree)/.git archive --prefix=$(perf-tar)/ \163 cmd_stage_perf_src = \
149 HEAD^{tree} $$(cd $(srctree); \164 rm -rf $@; \
150 echo $$(cat tools/perf/MANIFEST)) \165 mkdir -p $@; \
151 -o $(perf-tar).tar; \166 tar -c -f - --exclude-from=$<_exclude -C $(srctree) --files-from=$(srctree)/tools/perf/MANIFEST | \
152mkdir -p $(perf-tar); \167 tar -x -f - -C $@
153git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD; \168
154(cd $(srctree)/tools/perf; \169.tmp_perf: .tmp_filelist
155util/PERF-VERSION-GEN $(CURDIR)/$(perf-tar)/); \170 $(call cmd,stage_perf_src)
156tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \171
157rm -r $(perf-tar); \172filechk_perf_head = \
158$(if $(findstring tar-src,$@),, \173 if test -z "$(git -C $(srctree) rev-parse --show-cdup 2>/dev/null)" && \
159$(if $(findstring bz2,$@),$(KBZIP2), \174 head=$$(git -C $(srctree) rev-parse --verify HEAD 2>/dev/null); then \
160$(if $(findstring gz,$@),$(KGZIP), \175 echo $$head; \
161$(if $(findstring xz,$@),$(XZ), \176 else \
162$(if $(findstring zst,$@),$(ZSTD), \177 echo "not a git tree"; \
163$(error unknown target $@))))) \178 fi
164 -f -9 $(perf-tar).tar)179
165 180.tmp_perf/HEAD: .tmp_perf FORCE
166perf-tar-pkgs := perf-tar-src-pkg perf-targz-src-pkg perf-tarbz2-src-pkg \181 $(call filechk,perf_head)
167 perf-tarxz-src-pkg perf-tarzst-src-pkg182
168PHONY += $(perf-tar-pkgs)183quiet_cmd_perf_version_file = GEN $@
169$(perf-tar-pkgs):184 cmd_perf_version_file = cd $(srctree)/tools/perf; util/PERF-VERSION-GEN $(dir $(abspath $@))
170 $(call cmd,perf_tar)185
186# PERF-VERSION-FILE and HEAD are independent, but this avoids updating the
187# timestamp of PERF-VERSION-FILE.
188# The best is to fix tools/perf/util/PERF-VERSION-GEN.
189.tmp_perf/PERF-VERSION-FILE: .tmp_perf/HEAD $(srctree)/tools/perf/util/PERF-VERSION-GEN
190 $(call cmd,perf_version_file)
191
192define perf-tar-src-pkg-rule
193PHONY += $(perf-tar-src-pkg-phony)
194$(perf-tar-src-pkg-phony): $(perf-tar-src-pkg-tarball)
195 @:
196
197$(perf-tar-src-pkg-tarball): private tar-rootdir := .tmp_perf
198$(perf-tar-src-pkg-tarball): .tmp_filelist .tmp_perf/HEAD .tmp_perf/PERF-VERSION-FILE
199endef
200
201$(foreach x, tar tar.gz tar.bz2 tar.xz tar.zst, $(eval $(call perf-tar-src-pkg-rule,$(x))))
171 202
172# Help text displayed when executing 'make help'203# Help text displayed when executing 'make help'
173# ---------------------------------------------------------------------------204# ---------------------------------------------------------------------------
@@ -186,11 +217,11 @@ help: · 12 unmodified lines
186 @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'217 @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
187 @echo ' tarxz-pkg - Build the kernel as a xz compressed tarball'218 @echo ' tarxz-pkg - Build the kernel as a xz compressed tarball'
188 @echo ' tarzst-pkg - Build the kernel as a zstd compressed tarball'219 @echo ' tarzst-pkg - Build the kernel as a zstd compressed tarball'
189 @echo ' perf-tar-src-pkg - Build $(perf-tar).tar source tarball'220 @echo ' perf-tar-src-pkg - Build the perf source tarball with no compression'
190 @echo ' perf-targz-src-pkg - Build $(perf-tar).tar.gz source tarball'221 @echo ' perf-targz-src-pkg - Build the perf source tarball with gzip compression'
191 @echo ' perf-tarbz2-src-pkg - Build $(perf-tar).tar.bz2 source tarball'222 @echo ' perf-tarbz2-src-pkg - Build the perf source tarball with bz2 compression'
192 @echo ' perf-tarxz-src-pkg - Build $(perf-tar).tar.xz source tarball'223 @echo ' perf-tarxz-src-pkg - Build the perf source tarball with xz compression'
193 @echo ' perf-tarzst-src-pkg - Build $(perf-tar).tar.zst source tarball'224 @echo ' perf-tarzst-src-pkg - Build the perf source tarball with zst compression'
194 225
195PHONY += FORCE226PHONY += FORCE
196FORCE:227FORCE: