removing a dir, regardless of content

Matthew Seaman matthew at FreeBSD.org
Sun Dec 21 09:11:07 UTC 2014


On 20/12/2014 23:29, Dan Langille wrote:
> A webapp, www/bacula-web puts cache files at
> %%BASE%%/application/view/cache and on deinstall, that directory
> should be removed, even though there are files there.
> 
> Can that be done?
> 
> I’ve tried this in pkg-plist: @unexec rm -rf
> %%BASE%%/application/view/cache

The best way to handle this is by writing a pkg-deinstall.sh script:

https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/pkg-deinstall.html

(it's usually the case that you'ld create a pkg-deinstall.sh.in and add
that to SUBFILES so you can add whatever %%TOKENS%% you want to pull in
settings from the port Makefile. There are plenty of examples in the
ports, but more usually of the very similar pkg-install.sh mechanism.)

On deinstall, the pkg-deinstall.sh script should be run the first time
before processing the plist, so you can delete everything in your cache
directory at that point.  Just make the second run do nothing.

I'd still put the cache directory itself into the pkg-plist as an @dir
item, as that will simplify the installation side of things.

However, one point is that this sort of cache directory should live
somewhere under /var according to hier(7).  Does this application allow
relocating the cace directory there?  Not that most web application
writers have any conception of the filesystem management disipline we
impose on ourselves...

	Cheers,

	Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.
PGP: http://www.infracaninophile.co.uk/pgpkey


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 971 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-ports/attachments/20141221/dfb253e9/attachment.sig>


More information about the freebsd-ports mailing list