librelist archives

« back to archive

Keeping a record of the "active" keg

Keeping a record of the "active" keg

From:
Max Howell
Date:
2010-09-13 @ 11:26
Most commands dislike there being multiple installed kegs. Eg, try to
`brew ls git` if you have multiple git kegs.

This is because homebrew doesn't know which keg is "active".

There are a few options:

/usr/local/OnTap/git -> ../Cellar/git/1.7.2.3
/usr/local/OnTap/foo -> ../Cellar/foo/2.1

So we have another directory that serves as a record of the active
installation. This is pretty cool in that the symlinks are generally
useful. No more caveats that say "add `brew
--prefix`/Cellar/foo/2.1/lib to your ~/.bashrc". Now they can point to
the OnTap directory and not worry about keeping that crap up to date
across upgrades.

However it sucks because we are "caching" the installation. This could
in theory be determined by checking for symlinks in /usr/local and
figuring out which keg is installed.

However stale symlinks persist etc. determining which keg is installed sucks.

Homebrew should be maintainable with standard tools. However the act
of linking and unlinking requires the brew command. Doing it by hand
would be ridiculous. Also we can make it so nothing in Homebrew
depends on the OnTap link too much. Most commands already work fine
without it.

Another option is to use HFS metadata to write some tag to the active keg.

Max

Re: [homebrew] Keeping a record of the "active" keg

From:
Michael Dippery
Date:
2010-10-05 @ 14:36
I know this discussion is a few weeks old, but I had an idea I wanted to 
pose to the group (even if it's just to see why it's infeasible). What 
about using a symlink called "current" in the same directory as the keg 
that points to the active version, kind of like the Current symlink in OS 
X framework bundles? For example:

    /usr/local/Cellar/foo/1.0/
    /usr/local/Cellar/foo/1.1/
    /usr/local/Cellar/foo/current -> ./1.1



----
Michael Dippery
mdippery@gmail.com | www.monkey-robot.com

Re: [homebrew] Keeping a record of the "active" keg

From:
Max Howell
Date:
2010-10-07 @ 09:45
Indeed it's a good idea, but the reason I rejected this is that it
breaks the ability to just list a directory to get all versions. And
Homebrew is beautifully simple because of lots of little decisions
like this. The symlink would have to be in a separate directory.

> I know this discussion is a few weeks old, but I had an idea I wanted to
pose to the group (even if it's just to see why it's infeasible). What 
about using a symlink called "current" in the same directory as the keg 
that points to the active version, kind of like the Current symlink in OS 
X framework bundles? For example:

Re: [homebrew] Keeping a record of the "active" keg

From:
Mike McQuaid
Date:
2010-10-07 @ 10:14
On 7 Oct 2010, at 10:45, Max Howell wrote:

> Indeed it's a good idea, but the reason I rejected this is that it
> breaks the ability to just list a directory to get all versions. And
> Homebrew is beautifully simple because of lots of little decisions
> like this. The symlink would have to be in a separate directory.


Yeh, fair enough. Somewhere other than Cellar could work.

--
Cheers,
Mike McQuaid
http://mikemcquaid.com

Re: [homebrew] Keeping a record of the "active" keg

From:
Mike McQuaid
Date:
2010-10-07 @ 10:14
On 7 Oct 2010, at 10:45, Max Howell wrote:

> Indeed it's a good idea, but the reason I rejected this is that it
> breaks the ability to just list a directory to get all versions. And
> Homebrew is beautifully simple because of lots of little decisions
> like this. The symlink would have to be in a separate directory.


Yeh, fair enough. Somewhere other than Cellar could work.

--
Cheers,
Mike McQuaid
http://mikemcquaid.com

Re: [homebrew] Keeping a record of the "active" keg

From:
Adam Vandenberg
Date:
2010-10-05 @ 15:00
"current" is what I thought about calling it too; not looking forward
to the work needed across various commands to filter out this special
folder though.

Another thought: Perhaps in the meantime we could except keg-only
brews from "brew cleanup"; ie, if you have 2 versions of a keg-only
brew installed, cleanup won't nuke the old, still-linked one.

On Tue, Oct 5, 2010 at 7:36 AM, Michael Dippery <mdippery@gmail.com> wrote:
> I know this discussion is a few weeks old, but I had an idea I wanted to
pose to the group (even if it's just to see why it's infeasible). What 
about using a symlink called "current" in the same directory as the keg 
that points to the active version, kind of like the Current symlink in OS 
X framework bundles? For example:
>
>    /usr/local/Cellar/foo/1.0/
>    /usr/local/Cellar/foo/1.1/
>    /usr/local/Cellar/foo/current -> ./1.1
>
>
>
> ----
> Michael Dippery
> mdippery@gmail.com | www.monkey-robot.com
>
>

Re: [homebrew] Keeping a record of the "active" keg

From:
Mike McQuaid
Date:
2010-10-05 @ 15:17
On 5 Oct 2010, at 16:00, Adam Vandenberg wrote:

> "current" is what I thought about calling it too; not looking forward
> to the work needed across various commands to filter out this special
> folder though.

The insane pedant in me prefers "Current" over "current". Otherwise, 
sounds great to me.

--
Cheers,
Mike McQuaid
http://mikemcquaid.com

Re: [homebrew] Keeping a record of the "active" keg

From:
Dreamcat4
Date:
2010-09-13 @ 18:11
On Mon, Sep 13, 2010 at 12:26 PM, Max Howell <max@methylblue.com> wrote:
> Most commands dislike there being multiple installed kegs. Eg, try to
> `brew ls git` if you have multiple git kegs.
>
> This is because homebrew doesn't know which keg is "active".
>
> There are a few options:
>
> /usr/local/OnTap/git -> ../Cellar/git/1.7.2.3
> /usr/local/OnTap/foo -> ../Cellar/foo/2.1
>
> So we have another directory that serves as a record of the active
> installation. This is pretty cool in that the symlinks are generally
> useful. No more caveats that say "add `brew
> --prefix`/Cellar/foo/2.1/lib to your ~/.bashrc". Now they can point to
> the OnTap directory and not worry about keeping that crap up to date
> across upgrades.
>
> However it sucks because we are "caching" the installation. This could
> in theory be determined by checking for symlinks in /usr/local and
> figuring out which keg is installed.
>
> However stale symlinks persist etc. determining which keg is installed sucks.

Hi Max,

For the scenario you are suggesting, its significantly less complex
than the launchd symlinks. Which is a parallel situation which I have
been working on recently (please believe me its easier than that
one!).

IMHO If you can inexpensively detect a broken / missing keg directory
symlink then its certainly feasible. Perhaps a quick check each time
the brew command is run. Its not necessarily very much overhead,
providing you're only checking ~1 file per installed formula.

Any actual "fixing" of the symlinks should be an infrequent enough
event. Only necessary if someone has bypassed brew and left their brew
directories in an inconsistent state. So I guess we are talking about
the rm -rf of an active keg there. Or otherwise some manual install /
uninstall procedures utilizing the brew tree.

> Homebrew should be maintainable with standard tools. However the act
> of linking and unlinking requires the brew command. Doing it by hand
> would be ridiculous. Also we can make it so nothing in Homebrew
> depends on the OnTap link too much. Most commands already work fine
> without it.
>
> Another option is to use HFS metadata to write some tag to the active keg.

If you choose HFS Metadata... well obviously not going to work for
those guys, whoever likes to keep Homebrew on their FAT32 thumbdrives.
Or any other kind of drive which isnt Mac HFS(+) including all those
other kinds of media, network drives, etc.

But symlinks to work on many kinds of popular filesystems - they're
kinnda great! (well i seem to think so anyway)

>
> Max
>

Re: [homebrew] Keeping a record of the "active" keg

From:
Max Howell
Date:
2010-09-14 @ 10:30
> For the scenario you are suggesting, its significantly less complex
> than the launchd symlinks. Which is a parallel situation which I have
> been working on recently (please believe me its easier than that
> one!).

I'd like to re-familarise myself with this as we need to solve this
properly. Homebrew should be very useful for OS X. Which means helping
you with the launchd stuff as much as possible. Though not too much.
Homebrew is there to help you, but you should still know what you are
doing.

Re: [homebrew] Keeping a record of the "active" keg

From:
Max Howell
Date:
2010-09-14 @ 10:28
I think the symlink for the current prefix is very potentially useful.
So we should do it.

The name on OnTap is pretty cool, but maybe it sucks? I'm not entirely
satisfied with it. Nor am I entirely thrilled to put it in the root,
but oh well. No where else is sensible.

Re: [homebrew] Keeping a record of the "active" keg

From:
Dreamcat4
Date:
2010-09-14 @ 14:06
On Tue, Sep 14, 2010 at 11:28 AM, Max Howell <max@methylblue.com> wrote:
> I think the symlink for the current prefix is very potentially useful.
> So we should do it.
>
> The name on OnTap is pretty cool, but maybe it sucks? I'm not entirely
> satisfied with it. Nor am I entirely thrilled to put it in the root,
> but oh well. No where else is sensible.
>

Maybe its hard to figure the placement because the inner directory
stucture of the Cellar is flat. Thereby forcing you to put this
outside of the cellar. The word Cellar connotes and alludes to being
somehow "self-contained".

If homebrew/Cellar were not necessarily a flat structure, it could be
further organised and partitioned, like so:

homebrew/Cellar/active
homebrew/Cellar/all

or (its the same thing)

homebrew/Kegs/active
homebrew/Kegs/all


Its thats not possible then overall, I think your choice for the OnTap
folder name is okay. Unless you are going to take a shine to putting a
more longhanded name (eg "ActiveKegs", "OpenKegs") in the brew root.

Hell, maybe you should just go off to the pub and ask to look
downstairs in their cellar. Ask the barman.

Re: [homebrew] Keeping a record of the "active" keg

From:
Mike McQuaid
Date:
2010-09-14 @ 07:14
On 13 Sep 2010, at 19:11, Dreamcat4 wrote:

> If you choose HFS Metadata... well obviously not going to work for
> those guys, whoever likes to keep Homebrew on their FAT32 thumbdrives.
> Or any other kind of drive which isnt Mac HFS(+) including all those
> other kinds of media, network drives, etc.


FAT32 doesn't even support unix permissions. I'd say HFS+ would have some 
concerns but FAT32 is a bad example as it supports practically nothing. 
Any valid Unix filesystem might be a good requirement. Then again, HFS+ is
what's installed by default and it's not hard to make a DMG or something 
to store Homebrew in if you have problems on your FAT32 device.
--
Cheers,
Mike McQuaid
http://mikemcquaid.com