* Renames --force to --overwrite, freeing up brew ln --force for Homebrew/homebrew#13349
* Changes --dry-run to preview linking by default, rather than
overwriting. An overwrite dry-run can be simulated via both
--dry-run --overwrite
* Adds some basic Keg tests
For real this time.
This makes sure that files won't be unlinked if they resolve into
other kegs. For example: if fish and fishfish are both installed,
with fishfish linked and fish unlinked, `brew unlink fish` would
unlink some files that resolve into fishfish's keg.
Similar to the LinkedKegs record, we write a symlink for installed kegs to PREFIX/opt.
Unlike the linked-keg record, unlinking doesn't remove the link, only uninstalling, and keg-only formula have a record too.
The reason for this addition is so that formula that depend on keg-only formula can build against the opt directory and not the cellar keg. Thus surviving upgrades.
To enforce this fix_install_names and built were adapted to use the opt path.
Standard kegs also create an opt symlink so that caveats can now refer to the opt directory and thus provide steps that survive upgrades too.
Thus the choice of /opt. It is short, neat and the right choice: POSIX dictates that opt is for stand-alone prefixes of software.
Refusing to unlink files from another keg introduced issues when
files changed between formula versions; for instance, this
introduced issues when upgrading from gtk+ 2.24.10 to 2.24.11.
See Homebrew/homebrew#12778.
Rather than skip unlinking if there's no linked keg record, check to
see whether the destination's realpath is the same as the source file
in the keg being unlinked.
`brew link` can now be made to delete any conflicting files using
the --force argument. It also has a --dry-run option, similar to
git clean -n, which will list any files which would be deleted
without touching the filesystem.
ClosesHomebrew/homebrew#11811.
Signed-off-by: Misty De Meo <mistydemeo@gmail.com>
In 1.8, Pathname.find would work (and do nothing) if the
source path didn't exist. In 1.9 this throws an exception
instead, so check whether the file exists before trying.
This fixes the `site-scripts` and `site-functions` directories
so that zsh points to the HOMEBREW_PREFIX version of these files
instead of the Cellar version.
This means you can drop files in these directories and the files
will persist when you upgrade zsh. Otherwise they disappear when
you upgrade zsh.
ClosesHomebrew/homebrew#11955.
[jn: mkpath everything under share/zsh]
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
The python formula explicity creates lib/python2.7/site-packages.
However, that path may already exist as a symlink if something that
installs python bindings is installed before python itself. The result
is that some random keg will end up hosting the site-packages directory
instead of the top-level directory.
Fix this by explicitly creating directories under lib/python* during
linking.
FixesHomebrew/homebrew#11882.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This massively speeds up upgrades for certain formula, ie. formula with lots of files that aren't in the directories we link. I found upgrading android took ages before the un-tar step and it was indeed for this reason.
share/info files were always being linked if they existed, regardless of
whether the user had HOMEBREW_KEEP_INFO set. This primarily affects
users with software built before
9610ff2e9e06931693f49d4377ee26c0e664c547.
This also fixes a bug in Keg#link_dir, in which a file would always be
linked if no argument was passed.
The regexp that handles skipping info files was only skipping
info/*.info files, but several formula would create info/dir files as
well. Since these conflicted with each other, Homebrew would error out
during the linking step.
If the link already exists exactly (well almost exactly) as we are about to correct it, then it's okay. Otherwise we error out. This is a safe choice, and really, the correct choice too.
This will prevent the tickets like Homebrew/homebrew#11050 from occurring.
ed1a674c ("keg: allow selective linking at the file level") had a
regression which caused the link step to skip files with the same name
as a directory in the user's CWD.
Keg#link_dir yields a relative pathname, so assumptions cannot be made
about the nature of that pathname in the block.
Instead, introduce ":skip_dir" and ":skip_file" to replace the existing
":skip" directive. This way, we won't skip things marked ":skip_dir"
when linking a file, and vice-versa.
FixesHomebrew/homebrew#10860.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
When other packages install gdk-pixbuf modules, they get installed into
the gdk-pixbuf keg. To avoid this, we explicitly create the top level
lib directories for gdk-pixbuf and hack the pkgconfig file to point at
the top-level directories instead of the keg.
This results in other packages installing modules into the top-level
directory and as such they are "lost" and treated as unbrewed files, but
that is still better than losing them during upgrades of gdk-pixbuf
itself.
If we had a post-link hook, we could keep everything confined to its own
keg, linked into the top-level modules directory, and then run
gdk-pixbuf-query-loaders --update-cache
ourselves. In the abscence of that, I think this is the best compromise.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Some parts of a keg's tree are not subject to the cleaner, and sometimes
we still want to remove things in directories marked skip_clean; this
allows us that freedom.
If 'lib' is marked skip_clean, we still want to avoid linking the
charset.alias file into the top of the tree. The same needs to be done
for the locale.alias file in share/locale.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
If HOMEBREW_KEEP_INFO environment variable is set:
- Do not symlink the info directory file (aka 'share/info/dir')
otherwise it gets overwritten by next installed brew.
- Install an entry in the directory for each linked info file when the
brew is linked.
- Uninstall the entry when the brew is unlinked.
ClosesHomebrew/homebrew#9700.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Ocaml packages that need to install here will cause the site-lib
directory to be created, and the symlink in the ocaml keg will work as
intended. This is necessary for the ocaml bottle to work properly.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Will be useful for a variety of reasons, but for now, I'm just using it to ensure install won't install again if something is already installed (use brew upgrade instead).
But means that brew switch and that can work properly etc.
The code was sucking. To the extent that maintenance was hard. It's a lot
easier to work with code that is sensibly split at sensible boundaries. So
now it is more like that.
But the refactor is minimal. Because we don't want you to have more merge
hell than absolutely necessary.
If you merge you will need to pay attention to brew.h.rb (as it is deleted)
and bin/brew (as command logic is gone). It will be painful, but you will just
have to help git out by moving any changes around manually.
Note compatibility.rb. It ensures that any function renames or removals don't
break anything. We're pretty serious about backwards compatibility. And that's
because we encourage you to hack around with the innards. And we couldn't do
that if we would then just make stuff disappear behind your back.
Treat the "lib/node" folder like Python, Perl, etc.
Create it as a real folder in HOMEBREW_PREFIX, so that
package managers (npm) have a stable place to drop libs.
Eg /usr/local/lib/juice/foo points somewhere else where the user has modules that he wants juice to use.
Basically don't error out for stuff that isn't ours.
The code in Keg.self.for path uses "path = path.parent.realpath" to walk
up subfolders looking for a Keg.
Because 'realpath' is in there, and the path is checked against
HOMEBREW_CELLAR, which may be a symlink, we need to do realpath-to-realpath
comparisons in Keg. Otherwise, we will hit equivalent but symlinked folders,
not see that they are the same, and walk all the way up to / and then
error out.
During the link step, if the destination symlink already exists, unlink it, and create a directory instead, then relink the original contents. Then continue linking the formula in question.
FixesHomebrew/homebrew#62