Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 619bc23

Browse files
committed
make dist uses git archive
This changes "make dist" to directly use "git archive", rather than the custom shell script it currently runs. This is to make the creation of the distribution tarball more directly traceable to the git repository. That is why we removed the "make distprep" step. "make dist" continues to produce a .gz and a .bz2 tarball as before. The archives produced this way are deterministic and reproducible, meaning for a given commit the result file should always be bit-for-bit identical. The exception is that if you use a git version older than 2.38.0, gzip records the platform in the archive, so you'd get a different output on Windows vs. macOS vs. "UNIX" (everything else). In git 2.38.0, this was changed so that everything is recorded as "UNIX" now. This is just something to keep in mind. This issue is specific to the gzip format, it does not affect other compression formats. Meson has its own distribution building command (meson dist), but we are not using that at this point. The main problem is that, the way they have implemented it, it is not deterministic in the above sense. Also, we want a "make" version for the time being. But the target name "dist" in meson is reserved for that reason, so we call the custom target "pgdist" (so call something like "meson compile -C build pgdist"). Reviewed-by: Tristan Partin <tristan@neon.tech> Discussion: https://www.postgresql.org/message-id/flat/40e80f77-a294-4f29-a16f-e21bc7bc75fc%40eisentraut.org
1 parent 80d5d49 commit 619bc23

File tree

2 files changed

+79
-18
lines changed

2 files changed

+79
-18
lines changed

GNUmakefile.in

+14-18
Original file line numberDiff line numberDiff line change
@@ -87,29 +87,25 @@ update-unicode: | submake-generated-headers submake-libpgport
8787
distdir = postgresql-$(VERSION)
8888
dummy = =install=
8989

90-
dist: $(distdir).tar.gz $(distdir).tar.bz2
91-
rm -rf $(distdir)
90+
GIT = git
9291

93-
$(distdir).tar: distdir
94-
$(TAR) chf $@ $(distdir)
92+
dist: $(distdir).tar.gz $(distdir).tar.bz2
9593

96-
.INTERMEDIATE: $(distdir).tar
94+
.PHONY: $(distdir).tar.gz $(distdir).tar.bz2
9795

9896
distdir-location:
9997
@echo $(distdir)
10098

101-
distdir:
102-
rm -rf $(distdir)* $(dummy)
103-
for x in `cd $(top_srcdir) && find . \( -name CVS -prune \) -o \( -name .git -prune \) -o -print`; do \
104-
file=`expr X$$x : 'X\./\(.*\)'`; \
105-
if test -d "$(top_srcdir)/$$file" ; then \
106-
mkdir "$(distdir)/$$file" && chmod 777 "$(distdir)/$$file"; \
107-
else \
108-
ln "$(top_srcdir)/$$file" "$(distdir)/$$file" >/dev/null 2>&1 \
109-
|| cp "$(top_srcdir)/$$file" "$(distdir)/$$file"; \
110-
fi || exit; \
111-
done
112-
$(MAKE) -C $(distdir) distclean
99+
# Note: core.autocrlf=false is needed to avoid line-ending conversion
100+
# in case the environment has a different setting. Without this, a
101+
# tarball created on Windows might be different than on, and unusable
102+
# on, Unix machines.
103+
104+
$(distdir).tar.gz:
105+
$(GIT) -C $(srcdir) -c core.autocrlf=false archive --format tar.gz -9 --prefix $(distdir)/ HEAD -o $(abs_top_builddir)/$@
106+
107+
$(distdir).tar.bz2:
108+
$(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)/$@
113109

114110
distcheck: dist
115111
rm -rf $(dummy)
@@ -135,4 +131,4 @@ headerscheck: submake-generated-headers
135131
cpluspluscheck: submake-generated-headers
136132
$(top_srcdir)/src/tools/pginclude/headerscheck --cplusplus $(top_srcdir) $(abs_top_builddir)
137133

138-
.PHONY: dist distdir distcheck docs install-docs world check-world install-world installcheck-world headerscheck cpluspluscheck
134+
.PHONY: dist distcheck docs install-docs world check-world install-world installcheck-world headerscheck cpluspluscheck

meson.build

+65
Original file line numberDiff line numberDiff line change
@@ -3359,6 +3359,71 @@ run_target('help',
33593359

33603360

33613361

3362+
###############################################################
3363+
# Distribution archive
3364+
###############################################################
3365+
3366+
# Meson has its own distribution building command (meson dist), but we
3367+
# are not using that at this point. The main problem is that, the way
3368+
# they have implemented it, it is not deterministic. Also, we want it
3369+
# to be equivalent to the "make" version for the time being. But the
3370+
# target name "dist" in meson is reserved for that reason, so we call
3371+
# the custom target "pgdist".
3372+
3373+
git = find_program('git', required: false, native: true, disabler: true)
3374+
bzip2 = find_program('bzip2', required: false, native: true)
3375+
3376+
distdir = meson.project_name() + '-' + meson.project_version()
3377+
3378+
# Note: core.autocrlf=false is needed to avoid line-ending conversion
3379+
# in case the environment has a different setting. Without this, a
3380+
# tarball created on Windows might be different than on, and unusable
3381+
# on, Unix machines.
3382+
3383+
tar_gz = custom_target('tar.gz',
3384+
build_always_stale: true,
3385+
command: [git, '-C', '@SOURCE_ROOT@',
3386+
'-c', 'core.autocrlf=false',
3387+
'archive',
3388+
'--format', 'tar.gz',
3389+
'-9',
3390+
'--prefix', distdir + '/',
3391+
'-o', join_paths(meson.build_root(), '@OUTPUT@'),
3392+
'HEAD', '.'],
3393+
output: distdir + '.tar.gz',
3394+
)
3395+
3396+
if bzip2.found()
3397+
tar_bz2 = custom_target('tar.bz2',
3398+
build_always_stale: true,
3399+
command: [git, '-C', '@SOURCE_ROOT@',
3400+
'-c', 'core.autocrlf=false',
3401+
'-c', 'tar.tar.bz2.command="@0@" -c'.format(bzip2.path()),
3402+
'archive',
3403+
'--format', 'tar.bz2',
3404+
'--prefix', distdir + '/',
3405+
'-o', join_paths(meson.build_root(), '@OUTPUT@'),
3406+
'HEAD', '.'],
3407+
output: distdir + '.tar.bz2',
3408+
)
3409+
else
3410+
tar_bz2 = custom_target('tar.bz2',
3411+
command: [perl, '-e', 'exit 1'],
3412+
output: distdir + '.tar.bz2',
3413+
)
3414+
endif
3415+
3416+
alias_target('pgdist', [tar_gz, tar_bz2])
3417+
3418+
# Make the standard "dist" command fail, to prevent accidental use.
3419+
# But not if we are in a subproject, in case the parent project wants to
3420+
# create a dist using the standard Meson command.
3421+
if not meson.is_subproject()
3422+
meson.add_dist_script(perl, '-e', 'exit 1')
3423+
endif
3424+
3425+
3426+
33623427
###############################################################
33633428
# The End, The End, My Friend
33643429
###############################################################

0 commit comments

Comments
 (0)