imgcreate/creator.py | 4 ++++ imgcreate/kickstart.py | 15 ++++++++++++++- imgcreate/live.py | 4 +--- tools/livecd-iso-to-disk.sh | 22 ++++++++++++++++++++-- 4 files changed, 39 insertions(+), 6 deletions(-)
New commits: commit 35f007112280dfa451ff7b51b65f917b4cad3715 Author: Jeremy Katz katzj@redhat.com Date: Tue May 27 15:56:05 2008 -0400
Fix basing on a previous live image (#437906)
diff --git a/imgcreate/creator.py b/imgcreate/creator.py index 40ce1ef..fc4298b 100644 --- a/imgcreate/creator.py +++ b/imgcreate/creator.py @@ -830,6 +830,9 @@ class LoopImageCreator(ImageCreator):
""" return self.__instloop.resparse(size) + + def __base_on(self, base_on): + shutil.copyfile(base_on, self._image)
# # Actual implementation @@ -838,6 +841,7 @@ class LoopImageCreator(ImageCreator): self.__imgdir = self._mkdtemp()
if not base_on is None: + self.__base_on(base_on) shutil.copyfile(base_on, self._image)
self.__instloop = SparseExtLoopbackMount(self._image, diff --git a/imgcreate/live.py b/imgcreate/live.py index 130f7fa..ef07d19 100644 --- a/imgcreate/live.py +++ b/imgcreate/live.py @@ -127,7 +127,7 @@ class LiveImageCreatorBase(LoopImageCreator): # # Actual implementation # - def __base_on_iso(self, base_on): + def __base_on(self, base_on): """helper function to extract ext3 file system from a live CD ISO""" isoloop = LoopbackMount(base_on, self._mkdtemp())
@@ -173,8 +173,6 @@ class LiveImageCreatorBase(LoopImageCreator): isoloop.cleanup()
def _mount_instroot(self, base_on = None): - if not base_on is None: - self.__base_on_iso(base_on) LoopImageCreator._mount_instroot(self) self.__write_initrd_conf(self._instroot + "/etc/sysconfig/mkinitrd")
commit 9fa8210e2db91e1c2d0493aed785d626ac7d176e Author: Jeremy Katz katzj@redhat.com Date: Tue May 27 15:49:23 2008 -0400
Fix up tab/space inconsistency
diff --git a/imgcreate/kickstart.py b/imgcreate/kickstart.py index 7cc27ac..8f43f7c 100644 --- a/imgcreate/kickstart.py +++ b/imgcreate/kickstart.py @@ -151,7 +151,7 @@ class TimezoneConfig(KickstartConfig): try: shutil.copyfile(self.path("/usr/share/zoneinfo/%s" %(tz,)), self.path("/etc/localtime")) - except OSError, (errno, msg): + except OSError, (errno, msg): log.error("Error copying timezone: %s" %(msg,))
commit df086a2102b3c8f0103c5905d7b776e07b69cfbc Author: Jeremy Katz katzj@redhat.com Date: Tue May 27 15:42:23 2008 -0400
Handle using a loop device as the device to use for the target (#447345)
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh index 5250a20..e4acf85 100644 --- a/tools/livecd-iso-to-disk.sh +++ b/tools/livecd-iso-to-disk.sh @@ -40,6 +40,11 @@ exitclean() { getdisk() { DEV=$1
+ if [[ "$DEV" =~ "/dev/loop*" ]; then + device="/dev/$device" + return + fi + p=$(udevinfo -q path -n $DEV) if [ -e /sys/$p/device ]; then device=$(basename /sys/$p)
commit 898e853e789314e343e8531fb25c03dc41ff4f0c Author: Jeremy Katz katzj@redhat.com Date: Tue May 27 15:35:41 2008 -0400
Quote iso path (#446472)
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh index fb9d6e4..5250a20 100644 --- a/tools/livecd-iso-to-disk.sh +++ b/tools/livecd-iso-to-disk.sh @@ -194,7 +194,7 @@ fi if [ -z "$noverify" ]; then # verify the image echo "Verifying image..." - checkisomd5 --verbose $ISO + checkisomd5 --verbose "$ISO" if [ $? -ne 0 ]; then echo "Are you SURE you want to continue?" echo "Press Enter to continue or ctrl-c to abort" @@ -219,7 +219,7 @@ fi
# FIXME: would be better if we had better mountpoints CDMNT=$(mktemp -d /media/cdtmp.XXXXXX) -mount -o loop,ro $ISO $CDMNT || exitclean +mount -o loop,ro "$ISO" $CDMNT || exitclean USBMNT=$(mktemp -d /media/usbdev.XXXXXX) mount $USBDEV $USBMNT || exitclean
commit 77e575d26bf742c762023dbb28bc8116e917218b Author: Jeremy Katz katzj@redhat.com Date: Tue May 27 15:29:35 2008 -0400
Make sure that the disk isn't mounted before writing to it (#446472)
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh index 4ec7f06..fb9d6e4 100644 --- a/tools/livecd-iso-to-disk.sh +++ b/tools/livecd-iso-to-disk.sh @@ -144,6 +144,18 @@ checkSyslinuxVersion() { fi }
+checkMounted() { + dev=$1 + if grep -q "^$dev " /proc/mounts ; then + echo "$dev is mounted, please unmount for safety" + exitclean + fi + if grep -q "^$dev " /proc/swaps; then + echo "$dev is in use as a swap device, please disable swap" + exitclean + fi +} + if [ $(id -u) != 0 ]; then echo "You need to be root to run this script" exit 1 @@ -195,6 +207,7 @@ checkSyslinuxVersion checkFilesystem $USBDEV checkPartActive $USBDEV checkMBR $USBDEV +checkMounted $USBDEV [ -n $resetmbr ] && resetMBR $USBDEV
if [ -n "$overlaysizemb" -a "$USBFS" = "vfat" ]; then
commit d2de6738087c91ebf6eb570088d7b2d0296723c8 Author: Jeremy Katz katzj@redhat.com Date: Tue May 27 15:24:36 2008 -0400
Handle copying timezone to /etc/localtime (#445624)
diff --git a/imgcreate/kickstart.py b/imgcreate/kickstart.py index efa1ef7..7cc27ac 100644 --- a/imgcreate/kickstart.py +++ b/imgcreate/kickstart.py @@ -18,6 +18,7 @@
import os import os.path +import shutil import subprocess import time
@@ -147,6 +148,12 @@ class TimezoneConfig(KickstartConfig): f.write("ZONE="" + tz + ""\n") f.write("UTC=" + utc + "\n") f.close() + try: + shutil.copyfile(self.path("/usr/share/zoneinfo/%s" %(tz,)), + self.path("/etc/localtime")) + except OSError, (errno, msg): + log.error("Error copying timezone: %s" %(msg,)) +
class AuthConfig(KickstartConfig): """A class to apply a kickstart authconfig configuration to a system."""
commit 4793d9e38d18eeeb3a0464e331af23e573149fe2 Author: Jeremy Katz katzj@redhat.com Date: Tue May 27 15:15:18 2008 -0400
Make sure that commands exist and give a suitable error message
diff --git a/imgcreate/kickstart.py b/imgcreate/kickstart.py index ef7b9e4..efa1ef7 100644 --- a/imgcreate/kickstart.py +++ b/imgcreate/kickstart.py @@ -107,6 +107,8 @@ class KickstartConfig(object): os.chdir("/")
def call(self, args): + if not os.path.exists("%s/%s" %(self.chroot, args[0])): + raise errors.KickstartError("Unable to run %s!" %(args)) subprocess.call(args, preexec_fn = self.chroot)
def apply(self): @@ -178,6 +180,10 @@ class RootPasswordConfig(KickstartConfig): self.call(["/usr/sbin/usermod", "-p", password, "root"])
def set_unencrypted(self, password): + for p in ("/bin/echo", "/usr/bin/passwd"): + if not os.path.exists("%s/%s" %(self.chroot, p)): + raise errors.KickstartError("Unable to set unencrypted password due to lack of %s" % p) + p1 = subprocess.Popen(["/bin/echo", password], stdout = subprocess.PIPE, preexec_fn = self.chroot) @@ -331,7 +337,7 @@ class NetworkConfig(KickstartConfig):
for network in ksnet.network: if not network.device: - raise errros.KickstartError("No --device specified with " + raise errors.KickstartError("No --device specified with " "network kickstart command")
if (network.onboot and network.bootProto.lower() != "dhcp" and