Handle etc files more nicely #15751

Closed
MikeMcQuaid opened this Issue Oct 30, 2012 · 8 comments

Comments

Projects
None yet
3 participants
Owner

MikeMcQuaid commented Oct 30, 2012

See #15737 for background.

I don't think our current approach is sensible. I'd bet that most of our users are not changing etc files and therefore we never upgrade them for these users. This sucks.

You can see an approach I've taken in 8de552e to workaround a specific issue with redis.

Various solutions I'd suggest (of varying complexity):

  1. Flip the default so we overwrite the etc files by default and move the old file to etc/blah.conf.old
  2. Fix brew pull (or whatever people are using) so we detect these issues
  3. Keep a hash of the installed etc file in the tab and we replace it if it didn't change
  4. Check the modified time of the etc file (not sure if this is possible or would work) and we replace it if it didn't change
  5. Somehow store the etc files in a git repository so users can merge changes

Regardless I think we need to do something. Thoughts?

Member

mxcl commented Oct 30, 2012

Somehow store the etc files in a git repository so users can merge changes

This is ideal, since the user gets revision control over their configuration files. Which is something nobody else is doing, and it would certainly help with package management for the user.

  1. If no etc file, cp it and git add
  2. If one there already and there's a new etc file stash just that file, cp new revision, and then attempt to merge.
  3. If merge fails advise user, and provide the git commands to ignore the new changes, or just use the new changes, etc.

Would be pretty sweet.

Contributor

afb commented Oct 30, 2012

Etckeeper does this for apt on Ubuntu

Owner

MikeMcQuaid commented Oct 30, 2012

Yep, I've used etckeeper in the past and it is great.

Member

mxcl commented Nov 2, 2012

  1. /usr/local/Cellar/foo/1/etc/foorc, empty /usr/local/etc
  2. brew does: cp /usr/local/Cellar/foo/1/etc/foorc /usr/local/etc
  3. brew does: cd /usr/local/etc && git init
  4. brew does: cd /usr/local/etc && git commit foorc -m'foo-1: foorc'

User edits /usr/local/etc/foorc.

  1. brew upgrade foo # upgrades to foo2
  2. /usr/local/Cellar/foo/1/etc/foorc is same as the committed version of foorc in /usr/local/etc.
  3. Nothing changes

Months later:

  1. brew upgrade foo #upgrades to foo3
  2. /usr/local/Cellar/foo/1/etc/foorc is not the same as the committed version of foorc in /usr/local/etc.
  3. brew does: git checkout -b pre-foo3 && git commit foorc -mblah
  4. brew does: git checkout master && git checkout master foorc
  5. brew does: cp /usr/local/Cellar/foo/3/etc/foorc /usr/local/etc/foorc
  6. brew does: git commit foorc -m'foo-3: foorc
  7. brew does: git merge pre-foo3

And there we have it. The merge either succeeds or requires the user to do some git. We can have a brew etc helper for people who don't know git. But let's do that later.

Owner

MikeMcQuaid commented Nov 2, 2012

Looks good to me.

Member

mxcl commented Nov 2, 2012

The place for the code to go is in FormulaInstaller. I will attempt to write this code soon, but I have so many things taking up my time nowadays I cannot give an ETA.

If we all very lucky I will do it this weekend.

But that bugs in brew tap ticket is outstanding for me, and superenv has numerous issues with formula that expect userpaths and we decline to allow it and that is bad.

Owner

MikeMcQuaid commented Feb 3, 2013

Because of the way we install etc files to 'HOMEBREW_PREFIX/etc` 3. and 4. will be too hard.

@MikeMcQuaid MikeMcQuaid added a commit that referenced this issue Feb 8, 2013

@MikeMcQuaid MikeMcQuaid Use git to keep brew etc versioned.
Handles defaults and merging changes with new versions.

Closes #15751.
Closes #17682.
6cd0c9b
Owner

MikeMcQuaid commented Apr 3, 2013

Closing in favour of #17713.

MikeMcQuaid closed this Apr 3, 2013

@MikeMcQuaid MikeMcQuaid added a commit that referenced this issue Sep 7, 2013

@MikeMcQuaid MikeMcQuaid 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 #15751.
Closes #17713.
698e562

@handyman5 handyman5 pushed a commit to handyman5/homebrew that referenced this issue Oct 7, 2013

@MikeMcQuaid MikeMcQuaid 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 #15751.
Closes #17713.
6cc7fe2

xu-cheng locked and limited conversation to collaborators Feb 16, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.