tembo-io / trunk

Package manager and registry for Postgres extensions
PostgreSQL License
250 stars 14 forks source link

Refactor extension build command handling #606

Closed theory closed 8 months ago

theory commented 8 months ago

The contrib Dockerfiles run ./configure && make, so not only is there no need to do so here, but it was causing issues by running the commands in the parent directory of the unpacked extension directory:

Executing in container: "su postgres -c bash -c \"././postgis-3.4.0/configure && make -C ./postgis-3.4.0 check && echo done\""
configure: error: source directory already configured; run "make distclean" there first

Apparently ./configure won't re-run from a different directory unless make distclean is run. But it's not even necessary! So remove the check for the configure file in run_tests(), and then also remove the file_exists() function, as it's no longer uses.

Then refactor exec_in_container() and exec_in_container_with_exit_code() to take a directory argument, and pass it to bollard's CreateExecOptions(), then pass the unpacked directory name in the appropriate places.

That includes especially make check and make installcheck. Also modify them so they no longe run as the postgres user --- which can cause permission issues, as the source is unpacked and owned by root in the Dockerfiles --- and instead set the PGUSER environment variable. This ensure that all tests are run as the root system user but connect to the postgres database as the postgres user.