Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Jun 2010 23:34:16 -0700
From:      Darren Pilgrim <freebsd@bitfreak.org>
To:        Paul Schmehl <pschmehl_lists@tx.rr.com>
Cc:        FreeBSD Ports <freebsd-ports@freebsd.org>
Subject:   Re: This construction doesn't work
Message-ID:  <4C2993E8.8000504@bitfreak.org>
In-Reply-To: <F2F73A9F749C437672E35BFB@utd65257.utdallas.edu>
References:  <F2F73A9F749C437672E35BFB@utd65257.utdallas.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
Paul Schmehl 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.

Instead of doing this in Makefile, do it in pkg-plist:

@unexec if cmp -s %D/etc/barnyard2.conf.sample %D/etc/barnyard2.conf; 
then rm -f %D/etc/barnyard2.conf; fi
etc/barnyard2.conf.sample
@exec if [ ! -f %D/etc/barnyard2.conf ] ; then cp -p %D/%F 
%D/etc/barnyard2.conf && chmod 600 %D/etc/barnyard2.conf; fi

Relevant section of the Porter's Handbook:

http://www.freebsd.org/doc/en/books/porters-handbook/plist-config.html



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C2993E8.8000504>