summaryrefslogtreecommitdiff
path: root/plymouth/debian/local/plymouth.hook
blob: cf0c3a95de904a284f15ad878294e467992a8f4b (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/bin/sh

set -e

PREREQ=""

prereqs()
{
	echo "${PREREQ}"
}

case "${1}" in
	prereqs)
		prereqs
		exit 0
		;;
esac

. /usr/share/initramfs-tools/hook-functions

THEME="$(/usr/sbin/plymouth-set-default-theme || true)"
THEMES="/usr/share/plymouth/themes"

if [ -n "${THEME}" ]
then
	THEME_NAME="${THEME}"
	THEME="${THEMES}/${THEME}/${THEME}.plymouth"
else
	exit 0
fi

PLUGIN_PATH="$(plymouth --get-splash-plugin-path)"

case "${THEME_NAME}" in
	text|details|tribar)
		PLUGINS="text.so details.so"
		;;

	*)
		PLUGINS="text.so details.so label.so"
		;;
esac

MODULE="${PLUGIN_PATH}/$(sed -n 's/^ModuleName=\(.*\)/\1/p' ${THEME}).so"

if [ ! -e "$MODULE" ]
then
	echo "W: plymouth module ($MODULE) missing, skipping plymouth."
	exit 0
fi

# copy plugin and images for current theme
copy_exec "${MODULE}"
mkdir -p "${DESTDIR}/${THEMES}"
cp -r "${THEMES}/${THEME_NAME}" "${DESTDIR}/${THEMES}"

# copy binaries and base plugins
copy_exec /bin/plymouth
copy_exec /sbin/plymouthd

for PLUGIN in ${PLUGINS}
do
	if [ -f ${PLUGIN_PATH}/${PLUGIN} ]
	then
		copy_exec ${PLUGIN_PATH}/${PLUGIN}
	else
		echo "W: plymouth: The plugin ${PLUGIN} is missing, the selected theme might not work as expected."
		echo "W: plymouth: You might want to install the plymouth-themes package to fix this."
	fi
done

# copy base themes and logo
cp -a "${THEMES}/details" "${DESTDIR}/${THEMES}"
cp -a "${THEMES}/text" "${DESTDIR}/${THEMES}"

if [ -f /etc/os-release ]
then
	cp /etc/os-release "${DESTDIR}/etc"
fi

case "${THEME_NAME}" in
	text|details)

		;;

	*)
		cp /usr/share/plymouth/debian-logo.png "${DESTDIR}/usr/share/plymouth"

		# fontconfig
		mkdir -p "${DESTDIR}/etc/fonts/conf.d"
		cp -a /etc/fonts/fonts.conf "${DESTDIR}/etc/fonts"
		cp -rL /etc/fonts/conf.d/60-latin.conf "${DESTDIR}/etc/fonts/conf.d"
		mkdir -p "${DESTDIR}/var/cache/fontconfig"
		# This is only needed because fc-cache bellow fails if the directory doesn't exist
		mkdir -p "${DESTDIR}/usr/local/share/fonts"

		# fonts-dejavu
		if [ -e /usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf ]
		then
			# jessie
			mkdir -p "${DESTDIR}/usr/share/fonts/truetype/dejavu"
			cp -a /usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf "${DESTDIR}/usr/share/fonts/truetype/dejavu"
			cp -a /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf  "${DESTDIR}/usr/share/fonts/truetype/dejavu"
		else
			# wheezy
			mkdir -p "${DESTDIR}/usr/share/fonts/truetype/ttf-dejavu"
			cp -a /usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf "${DESTDIR}/usr/share/fonts/truetype/ttf-dejavu"
			cp -a /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf  "${DESTDIR}/usr/share/fonts/truetype/ttf-dejavu"
		fi
		fc-cache -s -y "${DESTDIR}" > /dev/null 2>&1

		# pango
		if ls /usr/lib/@DEB_HOST_MULTIARCH@/pango/1* > /dev/null 2>&1
		then
			# wheezy
			PANGO_VERSION="$(ls /usr/lib/@DEB_HOST_MULTIARCH@/pango)"

			mkdir -p "${DESTDIR}/usr/lib/@DEB_HOST_MULTIARCH@/pango/${PANGO_VERSION}/module-files.d"
			mkdir -p "${DESTDIR}/usr/lib/@DEB_HOST_MULTIARCH@/pango/${PANGO_VERSION}/modules"
			cp /usr/lib/@DEB_HOST_MULTIARCH@/pango/${PANGO_VERSION}/module-files.d/libpango1.0-0.modules ${DESTDIR}/usr/lib/@DEB_HOST_MULTIARCH@/pango/${PANGO_VERSION}/module-files.d/
			copy_exec /usr/lib/@DEB_HOST_MULTIARCH@/pango/${PANGO_VERSION}/modules/pango-basic-fc.so
		else
			# jessie
			copy_exec /usr/lib/@DEB_HOST_MULTIARCH@/libpango-1.0.so.0
		fi
		;;
esac

# add drm modules
copy_modules_dir kernel/drivers/gpu/drm mga r128 savage sis tdfx via

# copy renderers
copy_exec /usr/lib/@DEB_HOST_MULTIARCH@/plymouth/renderers/frame-buffer.so
copy_exec /usr/lib/@DEB_HOST_MULTIARCH@/plymouth/renderers/drm.so

# copy config files
mkdir -p "${DESTDIR}/etc/plymouth"

if [ -r /etc/plymouth/plymouthd.conf ]
then
	cp -a /etc/plymouth/plymouthd.conf "${DESTDIR}/etc/plymouth/"
fi

cp -a /usr/share/plymouth/plymouthd.defaults "${DESTDIR}/usr/share/plymouth/"

# temporarily include dummy root account lookup (#691598)
if ! grep -qs '^root:' "${DESTDIR}/etc/passwd"
then
	echo "root:x:0:0:root:/root:/bin/sh" >> "${DESTDIR}/etc/passwd"
fi

if ! grep -qs '^passwd: files' "${DESTDIR}/etc/nsswitch.conf"
then
	echo "passwd: files" >> "${DESTDIR}/etc/nsswitch.conf"
fi

for _LIBRARY in /lib/@DEB_HOST_MULTIARCH@/libnss_files*
do
	if [ -e "${_LIBRARY}" ]
	then
		copy_exec "${_LIBRARY}"
	fi
done
bgstack15