Howto remove empty dirs in post-deactivate?

Peter Danecek Peter.Danecek at
Wed Apr 16 13:52:44 PDT 2014

On 16 Apr 2014, at 22:41, Ryan Schmidt <ryandesign at> wrote:

> On Apr 16, 2014, at 15:34, Peter Danecek wrote:
>> I am looking for an elegant way to remove some directory (directories) if they are empty in a Portfile.
>> I would like to use this in the post-deactivate hook. There I remove some unregistered files, after related registered files are deactivated. However, afterwords I'd like to check if the dir now is empty and conditionally remove it. 
>> I am not very fluent in TCL, so any tip how to do this in an elegant way is welcome.
> MacPorts automatically removes empty directories from the destroot before installation. This is easy for it to do. It might be nice if there were a way for it to do the same post-

The directories were registered, but are unregistered in the deactivate step, even if they are not removed because not (yet) empty, right?

It would be most consistent to postpone this unregister step only after retrying to remove them after post-deactivate. Unfortunately, I do not know base too well. Would this be difficult to implement?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1762 bytes
Desc: not available
URL: <>

More information about the macports-dev mailing list