245 Commits

Author SHA1 Message Date
Jack Nagel
6008187d5f Encode formula revision in installation prefix
In order to allow kegs built with the same version but differing formula
revisions to coexist, we must encode the revision as part of the keg's
name. This is necessary to actually perform an upgrade, as we cannot
upgrade a keg in-place, and temporarily moving it pending the result of
the upgrade is error-prone and potentially slow.

To accomplish this, we introduce a new Formula#pkg_version method that
concatenates the active_spec version with the formula revision. An
exception is made for a formula that has no revision: the tag is
omitted. This preserves compatibility with existing installations.
2014-03-05 20:12:51 -06:00
Adam Vandenberg
bb5a2b587e Always keep info files
Closes Homebrew/homebrew#26659.
2014-02-23 08:30:50 -08:00
Mike McQuaid
d8d76da55f keg: add function to detect if .app(s) installed. 2014-01-19 14:19:07 -08:00
Mike McQuaid
744a8944b0 caveats: show python caveats if modules installed. 2014-01-04 13:19:20 +00:00
Jack Nagel
935091cd8e Pathname#extname returns a string 2013-12-14 09:35:57 -06:00
Adam Vandenberg
040d655d8d add lib/dtrace to non-owned directories 2013-11-17 10:34:19 -08:00
Mike McQuaid
a6e2245732 git_etc: update based on bottle etc/var changes. 2013-10-10 16:46:47 +01:00
Mike McQuaid
ab20ed0bc2 Optionally use git to keep brew etc versioned.
Still in alpha state.
Handles defaults and merging changes with new versions.
Enable by setting the HOMEBREW_GIT_ETC environment variable.

Closes Homebrew/homebrew#15751.
Closes Homebrew/homebrew#17713.
2013-09-07 13:39:43 +01:00
Samuel John
ad80b10de4 Keg should link symlinks directly.
If the `src` in the Cellar of a formula is a symlink to another dir
in the same Cellar (for example `Frameworks/QtGui.framework` is a
symlink to `lib/QtGui.framework`), then we should make a symlink
directly instead of possibly creating an empty dir.

This is needed because Ruby's `find` does not follow symlinks (newer
versions can, but we have to support 10.8 for a long time).

Currently this probably only occurs for Qt, where we put symlinks
into the Cellar/Frameworks and the frameworks linking code is a bit
special to create a directory to "merge" together different versions
of the same framework from different formulae. See `python` and
`python3`; both install `Python.framework` and only one can be the
`Current` but the other should still be put into
`Python.framework/Versions`. Therefore `Python.framework` has to
be a dir and no symlink.
2013-08-14 21:46:42 +02:00
Jack Nagel
966e82663f Make usage of ObserverPathnameExtension more obvious
Remove use of globals.

Closes Homebrew/homebrew#21795.
2013-08-10 19:02:00 -05:00
Jack Nagel
d5325eb4e4 Always prune empty toplevel directories when unlinking
Closes Homebrew/homebrew#21750.
2013-08-09 20:55:54 -05:00
Jack Nagel
e4b951520a Keep track of pruned parent directories 2013-08-09 20:50:43 -05:00
Jack Nagel
36f5452ae3 Handle mkpath of node_modules directory in keg 2013-07-31 13:51:05 -05:00
Adam Vandenberg
7964aa6648 keg: more gnome folders 2013-07-13 10:15:54 -07:00
Adam Vandenberg
e805b8636c Show symlink target if linking fails
Closes Homebrew/homebrew#21060.
2013-07-10 08:54:18 -07:00
Adam Vandenberg
6a83404fd5 add mime-info to Gnome folders 2013-07-08 09:59:45 -07:00
Adam Vandenberg
9fdfdc5680 Better handling of Gnome desktop files
Gnome desktop support has a lot of folders in share that should be created
directly in share, rather than shared.

Add these folders to keg, and don't link any icon cache files into share.

Closes Homebrew/homebrew#20340.
2013-07-02 08:59:33 -07:00
Samuel John
fbaf8a5968 Linking Frameworks correctly if multiple.
For example python and python3 both provide a
`Python.framework` and OS X Frameworks are made to
deal with this by putting them into `Versions` and
linking the default one as `Current`. However, brew
did not respect this and cleaned out stuff making
neither of the two versions work because `Current`
is replaced by an empty directory.

This commit fixes that. However, still one of the
two `Python.frameworks` has to remove it's
`Current` and `Headers` links, because brew cannot
decide alone which one is the "default" and allowed
to set the `Current` link.

A similar situation might apply to Qt 4 vs. 5..
2013-06-18 20:49:13 +02:00
Samuel John
20ac914112 keg.rb: minor comment fix 2013-06-07 17:58:55 +02:00
Samuel John
c524895666 Python 2.x and 3.x support
New `depends_on :python` Dependency.
New `depends_on :python3` Dependency.

To avoid having multiple formulae with endings -py2 and -py3,
we will handle support for different pythons (2.x vs. 3.x)
in the same formula.
Further brewed vs. external python will be transparently supported.

The formula also gets a new object `python`, which is false if
no Python is available or the user has disabled it. Otherwise
it is defined and provides several support methods:

python.site_packages # the site-packages in the formula's Cellar
python.global_site_packages
python.binary # the full path to the python binary
python.prefix
python.version
python.version.major
python.version.minor
python.xy # => e.g. "python2.7"
python.incdir # includes of python
python.libdir # the python dylib library
python.pkg_config_path # used internally by brew
python.from_osx?
python.framework?
python.universal?
python.pypy?
python.standard_caveats # Text to set PYTHONPATH for python.from_osx?
python.if3then3 # => "" for 2.x and to "3" for 3.x.

Further, to avoid code duplication, `python` takes an optional
block that is run twice if the formula defines depends_on
:python AND :python3.

python do
  system python, 'setup.py', "--prefix=#{prefix}"
end

Read more in the Homebrew wiki.
2013-06-03 17:29:43 +02:00
Desmond Brand
ba93e6d363 Overwrite broken symlinks with --overwrite
Closes Homebrew/homebrew#19480.

Signed-off-by: Misty De Meo <mistydemeo@gmail.com>
2013-05-09 09:21:34 -05:00
Jack Nagel
2e58fbf260 Keg requires OpenStruct 2013-04-14 15:38:14 -05:00
Jack Nagel
9db0e68eb6 Unify indentation of access modifiers
These are class method calls, not some special keyword, and should be
indented as such (also all standard Ruby indenters do this).
2013-04-07 20:59:49 -05:00
Jack Nagel
f037be5148 Don't shadow outer local variables 2013-02-18 12:13:36 -06:00
Jack Nagel
97d3ae1775 Extract formula locks into a class 2013-02-09 18:19:50 -06:00
Jack Nagel
61f01632c6 Keg#lock: guard against nil in ensure
Fixes Homebrew/homebrew#17403.
2013-01-29 10:26:00 -06:00
Jack Nagel
9a179d8b06 locks: ensure lock directory exists
Fixes Homebrew/homebrew#17326.
2013-01-26 13:18:45 -06:00
Jack Nagel
37a56fa513 FormulaInstaller: implement installation locks
FormulaInstaller now attempts to take a lock on a "foo.brewing" file for
the formula and all of its dependencies before attempting installation.

The lock is an advisory lock implemented using flock(), and as such it
only locks out other processes that attempt to take the lock. It also
means that it is never necessary to manually remove the lock file,
because the lock is not enforced by I/O.

The uninstall, link, and unlink commands all learn to respect this lock
as well, so that the installation cannot be corrupted by a concurrent
Homebrew process, and keg operations cannot occur simultaneously.
2013-01-26 12:14:45 -06:00
Jack Nagel
e3068f631a Prune LinkedKegs relative to correct path
Fixes Homebrew/homebrew#16948.
2013-01-08 11:03:13 -06:00
Mike McQuaid
faf51f254d Make generic caveats for launchd plist files. 2012-11-25 23:05:52 +00:00
Jack Nagel
7f9c03c1ff Link Frameworks into top-level Frameworks directory 2012-11-06 12:32:09 -06:00
Jack Nagel
2f542f657e Combine duplicated postfix conditionals 2012-11-06 12:32:09 -06:00
Jack Nagel
f8183d9510 Hoist top-level directory list into a constant 2012-11-06 12:32:09 -06:00
Misty De Meo
447f78c0d2 brew ln --force is now brew ln --overwrite
* 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
2012-10-20 21:00:46 -05:00
Jack Nagel
ca45225fad Flatten share_mkpaths
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-10-15 18:03:07 -05:00
Misty De Meo
0f2fe4a61b Keg#unlink: use ObserverPathnameExtension
#link was using the extension but #unlink wasn't, so the counting
criteria were potentially different and `brew unlink` was ignoring
--verbose.
2012-10-04 21:37:37 -05:00
Misty De Meo
a1f6f590d2 Keg#unlink: check file comes from the right keg
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.
2012-10-04 21:37:36 -05:00
Max Howell
f02d81ecbf Create active symlinks for installed formula
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.
2012-08-29 12:41:33 -04:00
Jack Nagel
31b61cb013 keg: add method to return the corresponding Version 2012-08-18 11:12:10 -05:00
Jack Nagel
1d295ff3bc Automatically append shell completion caveats
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-08-07 15:32:00 -05:00
Max Howell
da692fadc6 Don't chmod -R 0777 before uninstalling
If the user owns the parent directory we have the rights to rmtree. At least I believe so.

Fixes Homebrew/homebrew#13714.
2012-08-06 18:49:14 -04:00
Misty De Meo
70d7c0c122 Revert 66a4ea1c80fa36fe348b3d5ad6d2f6c61cf21c05
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.
2012-07-24 09:52:12 -05:00
Misty De Meo
17953f2b83 Keg#unlink: check destination before unlinking
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.
2012-07-22 10:58:19 -05:00
Misty De Meo
ba2d17b8d1 Keg#unlink: Don't try to unlink if keg is unlinked 2012-07-20 12:03:31 -05:00
Misty De Meo
14c8c7c9ce Fix brew link --dry-run
The last make_relative_symlink was missing the mode argument, which
caused spurious linking under certain circumstances.
2012-07-11 22:32:15 -05:00
Misty De Meo
743b5e6feb link: add --force and --dry-run options
`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.

Closes Homebrew/homebrew#11811.

Signed-off-by: Misty De Meo <mistydemeo@gmail.com>
2012-07-09 12:01:09 -05:00
Misty De Meo
44ccd122c2 Keg#unlink: skip find for non-extant files
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.
2012-07-06 10:32:56 -05:00
Christian Höltje
7b24382d14 zsh: support site specific files
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.

Closes Homebrew/homebrew#11955.

[jn: mkpath everything under share/zsh]

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-05-02 23:43:30 -05:00
Jack Nagel
07e24dda76 mkpath all directories under lib/python*
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.

Fixes Homebrew/homebrew#11882.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-04-26 20:35:09 -05:00
Max Howell
1e55c1f580 Fix brew unlink
Whoops.
2012-03-25 13:09:30 +01:00