@unexec equivalent in Makefile ?

Scot Hetzel swhetzel at gmail.com
Wed Feb 16 08:42:06 PST 2005


On Wed, 16 Feb 2005 15:42:12 +0200, Ion-Mihai Tetcu
<itetcu at people.tecnik93.com> wrote:
> Hi,
> 
> I have a port that installs 8 files (3 of them being PORTDOCS), so I
> rather not use a pkg-plist file. But I need to remove a .conf file on
> deinstall if it's identical to the distributed one, and I'm not aware of
> a way to do it in the Makefile; we don't have pre|post-deinstall targets
> and using a pkg-deinstall doesn't make sense just for this.
> 
You don't need to worry about deinstall targets in the Makefile, as
pkg_delete is called to remove your port.

Just place an @unexec to remove the file in the ports pkg-plist, for
example the www/apache13 port has the following 3 lines for it's
etc/apache/access.conf file:

@unexec if cmp -s %D/etc/apache/access.conf
%D/etc/apache/access.conf-dist; then rm -f %D/etc/apache/access.conf;
fi
etc/apache/access.conf-dist
@exec [ -f %B/access.conf ] || cp %B/%f %B/access.conf

You just need to make your port install the *.conf-dist file, and then
test if the *.conf file(s), and create them if they don't exist, in
the Makefile's post-install target:

post-install:
.for conffile in test.conf test2.conf
    if [ ! -f ${PREFIX}/etc/${conffile} ]; then \
        cp ${PREFIX}/etc/${conffile}-dist ${PREFIX}/etc/${conffile} ; \
    fi
.endfor

Scot


More information about the freebsd-ports mailing list