Bug 447156 - rpm cannot change directory to symlink (or the other way around)
rpm cannot change directory to symlink (or the other way around)
Status: ASSIGNED
Product: Fedora
Classification: Fedora
Component: rpm (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Fedora Packaging Toolset Team
Fedora Extras Quality Assurance
: FutureFeature, Reopened
: 647068 1124473 1205005 (view as bug list)
Depends On:
Blocks: 443275 638720 739318 974840 1054396
  Show dependency treegraph
 
Reported: 2008-05-18 07:17 EDT by Patrice Dumas
Modified: 2016-04-20 08:51 EDT (History)
24 users (show)

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
: 638720 (view as bug list)
Environment:
Last Closed: 2013-06-17 02:40:34 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Patrice Dumas 2008-05-18 07:17:22 EDT
Description of problem:

when a directory is changed to a symlink rpm errors out.
For example
https://bugzilla.redhat.com/show_bug.cgi?id=433096

error: unpacking of archive failed on file
/usr/lib/xulrunner-1.9pre/dictionaries: cpio: rename

This is a very important and urgent item since it can block any 
update.

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:
Comment 1 Jeff Johnson 2008-05-18 13:08:28 EDT
Add a %pretrans script to rename the directory and create the symlink.

WORKSFORME (and for all versions of rpm back to when %pretrans was added.)

You will have to worry about dependencies if you wish to install into an empty chroot.
%pretreans -p <lua> rather than using /bin/sh is recommended.
Comment 2 Patrice Dumas 2008-05-18 13:11:28 EDT
That's not a solution. rpm should handle this situation right.
Comment 3 devzero2000 2008-08-03 18:31:49 EDT
It is a solution that rpm can handle. What's the problem ? Other package management system, deb for example,have the same problem, but IMHO they can't handle it - almost in the past i am not sure today. Probably if it is difficult for most to implemt or know, well it is sufficent to write about it.

jmho
Comment 4 Patrice Dumas 2008-08-04 11:57:04 EDT
It is better to have a workaround than not to have one, but still
this is a bug. If it is hard to correct, it can be postponed, of
course, I haven't proposed a patch so I can wait an infinite time.

The fact that it is also a debian bug is not relevant, however.
Comment 5 Bug Zapper 2008-11-25 21:17:21 EST
This bug appears to have been reported against 'rawhide' during the Fedora 10 development cycle.
Changing version to '10'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 6 Bug Zapper 2009-06-09 05:34:34 EDT
This bug appears to have been reported against 'rawhide' during the Fedora 11 development cycle.
Changing version to '11'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 7 Christoph Wickert 2009-12-10 13:25:22 EST
Still a problem in F12. Raising priority and severity to high.
Comment 8 Christoph Wickert 2010-02-06 17:20:09 EST
Florian, we talked about on IRC this back in December. Is there any progress? This bug prevents us from doing some important updates.
Comment 9 Bug Zapper 2010-03-15 08:00:16 EDT
This bug appears to have been reported against 'rawhide' during the Fedora 13 development cycle.
Changing version to '13'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 10 Christoph Wickert 2010-03-18 09:10:51 EDT
This is getting more and more urgent as it will break updating to F13. Anyone with the Xfce Terminal package installed won't be able to update. Florian, please tell us what to do.

(Changing version back to 'rawhide' so this doesn't get closed without actually being fixed.)
Comment 11 Bug Zapper 2010-07-30 06:32:05 EDT
This bug appears to have been reported against 'rawhide' during the Fedora 14 development cycle.
Changing version to '14'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 12 Jeff Johnson 2010-08-02 16:14:11 EDT
Two years, two months, and two weeks after being reported
... (the RPM issue with symlinks <-> dirs is much much older) ...
... I still suggest using "%pretrans -p <lua>" as a solution.

Honking urgent! urgent! urgent! has not solved the issue for a decade.
Comment 13 Christoph Wickert 2010-09-08 16:44:58 EDT
Jeef, if you can provide me a working scriptlet' to change %{_docdir}/%{name}/html/foo from a directory to a symlink, I'd be more than happy. Several people and me have been looking at it and whatever we tried resulted ether in missing files or changes that showed up in rpm -V.

Florian, can this please get fixed? What more do you want us to do? We have pinged you several times and set the bug to NEEDINFO. What more does it take to get a response?

Changing version back to rawhide and adding the FutureFeature to avoid it gets rebased against release again.
Comment 14 devzero2000 2010-10-01 13:03:52 EDT
Probably answered@rpm5.org.

https://bugs.launchpad.net/rpm/+bug/633636/comments/3

Sure there is the possibility that exists some other minor flaw related to fix also.
Comment 15 Hicham HAOUARI 2010-10-25 11:02:32 EDT
rpm can't change symlink to directory also, see bug 646523
Comment 16 Jindrich Novy 2010-10-27 05:06:22 EDT
*** Bug 647068 has been marked as a duplicate of this bug. ***
Comment 17 Christoph Wickert 2011-01-17 10:33:58 EST
*** Bug 670210 has been marked as a duplicate of this bug. ***
Comment 18 Jan Vcelak 2011-09-20 04:35:10 EDT
What is the status of this bug? (If it is really a bug.)

I'm looking into RPM testsuite. There is a test "replace directory with symlink" with comment "this is expected to fail".

(I will fix bug #739318 using %pretrans workaround in the meantime.)
Comment 19 David Juran 2011-11-10 10:29:51 EST
As far as I can see, the needinfo flag was set to ask for a progress report. So clearing the flag to make the bug more visible...
Comment 20 Fedora Admin XMLRPC Client 2012-04-13 19:11:16 EDT
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.
Comment 21 Fedora Admin XMLRPC Client 2012-04-13 19:13:39 EDT
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.
Comment 22 Panu Matilainen 2012-11-19 07:26:13 EST
Rpm >= 4.11 detects unsupported replace-attempts and reports them as file conflicts, instead of barfing up in middle of transaction. %pretrans hacks can still be used to work around it though.

That's the extent to which this is going to be "fixed" for the foreseeable future. Of course if rpm some day learns to truly deal with some of these situations, conflicts can be lifted accordingly.
Comment 23 Adam Goode 2013-06-16 14:38:40 EDT
This seems to break yum, as %pretrans hacks here are ignored by yum in the transaction test. rpm will successfully upgrade packages, but yum will not.

Can this fix be rolled back? Or another workaround proposed?
Comment 24 Panu Matilainen 2013-06-17 02:40:34 EDT
If you're seeing a regression, please file a new bug with the reproducer details. Whether such a regression is caused by changes explained in comment #22 or something else cannot be determined without closer study, but if rpm works and yum doesn't then its likely to be "something else" (and it wouldn't be the first time either)
Comment 25 Adam Goode 2013-06-19 11:07:19 EDT
Filed in bug 975909.
Comment 26 Vít Ondruch 2013-07-30 08:55:27 EDT
I think this issue should be kept open to remind that the matter is not resolved yet. I needed this functionality just recently (bug 988490) and also the bug 975909 seems to be issue for that case.
Comment 27 Adam Williamson 2014-01-15 21:05:01 EST
Do we have an official / known good snippet for converting a *directory* into a *symlink*? I can't seem to find one anywhere. Converting a *symlink* into a *directory* isn't so bad as it's relatively trivial to remove a symlink in pure lua, but recursively removing a populated directory seems to be a much bigger problem, and I'm damned if I can find a snippet that looks trustworthy enough to use. Does anyone have one?

I'm currently sitting on two or three packages where I *really need* to replace a directory with a symlink, and I'm pretty stuck. :(
Comment 28 Panu Matilainen 2014-01-17 08:51:57 EST
Recursively removing a directory tree with pure Lua is hardly worth the trouble, shelling out to do 'rm -rf /some/path' with something like this is perfectly fine:

%pretrans -p <lua>
st = posix.stat("<path to dir>")
if st and st.type == "directory" then
  os.execute("rm -rf <path to dir>")
end

The directory you're wanting to remove can only exist on upgrades, in which case shell is going to be there too (or you're looking at one very ill system). The special case of initial install simply falls through there as there's no directory to remove.
Comment 29 Adam Williamson 2014-01-17 18:03:49 EST
I thought that might be the case, but I wasn't sure. Thanks.

Could you just state - here is fine, as I'll take it to FPC - a couple of recommended snippets for both main cases here (dir->symlink and symlink->dir) and I'll try and get them added to the packaging guidelines? I think it'd help people. thanks!
Comment 30 Ľuboš Kardoš 2014-07-30 06:41:11 EDT
*** Bug 1124473 has been marked as a duplicate of this bug. ***
Comment 31 Ľuboš Kardoš 2015-09-21 08:52:15 EDT
*** Bug 1205005 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.