librelist archives

« back to archive

How to handle correctly /etc style configuration files in a formula?

How to handle correctly /etc style configuration files in a formula?

From:
pascal bertrand
Date:
2011-01-16 @ 23:09
Hi everyone,

I am writing my first formula for a tool not yet handled by homebrew.

The soft has a configuration file which by default goes into /usr/local/etc.
The debian package puts it directly into /etc.

I haven't found anything related to this topic in the formula cookbook, but
I found #{etc} in the nginx formula. Can I use it to get a consistent
location across version updates? If I can't, how can I put
this file into a fixed location across updates which will be cleaned on
uninstall?


Thanks for your help,
Pascal BERTRAND

Jack of all trades, master of none,
though oftentimes better than master of one.

Re: [homebrew] How to handle correctly /etc style configuration files in a formula?

From:
Benoit Daloze
Date:
2011-01-17 @ 12:39
On 17 January 2011 00:09, pascal bertrand <pascal.bertrand@gmail.com> wrote:
> Hi everyone,
> I am writing my first formula for a tool not yet handled by homebrew.
> The soft has a configuration file which by default goes into /usr/local/etc.
> The debian package puts it directly into /etc.
> I haven't found anything related to this topic in the formula cookbook, but
> I found #{etc} in the nginx formula. Can I use it to get a consistent
> location across version updates? If I can't, how can I put
> this file into a fixed location across updates which will be cleaned on
> uninstall?
>
> Thanks for your help,
> Pascal BERTRAND
>
> Jack of all trades, master of none,
> though oftentimes better than master of one.

Hello,

etc is indeed a method which return a consistent Pathname across versions.

You can see in Library/Homebrew/formula.rb:149-150:

  # configuration needs to be preserved past upgrades
  def etc; HOMEBREW_PREFIX+'etc' end

However, the files there will not be cleaned AFAIK, as there is no
custom uninstall and etc is never cleaned.
But this is desirable, to keep your configuration even when you
reinstall or upgrade.

Re: [homebrew] How to handle correctly /etc style configuration files in a formula?

From:
John Pye
Date:
2011-01-18 @ 01:01
Benoit Daloze wrote:
> On 17 January 2011 00:09, pascal bertrand <pascal.bertrand@gmail.com> wrote:
>   
>> Hi everyone,
>> I am writing my first formula for a tool not yet handled by homebrew.
>> The soft has a configuration file which by default goes into /usr/local/etc.
>> The debian package puts it directly into /etc.
>> I haven't found anything related to this topic in the formula cookbook, but
>> I found #{etc} in the nginx formula. Can I use it to get a consistent
>> location across version updates? If I can't, how can I put
>> this file into a fixed location across updates which will be cleaned on
>> uninstall?
>>
>> Thanks for your help,
>> Pascal BERTRAND
>>
>> Jack of all trades, master of none,
>> though oftentimes better than master of one.
>>     
>
> Hello,
>
> etc is indeed a method which return a consistent Pathname across versions.
>
> You can see in Library/Homebrew/formula.rb:149-150:
>
>   # configuration needs to be preserved past upgrades
>   def etc; HOMEBREW_PREFIX+'etc' end
>
> However, the files there will not be cleaned AFAIK, as there is no
> custom uninstall and etc is never cleaned.
> But this is desirable, to keep your configuration even when you
> reinstall or upgrade.
>   
Hi Benoit

I respectfully disagree; sometimes after messing everything up with some
highly-customizable package (eg a webserver, mailserver, or similar) it
can be very helpful to be able to ensure a compeltely clean install.

It's useful to have the above as the default behaviour, however, there
needs to be a way to access the alternative 'purge' behaviour. Debian,
RPM, etc, certainly provide this, at the cost of an as-installed file
database.

RPM, I recall, gives you the choice of what you want to happen on a
reinstall: overwrite, keep, or compare the changed files, when
installing a file that overwrites prexisting known configuration files,
does Homebrew provide that?

Cheers
JP

Re: [homebrew] How to handle correctly /etc style configuration files in a formula?

From:
Mike McQuaid
Date:
2011-01-18 @ 09:11
On 18 January 2011 01:01, John Pye <john.pye@anu.edu.au> wrote:
> RPM, I recall, gives you the choice of what you want to happen on a
> reinstall: overwrite, keep, or compare the changed files, when
> installing a file that overwrites prexisting known configuration files,
> does Homebrew provide that?

Homebrew does not provide support for any uninstall hooks other than
`rm -rf Cellar/packagename/version/`. This is an intentional design
decision.

-- 
Mike McQuaid
http://mikemcquaid.com