Discussion:
Dependency problem when "post" runs command from the rpm
Toralf Lund
2008-09-11 09:15:41 UTC
Permalink
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?

- Toralf
Valery Reznic
2008-09-11 10:01:49 UTC
Permalink
Subject: Dependency problem when "post" runs command from the rpm
Date: Thursday, September 11, 2008, 12:15 PM
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
to keep Requires and Requires(post) in sync
you
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?
To keep Requires and Requires(post) in sync you can use rpmrebuild
(http://rpmrebuild.sf.net)
First you build your package as usual.
Then you use rpmrebuild to rebuild package. You'll need to write plugin for --change-spec-requires.
It's can be something like

sed -n -e 'p' -e 's/^Requires:/Requires(post):/p'

Valery
- Toralf
_______________________________________________
Rpm-list mailing list
https://www.redhat.com/mailman/listinfo/rpm-list
Toralf Lund
2008-09-12 06:49:44 UTC
Permalink
Post by Valery Reznic
Subject: Dependency problem when "post" runs command from the rpm
Date: Thursday, September 11, 2008, 12:15 PM
I've run into an installation order issue related to the
"post" [ ... ]
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. [ ... ]
\
To keep Requires and Requires(post) in sync you can use rpmrebuild
(http://rpmrebuild.sf.net)
First you build your package as usual.
Then you use rpmrebuild to rebuild package. You'll need to write plugin for --change-spec-requires.
It's can be something like
Right. I never thought of that.

This does seems like a rather roundabout way of going about it, though,
and I was really hoping for some sort of support within rpmbuild itself.

Thanks anyway...

- Toralf
Post by Valery Reznic
sed -n -e 'p' -e 's/^Requires:/Requires(post):/p'
Valery
- Toralf
_______________________________________________
Rpm-list mailing list
https://www.redhat.com/mailman/listinfo/rpm-list
_______________________________________________
Rpm-list mailing list
https://www.redhat.com/mailman/listinfo/rpm-list
--
Toralf Lund <***@procaptura.com> +47 66 85 51 22
ProCaptura AS +47 66 85 51 00 (switchboard)
http://www.procaptura.com/ +47 66 85 51 01 (fax)
Toralf Lund
2008-09-12 13:33:34 UTC
Permalink
Post by Toralf Lund
[ ... ]
Post by Toralf Lund
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. [ ... ]
\
To keep Requires and Requires(post) in sync you can use rpmrebuild
(http://rpmrebuild.sf.net)
First you build your package as usual.
Then you use rpmrebuild to rebuild package. You'll need to write
plugin for --change-spec-requires.
It's can be something like
Right. I never thought of that.
This does seems like a rather roundabout way of going about it,
though, and I was really hoping for some sort of support within
rpmbuild itself.
But actually, I can't seem to reproduce the original problem now, i.e.
when I retry the installation, the packages are installed in the
"correct" order without Requires(pre). And many this is what I should
expect; rpm does try to order packages according to (normal) Requires
these days, doesn't it.

Yet I'm quite sure that it somehow decided to install the package using
certain libs after the ones providing them when I tested this earlier.

I'm confused ;-(

- Toralf
Toralf Lund
2008-09-12 13:43:20 UTC
Permalink
Post by Toralf Lund
Post by Toralf Lund
[ ... ]
Post by Toralf Lund
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. [ ... ]
\
To keep Requires and Requires(post) in sync you can use rpmrebuild
(http://rpmrebuild.sf.net)
First you build your package as usual.
Then you use rpmrebuild to rebuild package. You'll need to write
plugin for --change-spec-requires.
It's can be something like
Right. I never thought of that.
This does seems like a rather roundabout way of going about it,
though, and I was really hoping for some sort of support within
rpmbuild itself.
But actually, I can't seem to reproduce the original problem now, i.e.
when I retry the installation, the packages are installed in the
"correct" order without Requires(pre). And many this is what I should
expect; rpm does try to order packages according to (normal) Requires
these days, doesn't it.
Yet I'm quite sure that it somehow decided to install the package
using certain libs after the ones providing them when I tested this
earlier.
I'm confused ;-(
... confused enough to get the above bit the wrong way around. What I
meant to say, was that a package requiring some libs was somewhat
unexpectedly installed first of all even though rpms providing the libs
were specified on the same command line.

- Toralf
Michael A. Peters
2008-09-16 03:24:00 UTC
Permalink
Post by Toralf Lund
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:

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.

My understanding of this may not be 100%
Jeff Johnson
2008-09-16 15:12:18 UTC
Permalink
Post by Michael A. Peters
Post by Toralf Lund
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?
Um, yes, wrong.
Post by Michael A. Peters
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.
Post by Michael A. Peters
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
Post by Michael A. Peters
_______________________________________________
Rpm-list mailing list
https://www.redhat.com/mailman/listinfo/rpm-list
Toralf Lund
2008-09-21 17:31:14 UTC
Permalink
Post by Jeff Johnson
Post by Toralf Lund
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 [ ... ]
Um, yes, wrong.
[ .. ]
The %pre and %post scripts are run immediately before/after a package
is installed,
not after all the packages are installed.
Exactly. This is what's causing me trouble; essentially, I have a
command that would be better to run at the end of the entire
transaction. But I think I understand why rpm doesn't work that way...
Post by Jeff Johnson
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.
Quite.
Post by Jeff Johnson
[ ... ]
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.
In my case the script and the package itself both need (more or less)
the same libs. Logically, they may be seen as independent sets of
dependencies, though, I think...
Post by Jeff Johnson
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
Well. It doesn't help me too much with my original issue. But, like I
said elsewhere, I can't seem to reproduce the problem I thought I had,
so maybe it doesn't matter. I'm still confused, though.

Question: Can I generally assume the packages are ordered according to
"Requires" these days, i.e. that if package A requires something
provided by package B, then B is installed before A (when A and B are
both part of the same transaction)? I'm fairly sure I couldn't when I
started using rpm, so I had to mess about with ""PreReq" instead...
Post by Jeff Johnson
73 de jeff
_______________________________________________
Rpm-list mailing list
https://www.redhat.com/mailman/listinfo/rpm-list
_______________________________________________
Rpm-list mailing list
https://www.redhat.com/mailman/listinfo/rpm-list
Jeff Johnson
2008-09-21 21:56:07 UTC
Permalink
Post by Toralf Lund
Post by Jeff Johnson
Post by Toralf Lund
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 [ ... ]
Um, yes, wrong.
[ .. ]
The %pre and %post scripts are run immediately before/after a
package is installed,
not after all the packages are installed.
Exactly. This is what's causing me trouble; essentially, I have a
command that would be better to run at the end of the entire
transaction. But I think I understand why rpm doesn't work that way...
There are %posttrans scriptlets that run at the end of the transaction.
Post by Toralf Lund
Post by Jeff Johnson
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.
Quite.
Post by Jeff Johnson
[ ... ]
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.
In my case the script and the package itself both need (more or
less) the same libs. Logically, they may be seen as independent sets
of dependencies, though, I think...
Post by Jeff Johnson
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
Well. It doesn't help me too much with my original issue. But, like
I said elsewhere, I can't seem to reproduce the problem I thought I
had, so maybe it doesn't matter. I'm still confused, though.
Question: Can I generally assume the packages are ordered according
to "Requires" these days, i.e. that if package A requires something
provided by package B, then B is installed before A (when A and B
are both part of the same transaction)? I'm fairly sure I couldn't
when I started using rpm, so I had to mess about with ""PreReq"
instead...
Yes, except for dependency loops, where all dependencies involved
in the loop are ignored for ordering purposes.

Requires: == PreReq: for like 8 years now, but I'm sure you can find
any answer you wish to hear regarding rpm PreReq:

73 de Jeff
Loading...