Allow selecting the git revision to be packaged by "make dist".

Commit 619bc23a1 changed "make dist" to invoke "git archive",
but hard-wired the call to specify that the HEAD revision should
be packaged.  Our tarball building process needs to be able to
specify which git commit to package (notably, for packaging
back branches).  While we could make that work with some hackery
to operate in detached-HEAD state, it's a lot nicer just to expose
git archive's ability to specify what to package.  Hence, invent
a new make variable PG_GIT_REVISION.  This is undocumented, but
so is "make dist".

Also make corresponding changes in the meson scripts.  We have no
near-term intention of using that for package building, but it
will likely happen eventually, so stay prepared.

Discussion: https://postgr.es/m/3552543.1713909947@sss.pgh.pa.us
This commit is contained in:
Tom Lane 2024-05-03 11:08:50 -04:00
parent a42fc1c903
commit 01df147634
3 changed files with 12 additions and 4 deletions

View File

@ -87,6 +87,9 @@ update-unicode: | submake-generated-headers submake-libpgport
distdir = postgresql-$(VERSION) distdir = postgresql-$(VERSION)
dummy = =install= dummy = =install=
# git revision to be packaged
PG_GIT_REVISION = HEAD
GIT = git GIT = git
dist: $(distdir).tar.gz $(distdir).tar.bz2 dist: $(distdir).tar.gz $(distdir).tar.bz2
@ -102,10 +105,10 @@ distdir-location:
# on, Unix machines. # on, Unix machines.
$(distdir).tar.gz: $(distdir).tar.gz:
$(GIT) -C $(srcdir) -c core.autocrlf=false archive --format tar.gz -9 --prefix $(distdir)/ HEAD -o $(abs_top_builddir)/$@ $(GIT) -C $(srcdir) -c core.autocrlf=false archive --format tar.gz -9 --prefix $(distdir)/ $(PG_GIT_REVISION) -o $(abs_top_builddir)/$@
$(distdir).tar.bz2: $(distdir).tar.bz2:
$(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)/$@ $(GIT) -C $(srcdir) -c core.autocrlf=false -c tar.tar.bz2.command='$(BZIP2) -c' archive --format tar.bz2 --prefix $(distdir)/ $(PG_GIT_REVISION) -o $(abs_top_builddir)/$@
distcheck: dist distcheck: dist
rm -rf $(dummy) rm -rf $(dummy)

View File

@ -3469,6 +3469,8 @@ bzip2 = find_program('bzip2', required: false, native: true)
distdir = meson.project_name() + '-' + meson.project_version() distdir = meson.project_name() + '-' + meson.project_version()
pg_git_revision = get_option('PG_GIT_REVISION')
# Note: core.autocrlf=false is needed to avoid line-ending conversion # Note: core.autocrlf=false is needed to avoid line-ending conversion
# in case the environment has a different setting. Without this, a # in case the environment has a different setting. Without this, a
# tarball created on Windows might be different than on, and unusable # tarball created on Windows might be different than on, and unusable
@ -3483,7 +3485,7 @@ tar_gz = custom_target('tar.gz',
'-9', '-9',
'--prefix', distdir + '/', '--prefix', distdir + '/',
'-o', join_paths(meson.build_root(), '@OUTPUT@'), '-o', join_paths(meson.build_root(), '@OUTPUT@'),
'HEAD', '.'], pg_git_revision],
output: distdir + '.tar.gz', output: distdir + '.tar.gz',
) )
@ -3497,7 +3499,7 @@ if bzip2.found()
'--format', 'tar.bz2', '--format', 'tar.bz2',
'--prefix', distdir + '/', '--prefix', distdir + '/',
'-o', join_paths(meson.build_root(), '@OUTPUT@'), '-o', join_paths(meson.build_root(), '@OUTPUT@'),
'HEAD', '.'], pg_git_revision],
output: distdir + '.tar.bz2', output: distdir + '.tar.bz2',
) )
else else

View File

@ -55,6 +55,9 @@ option('atomics', type: 'boolean', value: true,
option('spinlocks', type: 'boolean', value: true, option('spinlocks', type: 'boolean', value: true,
description: 'Use spinlocks') description: 'Use spinlocks')
option('PG_GIT_REVISION', type: 'string', value: 'HEAD',
description: 'git revision to be packaged by pgdist target')
# Compilation options # Compilation options