[filesystem] rename /media directory when replacing with symlink

Ondrej Vasik ovasik at fedoraproject.org
Tue Jul 29 13:16:41 UTC 2014


commit 5644914f69fe09f112a6eb9e7d962ad91c977442
Author: Ondřej Vašík <ovasik at redhat.com>
Date:   Tue Jul 29 15:16:34 2014 +0200

    rename /media directory when replacing with symlink

 filesystem.spec |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/filesystem.spec b/filesystem.spec
index 5fccdfb..1841d6a 100644
--- a/filesystem.spec
+++ b/filesystem.spec
@@ -1,7 +1,7 @@
 Summary: The basic directory layout for a Linux system
 Name: filesystem
 Version: 3.2
-Release: 28%{?dist}
+Release: 29%{?dist}
 License: Public Domain
 URL: https://fedorahosted.org/filesystem
 Group: System Environment/Base
@@ -138,6 +138,20 @@ posix.symlink("usr/%{_lib}", "/%{_lib}")
 posix.mkdir("/run")
 posix.mkdir("/run/media")
 posix.mkdir("/var")
+--#/media magic to be on the safe side - to prevent loss of userdata until F24
+path = "/media"
+st = posix.stat(path)
+if st and st.type == "directory" then
+  status = os.rename(path, path .. ".rpmmoved")
+  if not status then
+    suffix = 0
+    while not status do
+      suffix = suffix + 1
+      status = os.rename(path .. ".rpmmoved", path .. ".rpmmoved." .. suffix)
+    end
+    os.rename(path, path .. ".rpmmoved")
+  end
+end
 posix.symlink("run/media", "/media")
 posix.symlink("../run", "/var/run")
 posix.symlink("../run/lock", "/var/lock")
@@ -265,6 +279,10 @@ restorecon /run/media 2>/dev/null >/dev/null || :
 /var/yp
 
 %changelog
+* Tue Jul 29 2014 Ondrej Vasik <ovasik at redhat.com> - 3.2-29
+- rename /media directory when replacing with symlinks
+  to prevent potential data loss
+
 * Mon Jul 28 2014 Ondrej Vasik <ovasik at redhat.com> - 3.2-28
 - add ownership for /usr/share/licenses (#1121416)
 - have /media as symlink to /run/media (#965918)


More information about the scm-commits mailing list