140 lines
5.5 KiB
Ruby
140 lines
5.5 KiB
Ruby
class Postgis < Formula
|
|
desc "Adds support for geographic objects to PostgreSQL"
|
|
homepage "https://postgis.net/"
|
|
url "https://download.osgeo.org/postgis/source/postgis-2.5.0.tar.gz"
|
|
sha256 "be73abd747e9665f29748e0e7dc6b3f7b1ce98f32e3567f08259420ca10e36d5"
|
|
revision 1
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "1d0d8cbc1e420f274967666db47d5d3c625305624a8bebe486f574041f14e028" => :mojave
|
|
sha256 "2bd14e63c261c9e56e6bbcfe039c365452f6a3547632cc196f4de50f5fe2476f" => :high_sierra
|
|
sha256 "8355f8dac95902dc3892545162aea380fb55fbc177c1ac1c0ed85018eb00a8b3" => :sierra
|
|
end
|
|
|
|
head do
|
|
url "https://svn.osgeo.org/postgis/trunk/"
|
|
|
|
depends_on "autoconf" => :build
|
|
depends_on "automake" => :build
|
|
depends_on "libtool" => :build
|
|
end
|
|
|
|
option "with-gui", "Build shp2pgsql-gui in addition to command line tools"
|
|
option "with-protobuf-c", "Build with protobuf-c to enable Geobuf and Mapbox Vector Tile support"
|
|
|
|
depends_on "gpp" => :build
|
|
depends_on "pkg-config" => :build
|
|
depends_on "gdal" # for GeoJSON and raster handling
|
|
depends_on "geos"
|
|
depends_on "gtk+" if build.with? "gui"
|
|
depends_on "json-c" # for GeoJSON and raster handling
|
|
depends_on "pcre"
|
|
depends_on "postgresql"
|
|
depends_on "proj"
|
|
depends_on "sfcgal" # for advanced 2D/3D functions
|
|
depends_on "protobuf-c" => :optional
|
|
|
|
def install
|
|
ENV.deparallelize
|
|
|
|
args = [
|
|
"--with-projdir=#{Formula["proj"].opt_prefix}",
|
|
"--with-jsondir=#{Formula["json-c"].opt_prefix}",
|
|
"--with-pgconfig=#{Formula["postgresql"].opt_bin}/pg_config",
|
|
# Unfortunately, NLS support causes all kinds of headaches because
|
|
# PostGIS gets all of its compiler flags from the PGXS makefiles. This
|
|
# makes it nigh impossible to tell the buildsystem where our keg-only
|
|
# gettext installations are.
|
|
"--disable-nls",
|
|
]
|
|
|
|
args << "--with-gui" if build.with? "gui"
|
|
args << "--with-protobufdir=#{Formula["protobuf-c"].opt_bin}" if build.with? "protobuf-c"
|
|
|
|
system "./autogen.sh" if build.head?
|
|
system "./configure", *args
|
|
system "make"
|
|
|
|
mkdir "stage"
|
|
system "make", "install", "DESTDIR=#{buildpath}/stage"
|
|
|
|
bin.install Dir["stage/**/bin/*"]
|
|
lib.install Dir["stage/**/lib/*"]
|
|
include.install Dir["stage/**/include/*"]
|
|
(doc/"postgresql/extension").install Dir["stage/**/share/doc/postgresql/extension/*"]
|
|
(share/"postgresql/extension").install Dir["stage/**/share/postgresql/extension/*"]
|
|
pkgshare.install Dir["stage/**/contrib/postgis-*/*"]
|
|
(share/"postgis_topology").install Dir["stage/**/contrib/postgis_topology-*/*"]
|
|
|
|
# Extension scripts
|
|
bin.install %w[
|
|
utils/create_undef.pl
|
|
utils/postgis_proc_upgrade.pl
|
|
utils/postgis_restore.pl
|
|
utils/profile_intersects.pl
|
|
utils/test_estimation.pl
|
|
utils/test_geography_estimation.pl
|
|
utils/test_geography_joinestimation.pl
|
|
utils/test_joinestimation.pl
|
|
]
|
|
|
|
man1.install Dir["doc/**/*.1"]
|
|
end
|
|
|
|
def caveats
|
|
<<~EOS
|
|
To create a spatially-enabled database, see the documentation:
|
|
https://postgis.net/docs/manual-2.4/postgis_installation.html#create_new_db_extensions
|
|
If you are currently using PostGIS 2.0+, you can go the soft upgrade path:
|
|
ALTER EXTENSION postgis UPDATE TO "#{version}";
|
|
Users of 1.5 and below will need to go the hard-upgrade path, see here:
|
|
https://postgis.net/docs/manual-2.4/postgis_installation.html#upgrading
|
|
|
|
PostGIS SQL scripts installed to:
|
|
#{opt_pkgshare}
|
|
PostGIS plugin libraries installed to:
|
|
#{HOMEBREW_PREFIX}/lib
|
|
PostGIS extension modules installed to:
|
|
#{HOMEBREW_PREFIX}/share/postgresql/extension
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
require "base64"
|
|
(testpath/"brew.shp").write ::Base64.decode64 <<~EOS
|
|
AAAnCgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoOgDAAALAAAAAAAAAAAAAAAA
|
|
AAAAAADwPwAAAAAAABBAAAAAAAAAFEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAEAAAASCwAAAAAAAAAAAPA/AAAAAAAA8D8AAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAgAAABILAAAAAAAAAAAACEAAAAAAAADwPwAAAAAAAAAA
|
|
AAAAAAAAAAAAAAADAAAAEgsAAAAAAAAAAAAQQAAAAAAAAAhAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAQAAAASCwAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAABQAAABILAAAAAAAAAAAAAAAAAAAAAAAUQAAAAAAAACJAAAAA
|
|
AAAAAEA=
|
|
EOS
|
|
(testpath/"brew.dbf").write ::Base64.decode64 <<~EOS
|
|
A3IJGgUAAABhAFsAAAAAAAAAAAAAAAAAAAAAAAAAAABGSVJTVF9GTEQAAEMA
|
|
AAAAMgAAAAAAAAAAAAAAAAAAAFNFQ09ORF9GTEQAQwAAAAAoAAAAAAAAAAAA
|
|
AAAAAAAADSBGaXJzdCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
|
|
ICAgICAgICAgICAgIFBvaW50ICAgICAgICAgICAgICAgICAgICAgICAgICAg
|
|
ICAgICAgICAgU2Vjb25kICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
|
|
ICAgICAgICAgICAgICBQb2ludCAgICAgICAgICAgICAgICAgICAgICAgICAg
|
|
ICAgICAgICAgIFRoaXJkICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
|
|
ICAgICAgICAgICAgICAgUG9pbnQgICAgICAgICAgICAgICAgICAgICAgICAg
|
|
ICAgICAgICAgICBGb3VydGggICAgICAgICAgICAgICAgICAgICAgICAgICAg
|
|
ICAgICAgICAgICAgICAgIFBvaW50ICAgICAgICAgICAgICAgICAgICAgICAg
|
|
ICAgICAgICAgICAgQXBwZW5kZWQgICAgICAgICAgICAgICAgICAgICAgICAg
|
|
ICAgICAgICAgICAgICAgICBQb2ludCAgICAgICAgICAgICAgICAgICAgICAg
|
|
ICAgICAgICAgICAg
|
|
EOS
|
|
(testpath/"brew.shx").write ::Base64.decode64 <<~EOS
|
|
AAAnCgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARugDAAALAAAAAAAAAAAAAAAA
|
|
AAAAAADwPwAAAAAAABBAAAAAAAAAFEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAADIAAAASAAAASAAAABIAAABeAAAAEgAAAHQAAAASAAAA
|
|
igAAABI=
|
|
EOS
|
|
result = shell_output("#{bin}/shp2pgsql #{testpath}/brew.shp")
|
|
assert_match /Point/, result
|
|
assert_match /AddGeometryColumn/, result
|
|
end
|
|
end
|