Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Adding rudimentary hold support #9128

Closed
wants to merge 3 commits into from

4 participants

@dreynolds

As the title says, I added some rudimentary hold support as Max mentioned here http://librelist.com/browser//homebrew/2011/2/10/how-do-you-hold-a-package/#70c01a17185156a819144fe006e9cd3d

Apologies for any bad Ruby that I may have written.

@adamv
Owner

Cool. Needs some review (and I don't have the time to do it, sorry).

@dreynolds

Ugh, I didn't mean to do that

I fail at pull requests :(

@mxcl mxcl commented on the diff
Library/Homebrew/cmd/hold.rb
@@ -0,0 +1,42 @@
+require 'blacklist'
+
+module Homebrew extend self
+ def hold
+ # Make sure package exists
+ ARGV.named.each do |name|
+ msg = blacklisted? name
+ raise "No available formula for #{name}\n#{msg}" if msg
+ end unless ARGV.force?
@mxcl Collaborator
mxcl added a note

No need for this chunk of code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mxcl mxcl commented on the diff
Library/Homebrew/cmd/hold.rb
@@ -0,0 +1,42 @@
+require 'blacklist'
+
+module Homebrew extend self
+ def hold
+ # Make sure package exists
+ ARGV.named.each do |name|
+ msg = blacklisted? name
+ raise "No available formula for #{name}\n#{msg}" if msg
+ end unless ARGV.force?
+
+ # Make sure Hold directory exists
+ hold = HOMEBREW_REPOSITORY+'Library/Hold'
+ if not File.exists? hold
+ mkdir hold
+ end
@mxcl Collaborator
mxcl added a note

Can replace with simply:

(HOMEBREW_REPOSITORY+'Library/Hold').mkpath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mxcl
Collaborator

Seems great to me. Thanks for the work.

Sorry to @adamv that its abuse of Library again. But since we've started we should continue.

But for the mythical brew2 we could and probably should just stick an empty HOLD file in the rack directory.

@adamv
Owner

Willing to "give it up" until brew2

@mxcl
Collaborator

Despite the fact I argued against it last time you bought it up. I think it's the better way to do it.

@mikemcquaid
Owner

Closing. Will reopen when you update using the comments and rebase. Thanks!

@mikemcquaid mikemcquaid closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 15, 2011
  1. @dreynolds
Commits on Dec 21, 2011
  1. @dreynolds
  2. @dreynolds
This page is out of date. Refresh to see the latest.
View
3  .gitignore
@@ -7,4 +7,5 @@
!/bin/brew
!/share/man/man1/brew.1
.DS_Store
-/Library/LinkedKegs
+/Library/LinkedKegs
+/Library/Hold
View
42 Library/Homebrew/cmd/hold.rb
@@ -0,0 +1,42 @@
+require 'blacklist'
+
+module Homebrew extend self
+ def hold
+ # Make sure package exists
+ ARGV.named.each do |name|
+ msg = blacklisted? name
+ raise "No available formula for #{name}\n#{msg}" if msg
+ end unless ARGV.force?
@mxcl Collaborator
mxcl added a note

No need for this chunk of code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
+ # Make sure Hold directory exists
+ hold = HOMEBREW_REPOSITORY+'Library/Hold'
+ if not File.exists? hold
+ mkdir hold
+ end
@mxcl Collaborator
mxcl added a note

Can replace with simply:

(HOMEBREW_REPOSITORY+'Library/Hold').mkpath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
+ hold_formulae ARGV.formulae
+ end
+
+ def hold_formulae formulae
+ formulae = [formulae].flatten.compact
+ unless formulae.empty?
+ formulae.each do |f|
+ if f.installed_prefix.parent.children.length > 0
+ if not File.exists? f.hold_path
+ hold_this = nil
+ Dir.entries(f.installed_prefix.parent).each do |n|
+ hold_this = n if File.directory? n and n != '.' or n != '..'
+ end
+ hold_this = f.installed_prefix.parent+hold_this
+ File.symlink(hold_this, f.hold_path)
+ ohai "#{f.name} is now held"
+ else
+ ohai "#{f.name} is already held"
+ end
+ else
+ ohai "#{f.name} is not installed and hence cannot be held"
+ end
+ end
+ end
+ end
+end
View
2  Library/Homebrew/cmd/outdated.rb
@@ -22,7 +22,7 @@ def outdated_brews
name = rack.basename.to_s
f = Formula.factory name rescue nil
- f if f and not f.installed?
+ f if f and not f.installed? and not f.held?
end.compact
end
end
View
1  Library/Homebrew/cmd/upgrade.rb
@@ -15,6 +15,7 @@ def upgrade
Homebrew.outdated_brews
else
ARGV.formulae.each do |f|
+ next if f.held?
raise "#{f} already upgraded" if f.installed?
raise "#{f} not installed" unless f.rack.exist? and not f.rack.children.empty?
end
View
8 Library/Homebrew/formula.rb
@@ -303,6 +303,14 @@ def brew
end
end
+ def hold_path
+ HOMEBREW_REPOSITORY+'Library/Hold'+name
+ end
+
+ def held?
+ File.exists? hold_path
+ end
+
def == b
name == b.name
end
Something went wrong with that request. Please try again.