Bootloader --append option support?
by Ian Main
Howdy list!
So I've been working on adding serial console support to ovirt (http://ovirt.org). We use livecd-tools to create our images. I wanted to add the serial console to the kernel command line but found there was no real easy way to do this (I'm using livecd-tools-017.1-1.fc9.x86_64).
I see in the kickstart documentation that a --append flag is available to the 'bootloader' config option. However, it is ignored by livecd-creator. I was poking through the code and there's an 'extras' variable in the kernel command building, so the idea is there, it's just not hooked up.
Anyway, I was poking around in there so I could do up a patch, unless there's someone already mucking about or wants to fix that up. Let me know. I'm hoping this would be considered a bug and would go out in a point release?
Thanks,
Ian
15 years, 8 months
syslinux fails to create "ldlinux.sys"
by Ebbe Hansen
Need help to determine why "syslinux" fails to write to USB-drive. The
trace below indicates that everything works fine until the very end!
The call: "syslinux -d syslinux /dev/sdb1"
results in error: syslinux: failed to create ldlinux.sys
See below for details!
Previous "livecd-iso-to-disk" worked OK - something must have changed on
latest Fedora9-KDE load (downloaded on 7-18-08) or on my "setup" has
changed.
Is there a way to request diagnostics from the "syslinux" utility?
E Hansen @ SPYRUS
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++
Log of 'livecd-iso-to-disk' session on Fedora-9-KDE (downloaded on
7-18-08):
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++
[root@fedora91a /]# bash -x livecd-iso-to-disk --reset-mbr
--overlay-size-mb 1000 /usr/RedHat/Fedora-9-i686-Live-071808.iso
/dev/sdb1
+ export
PATH=/sbin:/usr/sbin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbi
n:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/bin
+
PATH=/sbin:/usr/sbin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbi
n:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/bin
++ id -u
+ '[' 0 '!=' 0 ']'
+ '[' 5 -gt 2 ']'
+ case $1 in
+ resetmbr=1
+ shift
+ '[' 4 -gt 2 ']'
+ case $1 in
+ overlaysizemb=1000
+ shift
+ shift
+ '[' 2 -gt 2 ']'
++ readlink -f /usr/RedHat/Fedora-9-i686-Live-071808.iso
+ ISO=/usr/RedHat/Fedora-9-i686-Live-071808.iso
+ USBDEV=/dev/sdb1
+ '[' -z /usr/RedHat/Fedora-9-i686-Live-071808.iso ']'
+ '[' '!' -b /usr/RedHat/Fedora-9-i686-Live-071808.iso -a '!' -f
/usr/RedHat/Fedora-9-i686-Live-071808.iso ']'
+ '[' -z /dev/sdb1 -o '!' -b /dev/sdb1 ']'
+ '[' -z '' ']'
+ echo 'Verifying image...'
Verifying image...
+ checkisomd5 --verbose /usr/RedHat/Fedora-9-i686-Live-071808.iso
/usr/RedHat/Fedora-9-i686-Live-071808.iso:
e9998706424174d69dda1f23f89b8953
Fragment sums:
fad79bb3621cb515652cdbfabaa5cba632af35ca9b739ef3ca35b91b5819
Fragment count: 20
Checking: 100.0%
The media check is complete, the result is: PASS.
It is OK to use this media.
+ '[' 0 -ne 0 ']'
+ checkSyslinuxVersion
+ '[' '!' -x /usr/bin/syslinux ']'
+ syslinux
+ grep -qe -d
+ SYSLINUXPATH=syslinux
+ checkFilesystem /dev/sdb1
+ dev=/dev/sdb1
++ /lib/udev/vol_id -t /dev/sdb1
+ USBFS=vfat
+ '[' vfat '!=' vfat -a vfat '!=' msdos -a vfat '!=' ext2 -a vfat '!='
ext3 ']'
++ /lib/udev/vol_id -u /dev/sdb1
+ USBLABEL=D0F3-E7C8
+ '[' -n D0F3-E7C8 ']'
+ USBLABEL=UUID=D0F3-E7C8
+ checkPartActive /dev/sdb1
+ dev=/dev/sdb1
+ getdisk /dev/sdb1
+ DEV=/dev/sdb1
++ udevinfo -q path -n /dev/sdb1
+
p=/devices/pci0000:00/0000:00:1d.7/usb1/1-7/1-7:1.0/host4/target4:0:0/4:
0:0:0/block/sdb/sdb1
+ '[' -e
/sys//devices/pci0000:00/0000:00:1d.7/usb1/1-7/1-7:1.0/host4/target4:0:0
/4:0:0:0/block/sdb/sdb1/device ']'
+++ readlink -f
/sys//devices/pci0000:00/0000:00:1d.7/usb1/1-7/1-7:1.0/host4/target4:0:0
/4:0:0:0/block/sdb/sdb1/../
++ basename
/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-7/1-7:1.0/host4/target4:0:0/
4:0:0:0/block/sdb
+ device=sdb
+ '[' '!' -e /sys/block/sdb -o '!' -e /dev/sdb ']'
+ device=/dev/sdb
+ '[' /dev/sdb1 = /dev/sdb ']'
++ /sbin/fdisk -l /dev/sdb
++ grep /dev/sdb1
++ awk '{print $2;}'
+ '[' '*' '!=' '*' ']'
+ checkMBR /dev/sdb1
+ getdisk /dev/sdb1
+ DEV=/dev/sdb1
++ udevinfo -q path -n /dev/sdb1
+
p=/devices/pci0000:00/0000:00:1d.7/usb1/1-7/1-7:1.0/host4/target4:0:0/4:
0:0:0/block/sdb/sdb1
+ '[' -e
/sys//devices/pci0000:00/0000:00:1d.7/usb1/1-7/1-7:1.0/host4/target4:0:0
/4:0:0:0/block/sdb/sdb1/device ']'
+++ readlink -f
/sys//devices/pci0000:00/0000:00:1d.7/usb1/1-7/1-7:1.0/host4/target4:0:0
/4:0:0:0/block/sdb/sdb1/../
++ basename
/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-7/1-7:1.0/host4/target4:0:0/
4:0:0:0/block/sdb
+ device=sdb
+ '[' '!' -e /sys/block/sdb -o '!' -e /dev/sdb ']'
+ device=/dev/sdb
++ mktemp /tmp/bs.XXXXXX
+ bs=/tmp/bs.vryiWZ
+ dd if=/dev/sdb of=/tmp/bs.vryiWZ bs=512 count=1
++ hexdump -n 2 /tmp/bs.vryiWZ
++ head -n 1
++ awk '{print $2;}'
+ mbrword=31fa
+ rm -f /tmp/bs.vryiWZ
+ '[' 31fa = 0000 ']'
+ return 0
+ checkMounted /dev/sdb1
+ dev=/dev/sdb1
+ grep -q '^/dev/sdb1 ' /proc/mounts
+ grep -q '^/dev/sdb1 ' /proc/swaps
+ '[' -n 1 ']'
+ resetMBR /dev/sdb1
+ getdisk /dev/sdb1
+ DEV=/dev/sdb1
++ udevinfo -q path -n /dev/sdb1
+
p=/devices/pci0000:00/0000:00:1d.7/usb1/1-7/1-7:1.0/host4/target4:0:0/4:
0:0:0/block/sdb/sdb1
+ '[' -e
/sys//devices/pci0000:00/0000:00:1d.7/usb1/1-7/1-7:1.0/host4/target4:0:0
/4:0:0:0/block/sdb/sdb1/device ']'
+++ readlink -f
/sys//devices/pci0000:00/0000:00:1d.7/usb1/1-7/1-7:1.0/host4/target4:0:0
/4:0:0:0/block/sdb/sdb1/../
++ basename
/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-7/1-7:1.0/host4/target4:0:0/
4:0:0:0/block/sdb
+ device=sdb
+ '[' '!' -e /sys/block/sdb -o '!' -e /dev/sdb ']'
+ device=/dev/sdb
+ '[' -f /usr/lib/syslinux/mbr.bin ']'
+ cat /usr/lib/syslinux/mbr.bin
+ '[' -n 1000 -a vfat = vfat ']'
+ '[' 1000 -gt 2047 ']'
++ mktemp -d /media/cdtmp.XXXXXX
+ CDMNT=/media/cdtmp.wlBTjg
+ mount -o loop,ro /usr/RedHat/Fedora-9-i686-Live-071808.iso
/media/cdtmp.wlBTjg
++ mktemp -d /media/usbdev.XXXXXX
+ USBMNT=/media/usbdev.SvMQxM
+ mount /dev/sdb1 /media/usbdev.SvMQxM
+ trap exitclean SIGINT SIGTERM
+ '[' -d /media/cdtmp.wlBTjg/LiveOS ']'
+ check=/media/cdtmp.wlBTjg/LiveOS
+ '[' -d /media/usbdev.SvMQxM/LiveOS ']'
++ du -s -B 1M /media/usbdev.SvMQxM/LiveOS
++ awk '{print $1;}'
+ tbd=1684
++ du -s -B 1M /media/cdtmp.wlBTjg/LiveOS
++ awk '{print $1;}'
+ livesize=684
++ df -B1M /dev/sdb1
++ tail -n 1
++ awk '{print $4;}'
+ free=2123
+ '[' 1684 -gt 3807 ']'
+ '[' -d /media/usbdev.SvMQxM/LiveOS ']'
+ echo 'Already set up as live image. Deleting old in fifteen
seconds...'
Already set up as live image. Deleting old in fifteen seconds...
+ sleep 15
+ rm -rf /media/usbdev.SvMQxM/LiveOS
+ echo 'Copying live image to USB stick'
Copying live image to USB stick
+ '[' '!' -d /media/usbdev.SvMQxM/syslinux ']'
+ '[' '!' -d /media/usbdev.SvMQxM/LiveOS ']'
+ mkdir /media/usbdev.SvMQxM/LiveOS
+ '[' -f /media/cdtmp.wlBTjg/LiveOS/squashfs.img ']'
+ cp /media/cdtmp.wlBTjg/LiveOS/squashfs.img
/media/usbdev.SvMQxM/LiveOS/squashfs.img
+ '[' -f /media/cdtmp.wlBTjg/LiveOS/osmin.img ']'
+ cp /media/cdtmp.wlBTjg/LiveOS/osmin.img
/media/usbdev.SvMQxM/LiveOS/osmin.img
+ cp /media/cdtmp.wlBTjg/isolinux/boot.cat
/media/cdtmp.wlBTjg/isolinux/initrd0.img
/media/cdtmp.wlBTjg/isolinux/isolinux.bin
/media/cdtmp.wlBTjg/isolinux/isolinux.cfg
/media/cdtmp.wlBTjg/isolinux/memtest
/media/cdtmp.wlBTjg/isolinux/splash.jpg
/media/cdtmp.wlBTjg/isolinux/vesamenu.c32
/media/cdtmp.wlBTjg/isolinux/vmlinuz0 /media/usbdev.SvMQxM/syslinux
+ echo 'Updating boot config file'
Updating boot config file
+ sed -i -e 's/CDLABEL=[^ ]*/UUID=D0F3-E7C8/' -e 's/rootfstype=[^
]*/rootfstype=vfat/' /media/usbdev.SvMQxM/syslinux/isolinux.cfg
+ '[' -n 1000 ']'
+ echo 'Initializing persistent overlay file'
Initializing persistent overlay file
++ /lib/udev/vol_id -l /dev/sdb1
++ /lib/udev/vol_id -u /dev/sdb1
+ OVERFILE=overlay-FEDORA9-D0F3-E7C8
+ '[' vfat = vfat ']'
+ dd if=/dev/zero
of=/media/usbdev.SvMQxM/LiveOS/overlay-FEDORA9-D0F3-E7C8 count=1000
bs=1M
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB) copied, 273.886 s, 3.8 MB/s
+ sed -i -e 's/liveimg/liveimg overlay=UUID=D0F3-E7C8/'
/media/usbdev.SvMQxM/syslinux/isolinux.cfg
+ sed -i -e 's/\ ro\ /\ rw\ /'
/media/usbdev.SvMQxM/syslinux/isolinux.cfg
+ echo 'Installing boot loader'
Installing boot loader
+ '[' vfat = vfat -o vfat = msdos ']'
+ mv /media/usbdev.SvMQxM/syslinux/isolinux.cfg
/media/usbdev.SvMQxM/syslinux/syslinux.cfg
+ cleanup
+ '[' -d /media/cdtmp.wlBTjg ']'
+ umount /media/cdtmp.wlBTjg
+ rmdir /media/cdtmp.wlBTjg
+ '[' -d /media/usbdev.SvMQxM ']'
+ umount /media/usbdev.SvMQxM
+ rmdir /media/usbdev.SvMQxM
+ '[' -n syslinux ']'
+ syslinux -d syslinux /dev/sdb1
syslinux: failed to create ldlinux.sys
+ echo 'USB stick set up as live image!'
USB stick set up as live image!
[root@fedora91a /]#
[root@fedora91a /]#
15 years, 8 months
imgcreate/fs.py
by Jeremy Katz
imgcreate/fs.py | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
New commits:
commit 6fd3e938dd9c7f36eb643db42b60e259f0834190
Author: Jeremy Katz <katzj(a)redhat.com>
Date: Wed Aug 6 11:11:30 2008 -0400
Fix up a few more problems from the refactor-mount patch
* Make sure that methods return the values they used to
* When resizing to the minimal image, we need to go back to the full size
otherwise, live images don't work
diff --git a/imgcreate/fs.py b/imgcreate/fs.py
index 4d8f87a..4a698e8 100644
--- a/imgcreate/fs.py
+++ b/imgcreate/fs.py
@@ -156,7 +156,7 @@ class SparseExtLoopbackMount(SparseLoopbackMount):
self.diskmount.disk.create()
def resize(self, size = None):
- self.diskmount.__resize_filesystem(size)
+ return self.diskmount.__resize_filesystem(size)
def mount(self):
self.diskmount.mount()
@@ -165,10 +165,10 @@ class SparseExtLoopbackMount(SparseLoopbackMount):
self.extdiskmount.__fsck()
def __get_size_from_filesystem(self):
- self.diskmount.__get_size_from_filesystem()
+ return self.diskmount.__get_size_from_filesystem()
def __resize_to_minimal(self):
- self.diskmount.__resize_to_minimal()
+ return self.diskmount.__resize_to_minimal()
def resparse(self, size = None):
return self.diskmount.resparse(size)
@@ -386,13 +386,13 @@ class ExtDiskMount(DiskMount):
current_size = os.stat(self.disk.lofile)[stat.ST_SIZE]
if size is None:
- size = self.size
+ size = self.disk.size
if size == current_size:
return
if size > current_size:
- self.expand(size)
+ self.disk.expand(size)
self.__fsck()
@@ -459,6 +459,7 @@ class ExtDiskMount(DiskMount):
self.cleanup()
minsize = self.__resize_to_minimal()
self.disk.truncate(minsize)
+ self.__resize_filesystem(size)
return minsize
class DeviceMapperSnapshot(object):
15 years, 8 months
persistence and "install to harddrive"
by Jerry Vonau
Hi all:
Just been playing around with a LiveUSB stick and persistence, and it
occurred to me that if you make any changes at all, anaconda will not
pick them up. The reasoning for this is that /usr/sbin/liveinst looks
for:
if [ -z "$LIVE_BLOCK" ]; then
if [ -b "/dev/mapper/live-osimg-min" ]; then
LIVE_BLOCK="/dev/mapper/live-osimg-min"
else
LIVE_BLOCK="/dev/live-osimg"
fi
fi
"live-osimg-min" is setup as part of the livecd init script and is made
up from the squashfs.img and osmin.img. Just wondering what the
advantages are in having the init script setup this device over trying
to create this device just before anaconda is called.
Now the real question, what would be the best way to have anaconda
pickup the persistent overlay for the "install to hard-drive" part.
Could you just create a second device-mapper snapshot using the same
overlay and squashfs.img just presented as read-only in /dev/mapper?
then do something like:
if [ -z "$LIVE_BLOCK" ]; then
if [ -b "/dev/mapper/live-osimg-min" ]; then
LIVE_BLOCK="/dev/mapper/live-osimg-min"
else
LIVE_BLOCK="/dev/live-osimg"
fi
if [ -b "/dev/mapper/live-usb-ro" ]; then
LIVE_BLOCK="/dev/mapper/live-usb-ro"
fi
fi
I'm thinking that an overlay file might be a mode that could be used in
the future to update the livecd just before you install to the disk.
Just some thoughts,
Jerry
15 years, 8 months
7 commits - imgcreate/creator.py imgcreate/fs.py imgcreate/kickstart.py imgcreate/live.py
by Jeremy Katz
imgcreate/creator.py | 17 +-
imgcreate/fs.py | 351 ++++++++++++++++++++++++++++++++++++-------------
imgcreate/kickstart.py | 3
imgcreate/live.py | 6
4 files changed, 278 insertions(+), 99 deletions(-)
New commits:
commit 5a3a91fe44795fb0d5c1f6215081b214d0af3f5b
Merge: 2a57a06... 5279213...
Author: Jeremy Katz <katzj(a)redhat.com>
Date: Tue Aug 5 20:25:23 2008 -0400
Merge branch 'refactor-mount'
diff --cc imgcreate/creator.py
index e63e96d,5fbf554..d9fa711
--- a/imgcreate/creator.py
+++ b/imgcreate/creator.py
@@@ -905,14 -904,14 +909,13 @@@ 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._base_on(base_on)
- self.__instloop = SparseExtLoopbackMount(self._image,
- self._instroot,
- self.__image_size,
- self.__fstype,
- self.__blocksize,
- self.fslabel)
+ self.__instloop = ExtDiskMount(SparseLoopbackDisk(self._image, self.__image_size),
+ self._instroot,
+ self.__fstype,
+ self.__blocksize,
+ self.fslabel)
try:
self.__instloop.mount()
diff --cc imgcreate/live.py
index 49d524b,abea730..f98f76c
--- a/imgcreate/live.py
+++ b/imgcreate/live.py
@@@ -129,9 -129,9 +129,9 @@@ class LiveImageCreatorBase(LoopImageCre
#
# Actual implementation
#
- def __base_on(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())
+ isoloop = Mount(LoopbackDisk(base_on), self._mkdtemp())
try:
isoloop.mount()
commit 5279213df3104c32b3cb08afc7e9698dceb1704d
Author: David Huff <dhuff(a)redhat.com>
Date: Tue Jul 22 17:36:52 2008 -0400
Separate out generation of non-disk mounts from other things for /etc/fstab
diff --git a/imgcreate/creator.py b/imgcreate/creator.py
index 64898c5..5fbf554 100644
--- a/imgcreate/creator.py
+++ b/imgcreate/creator.py
@@ -209,7 +209,11 @@ class ImageCreator(object):
"""
s = "/dev/root / %s defaults,noatime 0 0\n" %(self._fstype)
- s += "devpts /dev/pts devpts gid=5,mode=620 0 0\n"
+ s += self._get_fstab_special()
+ return s
+
+ def _get_fstab_special(self):
+ s = "devpts /dev/pts devpts gid=5,mode=620 0 0\n"
s += "tmpfs /dev/shm tmpfs defaults 0 0\n"
s += "proc /proc proc defaults 0 0\n"
s += "sysfs /sys sysfs defaults 0 0\n"
commit 1f20b4ded9e18257de787c71b28e147f592c09be
Author: David Huff <dhuff(a)redhat.com>
Date: Tue Jul 22 17:36:06 2008 -0400
Switch internal code to use new api
diff --git a/imgcreate/creator.py b/imgcreate/creator.py
index e61f034..64898c5 100644
--- a/imgcreate/creator.py
+++ b/imgcreate/creator.py
@@ -903,12 +903,11 @@ class LoopImageCreator(ImageCreator):
self.__base_on(base_on)
shutil.copyfile(base_on, self._image)
- self.__instloop = SparseExtLoopbackMount(self._image,
- self._instroot,
- self.__image_size,
- self.__fstype,
- self.__blocksize,
- self.fslabel)
+ self.__instloop = ExtDiskMount(SparseLoopbackDisk(self._image, self.__image_size),
+ self._instroot,
+ self.__fstype,
+ self.__blocksize,
+ self.fslabel)
try:
self.__instloop.mount()
diff --git a/imgcreate/live.py b/imgcreate/live.py
index e0bac09..abea730 100644
--- a/imgcreate/live.py
+++ b/imgcreate/live.py
@@ -131,7 +131,7 @@ class LiveImageCreatorBase(LoopImageCreator):
#
def __base_on(self, base_on):
"""helper function to extract ext3 file system from a live CD ISO"""
- isoloop = LoopbackMount(base_on, self._mkdtemp())
+ isoloop = Mount(LoopbackDisk(base_on), self._mkdtemp())
try:
isoloop.mount()
@@ -145,10 +145,10 @@ class LiveImageCreatorBase(LoopImageCreator):
else:
squashimg = isoloop.mountdir + "/LiveOS/squashfs.img"
- squashloop = LoopbackMount(squashimg, self._mkdtemp(), "squashfs")
+ squashloop = Mount(LoopbackDisk(squashimg), self._mkdtemp(), "squashfs")
try:
- if not os.path.exists(squashloop.lofile):
+ if not squashloop.disk.exists():
raise CreatorError("'%s' is not a valid live CD ISO : "
"squashfs.img doesn't exist" % base_on)
commit 7024f2cc0041d8fd038844c789d869875e4977af
Author: David Huff <dhuff(a)redhat.com>
Date: Mon Jul 28 14:22:00 2008 -0400
Added compat shims in fs.py for old api
Added a compat layer for backwards compatibility. These compat
classes internally create the new Disk objects, switching the old api
(LoopbackMount, SparseLoopbackMount, SparseExtLoopbackMount) types to
the new Disk and Mount classes
diff --git a/imgcreate/fs.py b/imgcreate/fs.py
index 0aca98d..4d8f87a 100644
--- a/imgcreate/fs.py
+++ b/imgcreate/fs.py
@@ -88,32 +88,16 @@ class BindChrootMount:
self.mounted = False
class LoopbackMount:
+ """LoopbackMount compatibility layer for old API"""
def __init__(self, lofile, mountdir, fstype = None):
- self.lofile = lofile
- self.mountdir = mountdir
- self.fstype = fstype
-
- self.mounted = False
+ self.diskmount = DiskMount(LoopbackDisk(lofile,size = 0),mountdir,fstype,rmmountdir = True)
self.losetup = False
- self.rmdir = False
- self.loopdev = None
-
+
def cleanup(self):
- self.unmount()
- self.lounsetup()
+ self.diskmount.cleanup()
def unmount(self):
- if self.mounted:
- rc = subprocess.call(["/bin/umount", self.mountdir])
- if rc == 0:
- self.mounted = False
-
- if self.rmdir and not self.mounted:
- try:
- os.rmdir(self.mountdir)
- except OSError, e:
- pass
- self.rmdir = False
+ self.diskmount.unmount()
def lounsetup(self):
if self.losetup:
@@ -143,152 +127,52 @@ class LoopbackMount:
self.losetup = True
def mount(self):
- if self.mounted:
- return
-
- self.loopsetup()
-
- if not os.path.isdir(self.mountdir):
- os.makedirs(self.mountdir)
- self.rmdir = True
-
- args = [ "/bin/mount", self.loopdev, self.mountdir ]
- if self.fstype:
- args.extend(["-t", self.fstype])
-
- rc = subprocess.call(args)
- if rc != 0:
- raise MountError("Failed to mount '%s' to '%s'" %
- (self.loopdev, self.mountdir))
-
- self.mounted = True
+ self.diskmount.mount()
class SparseLoopbackMount(LoopbackMount):
+ """SparseLoopbackMount compatibility layer for old API"""
def __init__(self, lofile, mountdir, size, fstype = None):
- LoopbackMount.__init__(self, lofile, mountdir, fstype)
- self.size = size
+ self.diskmount = DiskMount(SparseLoopbackDisk(lofile,size),mountdir,fstype,rmmountdir = True)
def expand(self, create = False, size = None):
- flags = os.O_WRONLY
- if create:
- flags |= os.O_CREAT
- makedirs(os.path.dirname(self.lofile))
-
- if size is None:
- size = self.size
-
- fd = os.open(self.lofile, flags)
-
- os.lseek(fd, size, 0)
- os.write(fd, '\x00')
- os.close(fd)
+ self.diskmount.disk.expand(create, size)
def truncate(self, size = None):
- if size is None:
- size = self.size
- fd = os.open(self.lofile, os.O_WRONLY)
- os.ftruncate(fd, size)
- os.close(fd)
+ self.diskmount.disk.truncate(size)
def create(self):
- self.expand(create = True)
+ self.diskmount.disk.create()
class SparseExtLoopbackMount(SparseLoopbackMount):
+ """SparseExtLoopbackMount compatibility layer for old API"""
def __init__(self, lofile, mountdir, size, fstype, blocksize, fslabel):
- SparseLoopbackMount.__init__(self, lofile, mountdir, size, fstype)
- self.blocksize = blocksize
- self.fslabel = fslabel
+ self.diskmount = ExtDiskMount(SparseLoopbackDisk(lofile,size), mountdir, fstype, blocksize, fslabel, rmmountdir = True)
+
def __format_filesystem(self):
- rc = subprocess.call(["/sbin/mkfs." + self.fstype,
- "-F", "-L", self.fslabel,
- "-m", "1", "-b", str(self.blocksize),
- self.lofile,
- str(self.size / self.blocksize)])
- if rc != 0:
- raise MountError("Error creating %s filesystem" % (self.fstype,))
- subprocess.call(["/sbin/tune2fs", "-c0", "-i0", "-Odir_index",
- "-ouser_xattr,acl", self.lofile])
+ self.diskmount.__format_filesystem()
def create(self):
- SparseLoopbackMount.create(self)
- self.__format_filesystem()
+ self.diskmount.disk.create()
def resize(self, size = None):
- current_size = os.stat(self.lofile)[stat.ST_SIZE]
-
- if size is None:
- size = self.size
-
- if size == current_size:
- return
-
- if size > current_size:
- self.expand(size)
-
- self.__fsck()
-
- resize2fs(self.lofile, size)
-
- if size < current_size:
- self.truncate(size)
- return size
+ self.diskmount.__resize_filesystem(size)
def mount(self):
- if not os.path.isfile(self.lofile):
- self.create()
- else:
- self.resize()
- return SparseLoopbackMount.mount(self)
-
+ self.diskmount.mount()
+
def __fsck(self):
- subprocess.call(["/sbin/e2fsck", "-f", "-y", self.lofile])
+ self.extdiskmount.__fsck()
def __get_size_from_filesystem(self):
- def parse_field(output, field):
- for line in output.split("\n"):
- if line.startswith(field + ":"):
- return line[len(field) + 1:].strip()
-
- raise KeyError("Failed to find field '%s' in output" % field)
-
- dev_null = os.open("/dev/null", os.O_WRONLY)
- try:
- out = subprocess.Popen(['/sbin/dumpe2fs', '-h', self.lofile],
- stdout = subprocess.PIPE,
- stderr = dev_null).communicate()[0]
- finally:
- os.close(dev_null)
-
- return int(parse_field(out, "Block count")) * self.blocksize
-
+ self.diskmount.__get_size_from_filesystem()
+
def __resize_to_minimal(self):
- self.__fsck()
-
- #
- # Use a binary search to find the minimal size
- # we can resize the image to
- #
- bot = 0
- top = self.__get_size_from_filesystem()
- while top != (bot + 1):
- t = bot + ((top - bot) / 2)
-
- if not resize2fs(self.lofile, t):
- top = t
- else:
- bot = t
- return top
-
+ self.diskmount.__resize_to_minimal()
+
def resparse(self, size = None):
- self.cleanup()
+ return self.diskmount.resparse(size)
- minsize = self.__resize_to_minimal()
-
- self.truncate(minsize)
- self.resize(size)
- return minsize
-
class Disk:
"""Generic base object for a disk
commit 8d6b5166013b766f0fca163a52ddd0801568a557
Author: Jeremy Katz <katzj(a)redhat.com>
Date: Tue Jul 22 17:15:29 2008 -0400
Clean up pydoc to be with the actual objects
diff --git a/imgcreate/fs.py b/imgcreate/fs.py
index 11348fa..0aca98d 100644
--- a/imgcreate/fs.py
+++ b/imgcreate/fs.py
@@ -290,28 +290,11 @@ class SparseExtLoopbackMount(SparseLoopbackMount):
return minsize
class Disk:
- """
- With the new disk API the image being produced can be partitioned into
- multiple chunks, with many filesystems. Furthermore, not all of them
- require loopback mounts, as the partitions themselves are already
- visible via /dev/mapper/
-
- There are now classes which deal with accessing / creating disks:
-
- Disk - generic base for disks
- RawDisk - a disk backed by a block device
- LoopbackDisk - a disk backed by a file
- SparseLoopbackDisk - a disk backed by a sparse file
+ """Generic base object for a disk
The 'create' method must make the disk visible as a block device - eg
by calling losetup. For RawDisk, this is obviously a no-op. The 'cleanup'
method must undo the 'create' operation.
-
- There are then classes which deal with mounting things:
-
- Mount - generic base for mounts
- DiskMount - able to mount a Disk object
- ExtDiskMount - able to format/resize ext3 filesystems when mounting
"""
def __init__(self, size, device = None):
self._device = device
@@ -335,6 +318,9 @@ class Disk:
class RawDisk(Disk):
+ """A Disk backed by a block device.
+ Note that create() is a no-op.
+ """
def __init__(self, size, device):
Disk.__init__(self, size, device)
@@ -345,6 +331,7 @@ class RawDisk(Disk):
return True
class LoopbackDisk(Disk):
+ """A Disk backed by a file via the loop module."""
def __init__(self, lofile, size):
Disk.__init__(self, size)
self.lofile = lofile
@@ -386,6 +373,7 @@ class LoopbackDisk(Disk):
class SparseLoopbackDisk(LoopbackDisk):
+ """A Disk backed by a sparse file via the loop module."""
def __init__(self, lofile, size):
LoopbackDisk.__init__(self, lofile, size)
@@ -419,6 +407,7 @@ class SparseLoopbackDisk(LoopbackDisk):
LoopbackDisk.create(self)
class Mount:
+ """A generic base class to deal with mounting things."""
def __init__(self, mountdir):
self.mountdir = mountdir
@@ -432,6 +421,7 @@ class Mount:
pass
class DiskMount(Mount):
+ """A Mount object that handles mounting of a Disk."""
def __init__(self, disk, mountdir, fstype = None, rmmountdir = True):
Mount.__init__(self, mountdir)
@@ -489,6 +479,7 @@ class DiskMount(Mount):
self.mounted = True
class ExtDiskMount(DiskMount):
+ """A DiskMount object that is able to format/resize ext[23] filesystems."""
def __init__(self, disk, mountdir, fstype, blocksize, fslabel, rmmountdir=True):
DiskMount.__init__(self, disk, mountdir, fstype, rmmountdir)
self.blocksize = blocksize
commit 129083062fb7b21a49e5f84196d673fa1c37a5bc
Author: David Huff <dhuff(a)redhat.com>
Date: Mon Jul 21 17:26:55 2008 -0400
Re-factor imgcreate/fs.py module
Most of the change here involves re-factoring the imgcreate/fs.py module to
separate the difference between a disk and a mount.
So this patch separates the roles. There are now classes which deal with
accessing / creating disks and classes which deal with mounting things.
Also fixed comments to use the standard pydoc """ format.
Based on a patch by Daniel Berrange <berrange(a)redhat.com>
diff --git a/imgcreate/fs.py b/imgcreate/fs.py
index 98c0db4..11348fa 100644
--- a/imgcreate/fs.py
+++ b/imgcreate/fs.py
@@ -24,6 +24,7 @@ import stat
import subprocess
import random
import string
+import logging
from imgcreate.errors import *
@@ -288,6 +289,303 @@ class SparseExtLoopbackMount(SparseLoopbackMount):
self.resize(size)
return minsize
+class Disk:
+ """
+ With the new disk API the image being produced can be partitioned into
+ multiple chunks, with many filesystems. Furthermore, not all of them
+ require loopback mounts, as the partitions themselves are already
+ visible via /dev/mapper/
+
+ There are now classes which deal with accessing / creating disks:
+
+ Disk - generic base for disks
+ RawDisk - a disk backed by a block device
+ LoopbackDisk - a disk backed by a file
+ SparseLoopbackDisk - a disk backed by a sparse file
+
+ The 'create' method must make the disk visible as a block device - eg
+ by calling losetup. For RawDisk, this is obviously a no-op. The 'cleanup'
+ method must undo the 'create' operation.
+
+ There are then classes which deal with mounting things:
+
+ Mount - generic base for mounts
+ DiskMount - able to mount a Disk object
+ ExtDiskMount - able to format/resize ext3 filesystems when mounting
+ """
+ def __init__(self, size, device = None):
+ self._device = device
+ self._size = size
+
+ def create(self):
+ pass
+
+ def cleanup(self):
+ pass
+
+ def get_device(self):
+ return self._device
+ def set_device(self, path):
+ self._device = path
+ device = property(get_device, set_device)
+
+ def get_size(self):
+ return self._size
+ size = property(get_size)
+
+
+class RawDisk(Disk):
+ def __init__(self, size, device):
+ Disk.__init__(self, size, device)
+
+ def fixed(self):
+ return True
+
+ def exists(self):
+ return True
+
+class LoopbackDisk(Disk):
+ def __init__(self, lofile, size):
+ Disk.__init__(self, size)
+ self.lofile = lofile
+
+ def fixed(self):
+ return False
+
+ def exists(self):
+ return os.path.exists(self.lofile)
+
+ def create(self):
+ if self.device is not None:
+ return
+
+ losetupProc = subprocess.Popen(["/sbin/losetup", "-f"],
+ stdout=subprocess.PIPE)
+ losetupOutput = losetupProc.communicate()[0]
+
+ if losetupProc.returncode:
+ raise MountError("Failed to allocate loop device for '%s'" %
+ self.lofile)
+
+ device = losetupOutput.split()[0]
+
+ logging.debug("Losetup add %s mapping to %s" % (device, self.lofile))
+ rc = subprocess.call(["/sbin/losetup", device, self.lofile])
+ if rc != 0:
+ raise MountError("Failed to allocate loop device for '%s'" %
+ self.lofile)
+ self.device = device
+
+ def cleanup(self):
+ if self.device is None:
+ return
+ logging.debug("Losetup remove %s" % self.device)
+ rc = subprocess.call(["/sbin/losetup", "-d", self.device])
+ self.device = None
+
+
+
+class SparseLoopbackDisk(LoopbackDisk):
+ def __init__(self, lofile, size):
+ LoopbackDisk.__init__(self, lofile, size)
+
+ def expand(self, create = False, size = None):
+ flags = os.O_WRONLY
+ if create:
+ flags |= os.O_CREAT
+ makedirs(os.path.dirname(self.lofile))
+
+ if size is None:
+ size = self.size
+
+ logging.debug("Extending sparse file %s to %d" % (self.lofile, size))
+ fd = os.open(self.lofile, flags)
+
+ os.lseek(fd, size, 0)
+ os.write(fd, '\x00')
+ os.close(fd)
+
+ def truncate(self, size = None):
+ if size is None:
+ size = self.size
+
+ logging.debug("Truncating sparse file %s to %d" % (self.lofile, size))
+ fd = os.open(self.lofile, os.O_WRONLY)
+ os.ftruncate(fd, size)
+ os.close(fd)
+
+ def create(self):
+ self.expand(create = True)
+ LoopbackDisk.create(self)
+
+class Mount:
+ def __init__(self, mountdir):
+ self.mountdir = mountdir
+
+ def cleanup(self):
+ self.unmount()
+
+ def mount(self):
+ pass
+
+ def unmount(self):
+ pass
+
+class DiskMount(Mount):
+ def __init__(self, disk, mountdir, fstype = None, rmmountdir = True):
+ Mount.__init__(self, mountdir)
+
+ self.disk = disk
+ self.fstype = fstype
+ self.rmmountdir = rmmountdir
+
+ self.mounted = False
+ self.rmdir = False
+
+ def cleanup(self):
+ Mount.cleanup(self)
+ self.disk.cleanup()
+
+ def unmount(self):
+ if self.mounted:
+ logging.debug("Unmounting directory %s" % self.mountdir)
+ rc = subprocess.call(["/bin/umount", self.mountdir])
+ if rc == 0:
+ self.mounted = False
+
+ if self.rmdir and not self.mounted:
+ try:
+ os.rmdir(self.mountdir)
+ except OSError, e:
+ pass
+ self.rmdir = False
+
+
+ def __create(self):
+ self.disk.create()
+
+
+ def mount(self):
+ if self.mounted:
+ return
+
+ if not os.path.isdir(self.mountdir):
+ logging.debug("Creating mount point %s" % self.mountdir)
+ os.makedirs(self.mountdir)
+ self.rmdir = self.rmmountdir
+
+ self.__create()
+
+ logging.debug("Mounting %s at %s" % (self.disk.device, self.mountdir))
+ args = [ "/bin/mount", self.disk.device, self.mountdir ]
+ if self.fstype:
+ args.extend(["-t", self.fstype])
+
+ rc = subprocess.call(args)
+ if rc != 0:
+ raise MountError("Failed to mount '%s' to '%s'" %
+ (self.disk.device, self.mountdir))
+
+ self.mounted = True
+
+class ExtDiskMount(DiskMount):
+ def __init__(self, disk, mountdir, fstype, blocksize, fslabel, rmmountdir=True):
+ DiskMount.__init__(self, disk, mountdir, fstype, rmmountdir)
+ self.blocksize = blocksize
+ self.fslabel = fslabel
+
+ def __format_filesystem(self):
+ logging.debug("Formating %s filesystem on %s" % (self.fstype, self.disk.device))
+ rc = subprocess.call(["/sbin/mkfs." + self.fstype,
+ "-F", "-L", self.fslabel,
+ "-m", "1", "-b", str(self.blocksize),
+ self.disk.device])
+ # str(self.disk.size / self.blocksize)])
+ if rc != 0:
+ raise MountError("Error creating %s filesystem" % (self.fstype,))
+ logging.debug("Tuning filesystem on %s" % self.disk.device)
+ subprocess.call(["/sbin/tune2fs", "-c0", "-i0", "-Odir_index",
+ "-ouser_xattr,acl", self.disk.device])
+
+ def __resize_filesystem(self, size = None):
+ current_size = os.stat(self.disk.lofile)[stat.ST_SIZE]
+
+ if size is None:
+ size = self.size
+
+ if size == current_size:
+ return
+
+ if size > current_size:
+ self.expand(size)
+
+ self.__fsck()
+
+ resize2fs(self.disk.lofile, size)
+ return size
+
+ def __create(self):
+ resize = False
+ if not self.disk.fixed() and self.disk.exists():
+ resize = True
+
+ self.disk.create()
+
+ if resize:
+ self.__resize_filesystem()
+ else:
+ self.__format_filesystem()
+
+ def mount(self):
+ self.__create()
+ DiskMount.mount(self)
+
+ def __fsck(self):
+ logging.debug("Checking filesystem %s" % self.disk.lofile)
+ subprocess.call(["/sbin/e2fsck", "-f", "-y", self.disk.lofile])
+
+ def __get_size_from_filesystem(self):
+ def parse_field(output, field):
+ for line in output.split("\n"):
+ if line.startswith(field + ":"):
+ return line[len(field) + 1:].strip()
+
+ raise KeyError("Failed to find field '%s' in output" % field)
+
+ dev_null = os.open("/dev/null", os.O_WRONLY)
+ try:
+ out = subprocess.Popen(['/sbin/dumpe2fs', '-h', self.disk.lofile],
+ stdout = subprocess.PIPE,
+ stderr = dev_null).communicate()[0]
+ finally:
+ os.close(dev_null)
+
+ return int(parse_field(out, "Block count")) * self.blocksize
+
+ def __resize_to_minimal(self):
+ self.__fsck()
+
+ #
+ # Use a binary search to find the minimal size
+ # we can resize the image to
+ #
+ bot = 0
+ top = self.__get_size_from_filesystem()
+ while top != (bot + 1):
+ t = bot + ((top - bot) / 2)
+
+ if not resize2fs(self.disk.lofile, t):
+ top = t
+ else:
+ bot = t
+ return top
+
+ def resparse(self, size = None):
+ self.cleanup()
+ minsize = self.__resize_to_minimal()
+ self.disk.truncate(minsize)
+ return minsize
+
class DeviceMapperSnapshot(object):
def __init__(self, imgloop, cowloop):
self.imgloop = imgloop
@@ -306,8 +604,8 @@ class DeviceMapperSnapshot(object):
if self.__created:
return
- self.imgloop.loopsetup()
- self.cowloop.loopsetup()
+ self.imgloop.create()
+ self.cowloop.create()
self.__name = "imgcreate-%d-%d" % (os.getpid(),
random.randint(0, 2**16))
@@ -315,8 +613,8 @@ class DeviceMapperSnapshot(object):
size = os.stat(self.imgloop.lofile)[stat.ST_SIZE]
table = "0 %d snapshot %s %s p 8" % (size / 512,
- self.imgloop.loopdev,
- self.cowloop.loopdev)
+ self.imgloop.device,
+ self.cowloop.device)
args = ["/sbin/dmsetup", "create", self.__name, "--table", table]
if subprocess.call(args) != 0:
@@ -365,32 +663,31 @@ class DeviceMapperSnapshot(object):
except ValueError:
raise SnapshotError("Failed to parse dmsetup status: " + out)
-#
-# Builds a copy-on-write image which can be used to
-# create a device-mapper snapshot of an image where
-# the image's filesystem is as small as possible
-#
-# The steps taken are:
-# 1) Create a sparse COW
-# 2) Loopback mount the image and the COW
-# 3) Create a device-mapper snapshot of the image
-# using the COW
-# 4) Resize the filesystem to the minimal size
-# 5) Determine the amount of space used in the COW
-# 6) Restroy the device-mapper snapshot
-# 7) Truncate the COW, removing unused space
-# 8) Create a squashfs of the COW
-#
def create_image_minimizer(path, image, minimal_size):
- imgloop = LoopbackMount(image, "None")
+ """
+ Builds a copy-on-write image which can be used to
+ create a device-mapper snapshot of an image where
+ the image's filesystem is as small as possible
+
+ The steps taken are:
+ 1) Create a sparse COW
+ 2) Loopback mount the image and the COW
+ 3) Create a device-mapper snapshot of the image
+ using the COW
+ 4) Resize the filesystem to the minimal size
+ 5) Determine the amount of space used in the COW
+ 6) Restroy the device-mapper snapshot
+ 7) Truncate the COW, removing unused space
+ 8) Create a squashfs of the COW
+ """
+ imgloop = LoopbackDisk(image, None) # Passing bogus size - doesn't matter
- cowloop = SparseLoopbackMount(os.path.join(os.path.dirname(path), "osmin"),
- None, 64L * 1024L * 1024L)
+ cowloop = SparseLoopbackDisk(os.path.join(os.path.dirname(path), "osmin"),
+ 64L * 1024L * 1024L)
snapshot = DeviceMapperSnapshot(imgloop, cowloop)
try:
- cowloop.create()
snapshot.create()
resize2fs(snapshot.path, minimal_size)
@@ -404,3 +701,4 @@ def create_image_minimizer(path, image, minimal_size):
mksquashfs(cowloop.lofile, path)
os.unlink(cowloop.lofile)
+
commit 8243a268c7791355832ba5efce6fff963a55f3f3
Author: David Huff <dhuff(a)redhat.com>
Date: Thu Jul 10 17:24:52 2008 -0400
Add method to get partitions from kickstart config
diff --git a/imgcreate/kickstart.py b/imgcreate/kickstart.py
index 451b133..e352e98 100644
--- a/imgcreate/kickstart.py
+++ b/imgcreate/kickstart.py
@@ -498,6 +498,9 @@ def get_groups(ks, required = []):
def get_excluded(ks, required = []):
return ks.handler.packages.excludedList + required
+def get_partitions(ks, required = []):
+ return ks.handler.partition.partitions
+
def ignore_missing(ks):
return ks.handler.packages.handleMissing == ksconstants.KS_MISSING_IGNORE
15 years, 8 months
Branch 'f9-branch' - 3 commits - imgcreate/creator.py imgcreate/live.py imgcreate/yuminst.py
by Jeremy Katz
imgcreate/creator.py | 20 ++++++++++++--------
imgcreate/live.py | 4 ++--
imgcreate/yuminst.py | 3 +++
3 files changed, 17 insertions(+), 10 deletions(-)
New commits:
commit aa5cd8ea83c26c399ae2cc376d19f469c079c550
Author: Jeremy Katz <katzj(a)redhat.com>
Date: Tue Aug 5 18:04:09 2008 -0400
And make --base-on really work
--base-on still wasn't quite working for the livecd case. This makes it so
that we actually pass the iso to base on as well as call the implementation's
method
diff --git a/imgcreate/creator.py b/imgcreate/creator.py
index 435b8cb..132c044 100644
--- a/imgcreate/creator.py
+++ b/imgcreate/creator.py
@@ -895,7 +895,7 @@ class LoopImageCreator(ImageCreator):
"""
return self.__instloop.resparse(size)
- def __base_on(self, base_on):
+ def _base_on(self, base_on):
shutil.copyfile(base_on, self._image)
#
@@ -905,8 +905,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._base_on(base_on)
self.__instloop = SparseExtLoopbackMount(self._image,
self._instroot,
diff --git a/imgcreate/live.py b/imgcreate/live.py
index 44633fe..57d4f4e 100644
--- a/imgcreate/live.py
+++ b/imgcreate/live.py
@@ -126,7 +126,7 @@ class LiveImageCreatorBase(LoopImageCreator):
#
# Actual implementation
#
- def __base_on(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())
@@ -172,7 +172,7 @@ class LiveImageCreatorBase(LoopImageCreator):
isoloop.cleanup()
def _mount_instroot(self, base_on = None):
- LoopImageCreator._mount_instroot(self)
+ LoopImageCreator._mount_instroot(self, base_on)
self.__write_initrd_conf(self._instroot + "/etc/sysconfig/mkinitrd")
def _unmount_instroot(self):
commit 4eeefd36da58fc31e6cceb6f2968b4c92d70f797
Author: Jeremy Katz <katzj(a)redhat.com>
Date: Tue Aug 5 18:02:26 2008 -0400
Don't fail if devices already exist
When in base-on mode, we could already have the device nodes created, so we
should only create them if they don't already exist
diff --git a/imgcreate/creator.py b/imgcreate/creator.py
index 4c22ac6..435b8cb 100644
--- a/imgcreate/creator.py
+++ b/imgcreate/creator.py
@@ -413,12 +413,17 @@ class ImageCreator(object):
('ptmx', 5, 2, 0666),
('tty', 5, 0, 0666),
('zero', 1, 5, 0666))
+ links = (("/proc/self/fd", "/dev/fd"),
+ ("/proc/self/fd/0", "/dev/stdin"),
+ ("/proc/self/fd/1", "/dev/stdout"),
+ ("/proc/self/fd/2", "/dev/stderr"))
+
for (node, major, minor, perm) in devices:
- os.mknod(self._instroot + "/dev/" + node, perm | stat.S_IFCHR, os.makedev(major,minor))
- os.symlink('/proc/self/fd', self._instroot + "/dev/fd")
- os.symlink('/proc/self/fd/0', self._instroot + "/dev/stdin")
- os.symlink('/proc/self/fd/1', self._instroot + "/dev/stdout")
- os.symlink('/proc/self/fd/2', self._instroot + "/dev/stderr")
+ if not os.path.exists(self._instroot + "/dev/" + node):
+ os.mknod(self._instroot + "/dev/" + node, perm | stat.S_IFCHR, os.makedev(major,minor))
+ for (src, dest) in links:
+ if not os.path.exists(self._instroot + dest):
+ os.symlink(src, self._instroot + dest)
os.umask(origumask)
def __create_selinuxfs(self):
commit 44aa6aa22704a56f0afe4c88cb11b838d92a1036
Author: Jeremy Katz <katzj(a)redhat.com>
Date: Tue Aug 5 18:00:58 2008 -0400
Ensure we don't have (stale) rpmdb locks
If we're basing on a previous ISO, we may have rpmdb locks left in the
image which could be from a different version of rpm than the version
we're using. So remove any before trying to open the rpmdb
diff --git a/imgcreate/yuminst.py b/imgcreate/yuminst.py
index ad428bf..268ac85 100644
--- a/imgcreate/yuminst.py
+++ b/imgcreate/yuminst.py
@@ -16,6 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+import glob
import os
import sys
@@ -69,6 +70,8 @@ class LiveCDYum(yum.YumBase):
def setup(self, confpath, installroot):
self._writeConf(confpath, installroot)
+ for f in glob.glob(installroot + "/var/lib/rpm/__db*"):
+ os.unlink(f)
self.doConfigSetup(fn = confpath, root = installroot)
self.conf.cache = 0
self.doTsSetup()
15 years, 8 months
3 commits - imgcreate/creator.py imgcreate/live.py imgcreate/yuminst.py
by Jeremy Katz
imgcreate/creator.py | 20 ++++++++++++--------
imgcreate/live.py | 4 ++--
imgcreate/yuminst.py | 3 +++
3 files changed, 17 insertions(+), 10 deletions(-)
New commits:
commit 2a57a06e1c6d43a7d4d55dccda4270ff63a7b44d
Author: Jeremy Katz <katzj(a)redhat.com>
Date: Tue Aug 5 18:04:09 2008 -0400
And make --base-on really work
--base-on still wasn't quite working for the livecd case. This makes it so
that we actually pass the iso to base on as well as call the implementation's
method
diff --git a/imgcreate/creator.py b/imgcreate/creator.py
index 846373d..e63e96d 100644
--- a/imgcreate/creator.py
+++ b/imgcreate/creator.py
@@ -895,7 +895,7 @@ class LoopImageCreator(ImageCreator):
"""
return self.__instloop.resparse(size)
- def __base_on(self, base_on):
+ def _base_on(self, base_on):
shutil.copyfile(base_on, self._image)
#
@@ -905,8 +905,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._base_on(base_on)
self.__instloop = SparseExtLoopbackMount(self._image,
self._instroot,
diff --git a/imgcreate/live.py b/imgcreate/live.py
index e0bac09..49d524b 100644
--- a/imgcreate/live.py
+++ b/imgcreate/live.py
@@ -129,7 +129,7 @@ class LiveImageCreatorBase(LoopImageCreator):
#
# Actual implementation
#
- def __base_on(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())
@@ -175,7 +175,7 @@ class LiveImageCreatorBase(LoopImageCreator):
isoloop.cleanup()
def _mount_instroot(self, base_on = None):
- LoopImageCreator._mount_instroot(self)
+ LoopImageCreator._mount_instroot(self, base_on)
self.__write_initrd_conf(self._instroot + "/etc/sysconfig/mkinitrd")
def _unmount_instroot(self):
commit 305eaabc1c4329ad4ad17bf3a665be4f6a84aaa6
Author: Jeremy Katz <katzj(a)redhat.com>
Date: Tue Aug 5 18:02:26 2008 -0400
Don't fail if devices already exist
When in base-on mode, we could already have the device nodes created, so we
should only create them if they don't already exist
diff --git a/imgcreate/creator.py b/imgcreate/creator.py
index e61f034..846373d 100644
--- a/imgcreate/creator.py
+++ b/imgcreate/creator.py
@@ -414,12 +414,17 @@ class ImageCreator(object):
('ptmx', 5, 2, 0666),
('tty', 5, 0, 0666),
('zero', 1, 5, 0666))
+ links = (("/proc/self/fd", "/dev/fd"),
+ ("/proc/self/fd/0", "/dev/stdin"),
+ ("/proc/self/fd/1", "/dev/stdout"),
+ ("/proc/self/fd/2", "/dev/stderr"))
+
for (node, major, minor, perm) in devices:
- os.mknod(self._instroot + "/dev/" + node, perm | stat.S_IFCHR, os.makedev(major,minor))
- os.symlink('/proc/self/fd', self._instroot + "/dev/fd")
- os.symlink('/proc/self/fd/0', self._instroot + "/dev/stdin")
- os.symlink('/proc/self/fd/1', self._instroot + "/dev/stdout")
- os.symlink('/proc/self/fd/2', self._instroot + "/dev/stderr")
+ if not os.path.exists(self._instroot + "/dev/" + node):
+ os.mknod(self._instroot + "/dev/" + node, perm | stat.S_IFCHR, os.makedev(major,minor))
+ for (src, dest) in links:
+ if not os.path.exists(self._instroot + dest):
+ os.symlink(src, self._instroot + dest)
os.umask(origumask)
def __create_selinuxfs(self):
commit 985092a541cbafbc91bccb73fd9d1bede2c4d283
Author: Jeremy Katz <katzj(a)redhat.com>
Date: Tue Aug 5 18:00:58 2008 -0400
Ensure we don't have (stale) rpmdb locks
If we're basing on a previous ISO, we may have rpmdb locks left in the
image which could be from a different version of rpm than the version
we're using. So remove any before trying to open the rpmdb
diff --git a/imgcreate/yuminst.py b/imgcreate/yuminst.py
index dd5b189..a7b04b6 100644
--- a/imgcreate/yuminst.py
+++ b/imgcreate/yuminst.py
@@ -16,6 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+import glob
import os
import sys
import logging
@@ -70,6 +71,8 @@ class LiveCDYum(yum.YumBase):
def setup(self, confpath, installroot):
self._writeConf(confpath, installroot)
+ for f in glob.glob(installroot + "/var/lib/rpm/__db*"):
+ os.unlink(f)
self.doConfigSetup(fn = confpath, root = installroot)
self.conf.cache = 0
self.doTsSetup()
15 years, 8 months
RE: Is it possible to have an updatable system on a usb stick?
by martin.x.long@jpmchase.com
I have a completely updated LiveUSB (as of yesterday 04 Aug 08) except for
these five bug fixes.
gnome-packagekit-0.2.3-9.fc9 (i386)
gnome-settings-daemon-2.22.2.1-2.fc9 (i385
PackageKit-0.2.3-6.fc9 (i386)
PackageKit-libs--0.2.3-6.fc9 (i386)
yum-packageKit-0.2.3-6.fc9 (i386)
I tried updating just the gnome and just the PackageKit but it keeps
locking up after the download/test into the "update" process. I get a
"hard fault" sounding beep. then the mouse stays live and the menus drop
down (minus the icons) and nothing works.
-----------------------------------------
This communication is for informational purposes only. It is not
intended as an offer or solicitation for the purchase or sale of
any financial instrument or as an official confirmation of any
transaction. All market prices, data and other information are not
warranted as to completeness or accuracy and are subject to change
without notice. Any comments or statements made herein do not
necessarily reflect those of JPMorgan Chase & Co., its subsidiaries
and affiliates.
This transmission may contain information that is privileged,
confidential, legally privileged, and/or exempt from disclosure
under applicable law. If you are not the intended recipient, you
are hereby notified that any disclosure, copying, distribution, or
use of the information contained herein (including any reliance
thereon) is STRICTLY PROHIBITED. Although this transmission and any
attachments are believed to be free of any virus or other defect
that might affect any computer system into which it is received and
opened, it is the responsibility of the recipient to ensure that it
is virus free and no responsibility is accepted by JPMorgan Chase &
Co., its subsidiaries and affiliates, as applicable, for any loss
or damage arising in any way from its use. If you received this
transmission in error, please immediately contact the sender and
destroy the material in its entirety, whether in electronic or hard
copy format. Thank you.
Please refer to http://www.jpmorgan.com/pages/disclosures for
disclosures relating to UK legal entities.
15 years, 8 months