89 Commits

Author SHA1 Message Date
Rylan Polster
4457dc904b
Cleanup using suggestions from code review 2021-05-13 11:02:39 -04:00
Rylan Polster
309e9e1c52
Remove Keg::Relocation#start_with_old_value? method 2021-05-11 15:45:43 -04:00
Rylan Polster
7d49dba7e9
Fix Keg::Relocation::start_with_old_value? 2021-05-11 14:28:47 -04:00
Rylan Polster
875282bc06
Add more keg relocation tests 2021-05-11 14:28:47 -04:00
Rylan Polster
f13f7b9326
Only use path regex when requested 2021-05-11 14:28:47 -04:00
Rylan Polster
5f781770b4
Extract Keg::text_matches_in_file from bottle command 2021-05-11 14:26:14 -04:00
Rylan Polster
fe7f80f647
Refactor out and correctly create path regex 2021-05-11 14:26:14 -04:00
Rylan Polster
db8f54cea1
keg_relocate: only replace matches at the start of a path 2021-05-11 14:26:13 -04:00
Bo Anderson
5f41016267
Support handling of rewriting shebangs with flags
Fixes #11108.
2021-05-10 06:13:58 +01:00
Bo Anderson
ae49b06600
keg_relocate: replace Perl shebangs 2021-05-10 06:13:54 +01:00
hyuraku
e6eeb2cbed delete HOMEBREW_REPOSITORY & some variables 2021-01-27 00:29:43 +09:00
Seeker
b9854bd4cf rubocops: add unless_multiple_conditions 2021-01-08 10:33:54 -08:00
Mike McQuaid
e2d032a6b6
keg_relocate: ensure @@HOMEBREW_REPOSITORY@@ is always relocated.
This will be needed to pour older bottles after 2.7.0.
2020-12-18 13:50:10 +00:00
Mike McQuaid
0bbf965807
More bottling HOMEBREW_LIBRARY changes
- Refuse to create bottles which have non-relocatable references to
  `HOMEBREW_LIBRARY`. This allows us to make all bottles ignore where
  `HOMEBREW_REPOSITORY` is (even those that aren't `cellar :any`).
  I cannot see any circumstances in which any bottle should link to
  anything within `HOMEBREW_REPOSITORY`.
- Remove audit that becomes unnecessary given the above change.
- Relocate references to `@HOMEBREW_LIBRARY@` but don't actually write
  any references yet. This will allow us to move to using
  `@HOMEBREW_LIBRARY` and remove all relocation of `HOMEBREW_REPOSITORY`
  in a future release (2.7.1, most likely).
2020-12-18 13:50:10 +00:00
Shaun Jackman
c56681a227 Comment needed changes if HOMEBREW_LIBRARY changes 2020-12-16 14:03:10 -08:00
Shaun Jackman
65b9e1231d Relocate HOMEBREW_LIBRARY conditionally
Relocate HOMEBREW_LIBRARY conditionally when
HOMEBREW_PREFIX = HOMEBREW_REPOSITORY.
2020-12-15 12:47:08 -08:00
Shaun Jackman
4edf28409d Relocate @@HOMEBREW_REPOSITORY@@/Library
Ensure that $HOMEBREW_REPOSITORY/Library is relocated to
@@HOMEBREW_REPOSITORY@@/Library even when
HOMEBREW_PREFIX = HOMEBREW_REPOSITORY.
2020-12-15 12:47:08 -08:00
Mike McQuaid
0f9bad0052
Fix bottle prefix and repository handling
We were previously only looking at the `cellar` value when pouring
bottles and ignoring the `prefix` and (implicit) `repository`.

Actually look at these values and set the defaults for each platform.

Also, when we're relocating to create or pour bottles when `prefix`
and `repository` are equal then skip relocating the `repository` and
always use references to the `prefix` instead.

Fixes #9453
2020-12-09 13:53:10 +00:00
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