Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Commit

Permalink
Add conflicts_with DSL method
Browse files Browse the repository at this point in the history
conflicts_with is a thin wrapper around Requirement which simplifies
marking conflicts between formulae.

Closes #13687.

Signed-off-by: Misty De Meo <mistydemeo@gmail.com>
  • Loading branch information
mistydemeo committed Jul 30, 2012
1 parent 08a1836 commit 2814e3a
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 22 deletions.
7 changes: 5 additions & 2 deletions Library/Formula/mariadb.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
require 'formula'

class Mariadb < Formula
# You probably don't want to have this and MySQL's formula linked at the same time
# Just saying.
url 'http://ftp.osuosl.org/pub/mariadb/mariadb-5.3.7/kvm-tarbake-jaunty-x86/mariadb-5.3.7.tar.gz'
homepage 'http://mariadb.org/'
sha1 '1ee2ef4895aefabd66b4884c382ba2cd1f7bbe2d'

depends_on 'readline'

conflicts_with 'mysql',
:because => "mariadb and mysql install the same binaries."
conflicts_with 'percona-server',
:because => "mariadb and percona-server install the same binaries."

fails_with :clang do
build 318
end
Expand Down
5 changes: 5 additions & 0 deletions Library/Formula/mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ class Mysql < Formula
depends_on 'readline'
depends_on 'pidof'

conflicts_with 'mariadb',
:because => "mysql and mariadb install the same binaries."
conflicts_with 'percona-server',
:because => "mysql and percona-server install the same binaries."

fails_with :llvm do
build 2326
cause "https://github.com/mxcl/homebrew/issues/issue/144"
Expand Down
3 changes: 3 additions & 0 deletions Library/Formula/par2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ class Par2 < Formula
url 'http://downloads.sourceforge.net/project/parchive/par2cmdline/0.4/par2cmdline-0.4.tar.gz'
sha1 '2fcdc932b5d7b4b1c68c4a4ca855ca913d464d2f'

conflicts_with "par2tbb",
:because => "par2 and par2tbb install the same binaries."

def patches
"http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/app-arch/par2cmdline/files/par2cmdline-0.4-gcc4.patch?revision=1.1"
end
Expand Down
18 changes: 5 additions & 13 deletions Library/Formula/par2tbb.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
require 'formula'

class Par2tbb < Formula
url 'http://chuchusoft.com/par2_tbb/par2cmdline-0.4-tbb-20100203.tar.gz'
homepage 'http://chuchusoft.com/par2_tbb/'
md5 'b1052a08c3c6eac8a7a0605addb161e7'
url 'http://chuchusoft.com/par2_tbb/par2cmdline-0.4-tbb-20100203.tar.gz'
sha1 '2fcdc932b5d7b4b1c68c4a4ca855ca913d464d2f'

depends_on 'tbb'

conficts_with "par2",
:because "par2tbb and par2 install the same binaries."

fails_with :clang do
build 318
end
Expand All @@ -21,11 +24,6 @@ def install
# but only 10.6+ are available on Xcode4
inreplace 'Makefile.am', /^.*-mmacosx-version.*$/, ''

if Formula.factory('par2').installed?
opoo "par2tbb conflicts with par2. Your par2 binaries will be overwritten.
If this bothers you, you can restore par2 with `brew link par2`."
end

host_triplet = MacOS.prefer_64_bit? ? "x86_64-apple-darwin11" : "i686-apple-darwin11"

system "./configure", "--disable-debug", "--disable-dependency-tracking",
Expand All @@ -34,12 +32,6 @@ def install
system "make install"
end

def caveats
<<-EOS.undent
par2tbb is a modified fork of par2 and conflicts with its binaries.
EOS
end

def test
system "#{bin}/par2"
end
Expand Down
7 changes: 5 additions & 2 deletions Library/Formula/percona-server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ class PerconaServer < Formula
version '5.5.25-27.1'
sha1 'f3388960311b159e46efd305ecdeb806fe2c7fdc'

keg_only "This brew conflicts with 'mysql'. It's safe to `brew link` if you haven't installed 'mysql'"

depends_on 'cmake' => :build
depends_on 'readline'
depends_on 'pidof'

conflicts_with 'mysql',
:because => "percona-server and mysql install the same binaries."
conflicts_with 'mariadb',
:because => "percona-server and mariadb install the same binaries."

skip_clean :all # So "INSTALL PLUGIN" can work.

fails_with :llvm do
Expand Down
8 changes: 3 additions & 5 deletions Library/Formula/rarian.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ class Rarian < Formula
url 'http://rarian.freedesktop.org/Releases/rarian-0.8.1.tar.bz2'
md5 '75091185e13da67a0ff4279de1757b94'

def install
if Formula.factory('scrollkeeper').installed?
opoo "rarian conflicts with scrollkeeper. Your scrollkeeper binaries will be overwritten.
If this bothers you, you can restore scrollkeeper with `brew link scrollkeeper`."
end
conflicts_with 'scrollkeeper',
:because => "rarian and scrollkeeper install the same binaries."

def install
system "./configure", "--disable-dependency-tracking",
"--prefix=#{prefix}"
system "make install"
Expand Down
3 changes: 3 additions & 0 deletions Library/Formula/scrollkeeper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ class Scrollkeeper < Formula
depends_on 'gettext'
depends_on 'docbook'

conflicts_with 'rarian',
:because => "scrollkeeper and rarian install the same binaries."

def install
system "./configure", "--prefix=#{prefix}",
"--mandir=#{man}",
Expand Down
5 changes: 5 additions & 0 deletions Library/Homebrew/cmd/info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ def info_formula f
end

puts "Depends on: #{f.deps*', '}" unless f.deps.empty?
conflicts = []
f.external_deps.each do |dep|
conflicts << dep.formula if dep.is_a? ConflictRequirement
end
puts "Conflicts with: #{conflicts*', '}" unless conflicts.empty?

if f.rack.directory?
kegs = f.rack.children
Expand Down
20 changes: 20 additions & 0 deletions Library/Homebrew/dependencies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,23 @@ def message
end

end

class ConflictRequirement < Requirement
attr_reader :formula

def initialize formula, message
@formula = formula
@message = message
end

def message; @message; end

def satisfied?
keg = Formula.factory(@formula).prefix
not keg.exist? && Keg.new(keg).linked?
end

def fatal?
not ARGV.force?
end
end
15 changes: 15 additions & 0 deletions Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,21 @@ def depends_on dep
dependencies.add(dep)
end

def conflicts_with formula, opts={}
message = <<-EOS.undent
#{formula} cannot be installed alongside #{name.downcase}.
EOS
message << "This is because #{opts[:reason]}\n" if opts[:reason]
if !ARGV.force? then message << <<-EOS.undent
Please `brew unlink` or `brew uninstall` #{formula} before continuing.
To install anyway, use:
brew install --force
EOS
end

dependencies.add ConflictRequirement.new(formula, message)
end

def skip_clean paths
if paths == :all
@skip_clean_all = true
Expand Down

0 comments on commit 2814e3a

Please sign in to comment.