git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 7/8] Makefile: don't delete dist tarballs directly by name

From
Ramsay Jones <ramsay@ramsayjones.plus.com>
Date
Nov 5, 2020, 21:09 UTC
Message-ID
<48fdd198-93ad-7282-27e6-9a0c6de93067@ramsayjones.plus.com>

A future patch requires the 'clean' target not to depend, either directly or indirectly, on the $(GIT_VERSION) variable. However, the distribution tarballs, $(GIT_TARNAME).tar.gz, $(htmldocs).tar.gz and $(manpages).tar.gz, all depend on $(GIT_VERSION). The 'clean' target attempts to remove these tarballs by name and so has the unwanted dependency.

The first attempt to remove this dependency involved creating the distribution tarballs in a new top-level directory (e.g. 'dist-tars/'), that didn't reference the version number, and could be simply removed in the 'clean' target. Unfortunately, this could lead to breaking an unknown number of scripts for an unknown number of developers. (This actually breaks one of my own scripts!). Despite this being my preferred solution, I had to abandon this approach, since I don't know what problems it may cause.

The second attempt involved using a wildcard pattern, in place of the $(GIT_VERSION) variable, in the distribution tarball filenames. This also proved to be an inadequate solution, no matter how elaborate the pattern became, because it was always possible that it could lead to the removal of some '*.tar.gz' file that would, otherwise, not have been removed (eg. git-2.29.0-saved-build.tar.gz).

Also, note that the current 'clean' target requires that you do not move the current branch away from the commit you were on, when creating the distribution tarballs, before issuing the 'make clean'. If you do so, then you will find that the tarballs are not removed:

  $ git checkout nclean
  ...
  $ make dist
  ...
  $ ls *.tar.gz
  git-2.29.0.6.g8255a76caf.tar.gz
  $
  $ git checkout master
  Switched to branch 'master'
  Your branch is up to date with 'origin/master'.
  $ make clean
  ...
  rm -f git-2.29.2.154.g8a58376a31.tar.gz
  rm -f git-htmldocs-2.29.2.154.g8a58376a31.tar.gz git-manpages-2.29.2.154.g8a58376a31.tar.gz
  ...
  $
  $ ls *.tar.gz
  git-2.29.0.6.g8255a76caf.tar.gz
  $

[I always find the documentation tarballs of the last release intact when I am just about to create the new tarballs for this release. This means that I invariably remove them by hand.]

In order to remove the version dependency, append the name of each distribution tarball created, in the 'dist' and 'doc-dist' targets, to a file ('dist-tars'). Then in the 'clean' target, simply iterate through the names in this file, if any, removing them as we go. (Not forgetting to clean up the 'dist-tars' file as well).

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
---
 .gitignore |  1 +
 Makefile   | 11 +++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/.gitignore b/.gitignore
index 6232d33924..425b8cc2a4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -191,6 +191,7 @@
 /gitweb/static/gitweb.min.*
 /config-list.h
 /command-list.h
+/dist-tars
 *.tar.gz
 *.dsc
 *.deb
diff --git a/Makefile b/Makefile
index 90e91a2185..bc9ce28bc3 100644
--- a/Makefile
+++ b/Makefile
@@ -3083,6 +3083,7 @@ dist: git-archive$(X) configure
 		--prefix=$(GIT_TARNAME)/ HEAD^{tree} > $(GIT_TARNAME).tar
 	@$(RM) -r .dist-tmp-dir
 	gzip -f -9 $(GIT_TARNAME).tar
+	@echo $(GIT_TARNAME).tar.gz >>dist-tars
 
 rpm::
 	@echo >&2 "Use distro packaged sources to run rpmbuild"
@@ -3112,6 +3113,7 @@ dist-doc:
 	$(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc
 	cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar $(TAR_DIST_EXTRA_OPTS) .
 	gzip -n -9 -f $(htmldocs).tar
+	@echo $(htmldocs).tar.gz >>dist-tars
 	:
 	$(RM) -r .doc-tmp-dir
 	mkdir -p .doc-tmp-dir/man1 .doc-tmp-dir/man5 .doc-tmp-dir/man7
@@ -3122,6 +3124,7 @@ dist-doc:
 		install
 	cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar $(TAR_DIST_EXTRA_OPTS) .
 	gzip -n -9 -f $(manpages).tar
+	@echo $(manpages).tar.gz >>dist-tars
 	$(RM) -r .doc-tmp-dir
 
 ### Cleaning rules
@@ -3151,8 +3154,12 @@ clean: profile-clean coverage-clean cocciclean
 	$(RM) -r po/build/
 	$(RM) *.pyc *.pyo */*.pyc */*.pyo $(GENERATED_H) $(ETAGS_TARGET) tags cscope*
 	$(RM) -r .dist-tmp-dir .doc-tmp-dir
-	$(RM) $(GIT_TARNAME).tar.gz
-	$(RM) $(htmldocs).tar.gz $(manpages).tar.gz
+	@if test -s dist-tars; then \
+		for i in $$(cat dist-tars); do \
+			$(RM) $$i; \
+		done \
+	fi
+	$(RM) dist-tars
 	$(MAKE) -C Documentation/ clean
 	$(RM) Documentation/GIT-EXCLUDED-PROGRAMS
 ifndef NO_PERL
-- 
2.29.0
Next: Junio C Hamano
Message 1 of 9 in “Makefile: don't delete dist tarballs directly by name”
  1. 7/8 Makefile: don't delete dist tarballs directly by nameRamsay Jones, Nov 5, 2020
  2. Junio C HamanoNov 5, 2020
  3. Junio C HamanoNov 5, 2020
  4. Ramsay JonesNov 6, 2020
  5. Junio C HamanoNov 6, 2020
  6. Ramsay JonesNov 6, 2020
  7. Junio C HamanoNov 6, 2020
  8. Ramsay JonesNov 6, 2020
  9. Ramsay JonesNov 6, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.