FS#25141 - Prevent certain directories from being removed when empty

Attached to Project: Pacman
Opened by Florian Pritz (bluewind) - Saturday, 16 July 2011, 13:49 GMT
Last edited by Allan McRae (Allan) - Tuesday, 19 July 2011, 05:24 GMT
Task Type Feature Request
Category Backend/Core
Status Closed
Assigned To Dan McGee (toofishes)
Dave Reisner (falconindy)
Architecture All
Severity Low
Priority Normal
Reported Version 3.5.3
Due in Version 4.0.0
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Right now pacman always removes empty directories, but this might lead to important directories being removed as described here:  FS#25133 

2 possible solutions:
1) An option in the package metadata which disables the empty directory check for the package .

2) A list of paths/directories (one per line) read from files in /etc/pacman.d/keep-dirs.d/ which shouldn't be removed when empty.
This task depends upon

Closed by  Allan McRae (Allan)
Tuesday, 19 July 2011, 05:24 GMT
Reason for closing:  Fixed
Additional comments about closing:  http://projects.archlinux.org/pacman.git /commit/?id=1c39e4fb
Comment by Dan McGee (toofishes) - Saturday, 16 July 2011, 13:59 GMT
Not a fan of option 1 as it puts an onus on the packager to get it right, and god knows AUR packages that install and empty /var/lock/ won't do so.

Let's KISS with option 2, we don't need a whole new format of config here- we have the Include framework, and we can just add a KeepDirs config variable if necessary.

However, how expensive/hard is it to just "do this right"? Psuedocode: if (file is directory) and (directory is empty) and (directory is unowned): remove, else keep

I don't see too much crazy here. The first check is super simple. The second is relatively easy (right now we just force an unlink and ignore errors, see related task). The third will take a bit of work and could potentially be "expensive", but I really don't think it would be all that bad.
Comment by Florian Pritz (bluewind) - Saturday, 16 July 2011, 13:59 GMT
3rd and most likely cleanest method:
Don't remove directories if any other installed package still contains them.
Comment by Xavier (shining) - Saturday, 16 July 2011, 17:15 GMT
We wondered several times whether to do that or not, but the cost slowed us down.
http://mailman.archlinux.org/pipermail/pacman-dev/2009-July/009012.html
I would say just do it, but don't forget the little benchmark.

Loading...