Current usage of sysconfdir

Scot Hetzel swhetzel at gmail.com
Mon Oct 2 07:11:07 PDT 2006


On 10/2/06, Markus Dolze <bsdfan at nurfuerspam.de> wrote:
> Hello,
>
> one port I am maintaining recently started using the sysconfdir set by
> GNU configure script to install default config files.
>
> By just using it, it will override user changed config files.
>
> I am thinking of using passing "--sysconfig=${EXAMPLESDIR}" as
> CONFIGURE_ARGS.
>
> Is EXAMPLESDIR a good/valid location? Should I print some message
> pointing the user to this directory?
>
While EXAMPLESDIR would be a good location for the example config
files, the problem is that when you set --sysconfig=${EXAMPLESDIR},
the program will look in EXAMPLESDIR for the config files, instead of
the default location (usually PREFIX/etc) for the config files.

> I am not sure if it has any side effects (used somewhere within the
> code), but I will check for this.
>
It is usually used within the code to locate where the config files are located.
>
> What is best current practice of installing default config files for
> FreeBSD ports?
>

The current practice is to patch the source Makefile (1) that is
installing the default config files so that they end in "-dist" (2).
Then add a check to the ports Makefile to see if there is already a
config file installed, if not then copy the example.conf-dist to
example.conf.  Finally, the pkg-plist file is also changed so that it
can create/remove the example.conf file at package creation/removal.

pkg-plist:
@unexec if cmp -s %D/etc/example.conf %D/etc/example.conf-dist; then
rm -f %D/example.conf; fi
etc/example.conf-dist
@exec [ -f %D/etc/example.conf ] || cp %D/etc/example.conf-dist
%D/etc/example.conf


Another way that is used by the www/apache22 port, which is to patch
the source Makefile (3), so that it installs the default config files
in the EXAMPLESDIR, and then tests if theses files exists in
PREFIX/etc/apache22, and copy the default config files to this
directory when they don't exist.  Again the pkg-plist is modified to
create/remove the config files from PREFIX/etc/apache22 depending on
if they exist.

pkg-plist:
@unexec if cmp -s %D/etc/apache22/httpd.conf
%D/%%EXAMPLESDIR%%/httpd.conf; then rm -f %D/etc/apache22/httpd.conf;
fi
%%EXAMPLESDIR%%/httpd.conf
@exec [ -f %D/etc/apache22/httpd.conf ] || cp
%D/%%EXAMPLESDIR%%/httpd.conf %D/etc/apache22/httpd.conf

Notes:
(1) see www/apache13/files/patch-ab (poor example, as it changes
.default to -dist)
(2) "-dist" is not standard, as some maintainers use
[.-][dist,example,orig,....]
(3) see www/apache22/files/patch-Makefile.in

Having the example config files in the EXAMPLESDIR would make
PREFIX/etc cleaner, as all of the [.-][dist,example,orig,default,...]
files wouldn't be there to clutter up that directory.  Only problem is
that administrators will need to know to look in these 2 directories
(PREFIX/etc/, EXAMPLESDIR) for the config files (working copy, example
copy), which is solved by displaying a note in PKG_MESSAGE about the
EXAMPLESDIR location.

Scot

-- 
DISCLAIMER:
No electrons were mamed while sending this message. Only slightly bruised.


More information about the freebsd-ports mailing list