Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rS0XM-00AlDM-EE for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Jan 2024 20:04:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rS0XL-006izr-Dl for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Jan 2024 20:04:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rS0XL-006izj-1w for pgsql-hackers@lists.postgresql.org; Mon, 22 Jan 2024 20:04:51 +0000 Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rS0XH-003AzK-NI for pgsql-hackers@postgresql.org; Mon, 22 Jan 2024 20:04:50 +0000 Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-6ddf05b1922so2686689a34.2 for ; Mon, 22 Jan 2024 12:04:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=neon.tech; s=google; t=1705953885; x=1706558685; darn=postgresql.org; h=in-reply-to:references:from:to:cc:subject:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=BcHAMPIXjJKoWDRyLUdo9Y3+2l4+WqK/zdKXKtAGNkA=; b=kRGY1Xv1jRwsqsnHyFxL7j2uffgWF53DG8J+oP2rqfzvOtEPCJPGNC2uHFPLg/5SXX lDAgMSq6+HSq5ik+P6xNYugqJQt0LDROKaM5HrhMn04WIpeFb5YdN/pbi86i40r4pTB8 HZmZ8Es5pH00X2iDuM6BRP8HJC1sHRc1/cxEQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705953885; x=1706558685; h=in-reply-to:references:from:to:cc:subject:message-id:date :content-transfer-encoding:mime-version:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=BcHAMPIXjJKoWDRyLUdo9Y3+2l4+WqK/zdKXKtAGNkA=; b=CF2KDeFy9SUYDVzRq6AXFFOVzBIRKF0R2gQiKHylHyXB80f7YFe1c+gEvZN8BI9JQM jtQ2NFZeOuWfIjsXRepRPFMfBhtu9JcdvzyD4dXA778RqgqskuuTNfJOnEszdtZIH2fk V62NhqABwahiUrm+WJUKMzurvNW19D66CGCqydc1w5LwvUK641sauFuBHstnvZ7I/mM9 0K6TPKvxyliztyCEvRExqKRDyzWtcN+gygz1tiG3KnyIxCZvbLhK/Jx/fmiW6lyi+9Ko 6SA7JpTK2psk8AZD7vYtFQJLgUCGQuucAKRFPAivnTMaDLGkQJI/hSg8JtlKVKwdxAjw mh8w== X-Gm-Message-State: AOJu0YxVxjC5h1qYC1sPO3DOlyvNJV5Q+zH5dEFDquOWlpaZ6iUVWvdH EeUxaC3PJnXzhVQtHRtIo8t2Ev78HBgqIGmOFhQJXezbAmIIXC1kLgrUPMWBLk3CVGHDbnIK2jw Y X-Google-Smtp-Source: AGHT+IHEh6pXS1SZfWl8cF+VLdq4WMZWGxmhLpowjkv74U2NhNYM6k76/J3AAU+SdkQW0aBjluq5mA== X-Received: by 2002:a9d:6a13:0:b0:6dd:c275:afc4 with SMTP id g19-20020a9d6a13000000b006ddc275afc4mr5580981otn.51.1705953884734; Mon, 22 Jan 2024 12:04:44 -0800 (PST) Received: from localhost ([2607:fb90:e683:8cf6:3996:e070:71ee:42fb]) by smtp.gmail.com with ESMTPSA id dm9-20020a0568303b8900b006dc4846ce3dsm1792621otb.59.2024.01.22.12.04.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Jan 2024 12:04:44 -0800 (PST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8; format=Flowed Date: Mon, 22 Jan 2024 14:04:43 -0600 Message-Id: Subject: Re: make dist using git archive Cc: "pgsql-hackers" To: "Peter Eisentraut" From: "Tristan Partin" X-Mailer: aerc 0.16.0-149-g2d8b81f619fc References: <40e80f77-a294-4f29-a16f-e21bc7bc75fc@eisentraut.org> In-Reply-To: <40e80f77-a294-4f29-a16f-e21bc7bc75fc@eisentraut.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon Jan 22, 2024 at 1:31 AM CST, Peter Eisentraut wrote: > From 4b128faca90238d0a0bb6949a8050c2501d1bd67 Mon Sep 17 00:00:00 2001 > From: Peter Eisentraut > Date: Sat, 20 Jan 2024 21:54:36 +0100 > Subject: [PATCH v0] make dist uses git archive > > --- > GNUmakefile.in | 34 ++++++++++++---------------------- > meson.build | 38 ++++++++++++++++++++++++++++++++++++++ > 2 files changed, 50 insertions(+), 22 deletions(-) > > diff --git a/GNUmakefile.in b/GNUmakefile.in > index eba569e930e..3e04785ada2 100644 > --- a/GNUmakefile.in > +++ b/GNUmakefile.in > @@ -87,29 +87,19 @@ update-unicode: | submake-generated-headers submake-l= ibpgport > distdir =3D postgresql-$(VERSION) > dummy =3D =3Dinstall=3D > =20 > +GIT =3D 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=3D`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) diff-index --quiet HEAD > + > +$(distdir).tar.gz: check-dirty-index > + $(GIT) archive --format tar.gz --prefix $(distdir)/ HEAD -o $@ > + > +$(distdir).tar.bz2: check-dirty-index > + $(GIT) -c tar.tar.bz2.command=3D'$(BZIP2) -c' archive --format tar.bz2 = --prefix $(distdir)/ HEAD -o $@ > =20 > distcheck: dist > rm -rf $(dummy) > diff --git a/meson.build b/meson.build > index c317144b6bc..f0d870c5192 100644 > --- a/meson.build > +++ b/meson.build > @@ -3347,6 +3347,44 @@ run_target('help', > =20 > =20 > =20 > +############################################################### > +# Distribution archive > +############################################################### > + > +git =3D find_program('git', required: false, native: true, disabler: tru= e) > +bzip2 =3D find_program('bzip2', required: false, native: true, disabler:= true) This doesn't need to be a disabler. git is fine as-is. See later=20 comment. Disablers only work like you are expecting when they are used=20 like how git is used. Once you call a method like .path(), all bets are=20 off. > +distdir =3D meson.project_name() + '-' + meson.project_version() > + > +check_dirty_index =3D run_target('check-dirty-index', > + command: [git, 'diff-index', '--quiet', '= HEAD']) Seems like you might want to add -C here too? > + > +tar_gz =3D custom_target('tar.gz', > + build_always_stale: true, > + command: [git, '-C', '@SOURCE_ROOT@', 'archive', > + '--format', 'tar.gz', > + '--prefix', distdir + '/', > + '-o', '@BUILD_ROOT@/@OUTPUT@', > + 'HEAD', '.'], > + install: false, > + output: distdir + '.tar.gz', > +) > + > +tar_bz2 =3D custom_target('tar.bz2', > + build_always_stale: true, > + command: [git, '-C', '@SOURCE_ROOT@', '-c', 'tar.tar.bz2.command=3D' += bzip2.path() + ' -c', 'archive', > + '--format', 'tar.bz2', > + '--prefix', distdir + '/', - '-o', '@BUILD_ROOT@/@OUTPUT@', + '-o', join_paths(meson.build_root(), '@OUTPUT@'), This will generate the tarballs in the build directory. Do the same for=20 the previous target. Tested locally. > + 'HEAD', '.'], > + install: false, > + output: distdir + '.tar.bz2', > +) The bz2 target should be wrapped in an `if bzip2.found()`. It is=20 possible for git to be found, but not bzip2. I might also define the bz2=20 command out of line. Also, you may want to add=20 these programs to meson_options.txt for overriding, even though the=20 "meson-ic" way is to use a machine file. > + > +alias_target('pgdist', [check_dirty_index, tar_gz, tar_bz2]) Are you intending for the check_dirty_index target to prohibit the other=20 two targets from running? Currently that is not the case. If it is what=20 you intend, use a stamp file or something to indicate a relationship.=20 Alternatively, inline the git diff-index into the other commands. These=20 might also do better as external scripts. It would reduce duplication=20 between the autotools and Meson builds. > + > + > + > ############################################################### > # The End, The End, My Friend > ############################################################### I am not really following why we can't use the builtin Meson dist=20 command. The only difference from my testing is it doesn't use=20 a --prefix argument. --=20 Tristan Partin Neon (https://neon.tech)