aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/remove-boot-splash
blob: 058b60b598e301cc4d8059ac7193782163e5292e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/sh
# -*- Mode: shell-script -*-
# Copyright (C) 2002 by Chmouel Boudjnah <chmouel@mandrakesoft.com>
# Copyright (C) 2012 by Colin Guthrie <colin@mageia.org>
# 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 <initrd>" >&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