Re: Removing directories/files in RPM erase

Jeff Johnson <[email protected]> Fri, 23 May 2008 08:48:22 -0400
Newsgroups gmane.linux.redhat.rpm.general
Message-ID <[email protected]>
On May 22, 2008, at 1:08 AM, Tim Mooney wrote:

> In regard to: Re: Removing directories/files in RPM erase, Jeff  
> Johnson...:
>
>>>> However, when I remove the RPM, it doesn't remove the directories  
>>>> because
>>>> they aren't empty.  Should I setup a post uninstall to see if  
>>>> this is the
>>>> last instance of the package and if it is, manually remove those
>>>> directories?
>>> Look up the %ghost attribute (?, token?, I'm not sure what it  
>>> should be
>>> classified as) and see if that does what you need.
>>
>> %ghost won't solve removing nonempty directories. The %ghost  
>> directive,
>> with its mysterious name, claims ownership for a package of a pre- 
>> existing path.
>
> No, but if the %ghost is applied to the log files and the other files
> that are created as part of the execution of the programs, then those
> will be removed when the package is removed, and hence the directory  
> will
> be empty.
>

Yes would "work" for if the file names are known.

Hmmm ... I could likely sneak a glob into RPMTAG_BASENAMES
for %ghost files, expanding and looping over unlink(2). But there
are large issues with, say ../../../../../../../* globs expanded in a  
unlink(2)
loop.

>> Establishing ownership of a directory in packaging, particularly  
>> for some public path in which, say, modules
>> are installed, can be quite complicated.
>
> :-)  Don't I know it! I started a pretty lengthy thread about that  
> exact
> issue right after 4.4.7 or 4.4.8 came out and I first experienced  
> needing
> to claim directories (which I also think is The Right Thing, it's just
> hard to do in some cases because of ambiguous ownership).
>

Yes lengthy and the issue of ownership of directories as well as
parent directory and symlink endpoint dependencies is arcane and
tedious support.

If up to me, I'd create one (or more) directory skeleton packages
like in the file system package, and move on to more interesting  
problems.