This patch prepends the fslabel that the user gives to livecd-creator,
to the filesystem image names on the livecd and liveusb.
This got a bit uglier than I had in mind at first, though possibly in a
way that has a beneficial side effect-
Currently in the liveusb case, instead of a CDLABEL being passed on the
kernel-commandline, a uuid is passed instead. Thus as far as I could
see (and maybe I'm just tired), at that point the cdlabel is lost to the
liveusb.
What I did was have livecd-creator write out the fslabel to
/etc/LiveOS-release. And then I had mayflower read this when generating
the initramfs init, so that it would know where to look for the file.
I think /etc/LiveOS-release would also solve a problem recently brought
up by Andy (asmith11), as to how to determine in the %post of whether or
not you are in a livecd environment or not.
Anyway, there may be better methods that just didn't occur to me, but
this doesn't seem so bad to me.
food for thought, like the rest of these patches...
So, with all of these, the final cdrom filesystem layout, for the F7
livecd, would have looked like...
/boot/isolinux/(stuff that used to be in /isolinux)
/LiveOS/Fedora-7-Live-i386.squashfs.img
/LiveOS/Fedora-7-Live-i386.osmin.img
(note, no /sysroot)
and inside the squashfs.img, is only /LiveOS/Fedora-7-Live-i386.ext3.img
Maybe there should be another patch to rename the .osmin.img to
.mininst.img or something...
Again, I am not at all opposed to just shelving these for a few months,
and seeing if people are more interested in them for F9. But I like them...
-dmc
diff -Naur livecd.6.ext3fs_to_ext3/creator/isotostick.sh livecd.7.prepend_fslabel_to_osimage/creator/isotostick.sh
--- livecd.6.ext3fs_to_ext3/creator/isotostick.sh 2007-09-21 08:14:46.000000000 +0000
+++ livecd.7.prepend_fslabel_to_osimage/creator/isotostick.sh 2007-09-21 09:06:54.000000000 +0000
@@ -203,20 +203,16 @@
echo "Copying live image to USB stick"
if [ ! -d $USBMNT/$SYSLINUXPATH ]; then mkdir -p $USBMNT/$SYSLINUXPATH ; fi
if [ ! -d $USBMNT/LiveOS ]; then mkdir $USBMNT/LiveOS ; fi
-# cases without /LiveOS and ext3fs are legacy detection, remove for F10
-if [ -f $CDMNT/LiveOS/squashfs.img ]; then
- cp $CDMNT/LiveOS/squashfs.img $USBMNT/LiveOS/squashfs.img || exitclean
+# cases without CDMNT/LiveOS are legacy detection, remove for F10
+if [ -f "$CDMNT/LiveOS/*.img" ]; then
+ cp -a $CDMNT/LiveOS/*.img $USBMNT/LiveOS/ || exitclean
elif [ -f $CDMNT/squashfs.img ]; then
cp $CDMNT/squashfs.img $USBMNT/LiveOS/squashfs.img || exitclean
-elif [ -f $CDMNT/LiveOS/ext3fs.img ]; then
- cp $CDMNT/LiveOS/ext3fs.img $USBMNT/LiveOS/ext3fs.img || exitclean
-elif [ -f $CDMNT/LiveOS/ext3.img ]; then
- cp $CDMNT/LiveOS/ext3.img $USBMNT/LiveOS/ext3.img || exitclean
elif [ -f $CDMNT/ext3fs.img ]; then
cp $CDMNT/ext3fs.img $USBMNT/LiveOS/ext3fs.img || exitclean
fi
-if [ -f $CDMNT/LiveOS/osmin.gz ]; then
- cp $CDMNT/LiveOS/osmin.gz $USBMNT/LiveOS/osmin.gz || exitclean
+if [ -f $CDMNT/LiveOS/*.osmin.gz ]; then
+ cp -a $CDMNT/LiveOS/*.osmin.gz $USBMNT/LiveOS/ || exitclean
elif [ -f $CDMNT/osmin.gz ]; then
cp $CDMNT/osmin.gz $USBMNT/LiveOS/osmin.gz || exitclean
fi
diff -Naur livecd.6.ext3fs_to_ext3/creator/livecd-creator livecd.7.prepend_fslabel_to_osimage/creator/livecd-creator
--- livecd.6.ext3fs_to_ext3/creator/livecd-creator 2007-09-21 08:16:21.000000000 +0000
+++ livecd.7.prepend_fslabel_to_osimage/creator/livecd-creator 2007-09-21 09:46:42.000000000 +0000
@@ -380,10 +380,16 @@
"""helper function to extract ext3 file system from a live CD ISO"""
isoloop = LoopbackMount(base_on, "%s/base_on_iso" %(self.build_dir,))
+ isolabelx = subprocess.Popen(['/lib/udev/vol_id', '-l', base_on],
+ stdout=subprocess.PIPE,
+ stderr=open('/dev/null', 'w')
+ ).communicate()[0]
+ # needed?: strip whitespace
+ isolabel = isolabelx.split()[0]
# legacy LiveOS filesystem layout support, remove for F9 or F10
- if os.path.exists("%s/LiveOS/squashfs.img" %(isoloop.mountdir,)):
- squashloop = LoopbackMount("%s/LiveOS/squashfs.img" %(isoloop.mountdir,),
+ if os.path.exists("%s/LiveOS/%s.squashfs.img" %(isoloop.mountdir,isolabel)):
+ squashloop = LoopbackMount("%s/LiveOS/%s.squashfs.img" %(isoloop.mountdir,isolabel),
"%s/base_on_squashfs" %(self.build_dir,),
"squashfs")
else:
@@ -398,22 +404,22 @@
raise InstallationError("Failed to loopback mount '%s' : %s" % (base_on, e))
if not os.path.exists(squashloop.lofile):
- raise InstallationError("'%s' is not a valid live CD ISO : squashfs.img doesn't exist" % base_on)
+ raise InstallationError("'%s' is not a valid live CD ISO : %s doesn't exist" %(base_on,squashloop.lofile))
try:
squashloop.mount()
except MountError, e:
- raise InstallationError("Failed to loopback mount squashfs.img from '%s' : %s" % (base_on, e))
+ raise InstallationError("Failed to loopback mount %s from '%s' : %s" % (squashloop.lofile, base_on, e))
# legacy LiveOS filesystem layout support, remove for F9 or F10
if os.path.exists(self.build_dir + "/base_on_squashfs/os.img"):
os_image = self.build_dir + "/base_on_squashfs/os.img"
- elif os.path.exists(self.build_dir + "/base_on_squashfs/LiveOS/ext3.img"):
- os_image = self.build_dir + "/base_on_squashfs/LiveOS/ext3.img"
+ elif os.path.exists(self.build_dir + "/base_on_squashfs/LiveOS/%s.ext3.img" % (isolabel,)):
+ os_image = self.build_dir + "/base_on_squashfs/LiveOS/%s.ext3.img" % (isolabel,)
else:
- raise InstallationError("'%s' is not a valid live CD ISO : os.img doesn't exist" % base_on)
+ raise InstallationError("'%s' is not a valid live CD ISO : LiveOS/%s.ext3.img doesn't exist" % (base_on,isolabel))
- shutil.copyfile(os_image, self.build_dir + "/data/LiveOS/ext3.img")
+ shutil.copyfile(os_image, self.build_dir + "/data/LiveOS/%s.ext3.img" % isolabel)
finally:
# unmount and tear down the mount points and loop devices used
squashloop.cleanup()
@@ -428,6 +434,11 @@
fstab.write("sysfs /sys sysfs defaults 0 0\n")
fstab.close()
+ def write_release(self):
+ fstab = open(self.build_dir + "/install_root/etc/LiveOS-release", "w")
+ fstab.write("%s\n" % self.fs_label)
+ fstab.close()
+
def setup(self, base_on = None, cachedir = None):
"""setup target ext3 file system in preparation for an install"""
@@ -446,11 +457,11 @@
# get backing ext3 image if we're based this build on an existing live CD ISO
self.base_on_iso(base_on)
- self.instloop = LoopbackMount("%s/data/LiveOS/ext3.img" %(self.build_dir,),
+ self.instloop = LoopbackMount("%s/data/LiveOS/%s.ext3.img" %(self.build_dir,self.fs_label),
"%s/install_root" %(self.build_dir,))
else:
- self.instloop = SparseExt3LoopbackMount("%s/data/LiveOS/ext3.img"
- %(self.build_dir,),
+ self.instloop = SparseExt3LoopbackMount("%s/data/LiveOS/%s.ext3.img"
+ %(self.build_dir,self.fs_label),
"%s/install_root"
%(self.build_dir,),
self.image_size,
@@ -482,6 +493,7 @@
os.symlink("../proc/mounts", self.build_dir + "/install_root/etc/mtab")
self.write_fstab()
+ self.write_release()
self.ayum = LiveCDYum()
self.ayum.setup(self.build_dir + "/data",
@@ -925,14 +937,14 @@
"""create compressed squashfs file system"""
if not self.skip_compression:
ret = subprocess.call(["/sbin/mksquashfs", "data",
- "./out/LiveOS/squashfs.img"],
+ "./out/LiveOS/%s.squashfs.img" % self.fs_label],
cwd="%s" %(self.build_dir,),
env={"PWD": "%s" %(self.build_dir,)})
if ret != 0:
raise InstallationError("mksquashfs exited with error (%d)" %(ret,))
else:
- shutil.move("%s/data/LiveOS/ext3.img" %(self.build_dir,),
- "%s/out/LiveOS/ext3.img" %(self.build_dir,))
+ shutil.move("%s/data/LiveOS/%s.ext3.img" %(self.build_dir,self.fs_label),
+ "%s/out/LiveOS/%s.ext3.img" %(self.build_dir,self.fs_label))
def _getBlockCountOfExt2FS(self, filesystem):
def parseField(output, field):
@@ -981,7 +993,7 @@
# resize2fs-to-uncompressed-size (with implicit resparsification)
#
def cleanupDeleted(self):
- image = "%s/data/LiveOS/ext3.img" %(self.build_dir,)
+ image = "%s/data/LiveOS/%s.ext3.img" %(self.build_dir,self.fs_label)
subprocess.call(["/sbin/e2fsck", "-f", "-y", image])
@@ -1009,7 +1021,7 @@
#
def genMinInstDelta(self):
# create the sparse file for the minimized overlay
- fd = os.open("%s/out/LiveOS/osmin" %(self.build_dir,),
+ fd = os.open("%s/out/LiveOS/%s.osmin" %(self.build_dir,self.fs_label),
os.O_WRONLY | os.O_CREAT)
off = long(64L * 1024L * 1024L)
os.lseek(fd, off, 0)
@@ -1017,12 +1029,12 @@
os.close(fd)
# associate os image with loop device
- osloop = LoopbackMount("%s/data/LiveOS/ext3.img" %(self.build_dir,), \
+ osloop = LoopbackMount("%s/data/LiveOS/%s.ext3.img" %(self.build_dir,self.fs_label), \
"None")
osloop.loopsetup()
# associate overlay with loop device
- minloop = LoopbackMount("%s/out/LiveOS/osmin" %(self.build_dir,), \
+ minloop = LoopbackMount("%s/out/LiveOS/%s.osmin" %(self.build_dir,self.fs_label), \
"None")
minloop.loopsetup()
@@ -1068,12 +1080,12 @@
minloop.lounsetup()
# truncate the unused excess portion of the sparse file
- fd = os.open("%s/out/LiveOS/osmin" %(self.build_dir,), os.O_WRONLY )
+ fd = os.open("%s/out/LiveOS/%s.osmin" %(self.build_dir,self.fs_label), os.O_WRONLY )
os.ftruncate(fd, minInstDeltaDataLength * 512)
os.close(fd)
# the delta data is *extremely* compressible (e.g. 1.2M->7kb)
- rc = subprocess.call(["/usr/bin/gzip", "osmin"],
+ rc = subprocess.call(["/usr/bin/gzip", "%s.osmin" % self.fs_label],
cwd="%s/out/LiveOS" %(self.build_dir,),
env={"PWD": "%s/out/LiveOS" %(self.build_dir,)})
if rc != 0:
diff -Naur livecd.6.ext3fs_to_ext3/creator/mayflower livecd.7.prepend_fslabel_to_osimage/creator/mayflower
--- livecd.6.ext3fs_to_ext3/creator/mayflower 2007-09-21 08:15:09.000000000 +0000
+++ livecd.7.prepend_fslabel_to_osimage/creator/mayflower 2007-09-21 09:20:19.000000000 +0000
@@ -260,6 +260,7 @@
live_ram=0
check_iso=0
live_locale=""
+live_id=$( < /etc/LiveOS-release )
# Parse kernel commandline options
#
@@ -289,6 +290,9 @@
live_locale=*)
live_locale=\${o#live_locale=}
;;
+ live_id=*)
+ live_id=\${o#live_id=}
+ ;;
check)
check_iso=1
;;
@@ -641,8 +645,8 @@
done
# we might have a genMinInstDelta delta file for anaconda to take advantage of
-if [ -e /sysroot/LiveOS/osmin.gz ]; then
- OSMINGZ=/sysroot/LiveOS/osmin.gz
+if [ -e /sysroot/LiveOS/\${live_id}.osmin.gz ]; then
+ OSMINGZ=/sysroot/LiveOS/\${live_id}.osmin.gz
fi
if [ -n "\$OSMINGZ" ]; then
@@ -654,8 +658,8 @@
# we might have an uncompressed embedded ext3 to use as rootfs (uncompressed live)
#
-if [ -e /sysroot/LiveOS/ext3.img ]; then
- EXT3FS="/sysroot/LiveOS/ext3.img"
+if [ -e /sysroot/LiveOS/\${live_id}.ext3.img ]; then
+ EXT3FS="/sysroot/LiveOS/\${live_id}.ext3.img"
fi
if [ -n "\$EXT3FS" ] ; then
@@ -676,8 +680,8 @@
# we might have an embedded ext3 on squashfs to use as rootfs (compressed live)
#
-if [ -e /sysroot/LiveOS/squashfs.img ]; then
- SQUASHED="/sysroot/LiveOS/squashfs.img"
+if [ -e /sysroot/LiveOS/\${live_id}.squashfs.img ]; then
+ SQUASHED="/sysroot/LiveOS/\${live_id}.squashfs.img"
fi
if [ -e "\$SQUASHED" ] ; then
@@ -693,11 +697,11 @@
if [ "\$live_ram" == "1" ] ; then
echo "Copying live image to RAM..."
echo "(this may take a few minutes)"
- dd if=\$SQUASHED of=/squashed.img bs=512 2> /dev/null
+ dd if=\$SQUASHED of=/\${live_id}.squashed.img bs=512 2> /dev/null
umount -n /sysroot
echo "Done copying live image to RAM."
eject -p /dev/root
- SQUASHED="/squashed.img"
+ SQUASHED="/\${live_id}.squashed.img"
fi
SQUASHED_LOOPDEV=\$( losetup -f )
@@ -706,7 +710,7 @@
mount -n -t squashfs -o ro \$SQUASHED_LOOPDEV /squashfs
BASE_LOOPDEV=\$( losetup -f )
- losetup \$BASE_LOOPDEV /squashfs/LiveOS/ext3.img
+ losetup \$BASE_LOOPDEV /squashfs/LiveOS/\${live_id}.ext3.img
umount -l /squashfs
if [ "\$live_ram" == "0" ] ; then
--
Fedora-livecd-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/fedora-livecd-list