as replied in the imagemagick bug with the same issue - %pretrans is even more dangerous than the cleanup in %pre - %pretrans does not support shell scripts it needs to be implemented in lua in general the recommendation is do _not_ replace directories with file/symlink or vice versa.