mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Nicolas Schier <nicolas@fjasle.eu>,
	Ben Hutchings <ben@decadent.org.uk>,
	Masahiro Yamada <masahiroy@kernel.org>
Subject: [PATCH v5 7/7] kbuild: make perf-tar*-src-pkg work without relying on git
Date: Sat, 11 Feb 2023 03:18:28 +0900	[thread overview]
Message-ID: <20230210181828.124765-7-masahiroy@kernel.org> (raw)
In-Reply-To: <20230210181828.124765-1-masahiroy@kernel.org>

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@kernel.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 > $@/HEAD; \
+	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


      parent reply	other threads:[~2023-02-10 18:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-10 18:18 [PATCH v5 1/7] kbuild: add a tool to list files ignored by git Masahiro Yamada
2023-02-10 18:18 ` [PATCH v5 2/7] kbuild: deb-pkg: create source package without cleaning Masahiro Yamada
2023-02-10 18:18 ` [PATCH v5 3/7] kbuild: rpm-pkg: build binary packages from source rpm Masahiro Yamada
2023-02-10 18:18 ` [PATCH v5 4/7] kbuild: srcrpm-pkg: create source package without cleaning Masahiro Yamada
2023-02-10 18:18 ` [PATCH v5 5/7] kbuild: deb-pkg: hide KDEB_SOURCENAME from Makefile Masahiro Yamada
2023-02-10 18:18 ` [PATCH v5 6/7] kbuild: deb-pkg: switch over to source format 3.0 (quilt) Masahiro Yamada
2023-02-10 18:18 ` Masahiro Yamada [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230210181828.124765-7-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=ben@decadent.org.uk \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nicolas@fjasle.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®