<commit_before>class Unlinked < Requirement
  fatal true

  satisfy(:build_env => false) { !osgeo_postgis_linked && !core_postgis_linked }

  def osgeo_postgis_linked
    Formula["osgeo-postgis"].linked_keg.exist?
  rescue
    return false
  end

  def core_postgis_linked
    Formula["postgis"].linked_keg.exist?
  rescue
    return false
  end

  def message
    s = "\033[31mYou have other linked versions!\e[0m\n\n"

    s += "Unlink with \e[32mbrew unlink osgeo-postgis\e[0m or remove with \e[32mbrew uninstall --ignore-dependencies osgeo-postgis\e[0m\n\n" if osgeo_postgis_linked
    s += "Unlink with \e[32mbrew unlink postgis\e[0m or remove with brew \e[32muninstall --ignore-dependencies postgis\e[0m\n\n" if core_postgis_linked
    s
  end
end

class OsgeoPostgisAT24 < Formula
  desc "Adds support for geographic objects to PostgreSQL"
  homepage "https://postgis.net/"
  # url "https://github.com/postgis/postgis/archive/2.4.8.tar.gz"
  # sha256 "d81f36abc4dc7235de65e4e58b00dee33d1ca14e9b70a3a2b888be90544b3cb5"
  url "https://github.com/postgis/postgis.git",
    :branch => "stable-2.4",
    :commit => "b495daed109f4771cc44066fcc0d4825131c7dc5"
  version "2.4.8"

  bottle do
    root_url "https://bottle.download.osgeo.org"
    cellar :any
    rebuild 1
    sha256 "445a238aafa26015fbbc74f12adbe3f4b625c545ed682c2f0bcb1c44ee774b2c" => :mojave
    sha256 "445a238aafa26015fbbc74f12adbe3f4b625c545ed682c2f0bcb1c44ee774b2c" => :high_sierra
    sha256 "c7beee0ddd6337a6f521b44a9b5cfbf57f824c20201b75d72dc115e379bcd509" => :sierra
  end

  revision 2

  head "https://github.com/postgis/postgis.git", :branch => "svn-2.4"

  option "with-html-docs", "Generate multi-file HTML documentation"
  option "with-api-docs", "Generate developer API documentation (long process)"
  option "with-pg10", "Build with PostgreSQL 10 client"

  # keg_only :versioned_formula
  # we will verify that other versions are not linked
  depends_on Unlinked

  depends_on "autoconf" => :build
  depends_on "automake" => :build
  depends_on "libtool" => :build
  depends_on "gpp" => :build
  depends_on "pkg-config" => :build
  depends_on "geos"
  depends_on "json-c" # for GeoJSON and raster handling
  depends_on "libiconv"
  depends_on "libxml2"
  depends_on "libxslt"
  depends_on "pcre"
  depends_on "osgeo-proj"
  depends_on "sfcgal" # for advanced 2D/3D functions
  depends_on "protobuf-c" #  Geobuf and Mapbox Vector Tile support
  depends_on "osgeo-gdal" # for GeoJSON and raster handling

  # The latest supported version of PostgreSQL by PostGIS 2.4 is 11,
  # and thus it's the standard version.
  # https://trac.osgeo.org/postgis/wiki/UsersWikiPostgreSQLPostGIS
  if build.with?("pg10")
    depends_on "osgeo-postgresql@10"
  else
    depends_on "osgeo-postgresql@11"
  end

  depends_on "gtk+" # for gui

  if build.with? "html-docs"
    depends_on "imagemagick"
    depends_on "docbook-xsl" # docbook-xsl-nons
  end

  if build.with? "api-docs"
    depends_on "graphviz"
    depends_on "doxygen"
  end

  def install
    # Follow the PostgreSQL linked keg back to the active Postgres installation
    # as it is common for people to avoid upgrading Postgres.
    # postgres_realpath = Formula["osgeo-postgresql@10"].opt_prefix.realpath
    ENV.append "CFLAGS", "-Diconv=libiconv -Diconv_open=libiconv_open -Diconv_close=libiconv_close"
    ENV.append "LDFLAGS", "-L#{Formula["libiconv"].opt_lib} -liconv" # ICONV_LDFLAGS

    ENV.deparallelize

    args = [
      "--with-libiconv=#{Formula["libiconv"].opt_prefix}",
      "--with-xml2config=#{Formula["libxml2"].opt_bin}/xml2-config",
      "--with-geosconfig=#{Formula["geos"].opt_bin}/geos-config",
      "--with-sfcgal=#{Formula["sfcgal"].opt_bin}/sfcgal-config",
      "--with-projdir=#{Formula["osgeo-proj"].opt_prefix}",
      "--with-jsondir=#{Formula["json-c"].opt_prefix}",
      "--with-protobufdir=#{Formula["protobuf-c"].opt_prefix}",
      "--with-pcredir=#{Formula["pcre"].opt_prefix}",
      "--with-gdalconfig=#{Formula["osgeo-gdal"].opt_bin}/gdal-config",
      "--with-gui",
      "--with-raster",
    ]

    # By default PostGIS will try to detect gettext support and compile with it,
    # how ever if your un into incompatibility issues that cause breakage of loader,
    # you can disable it entirely with this command. Refer to ticket
    # http://trac.osgeo.org/postgis/ticket/748 for an example issue solved by
    # configuring with this. NOTE: that you aren’t missing much by turning this off.
    # This is used for international help/label support for the GUI loader which is not
    # yet documented and still experimental.
    args << "--with-gettext=no" # or PATH

    # 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.
    args << "--disable-nls"

    # Wagyu will only be necessary if protobuf is present to build MVTs
    # args << "--with-wagyu"

    # Disable topology support.
    # There is no corresponding library as all logic needed for
    # topology is in postgis- 2.4.8 library.
    # args << "--without-topology"

    # Disable the address_standardizer extension
    # args << "--without-address-standardizer"

    # specify the dtd path for mathml2.dtd
    # args << "--with-mathmldtd=PATH"

    args << "--with-xsldir=#{Formula["docbook-xsl"].opt_prefix}/docbook-xsl" if build.with? "html-docs" # /docbook-xsl-nons

    if build.with?("pg10")
      args << "--with-pgconfig=#{Formula["osgeo-postgresql@10"].opt_bin}/pg_config"
    else
      args << "--with-pgconfig=#{Formula["osgeo-postgresql@11"].opt_bin}/pg_config"
    end

    system "./autogen.sh"
    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
<commit_msg>Revert PostGIS 2.4<commit_after>class Unlinked < Requirement
  fatal true

  satisfy(:build_env => false) { !osgeo_postgis_linked && !core_postgis_linked }

  def osgeo_postgis_linked
    Formula["osgeo-postgis"].linked_keg.exist?
  rescue
    return false
  end

  def core_postgis_linked
    Formula["postgis"].linked_keg.exist?
  rescue
    return false
  end

  def message
    s = "\033[31mYou have other linked versions!\e[0m\n\n"

    s += "Unlink with \e[32mbrew unlink osgeo-postgis\e[0m or remove with \e[32mbrew uninstall --ignore-dependencies osgeo-postgis\e[0m\n\n" if osgeo_postgis_linked
    s += "Unlink with \e[32mbrew unlink postgis\e[0m or remove with brew \e[32muninstall --ignore-dependencies postgis\e[0m\n\n" if core_postgis_linked
    s
  end
end

class OsgeoPostgisAT24 < Formula
  desc "Adds support for geographic objects to PostgreSQL"
  homepage "https://postgis.net/"
  url "https://github.com/postgis/postgis/archive/2.4.8.tar.gz"
  sha256 "6d0211a6bcbe45750967e850975ec0bcce4b14f5b4226a189f1e33694e7b8fe9"

  bottle do
    root_url "https://bottle.download.osgeo.org"
    cellar :any
    rebuild 1
    sha256 "445a238aafa26015fbbc74f12adbe3f4b625c545ed682c2f0bcb1c44ee774b2c" => :mojave
    sha256 "445a238aafa26015fbbc74f12adbe3f4b625c545ed682c2f0bcb1c44ee774b2c" => :high_sierra
    sha256 "c7beee0ddd6337a6f521b44a9b5cfbf57f824c20201b75d72dc115e379bcd509" => :sierra
  end

  #revision 3

  head "https://github.com/postgis/postgis.git", :branch => "svn-2.4"

  option "with-html-docs", "Generate multi-file HTML documentation"
  option "with-api-docs", "Generate developer API documentation (long process)"
  option "with-pg10", "Build with PostgreSQL 10 client"

  # keg_only :versioned_formula
  # we will verify that other versions are not linked
  depends_on Unlinked

  depends_on "autoconf" => :build
  depends_on "automake" => :build
  depends_on "libtool" => :build
  depends_on "gpp" => :build
  depends_on "pkg-config" => :build
  depends_on "geos"
  depends_on "json-c" # for GeoJSON and raster handling
  depends_on "libiconv"
  depends_on "libxml2"
  depends_on "libxslt"
  depends_on "pcre"
  depends_on "osgeo-proj"
  depends_on "sfcgal" # for advanced 2D/3D functions
  depends_on "protobuf-c" #  Geobuf and Mapbox Vector Tile support
  depends_on "osgeo-gdal" # for GeoJSON and raster handling

  if build.with?("pg10")
    depends_on "osgeo-postgresql@10"
  else
    depends_on "osgeo-postgresql"
  end

  depends_on "gtk+" # for gui

  if build.with? "html-docs"
    depends_on "imagemagick"
    depends_on "docbook-xsl" # docbook-xsl-nons
  end

  if build.with? "api-docs"
    depends_on "graphviz"
    depends_on "doxygen"
  end

  def install
    # Follow the PostgreSQL linked keg back to the active Postgres installation
    # as it is common for people to avoid upgrading Postgres.
    # postgres_realpath = Formula["osgeo-postgresql@10"].opt_prefix.realpath
    ENV.append "CFLAGS", "-Diconv=libiconv -Diconv_open=libiconv_open -Diconv_close=libiconv_close"
    ENV.append "LDFLAGS", "-L#{Formula["libiconv"].opt_lib} -liconv" # ICONV_LDFLAGS

    ENV.deparallelize

    args = [
      "--with-libiconv=#{Formula["libiconv"].opt_prefix}",
      "--with-xml2config=#{Formula["libxml2"].opt_bin}/xml2-config",
      "--with-geosconfig=#{Formula["geos"].opt_bin}/geos-config",
      "--with-sfcgal=#{Formula["sfcgal"].opt_bin}/sfcgal-config",
      "--with-projdir=#{Formula["osgeo-proj"].opt_prefix}",
      "--with-jsondir=#{Formula["json-c"].opt_prefix}",
      "--with-protobufdir=#{Formula["protobuf-c"].opt_prefix}",
      "--with-pcredir=#{Formula["pcre"].opt_prefix}",
      "--with-gdalconfig=#{Formula["osgeo-gdal"].opt_bin}/gdal-config",
      "--with-gui",
      "--with-raster",
    ]

    # By default PostGIS will try to detect gettext support and compile with it,
    # how ever if your un into incompatibility issues that cause breakage of loader,
    # you can disable it entirely with this command. Refer to ticket
    # http://trac.osgeo.org/postgis/ticket/748 for an example issue solved by
    # configuring with this. NOTE: that you aren’t missing much by turning this off.
    # This is used for international help/label support for the GUI loader which is not
    # yet documented and still experimental.
    args << "--with-gettext=no" # or PATH

    # 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.
    args << "--disable-nls"

    # Wagyu will only be necessary if protobuf is present to build MVTs
    # args << "--with-wagyu"

    # Disable topology support.
    # There is no corresponding library as all logic needed for
    # topology is in postgis- 2.4.8 library.
    # args << "--without-topology"

    # Disable the address_standardizer extension
    # args << "--without-address-standardizer"

    # specify the dtd path for mathml2.dtd
    # args << "--with-mathmldtd=PATH"

    args << "--with-xsldir=#{Formula["docbook-xsl"].opt_prefix}/docbook-xsl" if build.with? "html-docs" # /docbook-xsl-nons

    if build.with?("pg10")
      args << "--with-pgconfig=#{Formula["osgeo-postgresql@10"].opt_bin}/pg_config"
    else
      args << "--with-pgconfig=#{Formula["osgeo-postgresql"].opt_bin}/pg_config"
    end

    system "./autogen.sh"
    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

{'fraction_non_alphanumeric': 0.11999665747472216, 'fraction_numerical': 0.03868973009108381, 'mean_word_length': 3.4823970037453185, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 27, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2856796', 'n_tokens_mistral': 4578, 'n_tokens_neox': 4284, 'n_words': 1002}