From e6447b8a9ffd354549827e90e8bec007e703374d Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sun, 11 Feb 2024 23:58:42 +0100 Subject: [PATCH v3 1/2] make dist uses git archive Discussion: https://www.postgresql.org/message-id/flat/40e80f77-a294-4f29-a16f-e21bc7bc75fc%40eisentraut.org --- GNUmakefile.in | 34 ++++++++++++--------------------- meson.build | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 22 deletions(-) diff --git a/GNUmakefile.in b/GNUmakefile.in index eba569e930e..73560ea7d0a 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -87,29 +87,19 @@ update-unicode: | submake-generated-headers submake-libpgport distdir = postgresql-$(VERSION) dummy = =install= +GIT = git + dist: $(distdir).tar.gz $(distdir).tar.bz2 - rm -rf $(distdir) - -$(distdir).tar: distdir - $(TAR) chf $@ $(distdir) - -.INTERMEDIATE: $(distdir).tar - -distdir-location: - @echo $(distdir) - -distdir: - rm -rf $(distdir)* $(dummy) - for x in `cd $(top_srcdir) && find . \( -name CVS -prune \) -o \( -name .git -prune \) -o -print`; do \ - file=`expr X$$x : 'X\./\(.*\)'`; \ - if test -d "$(top_srcdir)/$$file" ; then \ - mkdir "$(distdir)/$$file" && chmod 777 "$(distdir)/$$file"; \ - else \ - ln "$(top_srcdir)/$$file" "$(distdir)/$$file" >/dev/null 2>&1 \ - || cp "$(top_srcdir)/$$file" "$(distdir)/$$file"; \ - fi || exit; \ - done - $(MAKE) -C $(distdir) distclean + +.PHONY: check-dirty-index +check-dirty-index: + $(GIT) -C $(srcdir) diff-index --quiet HEAD + +$(distdir).tar.gz: check-dirty-index + $(GIT) -C $(srcdir) -c core.autocrlf=false archive --format tar.gz --prefix $(distdir)/ HEAD -o $(abs_top_builddir)/$@ + +$(distdir).tar.bz2: check-dirty-index + $(GIT) -C $(srcdir) -c core.autocrlf=false -c tar.tar.bz2.command='$(BZIP2) -c' archive --format tar.bz2 --prefix $(distdir)/ HEAD -o $(abs_top_builddir)/$@ distcheck: dist rm -rf $(dummy) diff --git a/meson.build b/meson.build index 8ed51b6aae8..5d68c66ac0a 100644 --- a/meson.build +++ b/meson.build @@ -3352,6 +3352,58 @@ run_target('help', +############################################################### +# Distribution archive +############################################################### + +git = find_program('git', required: false, native: true) +bzip2 = find_program('bzip2', required: false, native: true) + +distdir = meson.project_name() + '-' + meson.project_version() + +check_dirty_index = run_target('check-dirty-index', + command: [git, '-C', '@SOURCE_ROOT@', 'diff-index', '--quiet', 'HEAD']) + +tar_gz = custom_target('tar.gz', + build_always_stale: true, + command: [git, '-C', '@SOURCE_ROOT@', + '-c', 'core.autocrlf=false', + 'archive', + '--format', 'tar.gz', + '--prefix', distdir + '/', + '-o', join_paths(meson.build_root(), '@OUTPUT@'), + 'HEAD', '.'], + install: false, + output: distdir + '.tar.gz', +) + +if bzip2.found() + tar_bz2 = custom_target('tar.bz2', + build_always_stale: true, + command: [git, '-C', '@SOURCE_ROOT@', + '-c', 'core.autocrlf=false', + '-c', 'tar.tar.bz2.command="' + bzip2.path() + '" -c', + 'archive', + '--format', 'tar.bz2', + '--prefix', distdir + '/', + '-o', join_paths(meson.build_root(), '@OUTPUT@'), + 'HEAD', '.'], + install: false, + output: distdir + '.tar.bz2', + ) +else + tar_bz2 = custom_target('tar.bz2', + command: ['sh', '-c', 'exit 1'], + output: distdir + '.tar.bz2', + ) +endif + +# FIXME: would like to add check_dirty_index here, broken(?) before +# meson 0.60.0 +alias_target('pgdist', [tar_gz, tar_bz2]) + + + ############################################################### # The End, The End, My Friend ############################################################### base-commit: ce571434ae7027462565706236a0c6fbdf603734 -- 2.43.1