lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20230210181828.124765-7-masahiroy@kernel.org>
Date:   Sat, 11 Feb 2023 03:18:28 +0900
From:   Masahiro Yamada <masahiroy@...nel.org>
To:     linux-kbuild@...r.kernel.org
Cc:     linux-kernel@...r.kernel.org,
        Nathan Chancellor <nathan@...nel.org>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Nicolas Schier <nicolas@...sle.eu>,
        Ben Hutchings <ben@...adent.org.uk>,
        Masahiro Yamada <masahiroy@...nel.org>
Subject: [PATCH v5 7/7] 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.

Signed-off-by: Masahiro Yamada <masahiroy@...nel.org>
---

Changes in v5:
  - New patch

 scripts/Makefile.package | 67 ++++++++++++++++++++++++----------------
 1 file changed, 40 insertions(+), 27 deletions(-)

diff --git a/scripts/Makefile.package b/scripts/Makefile.package
index 55be31d0e040..e676d14fef23 100644
--- a/scripts/Makefile.package
+++ b/scripts/Makefile.package
@@ -122,40 +122,53 @@ quiet_cmd_tar = TAR     $@
 
 tar-rootdir := $(srctree)
 
+%.tar: compress-opt :=
+%.tar: .tmp_filelist
+	$(call cmd,tar)
+
 %.tar.gz: compress-opt := -I $(KGZIP)
 %.tar.gz: .tmp_filelist
 	$(call cmd,tar)
 
+%.tar.bz2: compress-opt := -I $(KBZIP2)
+%.tar.bz2: .tmp_filelist
+	$(call cmd,tar)
+
+%.tar.xz: compress-opt := -I $(XZ)
+%.tar.xz: .tmp_filelist
+	$(call cmd,tar)
+
+%.tar.zst: compress-opt := -I $(ZSTD)
+%.tar.zst: .tmp_filelist
+	$(call cmd,tar)
+
 # perf-pkg - generate a source tarball with perf source
 # ---------------------------------------------------------------------------
 
-perf-tar=perf-$(KERNELVERSION)
-
-quiet_cmd_perf_tar = TAR
-      cmd_perf_tar = \
-git --git-dir=$(srctree)/.git archive --prefix=$(perf-tar)/         \
-	HEAD^{tree} $$(cd $(srctree);                               \
-		       echo $$(cat tools/perf/MANIFEST)) \
-	-o $(perf-tar).tar;                                         \
-mkdir -p $(perf-tar);                                               \
-git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD;    \
-(cd $(srctree)/tools/perf;                                          \
-util/PERF-VERSION-GEN $(CURDIR)/$(perf-tar)/);              \
-tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \
-rm -r $(perf-tar);                                                  \
-$(if $(findstring tar-src,$@),,                                     \
-$(if $(findstring bz2,$@),$(KBZIP2),                                 \
-$(if $(findstring gz,$@),$(KGZIP),                                  \
-$(if $(findstring xz,$@),$(XZ),                                     \
-$(if $(findstring zst,$@),$(ZSTD),                                  \
-$(error unknown target $@)))))                                      \
-	-f -9 $(perf-tar).tar)
-
-perf-tar-pkgs := perf-tar-src-pkg perf-targz-src-pkg perf-tarbz2-src-pkg \
-		 perf-tarxz-src-pkg perf-tarzst-src-pkg
-PHONY += $(perf-tar-pkgs)
-$(perf-tar-pkgs):
-	$(call cmd,perf_tar)
+perf-tar = perf-$(KERNELVERSION)
+
+perf-tar-phony = perf-$(subst .,,$(1))-src-pkg
+
+.tmp_perf: FORCE
+	$(Q)rm -rf $@
+	$(Q)mkdir $@
+	$(Q)tar -c -f - -C $(srctree) --files-from=$(srctree)/tools/perf/MANIFEST | tar -x -f - -C $@
+	$(Q)if test -z "$(git -C $(srctree) rev-parse --show-cdup 2>/dev/null)" && \
+	       head=$$(git -C $(srctree) rev-parse --verify HEAD 2>/dev/null); then \
+		echo $$head > $@...AD; \
+	fi
+	$(Q)cd $(srctree)/tools/perf; util/PERF-VERSION-GEN $(abspath $@)/
+
+define perf-pkg-rule
+PHONY += $(perf-tar-phony)
+$(perf-tar-phony): $(perf-tar).$(1)
+	@:
+
+$(perf-tar).$(1): private tar-rootdir := .tmp_perf
+$(perf-tar).$(1): | .tmp_perf
+endef
+
+$(foreach x, tar tar.gz tar.bz2 tar.xz tar.zst, $(eval $(call perf-pkg-rule,$(x))))
 
 # Help text displayed when executing 'make help'
 # ---------------------------------------------------------------------------
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ