Last active
September 30, 2021 21:39
-
-
Save tagliala/7f9b73cc7bb2937b8e73d0859fdf40e6 to your computer and use it in GitHub Desktop.
Postgres 11 - Postgis 3 - brew
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create postgis.control | |
/usr/local/opt/postgresql@11/share/postgresql@11/extension/postgis.control | |
# Manually move files to postgres folder | |
cp /usr/local/Cellar/postgis/3.0.1/lib/*.so /usr/local/Cellar/postgresql@11/11.7/lib | |
cp /usr/local/Cellar/postgis/3.0.1/share/postgis/*.* /usr/local/Cellar/postgresql@11/11.7/share/postgresql@11/extension | |
# Pin formuale | |
brew pin postgis | |
brew pin postgresql@11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# postgis extension | |
comment = 'PostGIS geometry, geography, and raster spatial types and functions' | |
default_version = '3.0.1' | |
module_pathname = '$libdir/postgis-3' | |
relocatable = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Postgis < Formula | |
desc "Adds support for geographic objects to PostgreSQL" | |
homepage "https://postgis.net/" | |
url "https://download.osgeo.org/postgis/source/postgis-3.0.1.tar.gz" | |
sha256 "5a5432f95150d9bae9215c6d1c7bb354e060482a7c379daa9b8384e1d03e6353" | |
bottle do | |
cellar :none | |
sha256 "e238007f629c888d6c24030ee5c8826855f8961bf6cdadf7ffbb81aff46aa257" => :catalina | |
sha256 "3e8ce334a79db049d9fbaa54a623f7f09b74c18a8b2a85c54644de0b00086a8c" => :mojave | |
sha256 "110f0856a4407adc8dee876b9c2eb94ef13d5c18b298deabf128533bb53975d2" => :high_sierra | |
end | |
head do | |
url "https://svn.osgeo.org/postgis/trunk/" | |
depends_on "autoconf" => :build | |
depends_on "automake" => :build | |
depends_on "libtool" => :build | |
end | |
depends_on "gpp" => :build | |
depends_on "pkg-config" => :build | |
depends_on "gdal" # for GeoJSON and raster handling | |
depends_on "geos" | |
depends_on "json-c" # for GeoJSON and raster handling | |
depends_on "pcre" | |
depends_on "postgresql@11" | |
depends_on "proj" | |
depends_on "protobuf-c" # for MVT (map vector tiles) support | |
depends_on "sfcgal" # for advanced 2D/3D functions | |
def install | |
ENV.deparallelize | |
args = [ | |
"--with-projdir=#{Formula["proj"].opt_prefix}", | |
"--with-jsondir=#{Formula["json-c"].opt_prefix}", | |
"--with-pgconfig=#{Formula["postgresql@11"].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 | |
# makes it nigh impossible to tell the buildsystem where our keg-only | |
# gettext installations are. | |
"--disable-nls", | |
] | |
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 | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment