Subject: Re: pgsql: Move snowball_create.sql creation into perl file

From: Christoph Berg <[email-masked]>
Date: Tue, 23 May 2023 15:47:46 +0200

Re: Andres Freund
> Move snowball_create.sql creation into perl file
> 
> This is in preparation for building postgres with meson / ninja.
> 
> We already have duplicated code for this between the make and msvc
> builds. Adding a third copy seems like a bad plan, thus move the generation
> into a perl script.
> 
> As we don't want to rely on perl being available for builds from tarballs,
> generate the file during distprep.
> 
> Author: Peter Eisentraut <[email-masked]>
> Author: Andres Freund <[email-masked]>
> Discussion: https://postgr.es/m/[email-masked]

Hi,

this seems to have broken out-of-tree builds from tarballs:

make -C backend/snowball install
make[3]: Entering directory '/srv/projects/postgresql/debian/16/build/src/backend/snowball'
/bin/mkdir -p '/srv/projects/postgresql/debian/16/build/tmp_install/usr/lib/postgresql/16/lib'
/bin/mkdir -p '/srv/projects/postgresql/debian/16/build/tmp_install/usr/share/postgresql/16' '/srv/projects/postgresql/debian/16/build/tmp_install/usr/share/postgresql/16/tsearch_data'
/usr/bin/install -c -m 755  dict_snowball.so '/srv/projects/postgresql/debian/16/build/tmp_install/usr/lib/postgresql/16/lib/dict_snowball.so'
/usr/bin/install -c -m 644 snowball_create.sql '/srv/projects/postgresql/debian/16/build/tmp_install/usr/share/postgresql/16'
/usr/bin/install: cannot stat 'snowball_create.sql': No such file or directory
make[3]: *** [Makefile:110: install] Error 1

The file is present in src/backend/snowball/ but not in build/src/backend/snowball/:

-rw-r--r-- 1 myon myon 44176 22. Mai 21:20 src/backend/snowball/snowball_create.sql

Christoph

---

From: Christoph Berg <[email-masked]>
Date: Tue, 23 May 2023 16:06:26 +0200

Re: To Andres Freund
> /usr/bin/install: cannot stat 'snowball_create.sql': No such file or directory

Fortunately, there is an easy workaround, just delete
src/backend/snowball/snowball_create.sql before building, it will then
be recreated in the proper build directory.

Christoph

---

From: Tom Lane <[email-masked]>
Date: Tue, 23 May 2023 10:46:30 -0400

>> /usr/bin/install: cannot stat 'snowball_create.sql': No such file or directory

I think the attached will do for a proper fix.  I'm not inclined
to re-wrap just for this.

			regards, tom lane

diff --git a/src/backend/snowball/Makefile b/src/backend/snowball/Makefile
index 29076371db..4bebfa0250 100644
--- a/src/backend/snowball/Makefile
+++ b/src/backend/snowball/Makefile
@@ -106,10 +106,13 @@ $(SQLSCRIPT): snowball_create.pl snowball_func.sql.in snowball.sql.in
 
 distprep: $(SQLSCRIPT)
 
-install: all installdirs install-lib
-	$(INSTALL_DATA) $(SQLSCRIPT) '$(DESTDIR)$(datadir)'
+install: all installdirs install-lib install-script
 	$(INSTALL_DATA) $(addprefix $(srcdir)/stopwords/,$(stop_files)) '$(DESTDIR)$(datadir)/$(DICTDIR)'
 
+# $(SQLSCRIPT) might be in the srcdir or the build dir
+install-script: $(SQLSCRIPT)
+	$(INSTALL_DATA) $< '$(DESTDIR)$(datadir)'
+
 installdirs: installdirs-lib
 	$(MKDIR_P) '$(DESTDIR)$(datadir)' '$(DESTDIR)$(datadir)/$(DICTDIR)'

---

From: Christoph Berg <[email-masked]>
Date: Tue, 23 May 2023 16:50:25 +0200

Re: Tom Lane
> to re-wrap just for this.

Sure, I just posted it here in case others run into the same problem.

Thanks!

Christoph

---

From: Andres Freund <[email-masked]>
Date: Tue, 23 May 2023 11:41:57 -0700

Hi,

On 2023-05-23 10:46:30 -0400, Tom Lane wrote:
> I think the attached will do for a proper fix.

Thanks.

> I'm not inclined to re-wrap just for this.

Agreed.

I wonder if we should add a CI task to test creating a tarball and building
from it, both inside the source directory and as a vpath build? We rebuild for
both gcc and clang, each with assertions and without, to check if there are
warnings. We could probably just switch to building from the tarball for some
of those.

I guess I need to go and check how long the "release" tarball generation
takes...

Greetings,

Andres Freund