Skip to content

Commit

Permalink
Clean up MacOS version method usage
Browse files Browse the repository at this point in the history
The MacOS.version? family of methods (other than "leopard?") are poorly
defined and lead to confusing code. Replace them in formulae with more
explicit comparisons.

"MacOS.version" is a special version object that can be compared to
numerics, symbols, and strings using the standard Ruby comparison
methods.

The old methods were moved to compat when the version comparison code
was merged, and they must remain there "forever", but they should not be
used in new code.

Signed-off-by: Jack Nagel <[email protected]>
  • Loading branch information
jacknagel committed Sep 10, 2012
1 parent db74b9b commit 6b8d25f
Show file tree
Hide file tree
Showing 70 changed files with 94 additions and 90 deletions.
2 changes: 1 addition & 1 deletion Library/Formula/abyss.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Abyss < Formula
depends_on 'google-sparsehash' => :build

# Snow Leopard comes with mpi but Lion does not
depends_on 'open-mpi' if MacOS.lion?
depends_on 'open-mpi' if MacOS.version >= :lion

# strip breaks the ability to read compressed files.
skip_clean 'bin'
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/alpine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Alpine < Formula
# http:https://trac.macports.org/ticket/20971
def patches
"https://trac.macports.org/export/89747/trunk/dports/mail/alpine/files/alpine-osx-10.6.patch"
end if MacOS.snow_leopard?
end if MacOS.version >= :snow_leopard

def install
ENV.j1
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/aria2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Aria2 < Formula
depends_on 'pkg-config' => :build

# Leopard's libxml2 is too old.
depends_on 'libxml2' if MacOS.leopard?
depends_on 'libxml2' if MacOS.version == :leopard

def install
system "./configure", "--disable-dependency-tracking",
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/avidemux.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def install

# For 32-bit compilation under gcc 4.2, see:
# http:https://trac.macports.org/ticket/20938#comment:22
if MacOS.leopard? or Hardware.is_32_bit?
if MacOS.version == :leopard or Hardware.is_32_bit?
inreplace 'cmake/admFFmpegBuild.cmake',
'${CMAKE_INSTALL_PREFIX})',
'${CMAKE_INSTALL_PREFIX} --extra-cflags=-mdynamic-no-pic)'
Expand Down
4 changes: 2 additions & 2 deletions Library/Formula/bind.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Bind < Formula
version '9.9.1-p2'
sha1 '449b12c32682b5bef64c7b53cd0fc0c6b731c8a7'

depends_on "openssl" if MacOS.leopard?
depends_on "openssl" if MacOS.version == :leopard

def install
ENV.libxml2
Expand All @@ -23,7 +23,7 @@ def install

# For Xcode-only systems we help a bit to find openssl.
# If CLT.installed?, it evaluates to "/usr", which works.
args << "--with-openssl=#{MacOS.sdk_path.to_s}/usr" unless MacOS.leopard?
args << "--with-openssl=#{MacOS.sdk_path.to_s}/usr" unless MacOS.version == :leopard

system "./configure", *args

Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/cairo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def install
]

args << '--with-x' unless build.include? 'without-x'
args << '--enable-xcb=no' if MacOS.leopard?
args << '--enable-xcb=no' if MacOS.version == :leopard

system "./configure", *args
system "make install"
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/clisp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def install
# The ulimit must be set, otherwise `make` will fail and tell you to do so
system "ulimit -s 16384 && make"

if MacOS.lion?
if MacOS.version >= :lion
opoo "`make check` fails on Lion, so we are skipping it."
puts "But it probably means there will be other issues too."
puts "Please take them upstream to the clisp project itself."
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/collectd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def install
--localstatedir=#{var}
--with-python=/usr/bin]

args << "--disable-embedded-perl" if MacOS.leopard?
args << "--disable-embedded-perl" if MacOS.version == :leopard

system "./configure", *args
system "make install"
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/couchdb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Couchdb < Formula
depends_on 'spidermonkey'
depends_on 'icu4c'
depends_on 'erlang'
depends_on 'curl' if MacOS.leopard?
depends_on 'curl' if MacOS.version == :leopard

def install
system "./bootstrap" if File.exists? "bootstrap"
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/disco.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Disco < Formula
head 'https://github.com/tuulos/disco.git'

depends_on 'erlang'
depends_on 'simplejson' => :python if MacOS.leopard?
depends_on 'simplejson' => :python if MacOS.version == :leopard
depends_on 'libcmph'

def install
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/e2fsprogs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def patches
]}

# MacPorts patch to allow compilation on Leopard.
if MacOS.leopard?
if MacOS.version == :leopard
p[:p0] << "https://trac.macports.org/export/92117/trunk/dports/sysutils/e2fsprogs/files/patch-lib-ext2fs-inline.c.diff"
end

Expand Down
4 changes: 2 additions & 2 deletions Library/Formula/ejabberd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Ejabberd < Formula
url "http:https://www.process-one.net/downloads/ejabberd/2.1.11/ejabberd-2.1.11.tgz"
sha1 'ae2c521d5e93fbd5bc826052c5524b5222dcfae6'

depends_on "openssl" if MacOS.leopard?
depends_on "openssl" if MacOS.version == :leopard
depends_on "erlang"

option "32-bit"
Expand All @@ -28,7 +28,7 @@ def install
"--sysconfdir=#{etc}",
"--localstatedir=#{var}"]

if MacOS.leopard?
if MacOS.version == :leopard
openssl = Formula.factory('openssl')
args << "--with-openssl=#{openssl.prefix}"
end
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/erlang.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def install
"--enable-shared-zlib",
"--enable-smp-support"]

args << "--with-dynamic-trace=dtrace" unless MacOS.leopard?
args << "--with-dynamic-trace=dtrace" unless MacOS.version == :leopard

unless build.include? 'disable-hipe'
# HIPE doesn't strike me as that reliable on OS X
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/ffmbc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Ffmbc < Formula
option "with-libvpx", "Enable VP8 video format"

# manpages won't be built without texi2html
depends_on 'texi2html' => :build if MacOS.mountain_lion?
depends_on 'texi2html' => :build if MacOS.version >= :mountain_lion
depends_on 'yasm' => :build

depends_on 'x264' unless build.include? 'without-x264'
Expand Down
4 changes: 2 additions & 2 deletions Library/Formula/ffmpeg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Ffmpeg < Formula
option 'with-tools', 'Enable additional FFmpeg tools'

# manpages won't be built without texi2html
depends_on 'texi2html' => :build if MacOS.mountain_lion?
depends_on 'texi2html' => :build if MacOS.version >= :mountain_lion
depends_on 'yasm' => :build

depends_on 'x264' unless build.include? 'without-x264'
Expand Down Expand Up @@ -79,7 +79,7 @@ def install

# For 32-bit compilation under gcc 4.2, see:
# http:https://trac.macports.org/ticket/20938#comment:22
ENV.append_to_cflags "-mdynamic-no-pic" if MacOS.leopard? or Hardware.is_32_bit?
ENV.append_to_cflags "-mdynamic-no-pic" if MacOS.version == :leopard or Hardware.is_32_bit?

system "./configure", *args

Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/fontforge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def install
# MACOSX_DEPLOYMENT_TARGET fixes ensuing Python 10.7 vs 10.8 clash.
# Discussed: https://github.com/mxcl/homebrew/pull/14097
# Reported: Not yet.
if MacOS.mountain_lion?
if MacOS.version >= :mountain_lion
ENV.macosxsdk("10.7")
ENV.append "CFLAGS", "-isysroot #{MacOS.sdk_path(10.7)}"
ENV["MACOSX_DEPLOYMENT_TARGET"] = "10.8"
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/ghc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class NeedsSnowLeopard < Requirement
def satisfied?
MacOS.snow_leopard?
MacOS.version >= :snow_leopard
end

def message; <<-EOS.undent
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def install
ENV['PYTHON_PATH'] = which 'python' # python can be brewed or unbrewed

# Clean XCode 4.x installs don't include Perl MakeMaker
ENV['NO_PERL_MAKEMAKER'] = '1' if MacOS.lion?
ENV['NO_PERL_MAKEMAKER'] = '1' if MacOS.version >= :lion

ENV['BLK_SHA1'] = '1' if build.include? 'with-blk-sha1'

Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/gnunet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Gnunet < Formula

depends_on 'libgcrypt'
depends_on 'libextractor'
depends_on 'curl' unless MacOS.lion? # needs >= v7.20.1
depends_on 'curl' if MacOS.version < :lion # needs >= v7.20.1

def install
system "./configure", "--disable-debug",
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/google-js-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def message
end

def satisfied?
MacOS.snow_leopard?
MacOS.version >= :snow_leopard
end
end

Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/graphicsmagick.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def install
"--prefix=#{prefix}",
"--enable-shared", "--disable-static"]
args << "--without-magick-plus-plus" if build.include? 'without-magick-plus-plus'
args << "--disable-openmp" if MacOS.leopard? or ENV.compiler == :clang # libgomp unavailable
args << "--disable-openmp" if MacOS.version == :leopard or ENV.compiler == :clang # libgomp unavailable
args << "--with-gslib" if ghostscript_srsly?
args << "--with-gs-font-dir=#{HOMEBREW_PREFIX}/share/ghostscript/fonts" \
unless ghostscript_fonts?
Expand Down
6 changes: 3 additions & 3 deletions Library/Formula/grass.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def headless?
#
# This restriction can be lifted once WxMac hits a stable release that is
# 64-bit capable.
ARGV.include? '--without-gui' or MacOS.lion?
ARGV.include? '--without-gui' or MacOS.version >= :lion
end

class Grass < Formula
Expand All @@ -31,7 +31,7 @@ class Grass < Formula
depends_on "libtiff"
depends_on "unixodbc"
depends_on "fftw"
depends_on "cairo" if MacOS.leopard?
depends_on "cairo" if MacOS.version == :leopard
depends_on :x11

# Patches ensure 32 bit system python is used for wxWidgets and that files
Expand Down Expand Up @@ -101,7 +101,7 @@ def install
end

# Deal with Cairo support
if MacOS.leopard?
if MacOS.version == :leopard
cairo = Formula.factory('cairo')
args << "--with-cairo-includes=#{cairo.include}/cairo"
args << "--with-cairo-libs=#{cairo.lib}"
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/imap-uw.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class ImapUw < Formula
sha1 '7a82ebd5aae57a5dede96ac4923b63f850ff4fa7'

def patches
if MacOS.snow_leopard?
if MacOS.version >= :snow_leopard
{ :p0 =>
'https://trac.macports.org/export/63088/trunk/dports/mail/imap-uw/files/patch-snowleopard.diff'
}
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/iodine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Iodine < Formula
sha1 '4fa9a248b8a84df8a727a5d749e669e58136edca'

def install
unless MacOS.leopard?
unless MacOS.version == :leopard
inreplace ["src/common.c", "src/dns.c", "src/iodine.c", "src/iodined.c"],
"arpa/nameser8_compat", "arpa/nameser_compat"
end
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/jstalk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class NeedsSnowLeopard < Requirement
def satisfied?
MacOS.snow_leopard?
MacOS.version >= :snow_leopard
end

def message
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/lftp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Lftp < Formula

def install
# Bus error
ENV.no_optimization if MacOS.leopard?
ENV.no_optimization if MacOS.version == :leopard

system "./configure", "--disable-dependency-tracking", "--prefix=#{prefix}"
system "make install"
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/libagg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Libagg < Formula
depends_on 'pkg-config' => :build
depends_on 'sdl'
depends_on :freetype => :optional if build.include? "with-freetype"
depends_on :libtool unless MacOS.mountain_lion?
depends_on :libtool unless MacOS.version >= :mountain_lion

fails_with :clang do
build 421
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/libmemcached.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Libmemcached < Formula
depends_on 'memcached'

def install
ENV.append_to_cflags "-undefined dynamic_lookup" if MacOS.leopard?
ENV.append_to_cflags "-undefined dynamic_lookup" if MacOS.version == :leopard

system "./configure", "--prefix=#{prefix}"
system "make install"
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/libmms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Libmms < Formula

def patches
# see https://trac.macports.org/ticket/27988
if MacOS.leopard?
if MacOS.version == :leopard
{ :p0 => "https://trac.macports.org/export/87883/trunk/dports/multimedia/libmms/files/src_mms-common.h.patch" }
end
end
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/librasterlite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Librasterlite < Formula
url 'http:https://www.gaia-gis.it/gaia-sins/librasterlite-sources/librasterlite-1.1c.tar.gz'
sha1 'c54f38ef2974bc92410e2c2196088af14bd9c21a'

depends_on "pkg-config" => :build unless MacOS.mountain_lion?
depends_on "pkg-config" => :build unless MacOS.version >= :mountain_lion
depends_on :libpng
depends_on "libgeotiff"
depends_on "libspatialite"
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/librets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Librets < Formula
sha1 '2de4d9e9cb26533eb0a9a090b3354a70ed3c41ec'

depends_on 'boost'
depends_on 'swig' if MacOS.lion?
depends_on 'swig' if MacOS.version >= :lion

def install
system "./configure", "--disable-debug",
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/libvirt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Libvirt < Formula
depends_on "gnutls"
depends_on "yajl"

if MacOS.leopard?
if MacOS.version == :leopard
# Definitely needed on Leopard, but not on Snow Leopard.
depends_on "readline"
depends_on "libxml2"
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/libxml++.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Libxmlxx < Formula

depends_on 'glibmm'
# LibXML++ can't compile agains the version of LibXML shipped with Leopard
depends_on 'libxml2' if MacOS.leopard?
depends_on 'libxml2' if MacOS.version == :leopard

def install
system "./configure", "--disable-dependency-tracking",
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/macvim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def install

# If building for 10.8, make sure that CC is set to "clang".
# Reference: https://github.com/b4winckler/macvim/wiki/building
ENV['CC'] = "clang" if MacOS.mountain_lion?
ENV['CC'] = "clang" if MacOS.version >= :mountain_lion

args = %W[
--with-features=huge
Expand Down
4 changes: 2 additions & 2 deletions Library/Formula/mapserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Mapserver < Formula
depends_on 'gdal'

depends_on 'geos' if build.include? 'with-geos'
depends_on 'postgresql' if build.include? 'with-postgresql' and not MacOS.lion?
depends_on 'postgresql' if build.include? 'with-postgresql' and not MacOS.version >= :lion
depends_on 'fcgi' if build.include? 'with-fastcgi'

def patches
Expand All @@ -41,7 +41,7 @@ def install
args << "--with-php=/usr/include/php" if build.include? 'with-php'

if build.include? 'with-postgresql'
if MacOS.lion? # Lion ships with PostgreSQL libs
if MacOS.version >= :lion # Lion ships with PostgreSQL libs
args << "--with-postgis"
else
args << "--with-postgis=#{HOMEBREW_PREFIX}/bin/pg_config"
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/md.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Md < Formula
sha1 '0128de65a4da2ef9655f3b1e6a94d2f8ae292414'

# OS X up to and including Lion 10.7 includes 'md'
keg_only :provided_by_osx unless MacOS.mountain_lion?
keg_only :provided_by_osx unless MacOS.version >= :mountain_lion

def install
cd 'md' do
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/mpd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def install
"--enable-fluidsynth",
"--enable-zip",
"--enable-lame-encoder"]
args << "--disable-curl" if MacOS.leopard?
args << "--disable-curl" if MacOS.version == :leopard
args << "--enable-lastfm" if build.include?("lastfm")

system "./configure", *args
Expand Down
Loading

0 comments on commit 6b8d25f

Please sign in to comment.