From Fedora Project Wiki
(first draft)
 
(→‎Replacing a directory with a symlink or vice versa: restructure so we can add more content)
Line 2: Line 2:


Due to a known limitation with RPM, it is not possible to replace a directory with a symlink, nor is it possible to replace a symlink with a directory, without RPM producing file conflict errors while trying to install the package.  For more information on the issues involved, refer to [https://bugzilla.redhat.com/show_bug.cgi?id=447156 bug 447156] and [https://bugzilla.redhat.com/show_bug.cgi?id=646523 bug 646523].
Due to a known limitation with RPM, it is not possible to replace a directory with a symlink, nor is it possible to replace a symlink with a directory, without RPM producing file conflict errors while trying to install the package.  For more information on the issues involved, refer to [https://bugzilla.redhat.com/show_bug.cgi?id=447156 bug 447156] and [https://bugzilla.redhat.com/show_bug.cgi?id=646523 bug 646523].
=== %pretrans workarounds === 


To work around this problem, you must include a [[Packaging:Guidelines#The_.25pretrans_scriptlet|%pretrans scriptlet written in lua]] that manually performs the conversion prior to RPM attempting to install the package.  Please use whichever of the two following snippets is necessary in packages that need this transition, replacing <code>&lt;path to dir&gt;</code> with the path to the directory that is being converted.
To work around this problem, you must include a [[Packaging:Guidelines#The_.25pretrans_scriptlet|%pretrans scriptlet written in lua]] that manually performs the conversion prior to RPM attempting to install the package.  Please use whichever of the two following snippets is necessary in packages that need this transition, replacing <code>&lt;path to dir&gt;</code> with the path to the directory that is being converted.


=== Scriptlet to replace a directory with a symlink ===
==== Scriptlet to replace a directory with a symlink ====


<pre>
<pre>
Line 15: Line 17:
</pre>
</pre>


=== Scriptlet to replace a symlink with a directory ===
==== Scriptlet to replace a symlink with a directory ====


<pre>
<pre>

Revision as of 02:57, 22 February 2014

Replacing a directory with a symlink or vice versa

Due to a known limitation with RPM, it is not possible to replace a directory with a symlink, nor is it possible to replace a symlink with a directory, without RPM producing file conflict errors while trying to install the package. For more information on the issues involved, refer to bug 447156 and bug 646523.

%pretrans workarounds

To work around this problem, you must include a %pretrans scriptlet written in lua that manually performs the conversion prior to RPM attempting to install the package. Please use whichever of the two following snippets is necessary in packages that need this transition, replacing <path to dir> with the path to the directory that is being converted.

Scriptlet to replace a directory with a symlink

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

Scriptlet to replace a symlink with a directory

%pretrans -p <lua>
st=posix.stat("<path to dir>")
if st and st.type == "link" then
  os.remove("<path to dir>")
  posix.mkdir("<path to dir>")
end