replacing folders with symlinks (pre vs pretrans)

Panu Matilainen pmatilai at
Tue May 28 16:21:27 UTC 2013

On 05/28/2013 06:50 PM, Stanislav Ochotnicky wrote:
> Quoting Panu Matilainen (2012-09-21 10:17:27)
>> A directory (empty or not) can't be automatically replaced by anything
>> else (symlink or otherwise) in the existing rpm versions. If absolutely
>> necessary, it can be accomplished by doing the necessary renames and
>> symlinks in "%pretrans -p <lua>" scriptlet, but that should be only seen
>> as the last resort as its not exactly a safe operation.
> This used to work in %pre scriptlet as well. It seems like RPM is now doing some
> additional checks and it will not even get to the point of %pre scriptlet. As
> far as I can see for F17/F18 %pre scriptlet will work, but F19+ %pretrans has to
> be used, correct?

%pre was never correct for the task because it means rpm wont know about 
the change, which can cause side-effects like files from the new package 
removed on cleanup of the older package, junk left behind etc. What 
exactly happens depends on the details.

And yes, rpm >= 4.11 enforces use of %pretrans for the purpose as it 
detects the issue early on, whereas older versions just merrily go ahead 
and likely ends up making a mess during the transaction.

> Since I *knew* we used %pre for this exact problem before, I have used it and
> it broke upgrade paths[1]. I assume just rewriting %pre[2] into following
> %pretrans will work:
>      for key, dir in pairs({"boot", "conf"}) do
>          path = "%{_datadir}/%{name}/" .. dir
>          if posix.readlink(path) then
>             os.remove(path)
>          end
>      end:
> It certainly seemed to work now, but I wonder if I am just missing something else.

Yup, something like that.

	- Panu -

> [1]
> [2]

More information about the devel mailing list