Skip to content

Commit

Permalink
Apply most brew audit recommendations
Browse files Browse the repository at this point in the history
And update client download URLs.
  • Loading branch information
theory committed Oct 2, 2023
1 parent 8effc2c commit 4baa2d3
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 143 deletions.
116 changes: 56 additions & 60 deletions Formula/sqitch.rb
Original file line number Diff line number Diff line change
@@ -1,44 +1,42 @@
require 'formula'
require_relative '../requirements/snowflake_req'
require_relative '../requirements/firebird_req'
require_relative '../requirements/oracle_req'
require_relative '../requirements/vertica_req'
require_relative '../requirements/exasol_req'
require_relative "../requirements/snowflake_req"
require_relative "../requirements/firebird_req"
require_relative "../requirements/oracle_req"
require_relative "../requirements/vertica_req"
require_relative "../requirements/exasol_req"

class Sqitch < Formula
homepage 'https://sqitch.org/'
version 'v1.4.0'
url "https://www.cpan.org/authors/id/D/DW/DWHEELER/App-Sqitch-#{stable.version}.tar.gz"
sha256 'b0db387031f77562662e003bc55d7a102a26380b4ad7fdb9a8a3bad5769e501c'
head 'https://github.com/sqitchers/sqitch.git', branch: 'main'
depends_on 'perl'
depends_on 'cpm' => :build

option 'with-postgres-support', "Support for managing PostgreSQL-compatible databases"
option 'with-sqlite-support', "Support for managing SQLite databases"
option 'with-mysql-support', "Support for managing MySQL databases"
option 'with-firebird-support', "Support for managing Firbird databases"
option 'with-oracle-support', "Support for managing Oracle databases"
option 'with-vertica-support', "Support for managing Vertica databases"
option 'with-exasol-support', "Support for managing Exasol databases"
option 'with-snowflake-support', "Support for managing Snowflake databases"
option 'with-std-env', "Build against custom non-Homebrew dependencies"

if build.with? "std-env"
env :std
end
desc "Sensible database change management"
homepage "https://sqitch.org/"
url "https://www.cpan.org/authors/id/D/DW/DWHEELER/App-Sqitch-v1.4.0.tar.gz"
sha256 "b0db387031f77562662e003bc55d7a102a26380b4ad7fdb9a8a3bad5769e501c"
license "MIT"
head "https://github.com/sqitchers/sqitch.git", branch: "develop"

option "with-postgres-support", "Support for managing PostgreSQL-compatible databases"
option "with-sqlite-support", "Support for managing SQLite databases"
option "with-mysql-support", "Support for managing MySQL databases"
option "with-firebird-support", "Support for managing Firbird databases"
option "with-oracle-support", "Support for managing Oracle databases"
option "with-vertica-support", "Support for managing Vertica databases"
option "with-exasol-support", "Support for managing Exasol databases"
option "with-snowflake-support", "Support for managing Snowflake databases"
option "with-std-env", "Build against custom non-Homebrew dependencies"

depends_on "cpm" => :build
depends_on FirebirdReq if build.with? "firebird-support"
depends_on "libpq" if build.with? "postgres-support"
depends_on "mysql-client" if build.with? "mysql-support"
depends_on OracleReq if build.with? "oracle-support"
depends_on "perl"
depends_on "sqlite" if build.with? "sqlite-support"

env :std if build.with? "std-env"

if build.head?
depends_on 'gettext' => :build
depends_on "gettext" => :build
depends_on "openssl@3" => :build
end

depends_on 'libpq' if build.with? "postgres-support"
depends_on 'sqlite' if build.with? "sqlite-support"
depends_on 'mysql-client' if build.with? "mysql-support"
depends_on FirebirdReq if build.with? "firebird-support"
depends_on OracleReq if build.with? "oracle-support"

if build.with? "vertica-support"
depends_on "libiodbc"
depends_on VerticaReq
Expand All @@ -56,33 +54,33 @@ class Sqitch < Formula

def install
# Download Module::Build and Menlo::CLI::Compat.
cpmArgs = %W[install --local-lib-contained instutil --no-test];
cpmArgs.push("--verbose") if verbose?
# cpmArgs.push("--quiet") if quiet?
system 'cpm', *cpmArgs, 'Menlo::CLI::Compat', 'Module::Build'
cpan_args = %w[install --local-lib-contained instutil --no-test]
cpan_args.push("--verbose") if verbose?
# cpan_args.push("--quiet") if quiet?
system "cpm", *cpan_args, "Menlo::CLI::Compat", "Module::Build"

ENV['PERL5LIB'] = "#{buildpath}/instutil/lib/perl5"
ENV['PERL_MM_OPT'] = 'INSTALLDIRS=vendor'
ENV['PERL_MB_OPT'] = '--installdirs vendor'
ENV["PERL5LIB"] = "#{buildpath}/instutil/lib/perl5"
ENV["PERL_MM_OPT"] = "INSTALLDIRS=vendor"
ENV["PERL_MB_OPT"] = "--installdirs vendor"

if build.head?
# Need to tell the compiler where to find Gettext.
ENV.prepend_path "PATH", Formula["gettext"].opt_bin

# Download Dist::Zilla and plugins, then make and cd into a build dir.
system 'cpm', *cpmArgs, 'Dist::Zilla'
system './instutil/bin/dzil authordeps --missing | xargs cpm ' + cpmArgs.join(' ')
system './instutil/bin/dzil', 'build', '--in', '.brew'
Dir.chdir '.brew'
system "cpm", *cpan_args, "Dist::Zilla"
system "./instutil/bin/dzil authordeps --missing | xargs cpm " + cpan_args.join(" ")
system "./instutil/bin/dzil", "build", "--in", ".brew"
Dir.chdir ".brew"
end

# Pull together features.
args = %W[Build.PL --install_base #{prefix} --etcdir #{etc}/sqitch]
args.push("--verbose") if verbose?
args.push("--quiet") if quiet?
%w{postgres sqlite mysql firebird oracle vertica exasol snowflake}.each { |f|
args.push("--with", f) if build.with? "#{ f }-support"
}
%w[postgres sqlite mysql firebird oracle vertica exasol snowflake].each do |f|
args.push("--with", f) if build.with? "#{f}-support"
end

# Build and bundle (install).
# XXX Fix for wayward Data::Dump in v1.4.0.
Expand All @@ -94,29 +92,27 @@ def install
# https://github.com/orgs/Homebrew/discussions/4391
if build.with?("postgres-support") || build.with?("mysql-support")
paths = []
if build.with? "postgres-support"
paths.push(Formula["libpq"].opt_bin)
end
if build.with? "mysql-support"
paths.push(Formula["mysql-client"].opt_bin)
end
paths.push(Formula["libpq"].opt_bin) if build.with? "postgres-support"
paths.push(Formula["mysql-client"].opt_bin) if build.with? "mysql-support"

mkdir_p libexec
mv bin/"sqitch", libexec/"sqitch"
(bin/"sqitch").write_env_script libexec/"sqitch", PATH: "#{paths.join(":")}:$PATH"
end

# Move the man pages from #{prefix}/man to #{prefix}/share/man.
mkdir "#{prefix}/share"
mv "#{prefix}/man", "#{prefix}/share/man"
# Move the man pages from #{prefix}/man to man.
mkdir share
mv "#{prefix}/man", man
end

def post_install
# Show notes from requirements.
requirements.each do |req|
if req.respond_to? :notes
ohai "#{ req.name } Support Notes", req.notes
end
ohai "#{req.name} Support Notes", req.notes if req.respond_to? :notes
end
end

test do
system bin/"sqitch", "--version"
end
end
10 changes: 4 additions & 6 deletions Formula/sqitch_firebird.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
require 'formula'

class SqitchFirebird < Formula
homepage 'https://sqitch.org/'
version '0'
url "file://#{HOMEBREW_REPOSITORY}/README.md", :using => :nounzip
desc "Replaced by `brew install sqitch --with-firebird-support`"
homepage "https://sqitch.org/"
url "file://#{HOMEBREW_REPOSITORY}/README.md", using: :nounzip
version "0"
sha256 Pathname.new("#{HOMEBREW_REPOSITORY}/README.md").sha256

def install
Expand All @@ -19,5 +18,4 @@ def install
EOS
end

end
10 changes: 4 additions & 6 deletions Formula/sqitch_mysql.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
require 'formula'

class SqitchMysql < Formula
homepage 'https://sqitch.org/'
version '0'
url "file://#{HOMEBREW_REPOSITORY}/README.md", :using => :nounzip
desc "Replaced by `brew install sqitch --with-mysql-support`"
homepage "https://sqitch.org/"
url "file://#{HOMEBREW_REPOSITORY}/README.md", using: :nounzip
version "0"
sha256 Pathname.new("#{HOMEBREW_REPOSITORY}/README.md").sha256

def install
Expand All @@ -19,5 +18,4 @@ def install
EOS
end

end
10 changes: 4 additions & 6 deletions Formula/sqitch_oracle.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
require 'formula'

class SqitchOracle < Formula
homepage 'https://sqitch.org/'
version '0'
url "file://#{HOMEBREW_REPOSITORY}/README.md", :using => :nounzip
desc "Replaced by `brew install sqitch --with-oracle-support`"
homepage "https://sqitch.org/"
url "file://#{HOMEBREW_REPOSITORY}/README.md", using: :nounzip
version "0"
sha256 Pathname.new("#{HOMEBREW_REPOSITORY}/README.md").sha256

def install
Expand All @@ -19,5 +18,4 @@ def install
EOS
end

end
10 changes: 4 additions & 6 deletions Formula/sqitch_pg.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
require 'formula'

class SqitchPg < Formula
homepage 'https://sqitch.org/'
version '0'
url "file://#{HOMEBREW_REPOSITORY}/README.md", :using => :nounzip
desc "Replaced by `brew install sqitch --with-postgres-support`"
homepage "https://sqitch.org/"
url "file://#{HOMEBREW_REPOSITORY}/README.md", using: :nounzip
version "0"
sha256 Pathname.new("#{HOMEBREW_REPOSITORY}/README.md").sha256

def install
Expand All @@ -19,5 +18,4 @@ def install
EOS
end

end
10 changes: 4 additions & 6 deletions Formula/sqitch_sqlite.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
require 'formula'

class SqitchSqlite < Formula
homepage 'https://sqitch.org/'
version '0'
url "file://#{HOMEBREW_REPOSITORY}/README.md", :using => :nounzip
desc "Replaced by `brew install sqitch --with-sqlite-support`"
homepage "https://sqitch.org/"
url "file://#{HOMEBREW_REPOSITORY}/README.md", using: :nounzip
version "0"
sha256 Pathname.new("#{HOMEBREW_REPOSITORY}/README.md").sha256

def install
Expand All @@ -19,5 +18,4 @@ def install
EOS
end

end
10 changes: 4 additions & 6 deletions Formula/sqitch_vertica.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
require 'formula'

class SqitchVertica < Formula
homepage 'https://sqitch.org/'
version '0'
url "file://#{HOMEBREW_REPOSITORY}/README.md", :using => :nounzip
desc "Replaced by `brew install sqitch --with-vertica-support`"
homepage "https://sqitch.org/"
url "file://#{HOMEBREW_REPOSITORY}/README.md", using: :nounzip
version "0"
sha256 Pathname.new("#{HOMEBREW_REPOSITORY}/README.md").sha256

def install
Expand All @@ -19,5 +18,4 @@ def install
EOS
end

end
20 changes: 9 additions & 11 deletions requirements/exasol_req.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
require "requirement"

class ExasolReq < Requirement
@@dylib = "/Library/ODBC/EXASolution\ ODBC.bundle/Contents/MacOS/libexaodbc-*.dylib"
@@client = "/Applications/EXAplus.app/Contents/MacOS/EXAplus"
@have_client = false
@have_dylib = false
fatal false
download "https://www.exasol.com/portal/display/DOWNLOAD/"
download "https://downloads.exasol.com"

def initialize(tags = [])
super
Expand All @@ -20,33 +18,33 @@ def initialize(tags = [])
def message
<<~EOS
Sqitch Exasol support requires the Exasol ODBC Driver and EXAplus client.
Downloads: #{ download }
Downloads: #{download}
EOS
end

def notes
msg = "Exasol support requires the ODBC Driver and EXAplus client\n\n"
# Show found items.
if @have_dylib
msg += "- Found Driver matching:\n #{ @@dylib }\n\n"
msg += "- Found Driver matching:\n #{@@dylib}\n\n"
end
if @have_client
msg += "- Found EXAplus:\n #{ @@client }\n" \
msg += "- Found EXAplus:\n #{@@client}\n" \
" Make sure it's in your \$PATH or tell Sqitch where to find it by running:\n\n" \
" sqitch config --user engine.exasol.client \"#{ @@client }\"\n\n"
" sqitch config --user engine.exasol.client \"#{@@client}\"\n\n"
end

# Show missing items.
if !@have_dylib
msg += "- Cannot find ODBC Driver: No file found matching\n\n" \
" #{ @@dylib }\n\n" \
" #{@@dylib}\n\n" \
" Download from:\n\n" \
" #{ download }\n\n"
" #{download}\n\n"
end
if !@have_client
msg += "- Cannot find client binary:\n #{ @@client }\n" \
msg += "- Cannot find client binary:\n #{@@client}\n" \
" Download from:\n\n" \
" #{ download }\n\n" \
" #{download}\n\n" \
" Once it's installed, make sure it's in your \$PATH or tell Sqitch\n" \
" where to find it by running:\n\n" \
" sqitch config --user engine.exasol.client /path/to/exaplus\n\n"
Expand Down
10 changes: 4 additions & 6 deletions requirements/firebird_req.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require "requirement"

class FirebirdReq < Requirement
@@framework = "/Library/Frameworks/Firebird.framework"
@@isql = "/Library/Frameworks/Firebird.framework/Resources/bin/isql"
Expand All @@ -20,17 +18,17 @@ def initialize(tags = [])
def message
<<~EOS
Sqitch Firebird support requires the Firebird Server Package.
Download from: #{ download }
Download from: #{download}
EOS
end

def notes
msg = "Firebird support requires the Firebird Server Framework\n\n" \
"- Found Framework #{ @@framework }\n"
"- Found Framework #{@@framework}\n"
if @have_isql
msg += "- Found isql binary: #{ @@isql }\n" \
msg += "- Found isql binary: #{@@isql}\n" \
" Make sure it's in your \$PATH or tell Sqitch where to find it by running:\n\n" \
" sqitch config --user engine.firebird.client #{ @@isql }\n\n"
" sqitch config --user engine.firebird.client #{@@isql}\n\n"
else
msg += "- Cannot find isql binary in framework; installation instructions:\n\n" \
" https://www.firebirdsql.org/file/documentation/reference_manuals/user_manuals/html/qsg3-installing.html\n\n" \
Expand Down
Loading

0 comments on commit 4baa2d3

Please sign in to comment.