Removing symlinks for CloudStack-248 and CloudStack-209 The problem that is described in both of those bugs is the deletion of files installed by cloud-scripts.
What is happening is that instead of fixing the paths to scripts in places where they are called, we tried to create a symlink in a %post section in the RPM so that there was a symlink to the new directory for the scripts. That does work (in new installs) but the problem that arises is that when RPM is setting up the transation it doesn't know about the symlink (it's in a %post, the symlinked directory is unowned from RPMs perspective, or rather it is only owned by the cloud-agent-scripts package, which will be removed. So what happens is that cloud-agent-scripts puts things in /foo - we come along to upgrade to 4.0 and that means we use cloud-scripts - which puts things in /bar - so we install things into /bar (/foo still exists at this point) then in a %post (and for the record, RPM doesn't know what happens in a %pre, %post, %preun, or %postun - they are outside the transation) we delete /foo and then create a symlink from /foo to /bar. Then we get to the transaction part where we are ready to remove cloud-agent-scripts - so it's time to delete /foo - except /foo is now a symlink to /bar and thus we wipe out the contents of /foo and /bar in one fell swoop. To quote Bill Notting from Red Hat who pointed this out: 15:43 < notting> rpm decides what to do with all the files (update, remove, or write new file) before the transaction. if the directory layout changes *during* the transaction, weird shit happens. Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/f3a9a835 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/f3a9a835 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/f3a9a835 Branch: refs/heads/javelin Commit: f3a9a835d32ceeecaefac70fb9b77272e914f18c Parents: ed2f1cf Author: David Nalley <[email protected]> Authored: Fri Oct 5 16:26:52 2012 -0400 Committer: David Nalley <[email protected]> Committed: Fri Oct 5 16:26:52 2012 -0400 ---------------------------------------------------------------------- cloud.spec | 15 --------------- 1 files changed, 0 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f3a9a835/cloud.spec ---------------------------------------------------------------------- diff --git a/cloud.spec b/cloud.spec index 3c6bf0e..d004331 100644 --- a/cloud.spec +++ b/cloud.spec @@ -392,21 +392,6 @@ if [ -x /etc/sysconfig/modules/kvm.modules ] ; then /bin/sh /etc/sysconfig/modules/kvm.modules fi -%post scripts -if [ -d %{_libdir}/%{name}/agent ]; then - rm -fr %{_libdir}/%{name}/agent -fi -# Symlink for backwards compatibility -if [ ! -h %{_libdir}/%{name}/agent ]; then - ln -s %{_libdir}/%{name}/common %{_libdir}/%{name}/agent -fi - -%postun scripts -# For uninstallation, remove symlink -if [ "$1" == "0" ]; then - rm -f %{_libdir}/%{name}/agent -fi - %post client if [ "$1" == "1" ] ; then /sbin/chkconfig --add %{name}-management > /dev/null 2>&1 || true
