Skip to content

Commit 0f20877

Browse files
committed
Add formula for Sqitch
Based on the sqitchers/sqitch tap, it supports PostgreSQL, MySQL, and SQLite out of the box, and Snowflake, Exasol, and Vertica with ODBC via the installation of additional client libraries. Snowflake support could use the `snowflake-snowsql` formula, but it's Cask only. The caveat output points to a URL that describes how to install these additional dependencies, which will be updated appropriately by sqitchers/sqitch.org#13. The install method installs all Perl modules in the Cellar directory, which is useful for keeping everything together and avoiding conflicts with other Perl applications, but means that they must all be re-installed when upgrading to a new version. Not supported: Oracle and Firebase, since there are no formulas for Instant Client or the Firebase server (or clients). The URL emitted by the Caveat points users who need to manage Oracle or Firebase databases to the Sqitch tap.
1 parent 603d03d commit 0f20877

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

Formula/sqitch.rb

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
class Sqitch < Formula
2+
desc "Sensible database change management"
3+
homepage "https://sqitch.org/"
4+
url "https://www.cpan.org/authors/id/D/DW/DWHEELER/App-Sqitch-v1.3.1.tar.gz"
5+
sha256 "f5e768d298cd4047ee2ae42319782e8c2cda312737bcbdbfaf580bd47efe8b94"
6+
license "MIT"
7+
head "https://github.com/sqitchers/sqitch.git", branch: "develop"
8+
9+
depends_on "cpm" => :build
10+
depends_on "libiodbc"
11+
depends_on "libpq"
12+
depends_on "mysql-client"
13+
depends_on "perl"
14+
uses_from_macos "sqlite"
15+
16+
if build.head?
17+
depends_on "gettext" => :build
18+
depends_on "openssl@3" => :build
19+
end
20+
21+
def install
22+
# Download Module::Build and Menlo::CLI::Compat.
23+
cpm_args = %w[install --local-lib-contained instutil --no-test]
24+
cpm_args.push("--verbose") if verbose?
25+
system "cpm", *cpm_args, "Menlo::CLI::Compat", "Module::Build"
26+
27+
ENV["PERL5LIB"] = "#{buildpath}/instutil/lib/perl5"
28+
ENV["PERL_MM_OPT"] = "INSTALLDIRS=vendor"
29+
ENV["PERL_MB_OPT"] = "--installdirs vendor"
30+
31+
if build.head?
32+
# Need to tell the compiler where to find Gettext.
33+
ENV.prepend_path "PATH", Formula["gettext"].opt_bin
34+
35+
# Download Dist::Zilla and plugins, then make and cd into a build dir.
36+
system "cpm", *cpm_args, "Dist::Zilla"
37+
system "./instutil/bin/dzil authordeps --missing | xargs cpm " + cpm_args.join(" ")
38+
system "./instutil/bin/dzil", "build", "--in", ".brew"
39+
Dir.chdir ".brew"
40+
end
41+
42+
# Assemble the Build.PL args, including supported native and ODBC engines.
43+
# Oracle and Firebird not currently supported.
44+
args = %W[
45+
Build.PL --install_base #{prefix} --etcdir #{etc}/sqitch
46+
--with postgres --with sqlite --with mysql
47+
--with vertica --with exasol --with snowflake
48+
]
49+
args.push("--verbose") if verbose?
50+
args.push("--quiet") if quiet?
51+
52+
# Build and bundle (install).
53+
system "perl", *args
54+
system "./Build", "bundle"
55+
56+
# Wrap the binary in client paths.
57+
mkdir_p libexec
58+
mv bin/"sqitch", libexec/"sqitch"
59+
paths = [
60+
Formula["libpq"].opt_bin,
61+
Formula["mysql-client"],
62+
]
63+
(bin/"sqitch").write_env_script libexec/"sqitch", PATH: "#{paths.join(":")}:$PATH"
64+
65+
# Move the man pages from #{prefix}/man to man.
66+
mkdir share
67+
mv "#{prefix}/man", man
68+
end
69+
70+
def caveats
71+
<<~EOS
72+
This Sqitch install includes clients to manage Postgres, MySQL, and SQLite.
73+
See https://sqitch.org/download/macos/ to install the client libraries
74+
required to manage Snowflake, Exasol, and Vertica. Use the sqitchers/sqitch
75+
tap to manage Oracle or Firebird.
76+
EOS
77+
end
78+
79+
test do
80+
system bin/"sqitch", "--version"
81+
end
82+
end

0 commit comments

Comments
 (0)