This construction doesn't work

Scot Hetzel swhetzel at gmail.com
Tue Jun 29 14:24:36 UTC 2010


On Mon, Jun 28, 2010 at 5:24 PM, Paul Schmehl <pschmehl_lists at tx.rr.com> wrote:
> I'm working on a port update for one of the ports that I maintain, and I've
> run into a problem that I can't seem to solve.
>
> I use this construction to ensure that the port doesn't overwrite the conf
> file, if one exists:
>
> .for f in barnyard2.conf
>       ${INSTALL_DATA} ${WRKSRC}/etc/${f} ${PREFIX}/etc/${f}-sample
>       [ -f ${PREFIX}/etc/${f} ] || \
>       ${INSTALL_DATA} ${WRKSRC}/etc/${f} ${PREFIX}/etc/${f}
> .endfor
>
> But it gets overwritten anyway.  What am I doing wrong?  I thought this
> worked before, but I can't be sure.  Testing proves that it does not work
> now.  I tried to changing to an if [ ! -f construction, but that didn't do a
> thing.
>
I did some testing with the following script:

cd /usr/ports/security/barnyard2
mkdir -p `make -V WRKSRC`/etc
touch `make -V WRKDIR`/pkg-message
echo "Test file1" > `make -V WRKSRC`/etc/barnyard2.conf
make -DNOPORTDOCS post-install
md5 /usr/local/etc/barnyard2.conf*
echo "Test file2" > `make -V WRKSRC`/etc/barnyard2.conf
make -DNOPORTDOCS post-install
md5 /usr/local/etc/barnyard2.conf*

With these results:

vbox# cd /usr/ports/security/barnyard2
vbox# mkdir -p `make -V WRKSRC`/etc
vbox# touch `make -V WRKDIR`/pkg-message
vbox# echo "Test file1" > `make -V WRKSRC`/etc/barnyard2.conf
vbox# make -DNOPORTDOCS post-install
install  -o root -g wheel -m 444
/usr/ports/security/barnyard2/work/barnyard2-1.7/etc/barnyard2.conf
/usr/local/etc/barnyard2.conf-sample
[ -f /usr/local/etc/barnyard2.conf ] ||  install  -o root -g wheel -m
444 /usr/ports/security/barnyard2/work/barnyard2-1.7/etc/barnyard2.conf
/usr/local/etc/barnyard2.conf
vbox# md5 /usr/local/etc/barnyard2.conf*
MD5 (/usr/local/etc/barnyard2.conf) = 66e0834ee2cd3f45a229c954894aaead
MD5 (/usr/local/etc/barnyard2.conf-sample) = 66e0834ee2cd3f45a229c954894aaead
vbox# echo "Test file2" > `make -V WRKSRC`/etc/barnyard2.conf
vbox# make -DNOPORTDOCS post-install
install  -o root -g wheel -m 444
/usr/ports/security/barnyard2/work/barnyard2-1.7/etc/barnyard2.conf
/usr/local/etc/barnyard2.conf-sample
[ -f /usr/local/etc/barnyard2.conf ] ||  install  -o root -g wheel -m
444 /usr/ports/security/barnyard2/work/barnyard2-1.7/etc/barnyard2.conf
/usr/local/etc/barnyard2.conf
vbox# md5 /usr/local/etc/barnyard2.conf*
MD5 (/usr/local/etc/barnyard2.conf) = 66e0834ee2cd3f45a229c954894aaead
MD5 (/usr/local/etc/barnyard2.conf-sample) = 2ef1fb610a51b51da31397511cac748f

The first time I ran `make post-install`, both barnyard2.conf and
barnyard2.conf-sample were installed, and then when the 2nd `make
post-install` was run, only barnyard2.conf-sample was updated.  If
didn't overwrite the existing barnyard2.conf.

Run the above script on your update port, and see if you get the same
results.  If you do, then the problem is not with the ports Makefile,
but with the sources Makefile installing barnyard2.conf.

Scot


More information about the freebsd-ports mailing list