git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 7/8] Makefile: don't delete dist tarballs directly by name
@ 2020-11-05 21:09 Ramsay Jones
  2020-11-05 22:01 ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Ramsay Jones @ 2020-11-05 21:09 UTC (permalink / raw)
  To: GIT Mailing-list; +Cc: Junio C Hamano


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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-11-06 20:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-05 21:09 [PATCH 7/8] Makefile: don't delete dist tarballs directly by name Ramsay Jones
2020-11-05 22:01 ` Junio C Hamano
2020-11-05 23:05   ` Junio C Hamano
2020-11-06  1:44     ` Ramsay Jones
2020-11-06  1:58       ` Junio C Hamano
2020-11-06  2:39         ` Ramsay Jones
2020-11-06 17:53           ` Junio C Hamano
2020-11-06 20:23             ` Ramsay Jones
2020-11-06  1:36   ` Ramsay Jones

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).