Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Handle etc files more nicely #15751

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

Handle etc files more nicely #15751

MikeMcQuaid opened this issue Oct 30, 2012 · 8 comments

Comments

@MikeMcQuaid
Copy link
Member

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?

@mxcl
Copy link
Contributor

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.

@afb
Copy link
Contributor

afb commented Oct 30, 2012

Etckeeper does this for apt on Ubuntu

@MikeMcQuaid
Copy link
Member Author

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

@mxcl
Copy link
Contributor

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.

@MikeMcQuaid
Copy link
Member Author

Looks good to me.

@mxcl
Copy link
Contributor

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.

@MikeMcQuaid
Copy link
Member Author

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

MikeMcQuaid added a commit that referenced this issue Feb 8, 2013
Handles defaults and merging changes with new versions.

Closes #15751.
Closes #17682.
@MikeMcQuaid
Copy link
Member Author

Closing in favour of #17713.

MikeMcQuaid added a commit that referenced this issue Sep 7, 2013
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.
handyman5 pushed a commit to handyman5/homebrew that referenced this issue Oct 7, 2013
Still in alpha state.
Handles defaults and merging changes with new versions.
Enable by setting the HOMEBREW_GIT_ETC environment variable.

Closes Homebrew#15751.
Closes Homebrew#17713.
@Homebrew Homebrew 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants