Discussion:
Disappearing symlinks in RPM transaction
Jos Vos
2008-08-08 17:12:05 UTC
Permalink
Hi,

I have a interesting RPM problem that I can't explain (yet).

I have a package, say foo-1-1. It contains a directory, say /opt/foo

I want to make an update, say foo-1-2, in which /opt/foo is not a
directory anymore, but a symlink, say /opt/foo -> bar.
Just packaging it as such does not seem to work, as the RPM says then:

error: unpacking of archive failed on file /opt/foo: cpio: rename

So, I tried a workaround and included in foo no /opt/foo at all, but
I included a post-install script:

%post
ln -snf bar /opt/foo

Later, I added some tracing (writing output to a file there) and
found out that after at the end of the post-install script the
symlink *does* exist. But it is gone when the RPM transaction
is finished!

Can someone shed a light on this? I'm afraid the actual remove
actions for foo-1-1 remove my symlink. The only thing I want to
do is replacing a directory with a symlink in an update of the
package. How should I do this?

This is using RPM 4.4.2 on a RHEL5 clone.

Thanks,

--
-- Jos Vos <***@xos.nl>
-- X/OS Experts in Open Systems BV | Phone: +31 20 6938364
-- Amsterdam, The Netherlands | Fax: +31 20 6948204
Jos Vos
2008-08-08 17:55:43 UTC
Permalink
Post by Jos Vos
Can someone shed a light on this? I'm afraid the actual remove
actions for foo-1-1 remove my symlink. The only thing I want to
do is replacing a directory with a symlink in an update of the
package. How should I do this?
To answer my own question, at least this seems to work:

%triggerpostun -- %{name} < %{version}-%{release}
ln -snf bar /opt/foo

Note that just "%triggerun" does not work, as this is run *before*
the actual files of the old version are removed.

Is this indeed the "recommended way"?
--
-- Jos Vos <***@xos.nl>
-- X/OS Experts in Open Systems BV | Phone: +31 20 6938364
-- Amsterdam, The Netherlands | Fax: +31 20 6948204
Wichmann, Mats D
2008-08-08 17:56:57 UTC
Permalink
Post by Jos Vos
Hi,
I have a interesting RPM problem that I can't explain (yet).
I have a package, say foo-1-1. It contains a directory, say /opt/foo
I want to make an update, say foo-1-2, in which /opt/foo is not a
directory anymore, but a symlink, say /opt/foo -> bar.
error: unpacking of archive failed on file /opt/foo: cpio: rename
no light: been there, same problem, no joy.

In our particular case, a toolchain became multi-version capable,
and thus changed from providing /opt/foo/lib to providing
/opt/foo/lib-1.0, /opt/foo/lib-2.0, etc. with /opt/foo/lib
becoming a symlink to the latest version.

What I did find was if there was *anything* that depended on
the old way (and in our case there was), it messed up, so ended
up removing all the packages, installing the base, and building
up from there again. Not exactly a transition-aware upgrade :(
Michael Jennings
2008-08-08 18:45:52 UTC
Permalink
On Friday, 08 August 2008, at 19:12:05 (+0200),
Post by Jos Vos
I have a interesting RPM problem that I can't explain (yet).
I have a package, say foo-1-1. It contains a directory, say /opt/foo
I want to make an update, say foo-1-2, in which /opt/foo is not a
directory anymore, but a symlink, say /opt/foo -> bar.
error: unpacking of archive failed on file /opt/foo: cpio: rename
So, I tried a workaround and included in foo no /opt/foo at all, but
%post
ln -snf bar /opt/foo
Later, I added some tracing (writing output to a file there) and
found out that after at the end of the post-install script the
symlink *does* exist. But it is gone when the RPM transaction
is finished!
Can someone shed a light on this? I'm afraid the actual remove
actions for foo-1-1 remove my symlink. The only thing I want to
do is replacing a directory with a symlink in an update of the
package. How should I do this?
This is using RPM 4.4.2 on a RHEL5 clone.
The solution is %pretrans, which a quick Google search on "rpm upgrade
symlink directory" turns up right away:

https://lists.dulug.duke.edu/pipermail/rpm-devel/2007-April/002257.html

Michael
--
Michael Jennings (a.k.a. KainX) http://www.kainx.org/ <***@kainx.org>
Linux Server/Cluster Admin, LBL.gov Author, Eterm (www.eterm.org)
-----------------------------------------------------------------------
"I have failed over and over again in my life. And that is why I
succeed." -- Michael Jordan
Loading...