313 Commits

Author SHA1 Message Date
Alyssa Ross
8b30abe060 keg: handle dependencies of moved/renamed formulae
In #1497 I switched from Keg#to_formula for comparing kegs to formulae
to comparing the name and tap in the keg's tab to the name and tap of
the formula.

However, this fails to match if the name and tap of the formula have
changed since the keg was installed, so it's clearly better to use
Keg#to_formula where possible, and fall back to the information in the
tab when #to_formula can't be used.
2016-12-31 17:53:06 +00:00
Mike McQuaid
33fbf3f32d Merge pull request #1750 from alyssais/fallback_dependencies
keg: fall back for dependencies of buggy tabs
2016-12-31 17:34:55 +00:00
Mike McQuaid
1c9651f04f Merge pull request #1756 from alyssais/nil_dependents
keg: don't return nil dependencies
2016-12-31 17:34:17 +00:00
Mike McQuaid
a571965df9 formula: make prefix usually return opt_prefix.
Return `opt_prefix` if it exists and `prefix` is not called from within
the same formula's `install` or `post_install` methods. Otherwise, fall
back to the existing functionality.

This avoids the need to use `opt_prefix` etc. everywhere and generally
means we don't expose an implementation detail (i.e. the full Cellar
path) to dependents that have a habit of hard-coding it.
2016-12-31 16:38:05 +00:00
Alyssa Ross
fb920668c8 keg: don't return nil dependencies
This is a proper fix to the problem addressed by #1510.

The problem arises when f_kegs is nil, which can happen if the name and
tap used to install a keg don't match the name and tap currently
associated with its formula (i.e. if it's been renamed or moved).
2016-12-31 14:16:38 +00:00
Alyssa Ross
b0a38c06bf docs: improve Keg.find_some_installed_dependencies
See https://github.com/Homebrew/brew/pull/1752#discussion_r94257147
2016-12-30 22:22:13 +00:00
Alyssa Ross
d998a3fcce tab: remove #reliable_runtime_dependencies?
See https://github.com/Homebrew/brew/pull/1750#discussion_r94243825 for
discussion.

Removes Tab#reliable_runtime_dependencies? in favour of returning nil
from Tab#runtime_dependencies if the list is unreliable.

Because Homebrew 1.1.6 hasn't been tagged yet, tabs created in tests
aren't created with a homebrew_version that marks the
runtime_dependencies in the Tab as reliable, so there are some tests
that fail. To work around this, I've had to add a line to some tests
that explicitly overrides the homebrew_version in the Tab. This is
really ugly though, so they should be removed as soon as possible after
1.1.6 is released.
2016-12-30 20:34:14 +00:00
Alyssa Ross
01e1f7d49e keg: fix fallback dependencies with multiple kegs
Fixes #1524.
2016-12-30 18:41:14 +00:00
Alyssa Ross
e5db7927c9 keg: fall back for dependencies of buggy tabs
Fixes #1554.
2016-12-30 16:16:53 +00:00
Alyssa Ross
3a27d81219 keg: fix dependents with unavailable formulae
Because of an accidental use of `=` instead of `==`, the source formula
check would be skipped when determining if a keg depended on another one
(so only the versions would be compared).

Fixed that comparison, and updated the corresponding test.

Glad I caught that!
2016-12-27 22:58:44 +00:00
Alyssa Ross
e5d7e13c63 keg: installed dependencies of unknown formulae
Previously, trying to resolve the dependencies of a keg would raise an
exception if the formulae for any of the dependencies could not be found
(e.g. if it had been moved to another tap).

This commit updates the dependency finding logic to catch these
exceptions, and fall back to comparing names and taps of formulae, which
should give the correct behaviour.

Fixes #1586.
2016-12-27 18:03:05 +00:00
Mike McQuaid
c317c3c31f Merge pull request #1616 from zachwhaley/zsh_functions_caveats
caveats: Differentiate zsh completion files and function files
2016-12-12 13:27:40 +00:00
Mike McQuaid
11483d55c9 keg: also prune opt.
If there's dead symlinks in there they should be removed.
2016-12-11 11:55:07 +00:00
Zach Whaley
14f46625a3 caveats: Differentiate zsh completion files and function files
When installing a file to zsh/site-functions directory, it is assumed this is a zsh completion file,
and the zsh completion caveat is printed after installation.

But not all files in the zsh/site-functions directory are completion files.
Some are files for functions that can be loaded on demand with zsh's autoload command.

- Edit Keg.completion_installed to search specifically for files in the zsh/site-functions
  directory starting with an underscore only (By convention, zsh completion files start with an underscore)
- Add Keg.zsh_functions_installed to search for non-completion files in the zsh/site-functions
- Add Caveats.zsh_function_caveats to print a caveat if non-completion files have been installed
  to zsh/site-functions
2016-12-08 07:23:26 -06:00
Zach Whaley
1995f65308 Add a method for installing fish function files
Fish shell allows third-party software vendors to put their own function files in a directory for their software.
For brew installed Fish shell, this is /usr/local/share/fish/vendor_functions.d
2016-12-04 13:21:42 -06:00
Alyssa Ross
f7f72093a8 keg: don't rely on #to_formula
It doesn't always work.
For example, a keg could have been installed with a formula from a
URL, which Homebrew now does not know how to access.

Fixes #1496.
2016-11-13 23:20:38 +00:00
Alyssa Ross
bb30b01d5d uninstall: go easier on the integration tests 2016-10-25 23:53:59 +01:00
Alyssa Ross
5a3d6c4c8f uninstall, keg: update style 2016-10-25 23:48:34 +01:00
Alyssa Ross
a4dc835ba0 uninstall: call Formula#missing_dependencies directly 2016-10-25 22:36:13 +01:00
Alyssa Ross
ef13f8eaca uninstall: only <=1 Diagnostic.missing_deps call 2016-10-25 22:34:35 +01:00
Alyssa Ross
452691528d Revert "keg: fallback to missing_deps if deps not in tab"
This reverts commit da1caba17c624f03fa8e6fbe59683f57fb7ac17a.
2016-10-25 22:34:35 +01:00
Alyssa Ross
ae3f53a1ec keg: fallback to missing_deps if deps not in tab 2016-10-25 22:34:35 +01:00
Alyssa Ross
563b56701b keg: rename #formula to #to_formula
@vladshablinsky pointed out that other Homebrew classes, like Dependency,
use #to_formula.
2016-10-25 22:34:34 +01:00
Alyssa Ross
08f3aecf6b uninstall: consistent spelling of "dependent"
@ilovezfs pointed out that Homebrew generally uses "dependent", rather than
"dependant".
2016-10-25 22:34:34 +01:00
Alyssa Ross
6f0aabe707 uninstall: refuse when dependants still installed
Closes #934.
2016-10-25 22:34:34 +01:00
Markus Reiter
58e36c7319 Fix Style/GuardClause. 2016-09-24 12:24:35 +02:00
Markus Reiter
e851c9bf6c Style/Alias: Prefer alias. 2016-09-23 18:19:53 +02:00
Markus Reiter
b5f8de8bf4 Fix Style/RegexpLiteral. 2016-09-23 15:30:07 +02:00
Markus Reiter
1c632f9c1e Fix Style/CaseIndentation. 2016-09-23 15:30:06 +02:00
Markus Reiter
42efb44e7d Fix Lint/EndAlignment. 2016-09-23 15:30:06 +02:00
Mike McQuaid
ac31a6518e keg: only prune var/homebrew/linked.
`var/homebrew` is too broad and ends up deleting and recreating the
locks directory repeatedly.
2016-09-18 21:52:42 +01:00
Mike McQuaid
6693915399 rubocop --auto-correct all remaining files.
But remove some manual `.freeze`s on constants that shouldn't be
constants.
2016-09-17 16:14:13 +01:00
Mike McQuaid
e3609b6fd4 Move LinkedKegs/PinnedKegs/Locks from Library.
These don't make sense to be tied to the `HOMEBREW_REPOSITORY` but
instead should live in the `HOMEBREW_PREFIX` as they all relate to its
state.
2016-09-16 13:51:56 +01:00
Mike McQuaid
1c5fa19f84 Merge pull request #966 from MikeMcQuaid/keg-lock-constants
Use constants for LinkedKegs/PinnedKegs/Locks.
2016-09-15 18:57:04 +01:00
Mike McQuaid
72d10fff0b Use constants for LinkedKegs/PinnedKegs/Locks.
These definitions are scattered throughout the codebase which makes it
hard to refactor them later (my goal is to move them outside of
HOMEBREW_LIBRARY). Unify their definitions for clearer code and easier
movement later.
2016-09-15 18:28:42 +01:00
Mike McQuaid
842d6ce8bd keg: add ALL_TOP_LEVEL_DIRECTORIES constant.
This is used in diagnostic (and will be used in other places later)
rather than hard-coding other directories later.
2016-09-15 09:20:39 +01:00
Dominyk Tiller
2aa32ea191
keg: make guile's site-dir persistent
Things that install Guile scheme objects should be doing so in
HOMEBREW_PREFIX/share/guile/site, which should be persistent rather
than a symlink to any formulae's Cellar, not even guile's necessarily as
f061d864d9
managed to expose.

I believe guile isn't actually configured correctly to expect
this directory, but since absolutely nobody has complained to
date as far as I can find & `gnutls` seems to be the only formula
using it this way the temptation is to leave it misconfigured
& use this directory for site schemes.

I don't really know the deeper issues around messing with Guile's
configuration so going for a minimal fix seems the safest option.
2016-09-12 03:24:53 +01:00
Xu Cheng
a8566c9848 various: eliminate the usage of any? (#638)
`any?` is not the opposite of `empty?`. Besides the case that
`[false, nil].any?` will return false, `any?`(O(n)) has much worse
performance than `empty?`(O(1)).
2016-08-05 22:01:32 +08:00
Xu Cheng
1eaa95b805
Keg#link: run optlink first
This prevents a link conflict during `brew upgrade` causing opt link
stuck to old version. At this point, users will have to run `brew switch`
to fix it.

Closes #533.

Signed-off-by: Xu Cheng <xucheng@me.com>
2016-07-17 02:16:18 +08:00
Luca Favatella
c6022104f9 bottle: delete .pyo files as with .pyc (#382)
This should make more bottles relocatable e.g. ansible.

.pyo files are bytecode as .pyc files but optimized -
[ref](https://www.python.org/dev/peps/pep-0488/)

Ref https://github.com/Homebrew/homebrew-core/pull/2125#issuecomment-226987124
2016-06-21 01:22:58 +02:00
Paolo G. Giarrusso
2f20a42292 Synchronize counts for link and unlink (#242)
Closes #239.
2016-05-15 12:07:58 +01:00
Dominyk Tiller
7faae5adf2 keg: mkpath on lua shares
Closes Homebrew/homebrew#48134.
2016-01-19 12:54:00 +00:00
Xu Cheng
885022a5e3 add Keg#empty_installation?
Avoid using `FormulaAuditor` in `FormulaInstaller`.

Closes Homebrew/homebrew#47887.

Signed-off-by: Xu Cheng <xucheng@me.com>
2016-01-09 20:28:15 +08:00
Rakesh
e4f2a1e0ef pathname: store file count and disk usage.
especially for directory instances of `Pathname` class and all
instances of `Keg` class.
2015-12-30 08:11:23 +00:00
Xu Cheng
d108bf0a55 move more deprecated methods to compat folder 2015-11-17 18:52:00 +08:00
Xu Cheng
8cf3402870 keg: mkpath for share/postgresql 2015-11-07 02:26:33 +08:00
Alex Dunn
d435f3ac41 keg.rb: guard against nonexistent site-lisp subdir
Fixes Homebrew/homebrew#45596.
2015-11-01 18:04:42 -08:00
Alex Dunn
168a2687f8 stricter audit for Emacs Lisp installs
Require that the subdirectory in site-lisp match the formula name
exactly.  This lets us provide better information in the caveats and
will make it easier for helper methods to write to the correct
location (as in in Homebrew/homebrew-emacs#13).
2015-11-01 17:34:28 -08:00
Martin Afanasjew
fdd3469fca linkapps: stop linking .app bundles from 'bin/'
`Keg#app_installed?` only checks the formula prefix and `libexec/` for
.app bundles to determine if a formula provides any. This is used by
`Caveats#app_caveats` to generate an appropriate message. The same list
should be used by `brew linkapps` for consistency.

Reduce likelihood of future inconsistencies by creating `Keg#apps` and
using it in place of the duplicate code.

Closes Homebrew/homebrew#45173.

Signed-off-by: Xu Cheng <xucheng@me.com>
2015-10-20 18:25:28 +08:00
M Jordan Stanway
a7df9c53eb keg: add java to SHARE_PATHS
Add `java` to `SHARE_PATHS` so that `HOMEBREW_PREFIX/share/java` is a folder with symlinks in it, rather than a symlink to a folder for a specific formula.

This way we avoid conflicts if multiple formulas put `jar` files in the
standard location `HOMEBREW_PREFIX/share/java`.

See also:
[pull request 44420](https://github.com/Homebrew/homebrew/pull/44420)

Closes Homebrew/homebrew#44456.

Signed-off-by: Xu Cheng <xucheng@me.com>
2015-10-08 16:23:40 +08:00