initrd.scripts: move splash functions to a separate file

Start to make the genkernel code a bit modular. Also add initrd.d
support to gen_initramfs.sh
master
Fabio Erculiani 12 years ago
parent f0775326eb
commit 90983b4fd2

@ -0,0 +1,116 @@
#!/bin/sh
splash() {
return 0
}
[ -e "${INITRD_SPLASH}" ] && . "${INITRD_SPLASH}"
is_fbsplash() {
if [ -e "${INITRD_SPLASH}" ] && [ "${FBSPLASH}" = '1' ]
then
return 0
fi
return 1
}
is_plymouth() {
if [ "${PLYMOUTH}" = '1' ] && [ "${QUIET}" = '1' ] \
&& [ -e "${PLYMOUTHD_BIN}" ]
then
return 0
fi
return 1
}
is_plymouth_started() {
[ -n "${PLYMOUTH_FAILURE}" ] && return 1
is_plymouth && "${PLYMOUTH_BIN}" --ping 2>/dev/null && return 0
return 1
}
splashcmd() {
# plymouth support
local cmd="${1}"
shift
case "${cmd}" in
init)
is_fbsplash && splash init
is_plymouth && plymouth_init
;;
verbose)
is_fbsplash && splash verbose
plymouth_hide
;;
quiet)
# no fbsplash support
plymouth_show
;;
set_msg)
is_fbsplash && splash set_msg "${1}"
plymouth_message "${1}"
;;
hasroot)
# no fbsplash support
plymouth_newroot "${1}"
;;
esac
}
plymouth_init() {
good_msg "Enabling Plymouth"
mkdir -p /run/plymouth || return 1
# Make sure that udev is done loading tty and drm
if is_udev
then
udevadm trigger --action=add --attr-match=class=0x030000 \
>/dev/null 2>&1
udevadm trigger --action=add --subsystem-match=graphics \
--subsystem-match=drm --subsystem-match=tty \
>/dev/null 2>&1
udevadm settle
fi
local consoledev=
local other=
read consoledev other < /sys/class/tty/console/active
consoledev=${consoledev:-tty0}
"${PLYMOUTHD_BIN}" --attach-to-session --pid-file /run/plymouth/pid \
|| {
bad_msg "Plymouth load error";
PLYMOUTH_FAILURE=1
return 1;
}
plymouth_show
good_msg "Plymouth enabled"
}
plymouth_hide() {
is_plymouth_started && "${PLYMOUTH_BIN}" --hide-splash
}
plymouth_show() {
is_plymouth_started && "${PLYMOUTH_BIN}" --show-splash
}
plymouth_message() {
is_plymouth_started && "${PLYMOUTH_BIN}" --update="${1}"
}
plymouth_newroot() {
is_plymouth_started && "${PLYMOUTH_BIN}" --newroot="${1}"
}
splash_init() {
if is_udev; then
# if udev, we can load the splash earlier
# In the plymouth case, udev will load KMS automatically
splashcmd init
fi
}

@ -1,121 +1,8 @@
#!/bin/sh #!/bin/sh
. /etc/initrd.defaults . /etc/initrd.defaults
. /etc/initrd.d/00-splash.sh
splash() {
return 0
}
[ -e "${INITRD_SPLASH}" ] && . "${INITRD_SPLASH}"
is_fbsplash() {
if [ -e "${INITRD_SPLASH}" ] && [ "${FBSPLASH}" = '1' ]
then
return 0
fi
return 1
}
is_plymouth() {
if [ "${PLYMOUTH}" = '1' ] && [ "${QUIET}" = '1' ] \
&& [ -e "${PLYMOUTHD_BIN}" ]
then
return 0
fi
return 1
}
is_plymouth_started() {
[ -n "${PLYMOUTH_FAILURE}" ] && return 1
is_plymouth && "${PLYMOUTH_BIN}" --ping 2>/dev/null && return 0
return 1
}
splashcmd() {
# plymouth support
local cmd="${1}"
shift
case "${cmd}" in
init)
is_fbsplash && splash init
is_plymouth && plymouth_init
;;
verbose)
is_fbsplash && splash verbose
plymouth_hide
;;
quiet)
# no fbsplash support
plymouth_show
;;
set_msg)
is_fbsplash && splash set_msg "${1}"
plymouth_message "${1}"
;;
hasroot)
# no fbsplash support
plymouth_newroot "${1}"
;;
esac
}
plymouth_init() {
good_msg "Enabling Plymouth"
mkdir -p /run/plymouth || return 1
# Make sure that udev is done loading tty and drm
if is_udev
then
udevadm trigger --action=add --attr-match=class=0x030000 \
>/dev/null 2>&1
udevadm trigger --action=add --subsystem-match=graphics \
--subsystem-match=drm --subsystem-match=tty \
>/dev/null 2>&1
udevadm settle
fi
local consoledev=
local other=
read consoledev other < /sys/class/tty/console/active
consoledev=${consoledev:-tty0}
"${PLYMOUTHD_BIN}" --attach-to-session --pid-file /run/plymouth/pid \
|| {
bad_msg "Plymouth load error";
PLYMOUTH_FAILURE=1
return 1;
}
plymouth_show
good_msg "Plymouth enabled"
}
plymouth_hide() {
is_plymouth_started && "${PLYMOUTH_BIN}" --hide-splash
}
plymouth_show() {
is_plymouth_started && "${PLYMOUTH_BIN}" --show-splash
}
plymouth_message() {
is_plymouth_started && "${PLYMOUTH_BIN}" --update="${1}"
}
plymouth_newroot() {
is_plymouth_started && "${PLYMOUTH_BIN}" --newroot="${1}"
}
splash_init() {
if is_udev; then
# if udev, we can load the splash earlier
# In the plymouth case, udev will load KMS automatically
splashcmd init
fi
}
call_func_timeout() { call_func_timeout() {
local func=$1 timeout=$2 pid watcher local func=$1 timeout=$2 pid watcher

@ -843,6 +843,15 @@ append_auxilary() {
cp "${GK_SHARE}/defaults/initrd.scripts" "${TEMP}/initramfs-aux-temp/etc/initrd.scripts" cp "${GK_SHARE}/defaults/initrd.scripts" "${TEMP}/initramfs-aux-temp/etc/initrd.scripts"
fi fi
if [ -d "${GK_SHARE}/arch/${ARCH}/initrd.d" ]
then
cp -r "${GK_SHARE}/arch/${ARCH}/initrd.d" \
"${TEMP}/initramfs-aux-temp/etc/"
else
cp -r "${GK_SHARE}/defaults/initrd.d" \
"${TEMP}/initramfs-aux-temp/etc/"
fi
if [ -f "${GK_SHARE}/arch/${ARCH}/initrd.defaults" ] if [ -f "${GK_SHARE}/arch/${ARCH}/initrd.defaults" ]
then then
cp "${GK_SHARE}/arch/${ARCH}/initrd.defaults" "${TEMP}/initramfs-aux-temp/etc/initrd.defaults" cp "${GK_SHARE}/arch/${ARCH}/initrd.defaults" "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
@ -879,6 +888,7 @@ append_auxilary() {
chmod +x "${TEMP}/initramfs-aux-temp/init" chmod +x "${TEMP}/initramfs-aux-temp/init"
chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.scripts" chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.scripts"
chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.defaults" chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.d/"*
if isTrue ${NETBOOT} if isTrue ${NETBOOT}
then then

Loading…
Cancel
Save