SvarDOS / bugz

SvarDOS bug tracker

Home Page:http://svardos.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'pkg remove' should display a note about any package leftovers

bttrx opened this issue · comments

I'd like to see, pkg remove to exit with some message like "Note: Check dir 'C:\PROGS\FOO' for any package leftovers, e. g., configuration or user files.", if it failed to delete the C:\PROGS\FOO directory.

I tried to implement this yesterday, but C is not my language. :-(

While looking at the code in pkgrem.c I noticed, pkg also tries to remove the C:\PROGS and C: directories. I don't like this approach, because a kernel bug or kernel feature might allow to rmdir a non-empty directory one day.

While looking at the code in pkgrem.c I noticed, pkg also tries to remove the C:\PROGS and C: directories. I don't like this approach, because a kernel bug or kernel feature might allow to rmdir a non-empty directory one day.

The idea here is that C:\PROGS (or whatever is configured by the user) is created only when needed - ie. when the first "PROGS"-belonging package is installed, and it is removed automatically if all packages of the category are removed without leaving any files behind.

If you ask me, trying to remove a directory is a good test to see if the directory is empty. :-)
It could be done differently of course, for example by checking first if the directory truly is empty, but it's extra code without any functionality change.

But back to the suggested feature: the idea of warning that a directory has been left behind because it contains some unexpected files is good. The implementation of such feature is much less sexy though, as it requires some rpm-like tracking of directories "ownership". PKG would need to figure out the part of the path that is belonging to the package at install time (having in mind that some packages share a common directory) and then write this information into the LSM listing of files so it can be used as a hint when the package will be removed.

The idea here is that C:\PROGS (or whatever is configured by the user) is created only when needed - ie. when the first "PROGS"-belonging package is installed, and it is removed automatically if all packages of the category are removed without leaving any files behind.

I see.

If you ask me, trying to remove a directory is a good test to see if the directory is empty. :-)

So, we agree to disagree here. It's a creative (ab)use of this function.

The implementation of such feature is much less sexy though, as it requires some rpm-like tracking of directories "ownership".

"much less sexy" is why I created this issue. :-) I didn't want to lose the idea, but it's not as easy as I thought at first.

A solution would be to (ab)use the case of directories in the list of files owned by the package to distinguish between "system-wide" and "packaged-owned" directories. Example:

image

The "C:\DRIVERS" part is upper-case, so pkg would interpret it as "system-wide". It would still try to rmdir() it during package removal, but silently ignore failure.

"doskey" is lower-case, so pkg would interpret it as "package-owned". If rmdir() on such directory fails, a warning would be displayed.

The only difficulty is to make sure that paths are written with the proper case in all possible situations.