FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > RPM Package Manager

 
 
LinkBack Thread Tools
 
Old 05-21-2008, 10:17 PM
"Hajducko, Steven"
 
Default Removing directories/files in RPM erase




So what's the best
practice for removing directories that your RPM owns that contain files that the
RPM doesn't know about?
*
For instance, I've
got an rpm that creates several directories and installs a utility.* When I
start the tool and it's clients, it starts creating files in one of the
directories that the RPM owns ( ssl certs, logs, etc ).
*
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?
*
Suggestions
welcome.
*
.................................................. ...................
Steven Hajducko
Systems
Engineer, Systems Integration
w:
818.597.6443** m: 805.377.9074


This email may contain confidential and privileged material for
the sole
use of the intended recipient. Any review or distribution
by others is
strictly prohibited. If you are not the intended
recipient please contact the
sender and delete all copies.

*
_______________________________________________
Rpm-list mailing list
Rpm-list@redhat.com
https://www.redhat.com/mailman/listinfo/rpm-list
 
Old 05-21-2008, 10:58 PM
devzero2000
 
Default Removing directories/files in RPM erase

In this case i do as you suggest.

Best Regards


2008/5/22 Hajducko, Steven <steven.hajducko@digitalinsight.com>:






So what's the best
practice for removing directories that your RPM owns that contain files that the
RPM doesn't know about?
*
For instance, I've
got an rpm that creates several directories and installs a utility.* When I
start the tool and it's clients, it starts creating files in one of the
directories that the RPM owns ( ssl certs, logs, etc ).
*
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?
*
Suggestions
welcome.
*
.................................................. ...................
Steven Hajducko

Systems
Engineer, Systems Integration
w:
818.597.6443** m: 805.377.9074


This email may contain confidential and privileged material for
the sole
use of the intended recipient. Any review or distribution
by others is
strictly prohibited. If you are not the intended
recipient please contact the
sender and delete all copies.

*

_______________________________________________

Rpm-list mailing list

Rpm-list@redhat.com

https://www.redhat.com/mailman/listinfo/rpm-list


_______________________________________________
Rpm-list mailing list
Rpm-list@redhat.com
https://www.redhat.com/mailman/listinfo/rpm-list
 
Old 05-21-2008, 11:27 PM
Tim Mooney
 
Default Removing directories/files in RPM erase

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.

Tim
--
Tim Mooney mooney@dogbert.cc.ndsu.NoDak.edu
Information Technology Services (701) 231-1076 (Voice)
Room 242-J6, IACC Building (701) 231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164

_______________________________________________
Rpm-list mailing list
Rpm-list@redhat.com
https://www.redhat.com/mailman/listinfo/rpm-list
 
Old 05-22-2008, 12:03 AM
Jeff Johnson
 
Default Removing directories/files in RPM erase

On May 21, 2008, at 7:27 PM, Tim Mooney wrote:



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. If the

path happens to be a directory, the erase behavior will be identical to
that when the directory is explicitly part of a package.

On erase, rpm runs rmdir(2) on "owned" (i.e. directories that are
explcitly

part of a package) directories. rmdir(2) will fail with ENOTEMPTY
if there are files within the directory. That behavior is (imho)
exactly what one wishes: rpm
already removes files in reverse order, i.e. members of the directory
before parent directory,
so any remaining files are from other packages (which will eventually
succeed with rmdir(2)),
or from side effects (in which case the unknown files should not be
touched).


If the directory contents are created outside of rpm, then its up to
something

other than rpm to manage the directory contents.

If the directory contents are being created by %post scripts, then the
additionally created

files should be removed in %preun for symmetry.

If the directory contents are within other packages you need pin down
which package
should "own" the directory, and arrange through dependencies for that
package to be installed
first (and removed last if you have erasure ordering). The "best
effort" rmdir(2) will
eventually succeed when all other contents are removed. The number of
files
within the directory works as a defacto reference count, the only
difference from
a true reference count is that a rmdir(2) is attempted, but silently/
harmlessly fails.


Establishing ownership of a directory in packaging, particularly for
some public path in which, say, modules
are installed, can be quite complicated. Putting the specific
directory path in its own package, or in
a directory path skeleton package like filesystem, or adding a
Requires: /path/to/directory (or other
ordering hint no matter how expressed) may help establish which
package is responsible for

removing a given directory.

73 de Jeff


_______________________________________________
Rpm-list mailing list
Rpm-list@redhat.com
https://www.redhat.com/mailman/listinfo/rpm-list
 
Old 05-22-2008, 05:08 AM
Tim Mooney
 
Default Removing directories/files in RPM erase

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.

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).

Tim
--
Tim Mooney mooney@dogbert.cc.ndsu.NoDak.edu
Information Technology Services (701) 231-1076 (Voice)
Room 242-J6, IACC Building (701) 231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164

_______________________________________________
Rpm-list mailing list
Rpm-list@redhat.com
https://www.redhat.com/mailman/listinfo/rpm-list
 
Old 05-22-2008, 04:23 PM
"Hajducko, Steven"
 
Default Removing directories/files in RPM erase

Cool, thanks for the sage words of advice guys.

As it turns out, the RPM would own this directory, because it's installing to it's own directory under /opt and it's in that directory that it's creating these files during run time.

Unfortunately, I can't possibly know the name of each file that it's going to create ( it creates ssl certs based on the hosts that connect to it.. ), so it looks like the %ghost attribute isn't going to work and I'll just have to go along with uninstall scripts.

Thanks again

--
sh

> -----Original Message-----
> From: rpm-list-bounces@redhat.com
> [mailto:rpm-list-bounces@redhat.com] On Behalf Of Tim Mooney
> Sent: Wednesday, May 21, 2008 10:08 PM
> To: RPM Package Manager
> Subject: Re: Removing directories/files in RPM erase
>
> 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.
>
> > 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).
>
> Tim
> --
> Tim Mooney
> mooney@dogbert.cc.ndsu.NoDak.edu
> Information Technology Services (701) 231-1076 (Voice)
> Room 242-J6, IACC Building (701) 231-8541 (Fax)
> North Dakota State University, Fargo, ND 58105-5164
>
> _______________________________________________
> Rpm-list mailing list
> Rpm-list@redhat.com
> https://www.redhat.com/mailman/listinfo/rpm-list
>

_______________________________________________
Rpm-list mailing list
Rpm-list@redhat.com
https://www.redhat.com/mailman/listinfo/rpm-list
 
Old 05-23-2008, 09:54 AM
Lars Vagt
 
Default Removing directories/files in RPM erase

Hajducko, Steven wrote:

Unfortunately, I can't possibly know the name of each file that it's going to create ( it creates ssl certs based on the hosts that connect to it.. ), so it looks like the %ghost attribute isn't going to work and I'll just have to go along with uninstall scripts.


I've seen %ghost directives with wildcards. (I never used one.)

HTH, Lars

_______________________________________________
Rpm-list mailing list
Rpm-list@redhat.com
https://www.redhat.com/mailman/listinfo/rpm-list
 
Old 05-23-2008, 12:48 PM
Jeff Johnson
 
Default Removing directories/files in RPM erase

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.



_______________________________________________
Rpm-list mailing list
Rpm-list@redhat.com
https://www.redhat.com/mailman/listinfo/rpm-list
 

Thread Tools




All times are GMT. The time now is 07:15 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org