[PATCH] fixup live install (#853988, #854962)
Brian C. Lane
bcl at redhat.com
Thu Sep 6 23:01:58 UTC 2012
From: "Brian C. Lane" <bcl at redhat.com>
liveinst:
use /dev/mapper/live-osimg-min as the install source. This is the original
filesystem before changes made by the live boot scripts.
updates overwrite unconditionally
anaconda:
handle livecd: method, set method to 'livecd' and partition to the path.
packaging:
Move new-kernel-pkg creation into a helper method, _recreateInitrds
Add a flag to prevent running new-kernel-pkg more than once
livepayload:
mount the install source on INSTALL_TREE and rsync it to the ROOT_PATH
Don't use verbose with rsync, results in huge program.log and slows
down install. Error will be logged.
Ignore rsync errors. It has problems with selinux xattrs. Log the
return value, but continue.
Call _recreateInitrds to create the initrd (#853988)
---
anaconda | 6 ++++++
data/liveinst/liveinst | 8 ++------
pyanaconda/packaging/__init__.py | 25 +++++++++++++++++--------
pyanaconda/packaging/livepayload.py | 21 ++++++++++++++++-----
4 files changed, 41 insertions(+), 19 deletions(-)
diff --git a/anaconda b/anaconda
index 3da6ada..66a608e 100755
--- a/anaconda
+++ b/anaconda
@@ -873,6 +873,12 @@ if __name__ == "__main__":
anaconda.methodstr.startswith("ftp"):
ksdata.method.method = "url"
ksdata.method.url = anaconda.methodstr
+ elif anaconda.methodstr.startswith("livecd"):
+ ksdata.method.method = "livecd"
+ device = anaconda.methodstr.split(":", 1)[1]
+ ksdata.method.partition = os.path.normpath(device)
+ else:
+ log.error("Unknown method: %s", (anaconda.methodstr,))
# now start the interface
setupDisplay(anaconda, opts)
diff --git a/data/liveinst/liveinst b/data/liveinst/liveinst
index 6c00100..f6bf686 100755
--- a/data/liveinst/liveinst
+++ b/data/liveinst/liveinst
@@ -43,12 +43,8 @@ fi
# Try to sort out where the live device is
if [ -z "$LIVE_BLOCK" ]; then
- if [ -b "/run/initramfs/live-baseloop" ]; then
- LIVE_BLOCK=`readlink -f /run/initramfs/live-baseloop`
- elif [ -b "/dev/mapper/live-osimg-min" ]; then
+ if [ -b "/dev/mapper/live-osimg-min" ]; then
LIVE_BLOCK="/dev/mapper/live-osimg-min"
- elif [ -b "/dev/live-osimg" ]; then
- LIVE_BLOCK="/dev/live-osimg"
fi
fi
@@ -123,7 +119,7 @@ if [ ! -z "$UPDATES" ]; then
# We officially support two updates.img formats: a filesystem image, and
# a compressed cpio blob.
if [ ! -z "$(file /tmp/updates.img | grep 'gzip compressed data')" ]; then
- ( cd / ; gzip -dc /tmp/updates.img | cpio -id )
+ ( cd / ; gzip -dc /tmp/updates.img | cpio -idu )
else
mkdir /tmp/updates.disk
mount -t auto /tmp/updates.img /tmp/updates.disk
diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py
index e916b1f..a4b42a9 100644
--- a/pyanaconda/packaging/__init__.py
+++ b/pyanaconda/packaging/__init__.py
@@ -142,6 +142,7 @@ class Payload(object):
"""
self.data = data
self._kernelVersionList = []
+ self._createdInitrds = False
def setup(self, storage):
""" Do any payload-specific setup. """
@@ -560,14 +561,22 @@ class Payload(object):
# prevent boot on some systems
if new_firmware:
- for kernel in self.kernelVersionList:
- log.info("recreating initrd for %s" % kernel)
- iutil.execWithRedirect("new-kernel-pkg",
- ["--mkinitrd", "--dracut",
- "--depmod", "--install", kernel],
- stdout="/dev/null",
- stderr="/dev/null",
- root=ROOT_PATH)
+ self._recreateInitrds()
+
+ def _recreateInitrds(self, force=False):
+ if not force and self._createdInitrds:
+ return
+
+ for kernel in self.kernelVersionList:
+ log.info("recreating initrd for %s" % kernel)
+ iutil.execWithRedirect("new-kernel-pkg",
+ ["--mkinitrd", "--dracut",
+ "--depmod", "--install", kernel],
+ stdout="/dev/null",
+ stderr="/dev/null",
+ root=ROOT_PATH)
+ self._createdInitrds = True
+
def _setDefaultBootTarget(self):
""" Set the default systemd target for the system. """
diff --git a/pyanaconda/packaging/livepayload.py b/pyanaconda/packaging/livepayload.py
index 501acef..78ff9e9 100644
--- a/pyanaconda/packaging/livepayload.py
+++ b/pyanaconda/packaging/livepayload.py
@@ -31,6 +31,7 @@
"""
import os
import stat
+from pyanaconda import isys
from . import *
@@ -52,10 +53,13 @@ _ = lambda x: gettext.ldgettext("anaconda", x)
class LiveImagePayload(ImagePayload):
""" A LivePayload copies the source image onto the target system. """
def setup(self, storage):
- if not os.path.ismount("/run/initramfs/live"):
- exn = PayloadSetupError("live image is not mounted")
+ # Mount the live device and copy from it instead of the overlay at /
+ osimg = storage.devicetree.getDeviceByPath(self.data.method.partition)
+ if not stat.S_ISBLK(os.stat(osimg.path)[stat.ST_MODE]):
+ exn = PayloadSetupError("%s is not a valid block device" % (self.data.method.partition,))
if errorHandler.cb(exn) == ERROR_RAISE:
raise exn
+ isys.mount(osimg.path, INSTALL_TREE, fstype="auto", readOnly=True)
def preInstall(self, packages=None, groups=None):
""" Perform pre-installation tasks. """
@@ -68,8 +72,8 @@ class LiveImagePayload(ImagePayload):
# preserve: permissions, owners, groups, ACL's, xattrs, times,
# symlinks, hardlinks
# go recursively, include devices and special files, don't cross
- # file system boundaries, print processed files
- args = ["-pogAXtlHrDxv", "/", ROOT_PATH]
+ # file system boundaries
+ args = ["-pogAXtlHrDx", INSTALL_TREE+"/", ROOT_PATH]
try:
rc = iutil.execWithRedirect(cmd, args,
stderr="/dev/tty5", stdout="/dev/tty5")
@@ -78,13 +82,20 @@ class LiveImagePayload(ImagePayload):
else:
err = None
if rc != 0:
- err = "%s exited with code %d" % (cmd, rc)
+ log.info("%s exited with code %d" % (cmd, rc))
if err:
exn = PayloadInstallError(err)
if errorHandler.cb(exn) == ERROR_RAISE:
raise exn
+ def postInstall(self):
+ """ Perform post-installation tasks. """
+ isys.umount(INSTALL_TREE, removeDir=True)
+
+ super(LiveImagePayload, self).postInstall()
+ self._recreateInitrds()
+
@property
def spaceRequired(self):
return Size(bytes=iutil.getDirSize("/")*1024)
--
1.7.11.4
More information about the anaconda-patches
mailing list