Skip to content

Instantly share code, notes, and snippets.

@wush978
Last active April 19, 2019 05:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wush978/6fb80fc25fb4daf4f893802e34776fcf to your computer and use it in GitHub Desktop.
Save wush978/6fb80fc25fb4daf4f893802e34776fcf to your computer and use it in GitHub Desktop.
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.2.tar.gz"
sha256 "b6cb286c5016029d984f8c440947bf9178da72e1f6f840ed639270e1c451db5e"
revision 2
bottle do
cellar :any
sha256 "b4249fd625f68664b121d896f9ef069ad3bf4469bc6fa0173b9d7aa0524bf160" => :mojave
sha256 "c3e4f07c51d0b8409c2ff8eec5203de906d06360db15245f359622e6cde1c73b" => :high_sierra
sha256 "bc929fc49418613e0eb1a9dde940ffbe756a42baae69b40a6fcb6847fffdde29" => :sierra
end
head do
url "https://svn.osgeo.org/postgis/trunk/"
end
def install
ENV.deparallelize
args = [
"--with-projdir=#{Formula["proj"].opt_prefix}",
"--with-jsondir=#{Formula["json-c"].opt_prefix}",
"--with-pgconfig=#{Formula["postgresql@9.6"].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@9.6/extension").install Dir["stage/**/share/doc/postgresql@9.6/extension/*"]
(share/"postgresql@9.6/extension").install Dir["stage/**/share/postgresql@9.6/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