From c65e83517bd32aee332ec8f8d2a42de9026d43c0 Mon Sep 17 00:00:00 2001
From: Diego Giovane Pasqualin <dpasqualin@c3sl.ufpr.br>
Date: Tue, 1 Oct 2013 20:08:35 -0300
Subject: [PATCH] 60-update-initrd_minicom: Apply changes made to
 60-update-initrd_le5

Signed-off-by: Diego Giovane Pasqualin <dpasqualin@c3sl.ufpr.br>
---
 scripts/60-update-initrd_minicom | 55 +++++++++++++++++++++++++-------
 1 file changed, 44 insertions(+), 11 deletions(-)

diff --git a/scripts/60-update-initrd_minicom b/scripts/60-update-initrd_minicom
index 105b098..895c2a4 100755
--- a/scripts/60-update-initrd_minicom
+++ b/scripts/60-update-initrd_minicom
@@ -46,13 +46,50 @@ else
     unlzma -c -S .lz "$INITRD" | cpio -id
 fi
 
-# unlzma -c -S .lz $CDDIR/casper/initrd.lz | cpio -id
+# Fix plymouth themes simlinks
+#
+# This is done because the existing references use absolute paths, and this makes
+# cpio fail to follow the links. After removing the broken links
+# new links are created using paths relative to the link location.
+#
+# For instance, originally there was this link:
+# ./lib/plymouth/themes/text.plymout -> /lib/plymouth/themes/le-text/le-text.plymouth
+# Since there is no /lib/plymouth/themes/le-text/le-text.plymouth on the
+# system running create-iso, cpio won't find the file and will fail.
+# The file the link should point to is ./lib/plymouth/themes/le-text/le-text.plymouth,
+# so a new link called "text.plymouth" is created in the ./lib/plymouth/themes/ directory,
+# poiting to le-text/le-text.plymouth (this works because "le-text" is in the same folder as
+# the new link):
+# ./lib/plymouth/themes/text.plymouth -> le-text/le-text.plymouth
+
+if test -L ./lib/plymouth/themes/text.plymouth; then
+    rm -f ./lib/plymouth/themes/text.plymouth
+    ln -s le-text/le-text.plymouth ./lib/plymouth/themes/text.plymouth
+fi
 
-# Update initrd boot splash
-#cp -af $CHROOTDIR/lib/plymouth/themes/le-logo ./lib/plymouth/themes/
-#cp -af $TEMPLATES/plymouth/default.plymouth ./lib/plymouth/themes/
+if test -L ./lib/plymouth/themes/default.plymouth; then
+    rm -f ./lib/plymouth/themes/default.plymouth
+    ln -s le-logo/le-logo.plymouth ./lib/plymouth/themes/default.plymouth
+fi
 
-#sed -i 's@[Uu]buntu@le5@g' ./etc/casper.conf
+# Fix blacklist-oss.conf and i386-linux-gnu_GL.conf simlinks
+#
+# Same issue as with the plymouth/themes references, but in this case
+# the files the links should point to are not part of the initramfs.
+# Instead of copying the file to the correct place and
+# then creating a symbolic link pointing to it, the correct file
+# simply overwrites the link.
+
+if test -L ./etc/modprobe.d/blacklist-oss.conf; then
+    rm -f ./etc/modprobe.d/blacklist-oss.conf
+    cp -af "$CHROOTDIR"/lib/linux-sound-base/noOSS.modprobe.conf ./etc/modprobe.d/blacklist-oss.conf
+fi
+
+if test -L ./etc/ld.so.conf.d/i386-linux-gnu_GL.conf; then
+    rm -f ./etc/ld.so.conf.d/i386-linux-gnu_GL.conf
+    cp -af "$CHROOTDIR"/usr/lib/i386-linux-gnu/mesa/ld.so.conf ./etc/ld.so.conf.d/i386-linux-gnu_GL.conf
+
+fi
 
 case "$1" in
     "minicom/client")
@@ -72,13 +109,9 @@ echo "export \"FLAVOUR=le5\"" >> ./etc/casper.conf
 
 cp -f "$TEMPLATES"/casper/10adduser ./scripts/casper-bottom/25adduser
 
-# Eventually cpio return some errors due to some (not important) missing
-# files. So we are disabling the pipefail option and will reenable again
-# after compressing the initrd file.
-set +o pipefail
-find | cpio --quiet --dereference -o -H newc | lzma -7 \
+# Regenarete initrd image
+find . -depth -print0 | cpio --quiet --dereference -o -H newc | lzma -7 \
     > $CDDIR/casper/initrd.lz
-set -o pipefail
 
 cp -af $(sed 's/initrd.img/vmlinuz/g' <<< $INITRD) \
         "$CDDIR"/casper/vmlinuz
-- 
GitLab