[PATCH 3/3] Rename anaconda-image-cleanup and use it for all cleanup in liveinst.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



New name is anaconda-cleanup.
---
 anaconda.spec.in               |    2 +-
 data/liveinst/liveinst         |   36 +-------------
 pyanaconda/constants.py        |    2 +
 pyanaconda/rescue.py           |   12 +++---
 scripts/Makefile.am            |    2 +-
 scripts/anaconda-cleanup       |   98 ++++++++++++++++++++++++++++++++++++++++
 scripts/anaconda-image-cleanup |   98 ----------------------------------------
 7 files changed, 111 insertions(+), 139 deletions(-)
 create mode 100755 scripts/anaconda-cleanup
 delete mode 100755 scripts/anaconda-image-cleanup

diff --git a/anaconda.spec.in b/anaconda.spec.in
index 3bfd268..784a5ec 100644
--- a/anaconda.spec.in
+++ b/anaconda.spec.in
@@ -217,7 +217,7 @@ update-desktop-database &> /dev/null || :
 %{_libdir}/python*/site-packages/log_picker/*
 %{_libdir}/anaconda*
 %{_bindir}/analog
-%{_bindir}/anaconda-image-cleanup
+%{_bindir}/anaconda-cleanup
 %ifarch %livearches
 %{_bindir}/liveinst
 %{_sbindir}/liveinst
diff --git a/data/liveinst/liveinst b/data/liveinst/liveinst
index 46213a8..7f7f8e5 100755
--- a/data/liveinst/liveinst
+++ b/data/liveinst/liveinst
@@ -98,38 +98,8 @@ for opt in `cat /proc/cmdline`; do
     esac
 done
 
-if [ $IMAGE_INSTALL = 0 ]; then
-    # devkit-disks is now mounting lots of stuff.  for now, let's just try to
-    # unmount it all
-    umount /media/* 2>/dev/null
-    tac /proc/mounts | grep ^/dev | grep -v live | \
-    while read dev mntpoint rest; do
-        # hack - don't unmount devices the storage test code requires
-        if [ "$mntpoint" = "/mnt/anactest" ]; then
-           continue
-        fi
-
-        if [ -b $dev ]; then
-           umount $mntpoint 2>/dev/null
-        fi
-    done
-
-    /sbin/swapoff -a
-    /sbin/lvm vgchange -an --ignorelockingfailure
-    for i in /dev/md*; do
-        if [ ! -b $i ]; then
-            continue
-        fi
-
-        case "$i" in
-            /dev/md*p*)
-                ;;
-            *)
-                mdadm --stop $i >/dev/null 2>&1
-                ;;
-        esac
-    done
-fi
+# unmount anything that shouldn't be mounted prior to install
+anaconda-cleanup $ANACONDA $*
 
 /sbin/udevadm control --env=ANACONDA=1
 
@@ -143,7 +113,7 @@ fi
 
 # try to teardown the filesystems if this was an image install
 if [ $IMAGE_INSTALL = 1 -a $RESCUE = 0 ]; then
-    anaconda-image-cleanup
+    anaconda-cleanup
 fi
 
 rm -f /dev/.in_sysinit 2>/dev/null
diff --git a/pyanaconda/constants.py b/pyanaconda/constants.py
index e2013ca..498d41f 100644
--- a/pyanaconda/constants.py
+++ b/pyanaconda/constants.py
@@ -100,3 +100,5 @@ relabelFiles = ["/etc/rpm/macros", "/etc/dasd.conf", "/etc/zfcp.conf",
 relabelDirs  = ["/etc/sysconfig/network-scripts", "/var/lib/rpm", "/etc/lvm",
                 "/dev/mapper", "/etc/iscsi", "/var/lib/iscsi", "/root",
                 "/var/log", "/etc/modprobe.d", "/etc/sysconfig", "/var/cache/yum" ]
+
+ANACONDA_CLEANUP = "anaconda-cleanup"
diff --git a/pyanaconda/rescue.py b/pyanaconda/rescue.py
index ee023a0..181fe26 100644
--- a/pyanaconda/rescue.py
+++ b/pyanaconda/rescue.py
@@ -223,8 +223,8 @@ def runShell(screen = None, msg=""):
         print (msg)
 
     if flags.imageInstall:
-        print(_("Run anaconda-image-cleanup to unmount the system "
-                "when you are finished."))
+        print(_("Run %s to unmount the system when you are finished.")
+              % ANACONDA_CLEANUP)
     else:
         print(_("When finished please exit from the shell and your "
                 "system will reboot."))
@@ -379,8 +379,8 @@ def runRescue(anaconda):
                 msg = _("The system will reboot automatically when you exit "
                         "from the shell.")
             else:
-                msg = _("Run anaconda-image-cleanup to unmount the system "
-                        "when you are finished.")
+                msg = _("Run %s to unmount the system "
+                        "when you are finished.") % ANACONDA_CLEANUP
 
             if rc == -1:
                 if anaconda.ksdata:
@@ -479,8 +479,8 @@ def runRescue(anaconda):
                     msg = _("The system will reboot automatically when you "
                             "exit from the shell.")
                 else:
-                    msg = _("Run anaconda-image-cleanup to unmount the system "
-                            "when you are finished.")
+                    msg = _("Run %s to unmount the system "
+                            "when you are finished.") % ANACONDA_CLEANUP
 
                 ButtonChoiceWindow(screen, _("Rescue"),
                     _("An error occurred trying to mount some or all of your "
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 692dd34..329a2fc 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -25,7 +25,7 @@ dist_scripts_DATA    = mk-images.* pyrc.py
 dist_noinst_SCRIPTS  = getlangnames.py upd-bootimage upd-initrd upd-kernel \
                        makeupdates
 
-dist_bin_SCRIPTS = analog anaconda-image-cleanup
+dist_bin_SCRIPTS = analog anaconda-cleanup
 
 stage2scriptsdir = $(datadir)/$(PACKAGE_NAME)
 dist_stage2scripts_SCRIPTS = restart-anaconda
diff --git a/scripts/anaconda-cleanup b/scripts/anaconda-cleanup
new file mode 100755
index 0000000..5107bfc
--- /dev/null
+++ b/scripts/anaconda-cleanup
@@ -0,0 +1,98 @@
+#!/usr/bin/python
+"""
+    image install:
+
+        - unmount everything under /mnt/sysimage
+        - populate a devicetree with only the image "disks"
+
+    live install:
+
+        - unmount everything under /mnt/sysimage
+        - unmount everything under /media
+        - populate a devicetree and tear everything down
+
+"""
+import os
+import sys
+
+live_install = "--liveinst" in sys.argv
+image_install = False
+
+# see if there are disk images to take down
+sys_class_block = "/sys/class/block"
+for dev in os.listdir(sys_class_block):
+    if not dev.startswith("dm-"):
+        continue
+
+    uuid = open("%s/%s/dm/uuid" % (sys_class_block, dev)).read().strip()
+    if uuid.startswith("ANACONDA-"):
+        image_install = True
+        break
+
+# set the imageInstall flag so the logger won't log to the syslog
+from pyanaconda.flags import flags
+flags.imageInstall = True
+
+import pyanaconda.anaconda_log
+pyanaconda.anaconda_log.init()
+
+from pyanaconda import iutil
+
+from pyanaconda.cmdline import InstallInterface
+from pyanaconda.storage import StorageDiscoveryConfig
+from pyanaconda.storage.devicetree import DeviceTree
+from pyanaconda.storage import devicelibs
+
+intf = InstallInterface()
+storage_config = StorageDiscoveryConfig()
+
+# find devices representing disk images
+sys_class_block = "/sys/class/block"
+for dev in os.listdir(sys_class_block):
+    if not dev.startswith("dm-"):
+        continue
+
+    name = open("%s/%s/dm/name" % (sys_class_block, dev)).read().strip()
+    uuid = open("%s/%s/dm/uuid" % (sys_class_block, dev)).read().strip()
+    if not name or not uuid.startswith("ANACONDA-"):
+        continue
+
+    loop = os.listdir("%s/%s/slaves" % (sys_class_block, dev))[0].strip()
+    path = devicelibs.loop.get_device_path(loop)
+    storage_config.diskImages[name] = path
+
+if not image_install and not live_install:
+    print >> sys.stderr, "not a live install or an image install -- exiting"
+    sys.exit(1)
+
+# unmount filesystems
+for mounted in reversed(open("/proc/mounts").readlines()):
+    (device, mountpoint, rest) = mounted.split(" ", 2)
+    if mountpoint.startswith("/mnt/anactest"):
+        continue
+
+    # If this is for an image install, only unmount all filesystems under
+    # /mnt/sysimage
+    if image_install and not mountpoint.startswith("/mnt/sysimage"):
+        continue
+
+    # If this is for a live install, unmount any non-nodev filesystem that
+    # isn't related to the live image.
+    if (not mountpoint.startswith("/media") and
+        not device.startswith("/dev") or
+        "live" in mounted):
+        continue
+
+    os.system("umount %s" % mountpoint)
+
+os.system("udevadm control --env=ANACONDA=1")
+os.system("udevadm trigger --subsystem-match block")
+os.system("udevadm settle")
+devicetree = DeviceTree(intf=intf, conf=storage_config)
+devicetree.populate(cleanupOnly=True)
+devicetree.teardownAll()
+for name in devicetree.diskImages.keys():
+    device = devicetree.getDeviceByName(name)
+    device.deactivate(recursive=True)
+os.system("udevadm control --env=ANACONDA=0")
+
diff --git a/scripts/anaconda-image-cleanup b/scripts/anaconda-image-cleanup
deleted file mode 100755
index 5107bfc..0000000
--- a/scripts/anaconda-image-cleanup
+++ /dev/null
@@ -1,98 +0,0 @@
-#!/usr/bin/python
-"""
-    image install:
-
-        - unmount everything under /mnt/sysimage
-        - populate a devicetree with only the image "disks"
-
-    live install:
-
-        - unmount everything under /mnt/sysimage
-        - unmount everything under /media
-        - populate a devicetree and tear everything down
-
-"""
-import os
-import sys
-
-live_install = "--liveinst" in sys.argv
-image_install = False
-
-# see if there are disk images to take down
-sys_class_block = "/sys/class/block"
-for dev in os.listdir(sys_class_block):
-    if not dev.startswith("dm-"):
-        continue
-
-    uuid = open("%s/%s/dm/uuid" % (sys_class_block, dev)).read().strip()
-    if uuid.startswith("ANACONDA-"):
-        image_install = True
-        break
-
-# set the imageInstall flag so the logger won't log to the syslog
-from pyanaconda.flags import flags
-flags.imageInstall = True
-
-import pyanaconda.anaconda_log
-pyanaconda.anaconda_log.init()
-
-from pyanaconda import iutil
-
-from pyanaconda.cmdline import InstallInterface
-from pyanaconda.storage import StorageDiscoveryConfig
-from pyanaconda.storage.devicetree import DeviceTree
-from pyanaconda.storage import devicelibs
-
-intf = InstallInterface()
-storage_config = StorageDiscoveryConfig()
-
-# find devices representing disk images
-sys_class_block = "/sys/class/block"
-for dev in os.listdir(sys_class_block):
-    if not dev.startswith("dm-"):
-        continue
-
-    name = open("%s/%s/dm/name" % (sys_class_block, dev)).read().strip()
-    uuid = open("%s/%s/dm/uuid" % (sys_class_block, dev)).read().strip()
-    if not name or not uuid.startswith("ANACONDA-"):
-        continue
-
-    loop = os.listdir("%s/%s/slaves" % (sys_class_block, dev))[0].strip()
-    path = devicelibs.loop.get_device_path(loop)
-    storage_config.diskImages[name] = path
-
-if not image_install and not live_install:
-    print >> sys.stderr, "not a live install or an image install -- exiting"
-    sys.exit(1)
-
-# unmount filesystems
-for mounted in reversed(open("/proc/mounts").readlines()):
-    (device, mountpoint, rest) = mounted.split(" ", 2)
-    if mountpoint.startswith("/mnt/anactest"):
-        continue
-
-    # If this is for an image install, only unmount all filesystems under
-    # /mnt/sysimage
-    if image_install and not mountpoint.startswith("/mnt/sysimage"):
-        continue
-
-    # If this is for a live install, unmount any non-nodev filesystem that
-    # isn't related to the live image.
-    if (not mountpoint.startswith("/media") and
-        not device.startswith("/dev") or
-        "live" in mounted):
-        continue
-
-    os.system("umount %s" % mountpoint)
-
-os.system("udevadm control --env=ANACONDA=1")
-os.system("udevadm trigger --subsystem-match block")
-os.system("udevadm settle")
-devicetree = DeviceTree(intf=intf, conf=storage_config)
-devicetree.populate(cleanupOnly=True)
-devicetree.teardownAll()
-for name in devicetree.diskImages.keys():
-    device = devicetree.getDeviceByName(name)
-    device.deactivate(recursive=True)
-os.system("udevadm control --env=ANACONDA=0")
-
-- 
1.7.3.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux