71 Commits

Author SHA1 Message Date
Mike McQuaid
9216d8abe6
rubocop-rails: make fixes. 2020-12-02 10:43:04 +00:00
EricFromCanada
3768b7a6e9 apidoc: update comment wording, punctuation, formatting 2020-11-06 00:21:02 -05:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Mike McQuaid
fb4d08a49a Fix brew style 2020-09-11 10:29:22 +01:00
Dario Vladovic
4f26d85a46
os/mac/keg_relocate: add missing libexec method 2020-06-03 17:30:15 +02:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Mike McQuaid
737b84b54b
brew style --fix fixes. 2018-11-02 17:29:23 +00:00
Shaun Jackman
605e61095a relocation_formulae: Poured bottles depend on gcc [Linux] 2018-10-23 09:03:20 -07:00
Markus Reiter
e9b9ea49a1 Update to RuboCop 0.59.1. 2018-09-17 03:45:59 +02:00
Shaun Jackman
1b688a3a25 Relocate bottles on Linux using patchelf
Ensure patchelf is installed to pour bottles and build bottles.
2018-07-12 10:21:26 -07:00
Xu Cheng
6cdc501a75
Keg#replace_text_in_files: fix incorrect replace order
The order of the regexes in `Keg#replace_text_in_files` matters.
Otherwise, `/usr/local/Cellar` will be replaced to
`@@HOMEBREW_PREFIX@@/Cellar` instead of `@@HOMEBREW_CELLAR@@`.

Fixes Homebrew/homebrew-core#26043.
2018-04-10 18:22:18 +08:00
Shaun Jackman
a4033c7196 Do not specify absolute paths to utilities
Specifying an absolute path to utilities is no longer needed,
since environment filtering uses a default PATH.
2017-12-12 09:25:16 -08:00
Shaun Jackman
03ae6aae3b text_files: Skip the formula in .brew/formula.rb 2017-10-01 18:27:05 -07:00
ilovezfs
01f52f54e3 keg_relocate: treat .lai files as libtool files.
Previously .lai files only had their locations replaced with
placeholders if /usr/bin/file recognized them as ASCII files, which is
only the case on macOS Sierra and above.
2017-09-16 07:04:26 -07:00
Markus Reiter
2d6ae61314 Re-revert "Fix operator spacing." 2017-06-02 19:22:05 +02:00
Tim D. Smith
8db2998819 Merge pull request #2598 from tdsmith/relocate-virtualenv-orig-prefix
Relocate virtualenv orig-prefix
2017-05-24 10:41:47 -07:00
Shaun Jackman
175c2e9303 replace_text_in_files: Regex match is greedy
The regex matches the longest possible string. Order does not matter.
2017-05-17 23:55:29 -07:00
Tim D. Smith
22d3a67b73 Relocate virtualenv orig-prefix.txt
Virtualenvs remember the path to the stdlib in a file named
orig_prefix.txt. This file wasn't being relocated because Homebrew skips
files that look like they're intended for human consumption by matching
against the list of metafile extensions. This led to the bug described
in https://github.com/Homebrew/homebrew-core/issues/12869. This fixes
relocation by creating an exception for orig-prefix.txt.
2017-05-06 15:56:55 -07:00
Mike McQuaid
2144c35539 keg_relocate: slim long lines. 2017-04-05 09:00:11 +01:00
Tim D. Smith
3b75075727 rubocop 2017-04-02 10:26:05 -07:00
Tim D. Smith
2f4eaf26a0 Use extend/OS mechanism for grep args 2017-04-02 09:04:49 -07:00
Tim D. Smith
d0feae0632 Unlink before rewriting link
ln_sf does the right thing when `dest` is a symlink pointing to a file:
the symlink gets overwritten with a link pointing to the new src. But
when dest points to a directory, we create a new symlink inside the
folder dest points to, which doesn't help us at all.
2017-04-02 08:19:29 -07:00
Tim D. Smith
51c4c84a3f Don't follow symlinks when hunting for strings
When we're assessing whether a bottle is relocatable, we shouldn't have
to descend into symlink paths we encounter. This is supposed to be the
default behavior but it doesn't appear to be (perhaps because we pass a
symlink to the keg on the command line?).

All of the switches that control this behavior differ between BSD and
GNU grep, so sniff the grep flavor first.
2017-04-02 08:17:07 -07:00
Viktor Szakats
cc8f029f22 secure urls + remove -k from in-doc curl command 2017-03-14 17:27:11 +00:00
Alyssa Ross
9e97eadccb rubocop: trailing comma in multiline method calls
Discussed in
https://github.com/Homebrew/brew/pull/1987/files#r100693581.

This was originally ommitted because it wasn't compatible with Ruby 1.8.
(See https://github.com/Homebrew/legacy-homebrew/pull/48144#r49928971).
2017-02-12 15:11:38 +00:00
Josh Hagins
e57d312ad1 keg_relocate: don't forget the hard links 2016-11-01 12:58:38 -04:00
Josh Hagins
d60020f1a9 keg_relocate: fix ordering of replacements 2016-11-01 12:07:14 -04:00
Josh Hagins
652c5bc865 formula_installer: fix regression in #1253
Apparently `cellar :any_skip_relocation` doesn't actually mean we
can skip relocation, at least for text files.
2016-10-25 03:41:37 -04:00
Josh Hagins
fab2cffe5d keg_relocate: wrap relocation locations in struct 2016-10-24 16:21:08 -04:00
Josh Hagins
adc4b1f0c7 keg_relocate: brew style fixes 2016-10-24 16:21:08 -04:00
Josh Hagins
9c519bbdbc keg_relocate: refactor relocate_text_files
Replace relocate_text_files with three methods that clarify intent:
replace_locations_with_placeholders, replace_placeholders_with_locations
and replace_text_in_files, the first two calling the third.
2016-10-24 16:21:08 -04:00
Josh Hagins
c46155aba4 keg_relocate: cache files rewritten during brew bottle
`brew bottle` replaces instances of the Homebrew prefix, cellar, and
repository with placeholders in all text files. Cache these files in
INSTALL_RECEIPT.json so that we don't have to check every single text
file for placeholders on install.
2016-10-24 16:21:08 -04:00
Tim D. Smith
22a64aa6c6 Explain why info could be nil 2016-10-15 23:52:55 -07:00
Tim D. Smith
371cd0dd3e Don't choke on invalid UTF-8 in file output
Sometimes `file` output contains data from the file under examination,
which may include binary data that does not represent valid UTF-8
codepoints. String#split dies if it doesn't understand the encoding, so
tell Ruby to treat `file` output as a bytestring.
2016-10-15 21:21:08 -07:00
Josh Hagins
24c2d0b3c2 keg_relocate: fix for multiline /usr/bin/file output 2016-10-12 11:53:06 -04:00
Mike McQuaid
2e306bcde0 keg_relocate: relocate text_executable? files.
This was omitted from #1258, incorrectly fixed in #1267, reverted in
 #1268 and re-applied in this commit.
2016-10-12 11:35:37 +01:00
Mike McQuaid
02c567cb12 Revert "keg_relocate: left out text_executable? check in #1258" 2016-10-12 11:29:33 +01:00
Josh Hagins
6cecc4c03e keg_relocate: left out text_executable? check in #1258 2016-10-12 04:02:47 -04:00
Josh Hagins
d8a6863283 keg_relocate: use xargs to batch file arguments 2016-10-11 21:19:08 -04:00
Markus Reiter
e851c9bf6c Style/Alias: Prefer alias. 2016-09-23 18:19:53 +02:00
Mike McQuaid
997ccb044d Relocate HOMEBREW_REPOSITORY when necessary.
Now that the default from the installer, our CI and soon all users
is `/usr/local/Homebrew` it's a lot easier to check if there's
references to it (as we cannot look for `/usr/local` as it's a too
commonly hardcoded path).
2016-09-18 16:31:58 +01:00
Mike McQuaid
3982950e61 rubocop --auto-correct all hash-rocket usage. 2016-09-17 16:14:13 +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
Dominyk Tiller
604f4b6a07
keg_relocate: refactor path.find change for performance
Closes #616.

Signed-off-by: Dominyk Tiller <dominyktiller@gmail.com>
2016-08-02 03:50:50 +01:00
Dominyk Tiller
196a6946e1
keg_relocate: work around file bug
There's an old bug in `file` which means it can't read certain files under a
non-C locale. This has been fixed upstream for some time, but Apple hasn't
picked that fix up & even on OS X El Capitan the `file` is ancient.

This is currently causing a lot of false positives in our bottle code around
relocating things like manpages translated into non-English languages, because
currently the test does:

```
pn = "/usr/local/Cellar/vim/7.4.2109/share/man/fr/man1/vim.1"
Utils.popen_read("/usr/bin/file", "--brief", pn).include?("text")
```
Which returns `false`. But it isn't returning `false` because the actual result
is false, but because `file` panics & fails, which for us equals a `false`. The
actual output when accessed is:
```
pn = "/usr/local/Cellar/vim/7.4.2109/share/man/fr/man1/vim.1"
Utils.popen_read("/usr/bin/file", "--brief", pn)
"ERROR: line 22: regexec error 17, (illegal byte sequence)\n"
```
Forcing this check to be done under a "C" locale eliminates this particular false
positive for strings we can't relocate & consequently things such as NLS may
prove to be more portable in some formulae than is currently the case.

Using `vim` again for the example:
```
pn = "/usr/local/Cellar/vim/7.4.2109/share/man/fr/man1/vim.1"
Utils.popen_read("/usr/bin/file", "--brief", pn).include?("text")
true
```
This reduces the flagged strings from `vim` from 4 issues to 2, the remaining
two with the `vim` executable itself which "remembers" the full path to perl,
python, ruby, etc during build & vomits that information out when requested
by the user. Both the manpages flagged before this change are no longer flagged
as unrelocatable.

This won't entirely resolve the NLS problem because some things hardcode in
a locale path, which will be stored in the executable, but at the very least it
should reduce the number of false positives & may enable relocation where that
locale path hasn't been burnt in.
2016-08-02 03:50:49 +01:00
Mike McQuaid
a1a8b3faa7 keg_relocate: don't relocate text files without /usr/bin/file. 2016-07-29 21:21:02 -06:00
Mike McQuaid
f1c4141885 keg_relocate: port to generic OS. (#453) 2016-07-09 13:52:05 +01:00
William Woodruff
d3ef56425a keg_relocate: Exclude hardlinks from mach_o_files. 2016-06-29 14:34:08 +02:00
Tim D. Smith
cab97cf4d7 Revert "keg_relocate: Exclude hardlinks from mach_o_files."
This reverts commit 3e5e14a59580325faf397b48d62a52f0013a17f2.
2016-06-27 23:25:15 -07:00
William Woodruff
3e5e14a595 keg_relocate: Exclude hardlinks from mach_o_files. 2016-06-27 22:56:12 -07:00