From ecef8d6d31c82ae40afd1734a476c366f8995018 Mon Sep 17 00:00:00 2001
From: Andreas Loibl <andreas@andreas-loibl.de>
Date: Fri, 4 Mar 2011 12:23:59 +0100
Subject: added support for multiple overlays in one container

---
 .../scripts/live-bottom/01gfxoverlay               | 31 +++++++++++++++-------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/config/chroot_local-includes/usr/share/initramfs-tools/scripts/live-bottom/01gfxoverlay b/config/chroot_local-includes/usr/share/initramfs-tools/scripts/live-bottom/01gfxoverlay
index d648beb..9e4d913 100755
--- a/config/chroot_local-includes/usr/share/initramfs-tools/scripts/live-bottom/01gfxoverlay
+++ b/config/chroot_local-includes/usr/share/initramfs-tools/scripts/live-bottom/01gfxoverlay
@@ -1,14 +1,25 @@
 #!/bin/sh
 
-if [ -e /etc/gfxoverlay ]; then
-  overlay="$(echo /root/live/image/gfxoverlay/$(cat /etc/gfxoverlay).*)"
-  if [ -f "$overlay" ]; then
-    #overlay_dev="$(losetup -f)"
-    #losetup "$overlay_dev" "$overlay"
-    mkdir -p /live/gfxoverlay /root/live/gfxoverlay
+[ ! -f /etc/gfxoverlay ] && exit 0
+
+gfx="$(cat /etc/gfxoverlay)"
+bit=32
+[ "$(uname -m)" = "x86_64" ] && bit=64
+
+mkdir -p /live/gfxoverlay /root/live/gfxoverlay
+for overlay in /root/live/image/gfxoverlay.* /root/live/image/gfxoverlay/$gfx.*
+do
+    [ ! -e "$overlay" ] && continue
     mount -o loop "$overlay" /live/gfxoverlay
-    mount -o remount,add:1:/live/gfxoverlay /root
-    mount -n -o move /live/gfxoverlay /root/live/gfxoverlay
-  fi
-fi
+    for dir in /live/gfxoverlay/overlay$bit-$gfx /live/gfxoverlay/$gfx /live/gfxoverlay
+    do
+        if [ -d $dir/lib ]; then
+            mount -o remount,add:1:$dir /root
+            mount -n -o move /live/gfxoverlay /root/live/gfxoverlay
+	    exit 0
+	fi
+    done
+    umount /live/gfxoverlay
+done
+rmdir /live/gfxoverlay /root/live/gfxoverlay
 
-- 
cgit v1.0