Skip to content

Commit

Permalink
postgis: depend on postgresql@14.
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMcQuaid authored and BrewTestBot committed Aug 27, 2022
1 parent 8a8c630 commit 69e7ca8
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions Formula/postgis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Postgis < Formula
url "https://download.osgeo.org/postgis/source/postgis-3.2.3.tar.gz"
sha256 "1b4d8b5c756e5aba59efbc1833b22efe4d6562778eeca56fa497feb2eb13668c"
license "GPL-2.0-or-later"
revision 1

livecheck do
url "https://download.osgeo.org/postgis/source/"
Expand Down Expand Up @@ -33,7 +34,7 @@ class Postgis < Formula
depends_on "geos"
depends_on "json-c" # for GeoJSON and raster handling
depends_on "pcre2"
depends_on "postgresql"
depends_on "postgresql@14"
depends_on "proj"
depends_on "protobuf-c" # for MVT (map vector tiles) support
depends_on "sfcgal" # for advanced 2D/3D functions
Expand All @@ -44,13 +45,19 @@ class Postgis < Formula

fails_with gcc: "5"

def postgresql
Formula["postgresql@14"]
end

def install
ENV.deparallelize

ENV["PG_CONFIG"] = postgresql.opt_bin/"pg_config"

args = [
"--with-projdir=#{Formula["proj"].opt_prefix}",
"--with-jsondir=#{Formula["json-c"].opt_prefix}",
"--with-pgconfig=#{Formula["postgresql"].opt_bin}/pg_config",
"--with-pgconfig=#{postgresql.opt_bin}/pg_config",
"--with-protobufdir=#{Formula["protobuf-c"].opt_bin}",
# Unfortunately, NLS support causes all kinds of headaches because
# PostGIS gets all of its compiler flags from the PGXS makefiles. This
Expand All @@ -72,7 +79,7 @@ def install
# the version of postgresql used to build postgis. Since we copy these
# files into the postgis keg and symlink them to HOMEBREW_PREFIX, postgis
# only needs to be rebuilt when there is a new major version of postgresql.
postgresql_prefix = Formula["postgresql"].prefix.realpath
postgresql_prefix = postgresql.prefix.realpath
postgresql_stage_path = File.join("stage", postgresql_prefix)
bin.install (buildpath/postgresql_stage_path/"bin").children
doc.install (buildpath/postgresql_stage_path/"share/doc").children
Expand All @@ -95,10 +102,10 @@ def install
end

test do
pg_version = Formula["postgresql"].version.major
pg_version = postgresql.version.major
expected = /'PostGIS built for PostgreSQL % cannot be loaded in PostgreSQL %',\s+#{pg_version}\.\d,/
postgis_version = Formula["postgis"].version.major_minor
assert_match expected, (share/"postgresql/contrib/postgis-#{postgis_version}/postgis.sql").read
assert_match expected, (share/postgresql.name/"contrib/postgis-#{postgis_version}/postgis.sql").read

require "base64"
(testpath/"brew.shp").write ::Base64.decode64 <<~EOS
Expand Down Expand Up @@ -135,5 +142,19 @@ def install
result = shell_output("#{bin}/shp2pgsql #{testpath}/brew.shp")
assert_match "Point", result
assert_match "AddGeometryColumn", result

pg_ctl = postgresql.opt_bin/"pg_ctl"
psql = postgresql.opt_bin/"psql"
port = free_port

system pg_ctl, "initdb", "-D", testpath/"test"
(testpath/"test/postgresql.conf").write <<~EOS, mode: "a+"
shared_preload_libraries = 'postgis-3'
port = #{port}
EOS
system pg_ctl, "start", "-D", testpath/"test", "-l", testpath/"log"
system psql, "-p", port.to_s, "-c", "CREATE EXTENSION \"postgis\";", "postgres"
system pg_ctl, "stop", "-D", testpath/"test"
end
end

0 comments on commit 69e7ca8

Please sign in to comment.