Re: Question about dpkg -r
Hope Duryea writes...
> I haven't read through the entire source, but from
> what I can tell by using dpkg -r on a package, and
> from looking at isdirectoryinuse(), and the call to it
> in remove.c, it seems the criteria for whether a
> directory is included in the removal of the package is
> whether any other package has installed into it. Is
> that correct?
Not just other packages, but also if anything remains in the directory, like
files a sysadmin put there, or installs outside the packaging system, etc.
Maybe that's what you mean, I just wanted to be clear.
> If it is, I would like to suggest that it only do that
> for directories it created as part of the install. In
> other words, if it didn't need to create / or /usr,
> but did have to create /usr/share, then, when the
> package is removed, if /usr/share is now empty, it can
> remove /usr/share, but since it didn't have to create
> /usr or /, it should not (try to) remove those.
What about the case where package A is the first things to install something
to /usr/share (and thus created it) and then package B installs something
there. Then you remove A first and then B. A created it but B still needs it
so you can't remove when removing A, and if you're only removing directories
if a package created them then it wouldn't be removed with B. The current
method of checking if a directory is empty each time a package removes it's
last file from it seems like the most straightforward way.
> If that doesn't seem likely to happen, then is there
> any way I can provide dpkg with the list of files to
> remove and limit its action to just that list?
What behavior are you trying to get? To not delete a directory you still have
non-package-system files in? It won't. To leave an empty directory? If you
want that, would touching a file in that dir to make it stick around work?
> didn't see anything in the code to suggest it reads in
> a file (but again, I haven't read through all of it),
> nor have I seen anything in any of the documentation
> I've read through that would suggest I could, but I
> figured it doesn't hurt to ask :)
I haven't read the dpkg code, my comments above are just based on observation
of using dpkg for a while. Often when dpkg is removing packages you will see
it report "not removing blah, directory not empty".
--
Matt Taggart
taggart@debian.org
Reply to: