#!/bin/sh # -*- Mode: shell-script -*- # Copyright (C) 2002 by Chmouel Boudjnah # Copyright (C) 2012 by Colin Guthrie # Redistribution of this file is permitted under the terms of the GNU # Public License (GPL) # $Id$ : ${splash_dir=/usr/share/bootsplash} [ $# = 1 ] || { echo "Usage: $0 " >&2; exit 1; } initrd_file=$1 tmp_dir= clean_tmp() { [ -n "$tmp_dir" ] && rm -rf "$tmp_dir" return 0 } clean_and_fail() { clean_tmp exit 1 } initrd_file="$(readlink -f "$initrd_file")" CPIO= [ -z "$CPIO" ] && zcat $initrd_file 2>/dev/null | cpio -it --quiet &>/dev/null && CPIO=gz [ -z "$CPIO" ] && xzcat $initrd_file 2>/dev/null | cpio -it --quiet &>/dev/null && CPIO=xz if [ -z "$CPIO" ]; then echo "remove-boot-splash: Format of $initrd_file not recognized" >&2 exit 1 fi tmp_dir=`mktemp -d` [ -n "$tmp_dir" ] || clean_and_fail EXTRACT=zcat COMPRESS="gzip -9" if [ "xz" = "$CPIO" ]; then EXTRACT=xzcat COMPRESS="xz --check=crc32 --lzma2=dict=1MiB" fi mkdir $tmp_dir/plymouth cd $tmp_dir/plymouth || clean_and_fail $EXTRACT $initrd_file | cpio -id --quiet || clean_and_fail if [ ! -d $tmp_dir/plymouth/usr/share/plymouth ]; then echo "remove-boot-splash: ERROR plymouth not found in $initrd_file" >&2 clean_and_fail fi echo "remove-boot-splash: Removing plymouth from initrd $initrd_file" >&2 rm -rf \ $tmp_dir/plymouth/usr/share/plymouth \ $tmp_dir/plymouth/usr/lib*/plymouth \ $tmp_dir/plymouth/usr/lib*/libply* \ $tmp_dir/plymouth/lib*/libply* \ $tmp_dir/plymouth/bin/plymouthd \ $tmp_dir/plymouth/bin/plymouth \ $tmp_dir/plymouth/etc/plymouth \ $tmp_dir/plymouth/etc/splashy \ $tmp_dir/plymouth/usr/share/splashy find . | \ cpio -R 0:0 -H newc -o --quiet | \ $COMPRESS > $tmp_dir/initrd || clean_and_fail mv -f $tmp_dir/initrd $initrd_file clean_tmp