├── README.md └── postgis.rb /README.md: -------------------------------------------------------------------------------- 1 | homebrew-postgis-for-93 2 | ============== 3 | 4 | Custom brew for using postgis with the brew versions postgresql93. 5 | 6 | Installation 7 | ------------ 8 | 9 | It's pretty easy, you just need homebrew version `0.9` or greater and some 10 | sauce: 11 | 12 | brew tap johnschultz/homebrew-postgis-for-93 13 | brew install postgis 14 | 15 | If the formula conflicts with one in `mxcl/master`, you can explicitly target this formula with: 16 | 17 | brew install johnschultz/postgis-for-93/postgis # yes without the 'homebrew-' 18 | 19 | Cheers. 20 | 21 | Credits 22 | ------- 23 | README.md shamelessly stolen from chuckg/homebrew-brewg 24 | -------------------------------------------------------------------------------- /postgis.rb: -------------------------------------------------------------------------------- 1 | class Postgis < Formula 2 | homepage "http://postgis.net" 3 | url "http://download.osgeo.org/postgis/source/postgis-2.1.7.tar.gz" 4 | sha256 "00ab79a3f609d7ea458f6fc358032ad059cb720baf88285243d6436a597a7ec2" 5 | revision 1 6 | 7 | def pour_bottle? 8 | # Postgres extensions must live in the Postgres prefix, which precludes 9 | # bottling: https://github.com/Homebrew/homebrew/issues/10247 10 | # Overcoming this will likely require changes in Postgres itself. 11 | false 12 | end 13 | 14 | head do 15 | url "http://svn.osgeo.org/postgis/trunk/" 16 | 17 | depends_on "autoconf" => :build 18 | depends_on "automake" => :build 19 | depends_on "libtool" => :build 20 | end 21 | 22 | option "with-gui", "Build shp2pgsql-gui in addition to command line tools" 23 | option "without-gdal", "Disable postgis raster support" 24 | option "with-html-docs", "Generate multi-file HTML documentation" 25 | option "with-api-docs", "Generate developer API documentation (long process)" 26 | 27 | depends_on "pkg-config" => :build 28 | depends_on "gpp" => :build 29 | depends_on "postgresql93" 30 | depends_on "proj" 31 | depends_on "geos" 32 | 33 | depends_on "gtk+" if build.with? "gui" 34 | 35 | # For GeoJSON and raster handling 36 | depends_on "json-c" 37 | depends_on "gdal" => :recommended 38 | 39 | # For advanced 2D/3D functions 40 | depends_on "sfcgal" => :recommended 41 | 42 | if build.with? "html-docs" 43 | depends_on "imagemagick" 44 | depends_on "docbook-xsl" 45 | end 46 | 47 | if build.with? "api-docs" 48 | depends_on "graphviz" 49 | depends_on "doxygen" 50 | end 51 | 52 | def install 53 | # Follow the PostgreSQL linked keg back to the active Postgres installation 54 | # as it is common for people to avoid upgrading Postgres. 55 | postgres_realpath = Formula["postgresql93"].opt_prefix.realpath 56 | 57 | ENV.deparallelize 58 | 59 | args = [ 60 | # Can't use --prefix, PostGIS disrespects it and flat-out refuses to 61 | # accept it with 2.0. 62 | "--with-projdir=#{HOMEBREW_PREFIX}", 63 | "--with-jsondir=#{Formula["json-c"].opt_prefix}", 64 | # This is against Homebrew guidelines, but we have to do it as the 65 | # PostGIS plugin libraries can only be properly inserted into Homebrew's 66 | # Postgresql keg. 67 | "--with-pgconfig=#{postgres_realpath}/bin/pg_config", 68 | # Unfortunately, NLS support causes all kinds of headaches because 69 | # PostGIS gets all of its compiler flags from the PGXS makefiles. This 70 | # makes it nigh impossible to tell the buildsystem where our keg-only 71 | # gettext installations are. 72 | "--disable-nls" 73 | ] 74 | 75 | args << "--with-gui" if build.with? "gui" 76 | args << "--without-raster" if build.without? "gdal" 77 | 78 | args << "--with-xsldir=#{Formula["docbook-xsl"].opt_prefix}/docbook-xsl" if build.with? "html-docs" 79 | 80 | system "./autogen.sh" if build.head? 81 | system "./configure", *args 82 | system "make" 83 | 84 | if build.with? "html-docs" 85 | cd "doc" do 86 | ENV["XML_CATALOG_FILES"] = "#{etc}/xml/catalog" 87 | system "make", "chunked-html" 88 | doc.install "html" 89 | end 90 | end 91 | 92 | if build.with? "api-docs" 93 | cd "doc" do 94 | system "make", "doxygen" 95 | doc.install "doxygen/html" => "api" 96 | end 97 | end 98 | 99 | # PostGIS includes the PGXS makefiles and so will install __everything__ 100 | # into the Postgres keg instead of the PostGIS keg. Unfortunately, some 101 | # things have to be inside the Postgres keg in order to be function. So, we 102 | # install everything to a staging directory and manually move the pieces 103 | # into the appropriate prefixes. 104 | mkdir "stage" 105 | system "make", "install", "DESTDIR=#{buildpath}/stage" 106 | 107 | # Install PostGIS plugin libraries into the Postgres keg so that they can 108 | # be loaded and so PostGIS databases will continue to function even if 109 | # PostGIS is removed. 110 | (postgres_realpath/"lib").install Dir["stage/**/*.so"] 111 | 112 | # Install extension scripts to the Postgres keg. 113 | # `CREATE EXTENSION postgis;` won't work if these are located elsewhere. 114 | (postgres_realpath/"share/postgresql/extension").install Dir["stage/**/extension/*"] 115 | 116 | bin.install Dir["stage/**/bin/*"] 117 | lib.install Dir["stage/**/lib/*"] 118 | include.install Dir["stage/**/include/*"] 119 | 120 | # Stand-alone SQL files will be installed the share folder 121 | (share/"postgis").install Dir["stage/**/contrib/postgis-2.1/*"] 122 | 123 | # Extension scripts 124 | bin.install %w[ 125 | utils/create_undef.pl 126 | utils/postgis_proc_upgrade.pl 127 | utils/postgis_restore.pl 128 | utils/profile_intersects.pl 129 | utils/test_estimation.pl 130 | utils/test_geography_estimation.pl 131 | utils/test_geography_joinestimation.pl 132 | utils/test_joinestimation.pl 133 | ] 134 | 135 | man1.install Dir["doc/**/*.1"] 136 | end 137 | 138 | def caveats; 139 | pg = Formula["postgresql93"].opt_prefix 140 | <<-EOS.undent 141 | To create a spatially-enabled database, see the documentation: 142 | http://postgis.net/docs/manual-2.1/postgis_installation.html#create_new_db_extensions 143 | If you are currently using PostGIS 2.0+, you can go the soft upgrade path: 144 | ALTER EXTENSION postgis UPDATE TO "2.1.5"; 145 | Users of 1.5 and below will need to go the hard-upgrade path, see here: 146 | http://postgis.net/docs/manual-2.1/postgis_installation.html#upgrading 147 | 148 | PostGIS SQL scripts installed to: 149 | #{HOMEBREW_PREFIX}/share/postgis 150 | PostGIS plugin libraries installed to: 151 | #{pg}/lib 152 | PostGIS extension modules installed to: 153 | #{pg}/share/postgresql/extension 154 | EOS 155 | end 156 | 157 | test do 158 | require "base64" 159 | (testpath/"brew.shp").write(::Base64.decode64("AAAnCgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoOgDAAALAAAAAAAAAAAAAAAA\nAAAAAADwPwAAAAAAABBAAAAAAAAAFEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAEAAAASCwAAAAAAAAAAAPA/AAAAAAAA8D8AAAAAAAAA\nAAAAAAAAAAAAAAAAAgAAABILAAAAAAAAAAAACEAAAAAAAADwPwAAAAAAAAAA\nAAAAAAAAAAAAAAADAAAAEgsAAAAAAAAAAAAQQAAAAAAAAAhAAAAAAAAAAAAA\nAAAAAAAAAAAAAAQAAAASCwAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAA\nAAAAAAAAAAAABQAAABILAAAAAAAAAAAAAAAAAAAAAAAUQAAAAAAAACJAAAAA\nAAAAAEA=\n")) 160 | (testpath/"brew.dbf").write(::Base64.decode64("A3IJGgUAAABhAFsAAAAAAAAAAAAAAAAAAAAAAAAAAABGSVJTVF9GTEQAAEMA\nAAAAMgAAAAAAAAAAAAAAAAAAAFNFQ09ORF9GTEQAQwAAAAAoAAAAAAAAAAAA\nAAAAAAAADSBGaXJzdCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgIFBvaW50ICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgU2Vjb25kICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICBQb2ludCAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgIFRoaXJkICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgUG9pbnQgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICBGb3VydGggICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgIFBvaW50ICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgQXBwZW5kZWQgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICBQb2ludCAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAg\n")) 161 | (testpath/"brew.shx").write(::Base64.decode64("AAAnCgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARugDAAALAAAAAAAAAAAAAAAA\nAAAAAADwPwAAAAAAABBAAAAAAAAAFEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAADIAAAASAAAASAAAABIAAABeAAAAEgAAAHQAAAASAAAA\nigAAABI=\n")) 162 | result = shell_output("#{bin}/shp2pgsql #{testpath}/brew.shp") 163 | assert_match /Point/, result 164 | assert_match /AddGeometryColumn/, result 165 | end 166 | end 167 | --------------------------------------------------------------------------------