-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to install any spec #1343
Allow to install any spec #1343
Conversation
6ed9ca4
to
a23b700
Compare
What is the command line to install stable if devel or HEAD is already installed? |
Just |
current = f if f.installed? | ||
current ||= f.old_installed_formulae.first | ||
if f.keg_only? && !f.installed_prefixes.empty? && f.opt_prefix.symlink? && !ARGV.force? | ||
# keg-only install is only possible when no ohter version is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohter
-> other
current ||= f.old_installed_formulae.first | ||
if f.keg_only? && !f.installed_prefixes.empty? && f.opt_prefix.symlink? && !ARGV.force? | ||
# keg-only install is only possible when no ohter version is | ||
# optlinked, because silent install can break dependencies. Therefore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optlinked
-> linked to opt
. Not sure I understand what "silent install" means.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will replace "silent install" with install without any warnings.
# optlinked, because silent install can break dependencies. Therefore | ||
# before performing other checks we need to be sure --force flag is | ||
# passed. | ||
opoo "#{f.full_name} is a keg-only and another version is optlinked." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optlinked
->linked to opt
puts "Use `brew install --force` if you want to install this version" | ||
elsif (ARGV.build_head? && (version = f.latest_head_version) && | ||
!f.head_version_outdated?(version, fetch_head: ARGV.fetch_head?)) || | ||
(f.prefix.exist? && !f.prefix.children.empty?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split some/all of these conditionals into variables. Similarly consider doing so for the if
too.
end | ||
|
||
msg = "#{f.full_name}-#{installed_version} already installed" | ||
if f.linked_keg.symlink? && f.linked_keg.resolved_path != f.prefix(installed_version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f.linked_keg.resolved_path != f.prefix(installed_version)
could be a helper method or just variable.
else | ||
version.update_commit(commit) | ||
false | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this doing, out of interest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tries to shrink the commit for the version if it's possible. When we pass the commit to this method, we can fetch a full-length commit and overwrite short one with full-length for the formula. If there is no multiple short commits, there is no need to keep it full-length and we update it with initial one.
commit_outdated?
is called here: https://github.com/Homebrew/brew/blob/master/Library/Homebrew/formula.rb#L522
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, works for me.
Liking where this is going, nice work @vladshablinsky! |
3fd1461
to
9354579
Compare
@MikeMcQuaid is it getting better? Still needs some fixes in documentation and I guess tests, but will go for it when we're fine with the behaviour and the code. |
9354579
to
1a5c1a8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more changes but looking good 👍
# sure --force flag is passed. | ||
opoo "#{f.full_name} is a keg-only and another version is linked to opt." | ||
puts "Use `brew install --force` if you want to install this version" | ||
elsif ARGV.build_head? && new_head_installed || prefix_installed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
split new_head_installed || prefix_installed
into another variable because the parity is ambiguous.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it's (ARGV.build_head? && new_head_installed) || prefix_installed
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, see! 😀
|
||
# Is formula's linked keg points to the prefix. | ||
def prefix_linked?(v = pkg_version) | ||
linked? && linked_keg.resolved_path == prefix(v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return false unless linked?
end | ||
elsif !f.any_version_installed? && old_formula = f.old_installed_formulae.first | ||
msg = "#{old_formula.full_name}-#{old_formula.installed_version} already installed" | ||
unless old_formula.linked? || old_formula.keg_only? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use if
here because unless ||
hurts my brain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 OK. The reason I didn't change it is that unless
had been here before any change was made.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeh, not your issue but may as well clean it up while you're refactoring the other bits 👍
end | ||
|
||
msg = "#{f.full_name}-#{installed_version} already installed" | ||
if f.linked? && f.linked_version != installed_version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could make f.linked_version != installed_version
another variable for clarity but feel free to ignore that.
msg = "#{current.full_name}-#{current.installed_version} already installed" | ||
unless current.linked_keg.symlink? || current.keg_only? | ||
msg << ", it's just not linked" | ||
prefix_installed = (f.prefix.exist? && !f.prefix.children.empty?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can probably skip parentheses here.
@vladshablinsky Any news here? Thanks! |
1a5c1a8
to
ca57c2c
Compare
Sorry for absence during last week, left some comments and updated the code. |
@vladshablinsky No need to apologise or be Homebrewing every week. Just checking in 😁 |
ae91ccb
to
d52a36c
Compare
It's probably set for adding tests now. |
@vladshablinsky Agreed, code looks good. If you could add some tests and also detail how you're testing this manually (so I can do so myself too). Thanks! |
Will add tests later this week. As for manual testing -- I was patching |
Great, thanks. |
57ebda4
to
3c0ebb9
Compare
3c0ebb9
to
a37334a
Compare
* `Formula#linked?` returns true if formula linked * `Formula#optlinked?` returns true if formula linked to opt formula installed to the Cellar * `Formula#prefix_linked?` returns true if linked keg points to the prefix passed as an argument * `Formula#linked_version` to get linked version of the formula
* installing HEAD keg_only should be possible only if: 1. - Old version installed differs from new one and optlinked - `--force` flag is passed - HEAD is seriously outdated or outdated with `--fetch-HEAD` or 2. - Old version installed differs from new one and not optlinked or 3. - This formula is not installed * installing keg_only should be possible only if: 1. - Old version installed differs from new one and optlinked - `--force` flag is passed or 2. - Old version installed differs from new one and not optlinked or 3. - This formula is not installed * installing HEAD should be possible only if: 1. - Old HEAD is seriously outdated or outdated with `--fetch-HEAD` or 2. - HEAD is not installed * installing stable or devel should be possible only if: - Old version installed differs from new one
a37334a
to
ae80110
Compare
@MikeMcQuaid seems like it's almost ready, however El Capitan caks tests fail, what should I do? |
@vladshablinsky I reckon just a random failure. Have requeued. |
end | ||
EOS | ||
|
||
# Ignore dependincies, because we'll try to resolve requirements in build.rb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dependincies
ae80110
to
a24a919
Compare
Will merge as soon as I am able to be around 4 hours after the merge. |
brew tests
with your changes locally?This is a possible fix for
install
part of #1162 and possible replacement for #1296.For now it has some complicated if statements that should probably be replaced and some feedback on how it can be achieved is appreciated.
The behaviour for
install
should be the following:installing HEAD keg_only should be possible only if:
--force
flag is passed--fetch-HEAD
OR
OR
installing keg_only should be possible only if:
--force
flag is passedOR
OR
installing HEAD should be possible only if:
--fetch-HEAD
OR
installing stable or devel should be possible only if:
Here is an example of how it looks like:
CC @MikeMcQuaid @ilovezfs