RPM Community Forums

Mailing List Message of <rpm-devel>

Re: %post-script prerequisites

From: Alexey Tourbin <at@altlinux.ru>
Date: Wed 24 Sep 2008 - 21:08:54 CEST
Message-ID: <20080924190853.GO839@altlinux.org>
On Wed, Sep 24, 2008 at 01:56:35PM -0400, Jeff Johnson wrote:
> >Anyway, perhaps I should do some rewording in my initial description
> >of the problem.  In ALT Linux mailing list (in Russian), there seems
> >to be some misunderstanding (or maybe a lack of thereof), too.
> 
> Lots of misunderstandings wrto Requires(post): and PreReq:.
> 
> But I still question whether "(post)" is fixing anything at all. Try  
> and see,
> push a reproducer to me if you'ld like comments.

Sample specfile:

Name: foo
Version: 1.0
Release: 1
Summary: foo
License: GPL
Group: Development/Other
Requires: /usr/bin/bar
BuildArch: noarch
AutoReqProv: no
%package -n bar
Summary: bar
Group: Development/Other
AutoReqProv: no
%description
%description -n bar
%install
mkdir -p %buildroot/usr/bin
cat >%buildroot/usr/bin/foo <<EOF
/usr/bin/bar
EOF
cat >%buildroot/usr/bin/bar <<EOF
:
EOF
chmod +x %buildroot/usr/bin/*
%files
/usr/bin/foo
%files -n bar
/usr/bin/bar
%post
/usr/bin/foo

Build it:
Wrote: /home/at/RPM/RPMS/noarch/foo-1.0-1.noarch.rpm
Wrote: /home/at/RPM/RPMS/noarch/bar-1.0-1.noarch.rpm

In package foo, program /usr/bin/foo is both packaged *and* called
in its %post script.  The program /usr/bin/foo runs /usr/bin/bar,
for which we have the dependency "Requires: /usr/bin/bar".

Let's try to install the packages.

$ sudo rpm -iv /home/at/RPM/RPMS/noarch/foo-1.0-1.noarch.rpm /home/at/RPM/RPMS/noarch/bar-1.0-1.noarch.rpm
Preparing packages for installation...
bar-1.0-1
foo-1.0-1
$

Okay, rpm reordered the packages, so that bar is installed before foo.
But let's see what happens if the order breaks:

$ sudo rpm -ev foo bar
$ sudo rpm -iv --noorder /home/at/RPM/RPMS/noarch/foo-1.0-1.noarch.rpm /home/at/RPM/RPMS/noarch/bar-1.0-1.noarch.rpm
Preparing packages for installation...
foo-1.0-1
/usr/bin/foo: line 1: /usr/bin/bar: No such file or directory
error: execution of %post scriptlet from foo-1.0-1 failed, exit status 127
bar-1.0-1
$

Oops, all the dependencies are met, but %post scriptlet failed with "No
such file or directory", which basically indicates that the dependencies
are not enough.  Since /usr/bin/foo is *called in its own %post script*,
the dependencies of /usr/bin/foo must be indicated as Requires(post),
along with bare Requires.

--- test.spec-	2008-09-24 18:49:32 +0000
+++ test.spec	2008-09-24 19:03:06 +0000
@@ -5,6 +5,7 @@
 License: GPL
 Group: Development/Other
 Requires: /usr/bin/bar
+Requires(post): /usr/bin/bar
 BuildArch: noarch
 AutoReqProv: no
 %package -n bar

$ sudo rpm -iv --noorder /home/at/RPM/RPMS/noarch/foo-1.0-1.noarch.rpm /home/at/RPM/RPMS/noarch/bar-1.0-1.noarch.rpm
Preparing packages for installation...
foo-1.0-1
/usr/bin/foo: line 1: /usr/bin/bar: No such file or directory
error: execution of %post scriptlet from foo-1.0-1 failed, exit status 127
bar-1.0-1
$ 

Oops, adding Requires(post) does not help, it still fails (note that
this is rpm-4.0.4+).  But *rather* it should have said that the
dependencies cannot be resolved (without reordering the packages).


  • application/pgp-signature attachment: stored
Received on Wed Sep 24 21:22:03 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.