Re: Dependency problem when "post" runs command from the rpm

Jeff Johnson <[email protected]> Tue, 16 Sep 2008 11:12:18 -0400
Newsgroups gmane.linux.redhat.rpm.general
Message-ID <[email protected]>
On Sep 15, 2008, at 11:24 PM, Michael A. Peters wrote:

> Toralf Lund wrote:
>> I've run into an installation order issue related to the "post"  
>> scriptlet in one of my packages. Basically, this scripts executes a  
>> (command-line only) program installed by the package, and this  
>> program pretty much needs everything required by the package. The  
>> problem is, if I install my package along with some of the required  
>> software, the requirements are often installed *after* the "main"  
>> package - which means the "post" script won't work because some of  
>> what the program needs isn't installed yet.
>> So, this is when I use "Requires(post)", isn't it? But how do I set  
>> it up? The Requires of the package is a very long list, and most of  
>> the entries are added via the "AutoReqProv" mechanism, so  
>> duplicating the info by hand for "Requires(post)" is rather hard.  
>> Is there an alternative? Can I somehow say that everything in the  
>> main Requires list is also required by "post"? Or alternatively,  
>> can I enable automatic search for shared objects etc. for  
>> Requires(post) just like for Requires?
>
> Perhaps my understanding is wrong - but I believe:
>


Um, yes, wrong.

> Requires(pre) is when something is required for a pre-install script.
> Requires(post) is when something is required for a post-install  
> script but not necessarily for the package itself - IE you could  
> remove the dependency after the post script has run.
>
> When installing a group of RPMs together, the post scripts are not  
> run until after all the packages are installed - so if foo requires  
> bar and the foo post script needs bar installed - just Requires: bar  
> should ensure that bar is actually installed before the foo post  
> scriptlet runs.
>

The %pre and %post scripts are run immediately before/after a package  
is installed,
not after all the packages are installed.

This is also true for %preun/%postun when a package is erased, the  
scripts are run
immediately before/after the erasure.

> My understanding of this may not be 100%
>

What is most confusing is that rpm does install before erase. Which  
means that %post
scriptlet is run before %preun is run, which is perhaps counter- 
intuitive, but is exactly
what is needed if shared libraries are being upgraded on live systems.  
The new librrary
must be installed before the old library is removed in ordeer to  
minimize the window
where the library is not available.

Another confusion is the relationship on upgrade between the new  
installed package and
the older erased package(s) (note that Obsoletes: can/will lead to  
multiple packages to be
erased). rpm has never guaranteed any relation between installed <->  
erased package
ordering other than "Erasing is after install." As originally  
implemented, erasing was immediately
after install. Nothing wrong with that except that forces the erasure  
to happen before
the next install is attempted, whgich is slower than delaying all  
erasures until later,
as erasures can always be run in parallel (assuming that erasure  
dependencies
are accurate and that erasures are well ordered, but even those  
details usually
don't matter on upgrade).

And finally that brings the topic to context markers like  
Requires(post) etc.

Context markers like Requires(post) are intended to break dependency  
loops while
ordering.

A package that "needs" some other package solely while running a %post  
scriptlet,
not after being installed, can carry a Requires(post) hint to the  
ordering within rpm.

The hint excludes dependency loops between install <=> erase packages.

The other major affect of adding an explicit Requires(post) hint is  
that those
dependencies are not registered in an rpmdb because they were needed  
solely
for installing, not for using or erasing, a package. There's no need  
to keep track
of the install context dependencies after the install has been done  
because
the %post scriptlet is run only during install, never run after install.

hth

73 de jeff

> _______________________________________________
> Rpm-list mailing list
> [email protected]
> https://www.redhat.com/mailman/listinfo/rpm-list