Date: Mon, 16 May 2011 00:59:50 +0200 From: Olli Hauer <ohauer@FreeBSD.org> To: utisoft@gmail.com Cc: ports@freebsd.org Subject: Re: Propose new macro: INSTALL_CONF Message-ID: <4DD05AE6.8070005@FreeBSD.org> In-Reply-To: <BANLkTinQh3GEQ7mYUd4ApNwYs%2B95=xsUiQ@mail.gmail.com> References: <BANLkTimYjuzp%2BV%2Bpi4bpOUv=uwe9UqjmGA@mail.gmail.com> <BANLkTikRxcqbvhyyryxyvt__4eeFSa-siQ@mail.gmail.com> <BANLkTi=ngB4iayhSB5rUziXH=iBPt0Nn1w@mail.gmail.com> <4DD0444B.7040600@gmx.de> <BANLkTinQh3GEQ7mYUd4ApNwYs%2B95=xsUiQ@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2011-05-16 00:12, Chris Rees wrote: > On 15 May 2011 22:23, olli hauer <ohauer@gmx.de> wrote: >> On 2011-05-15 22:56, Chris Rees wrote: >>> On 14 May 2011 18:32, Chris Rees <utisoft@gmail.com> wrote: >>>> On 14 May 2011 16:39, Chris Rees <utisoft@gmail.com> wrote: >>>>> Hi all, >>>>> >>>>> I'm getting frustrated with editing config files of ports in vi, and >>>>> being told it's read-only. >>>>> >>>>> This stops me using ZZ to quit, which makes me sad. >>>>> >>>>> It's also inconsistent with src/etc/Makefile which uses for example: >>>>> >>>>> .if ${MK_OPENSSH} != "no" >>>>> cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \ >>>>> ${SSH} ${DESTDIR}/etc/ssh >>>>> .endif >>>>> >>>>> The problem stems from installing .sample files as DATA, and then using >>>>> cp -p preserving the -w bits --> 444 makes perfect sense for a .sample file, >>>>> but not at all for a config file. >>>>> >>>>> I have two options proposed. >>>>> >>>>> For both introduce CONFMODE into src/share/mk/bsd.own.mk, patch for >>>>> which is at [1]. >>>>> >>>>> Option 1: Rewrite the Porter's Handbook section on config files to use >>>>> a macro involving CONFMODE instead of cp -p, which gets complicated >>>>> when using with @exec in pkg-plist >>>>> >>>>> Option 2: Create an INSTALL_CONF macro, which handles the .conf.sample >>>>> -> .conf automagically and sticks the right lines into TMPPLIST. >>>>> >>>>> I'm swinging towards Option 2, but I haven't written the code for that >>>>> yet in case someone shoots me down :P >>>>> >>>>> Any concerns about inconsistencies between the INSTALL_* macros could >>>>> be addressed by calling it something different; I'm open to >>>>> suggestions! >>>>> >>>>> We'd also need to deal with the MFC and subsequent updates of bsd.own.mk... >>>>> >>>>> Chris >>>>> >>>>> [1] http://www.bayofrum.net/~crees/patches/bsd-own-mk-confmode.patch >>>> >>>> A third option has occurred to me: >>>> >>>> Create a new variable USE_CONF_FILES to work in a similar vein to USE_RC_SUBR... >>>> >>> >>> Right, I've fleshed this out with some real code. >>> >>> New variables: CONF_FILES and CONF_DIRS. >>> >>> CONF_FILES is like *_DEPENDS as a colon-separated field: >>> >>> CONF_FILES= absolute_path_to_source_file:prefix_relative_path_to_target_file >>> >>> CONF_DIRS= dirs to add with @dirrmtry behaviour, in correct order. >>> >>> Of course, CONF_FILES clashes with some other ports, so before >>> importing this we'd need to shift those aside / choose a different >>> name for this variable. >>> >>> >>> Patch to bsd.port.mk at [1], and a sample patch to net/opentracker [2] >>> with syntax. >>> >>> Try it out with ${FAVOURITE_PORT}! >>> >>> I also promise to document it (if approved) in the Porter's Handbook, >>> code it into portlint and maintain the code as well as take flak from >>> porters! >>> >>> Feedback very welcome. >>> >>> Chris >>> >> >> >> Hm, until now I just overwrite the mode during install >> ${INSTALL} or ${INSTALL_DATA} -m 644 > > Is this the Right Thing though, or a hack around missing code? You've > just hardcoded a mode in that people might not like. It is a hack to overcome the 444 mode and I used it only for some config files > Also, do you install the .sample like that, or do you use it to copy > the .sample to the actual config file? .sample files shouldn't be +w. It depends, how the files are installed. Some ports install everything with the scripts in the source (example: nagios/postfix ...) the only way is to patch this scripts and install/copy later the .sample to a .config if .config does not exist. Some will be installed by ${COPYTREE_SHARE} or other methods since they have a lot of files. In post-install now the trick is to lookup if there is already a .conf file before overwriting with the .sample which makes users unhappy if you destroy a existing config. > What do you put in pkg-plist? pkg-plist example > @unexec if [ -f %D/etc/PortName.conf ] && cmp -s %D/etc/PortName.conf %D/etc/PortName.conf-sample; then rm -f %D/etc/PortName.conf; fi > etc/PortName.conf-sample > @exec if [ ! -f %D/etc/PortName.conf ] ; then cp -p %D/%F %B/PortName.conf; fi The filemode is preserved, no need for pkg-install script But there are situations I don't like for example if a port has full write access to www/PortName since the maintainer decide to do a chown www:www %%WWWDIR%% Example solution: net-mgmt/nagvis/files/pkg-install.in >> and for sensitive config files >> ${INSTALL} or ${INSTALL_DATA} -m 640 -o ... -g ... > >> For config dirs (in the Makefile) >> PLIST_DIRSTRY= %%ETCDIR%% > > This I'll concede! > >> This seems easier to me. > > It certainly doesn't seem easier to me; instead of: > > CONF_FILES= source:dest > > you still have to have a post-install bit, an @exec line in pkg-plist > with weird hieroglyphs, and an @unexec line _for each config file > installed_ > > Can anyone explain why we bend over backwards to make ports > DATADIR-safe for example but completely ignore the user's preferences > with config files??? No, I cannot explain but those macros are also used for a long time in the auto-scripts (autoconf/automake) > I just don't understand how the priority lies here. > > Chris If I find the time I will test your patch with some ports to get a feeling for it. olli
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4DD05AE6.8070005>