mkinitrd unification across distributions
 help / color / mirror / Atom feed
* small updates for dmsquash-live module
@ 2011-08-01 20:21 Will Woods
       [not found] ` <1312230069-10674-1-git-send-email-wwoods-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Will Woods @ 2011-08-01 20:21 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

These are just some smallish updates for dmsquash-live.

Patch 1/3 is just a few cleanups - inessential, but nice to have.

Patch 2/3 makes dmsquash-live-root determine the image type (i.e.
squashed or unsquashed) by mounting it and checking the filesystem
type, rather than requiring a specific filename. This is important for
the livenet module (which will be appearing in a later email).

Patch 3/3 is simple and useful - it adds a pre-pivot hook which will
copy any files found in /updates in the initramfs into the live
filesystem. This allows hotfixes to live images. Whee!

 modules.d/90dmsquash-live/apply-live-updates.sh |    7 ++++++
 modules.d/90dmsquash-live/dmsquash-live-root    |   27 ++++++++++++++--------
 modules.d/90dmsquash-live/module-setup.sh       |    1 +
 3 files changed, 25 insertions(+), 10 deletions(-)

-w

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] dmsquash-live-root cleanups/mini-fixes
       [not found] ` <1312230069-10674-1-git-send-email-wwoods-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2011-08-01 20:21   ` Will Woods
  2011-08-01 20:21   ` [PATCH 2/3] dmsquash-live-root: determine img type by contents, not name Will Woods
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Will Woods @ 2011-08-01 20:21 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

- use last ro/rw cmdline arg rather than favoring 'rw' over 'ro'
- don't bother with useless RES variable for holding $?
- only do fs check when $livedev is a block device

Signed-off-by: Will Woods <wwoods-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 modules.d/90dmsquash-live/dmsquash-live-root |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/modules.d/90dmsquash-live/dmsquash-live-root b/modules.d/90dmsquash-live/dmsquash-live-root
index 4d1d902..a76cbc7 100755
--- a/modules.d/90dmsquash-live/dmsquash-live-root
+++ b/modules.d/90dmsquash-live/dmsquash-live-root
@@ -25,7 +25,8 @@ getargbool 0 rd.live.overlay.reset -y reset_overlay && reset_overlay="yes"
 getargbool 0 rd.live.overlay.readonly -y readonly_overlay && readonly_overlay="--readonly" || readonly_overlay=""
 overlay=$(getarg rd.live.overlay overlay)
 
-[ -e $livedev ] && fs=$(blkid -s TYPE -o value $livedev)
+# CD/DVD media check
+[ -b $livedev ] && fs=$(blkid -s TYPE -o value $livedev)
 if [ "$fs" = "iso9660" -o "$fs" = "udf" ]; then
     check="yes"
 fi
@@ -40,9 +41,7 @@ if [ -n "$check" ]; then
     [ -x /bin/plymouth ] && /bin/plymouth --show-splash
 fi
 
-getarg ro && liverw=ro
-getarg rw && liverw=rw
-[ -z "$liverw" ] && liverw=ro
+for arg in $CMDLINE; do case $arg in ro|rw) liverw=$arg ;; esac; done
 # mount the backing of the live image first
 mkdir -m 0755 -p /run/initramfs/live
 if [ -f $livedev ]; then
@@ -52,9 +51,8 @@ if [ -f $livedev ]; then
         *ext3fs.img|*rootfs.img) FSIMG=$livedev ;;
     esac
 else
-    mount -n -t $fstype -o $liverw $livedev /run/initramfs/live
-    RES=$?
-    if [ "$RES" != "0" ]; then
+    mount -n -t $fstype -o ${liverw:-ro} $livedev /run/initramfs/live
+    if [ "$?" != "0" ]; then
         die "Failed to mount block device of live image"
         exit 1
     fi
-- 
1.7.6

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] dmsquash-live-root: determine img type by contents, not name
       [not found] ` <1312230069-10674-1-git-send-email-wwoods-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  2011-08-01 20:21   ` [PATCH 1/3] dmsquash-live-root cleanups/mini-fixes Will Woods
@ 2011-08-01 20:21   ` Will Woods
  2011-08-01 20:21   ` [PATCH 3/3] add apply-live-updates.sh to pre-pivot hook Will Woods
  2011-08-12  6:06   ` small updates for dmsquash-live module Harald Hoyer
  3 siblings, 0 replies; 5+ messages in thread
From: Will Woods @ 2011-08-01 20:21 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

Currently dmsquash-live-root requires that squashfs images be named
"squashfs.img" and all others be "ext3fs.img" or "rootfs.img".

If we've got a live image in initramfs, this patch will make dracut use
losetup and det_fs to determine the actual filesystem type of the image.

Signed-off-by: Will Woods <wwoods-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 modules.d/90dmsquash-live/dmsquash-live-root |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/modules.d/90dmsquash-live/dmsquash-live-root b/modules.d/90dmsquash-live/dmsquash-live-root
index a76cbc7..265de19 100755
--- a/modules.d/90dmsquash-live/dmsquash-live-root
+++ b/modules.d/90dmsquash-live/dmsquash-live-root
@@ -41,14 +41,23 @@ if [ -n "$check" ]; then
     [ -x /bin/plymouth ] && /bin/plymouth --show-splash
 fi
 
+# determine filesystem type for a filesystem image
+det_img_fs() {
+    local _img="$1" _loop=$(losetup -f) _fs
+    losetup $_loop $_img; _fs=$(det_fs $_loop); losetup -d $_loop
+    echo $_fs
+}
+
 for arg in $CMDLINE; do case $arg in ro|rw) liverw=$arg ;; esac; done
 # mount the backing of the live image first
 mkdir -m 0755 -p /run/initramfs/live
 if [ -f $livedev ]; then
     # no mount needed - we've already got the LiveOS image in initramfs
-    case $livedev in
-        *squashfs.img) SQUASHED=$livedev ;;
-        *ext3fs.img|*rootfs.img) FSIMG=$livedev ;;
+    # check filesystem type and handle accordingly
+    case `det_img_fs $livedev` in
+        squashfs) SQUASHED=$livedev ;;
+        auto) die "cannot mount live image (unknown filesystem type)" ;;
+        *) FSIMG=$livedev ;;
     esac
 else
     mount -n -t $fstype -o ${liverw:-ro} $livedev /run/initramfs/live
-- 
1.7.6

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] add apply-live-updates.sh to pre-pivot hook
       [not found] ` <1312230069-10674-1-git-send-email-wwoods-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  2011-08-01 20:21   ` [PATCH 1/3] dmsquash-live-root cleanups/mini-fixes Will Woods
  2011-08-01 20:21   ` [PATCH 2/3] dmsquash-live-root: determine img type by contents, not name Will Woods
@ 2011-08-01 20:21   ` Will Woods
  2011-08-12  6:06   ` small updates for dmsquash-live module Harald Hoyer
  3 siblings, 0 replies; 5+ messages in thread
From: Will Woods @ 2011-08-01 20:21 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

If we're about to start a Live image (i.e. if /dev/mapper/live-rw
exists) this script will take any files found in /updates (inside the
initramfs!) and and copy them into $NEWROOT.

This allows for hotfixes to be applied to existing Live images without
rebuilding the entire image.

Signed-off-by: Will Woods <wwoods-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 modules.d/90dmsquash-live/apply-live-updates.sh |    7 +++++++
 modules.d/90dmsquash-live/module-setup.sh       |    1 +
 2 files changed, 8 insertions(+), 0 deletions(-)
 create mode 100755 modules.d/90dmsquash-live/apply-live-updates.sh

diff --git a/modules.d/90dmsquash-live/apply-live-updates.sh b/modules.d/90dmsquash-live/apply-live-updates.sh
new file mode 100755
index 0000000..dfdb404
--- /dev/null
+++ b/modules.d/90dmsquash-live/apply-live-updates.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+if [ -b /dev/mapper/live-rw ]; then
+    if [ "`echo /updates/*`" != "/updates/*" ]; then
+        echo "Applying updates to live image..."
+        /bin/cp -a /updates/* $NEWROOT
+    fi
+fi
diff --git a/modules.d/90dmsquash-live/module-setup.sh b/modules.d/90dmsquash-live/module-setup.sh
index 8ed633f..684655f 100755
--- a/modules.d/90dmsquash-live/module-setup.sh
+++ b/modules.d/90dmsquash-live/module-setup.sh
@@ -34,6 +34,7 @@ install() {
     inst_hook cmdline 30 "$moddir/parse-dmsquash-live.sh"
     inst_hook pre-udev 30 "$moddir/dmsquash-live-genrules.sh"
     inst_hook pre-udev 30 "$moddir/dmsquash-liveiso-genrules.sh"
+    inst_hook pre-pivot 20 "$moddir/apply-live-updates.sh"
     inst "$moddir/dmsquash-live-root" "/sbin/dmsquash-live-root"
     # should probably just be generally included
     inst_rules 60-cdrom_id.rules
-- 
1.7.6

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: small updates for dmsquash-live module
       [not found] ` <1312230069-10674-1-git-send-email-wwoods-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
                     ` (2 preceding siblings ...)
  2011-08-01 20:21   ` [PATCH 3/3] add apply-live-updates.sh to pre-pivot hook Will Woods
@ 2011-08-12  6:06   ` Harald Hoyer
  3 siblings, 0 replies; 5+ messages in thread
From: Harald Hoyer @ 2011-08-12  6:06 UTC (permalink / raw)
  To: Will Woods; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA

On 01.08.2011 22:21, Will Woods wrote:
> These are just some smallish updates for dmsquash-live.
> 
> Patch 1/3 is just a few cleanups - inessential, but nice to have.
> 
> Patch 2/3 makes dmsquash-live-root determine the image type (i.e.
> squashed or unsquashed) by mounting it and checking the filesystem
> type, rather than requiring a specific filename. This is important for
> the livenet module (which will be appearing in a later email).
> 
> Patch 3/3 is simple and useful - it adds a pre-pivot hook which will
> copy any files found in /updates in the initramfs into the live
> filesystem. This allows hotfixes to live images. Whee!
> 
>  modules.d/90dmsquash-live/apply-live-updates.sh |    7 ++++++
>  modules.d/90dmsquash-live/dmsquash-live-root    |   27 ++++++++++++++--------
>  modules.d/90dmsquash-live/module-setup.sh       |    1 +
>  3 files changed, 25 insertions(+), 10 deletions(-)
> 
> -w
> 
> --
> To unsubscribe from this list: send the line "unsubscribe initramfs" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

pushed

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-08-12  6:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-01 20:21 small updates for dmsquash-live module Will Woods
     [not found] ` <1312230069-10674-1-git-send-email-wwoods-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-08-01 20:21   ` [PATCH 1/3] dmsquash-live-root cleanups/mini-fixes Will Woods
2011-08-01 20:21   ` [PATCH 2/3] dmsquash-live-root: determine img type by contents, not name Will Woods
2011-08-01 20:21   ` [PATCH 3/3] add apply-live-updates.sh to pre-pivot hook Will Woods
2011-08-12  6:06   ` small updates for dmsquash-live module Harald Hoyer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox