Last active
January 21, 2016 16:14
-
-
Save F1LT3R/7ff50b1936f868160c1e to your computer and use it in GitHub Desktop.
postgis.rb
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
# Modified from origin: https://raw.githubusercontent.com/Homebrew/homebrew/6063022e63b22b84547c64e4ab2d477f1459f9ee/Library/Formula/postgis.rb | |
class Postgis < Formula | |
desc "Adds support for geographic objects to PostgreSQL" | |
homepage "http://postgis.net" | |
url "http://download.osgeo.org/postgis/source/postgis-2.2.1.tar.gz" | |
sha256 "0fe500b0250203aac656bfa8f42f8458b63f33258404844e066e0e535988fa09" | |
bottle do | |
cellar :any | |
sha256 "cc9dbfb85f80eb2370343e17e578dc9cf1defb0ed35228fe9407ecf45b5139ea" => :el_capitan | |
sha256 "781e86fad5263f8b85e795b877816e1a5cfad1a9b34c32aa72c902152604b1e1" => :yosemite | |
sha256 "8c086c1c1c93f5ce67930ad1d4f4dd9253f77fbe7d1815a5a78378fdb39facb6" => :mavericks | |
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 "without-gdal", "Disable postgis raster support" | |
option "with-html-docs", "Generate multi-file HTML documentation" | |
option "with-api-docs", "Generate developer API documentation (long process)" | |
depends_on "pkg-config" => :build | |
depends_on "gpp" => :build | |
depends_on "homebrew/versions/postgresql94" | |
depends_on "proj" | |
depends_on "geos" | |
depends_on "gtk+" if build.with? "gui" | |
# For GeoJSON and raster handling | |
depends_on "json-c" | |
depends_on "gdal" => :recommended | |
# For advanced 2D/3D functions | |
depends_on "sfcgal" => :recommended | |
if build.with? "html-docs" | |
depends_on "imagemagick" | |
depends_on "docbook-xsl" | |
end | |
if build.with? "api-docs" | |
depends_on "graphviz" | |
depends_on "doxygen" | |
end | |
def install | |
ENV.deparallelize | |
args = [ | |
"--with-projdir=#{Formula["proj"].opt_prefix}", | |
"--with-jsondir=#{Formula["json-c"].opt_prefix}", | |
"--with-pgconfig=#{Formula["homebrew/versions/postgresql94"].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 << "--without-raster" if build.without? "gdal" | |
args << "--with-xsldir=#{Formula["docbook-xsl"].opt_prefix}/docbook-xsl" if build.with? "html-docs" | |
system "./autogen.sh" if build.head? | |
system "./configure", *args | |
system "make" | |
if build.with? "html-docs" | |
cd "doc" do | |
ENV["XML_CATALOG_FILES"] = "#{etc}/xml/catalog" | |
system "make", "chunked-html" | |
doc.install "html" | |
end | |
end | |
if build.with? "api-docs" | |
cd "doc" do | |
system "make", "doxygen" | |
doc.install "doxygen/html" => "api" | |
end | |
end | |
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/extentsion").install Dir["stage/**/share/doc/postgresql/extension/*"] | |
(share/"postgresql/extension").install Dir["stage/**/share/postgresql/extension/*"] | |
(share/"postgis").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.undent | |
To create a spatially-enabled database, see the documentation: | |
http://postgis.net/docs/manual-2.2/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: | |
http://postgis.net/docs/manual-2.2/postgis_installation.html#upgrading | |
PostGIS SQL scripts installed to: | |
#{HOMEBREW_PREFIX}/share/postgis | |
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("AAAnCgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoOgDAAALAAAAAAAAAAAAAAAA\nAAAAAADwPwAAAAAAABBAAAAAAAAAFEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAEAAAASCwAAAAAAAAAAAPA/AAAAAAAA8D8AAAAAAAAA\nAAAAAAAAAAAAAAAAAgAAABILAAAAAAAAAAAACEAAAAAAAADwPwAAAAAAAAAA\nAAAAAAAAAAAAAAADAAAAEgsAAAAAAAAAAAAQQAAAAAAAAAhAAAAAAAAAAAAA\nAAAAAAAAAAAAAAQAAAASCwAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAA\nAAAAAAAAAAAABQAAABILAAAAAAAAAAAAAAAAAAAAAAAUQAAAAAAAACJAAAAA\nAAAAAEA=\n")) | |
(testpath/"brew.dbf").write(::Base64.decode64("A3IJGgUAAABhAFsAAAAAAAAAAAAAAAAAAAAAAAAAAABGSVJTVF9GTEQAAEMA\nAAAAMgAAAAAAAAAAAAAAAAAAAFNFQ09ORF9GTEQAQwAAAAAoAAAAAAAAAAAA\nAAAAAAAADSBGaXJzdCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgIFBvaW50ICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgU2Vjb25kICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICBQb2ludCAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgIFRoaXJkICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgUG9pbnQgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICBGb3VydGggICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgIFBvaW50ICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgQXBwZW5kZWQgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICBQb2ludCAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAg\n")) | |
(testpath/"brew.shx").write(::Base64.decode64("AAAnCgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARugDAAALAAAAAAAAAAAAAAAA\nAAAAAADwPwAAAAAAABBAAAAAAAAAFEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAADIAAAASAAAASAAAABIAAABeAAAAEgAAAHQAAAASAAAA\nigAAABI=\n")) | |
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