diff options
author | Cecil Hugh Watson <knoppmyth@gmail.com> | 2009-09-26 01:57:08 (GMT) |
---|---|---|
committer | Cecil Hugh Watson <knoppmyth@gmail.com> | 2009-09-26 01:57:08 (GMT) |
commit | 7b29169fff9e7c624890c5edffe85def8a293136 (patch) | |
tree | 47753889faa3a2063b66d1c7e7681e703eb1b39a /abs/core/fbsplash | |
parent | c491dea779dac29afff3578bf8245943817c2339 (diff) | |
download | linhes_pkgbuild-7b29169fff9e7c624890c5edffe85def8a293136.zip linhes_pkgbuild-7b29169fff9e7c624890c5edffe85def8a293136.tar.gz linhes_pkgbuild-7b29169fff9e7c624890c5edffe85def8a293136.tar.bz2 |
LinHES 6.01.00
Diffstat (limited to 'abs/core/fbsplash')
-rw-r--r-- | abs/core/fbsplash/PKGBUILD | 56 | ||||
-rw-r--r-- | abs/core/fbsplash/__changelog | 4 | ||||
-rw-r--r-- | abs/core/fbsplash/darch.tar.bz2 | bin | 0 -> 1572821 bytes | |||
-rw-r--r-- | abs/core/fbsplash/extra/encrypt_hook.patch | 24 | ||||
-rw-r--r-- | abs/core/fbsplash/fbsplash.bootsteps | 1 | ||||
-rw-r--r-- | abs/core/fbsplash/fbsplash.conf | 8 | ||||
-rw-r--r-- | abs/core/fbsplash/fbsplash.daemon | 56 | ||||
-rw-r--r-- | abs/core/fbsplash/fbsplash.initcpio_install | 29 | ||||
-rw-r--r-- | abs/core/fbsplash/fbsplash.inithooks | 91 | ||||
-rw-r--r-- | abs/core/fbsplash/fbsplash.install | 33 | ||||
-rw-r--r-- | abs/core/fbsplash/splash-functions-arch.sh | 71 | ||||
-rw-r--r-- | abs/core/fbsplash/splash-functions.sh | 618 |
12 files changed, 991 insertions, 0 deletions
diff --git a/abs/core/fbsplash/PKGBUILD b/abs/core/fbsplash/PKGBUILD new file mode 100644 index 0000000..736da1f --- /dev/null +++ b/abs/core/fbsplash/PKGBUILD @@ -0,0 +1,56 @@ +# Maintainer: Greg Helton <gt@fallendusk.org> + +pkgname=fbsplash +pkgver=1.5.4.3 +pkgrel=15 +pkgdesc="A userspace implementation of a splash screen for Linux (formerly known as gensplash)" +arch=('i686' 'x86_64') +url="http://fbsplash.berlios.de" +license=('GPL') +backup=('etc/conf.d/fbsplash.conf' 'etc/conf.d/fbsplash.bootsteps') +makedepends=('klibc') +depends=('initscripts' 'miscsplashutils' 'libjpeg' 'libpng' 'freetype2-static' 'gpm' 'libmng' 'which' 'linhes-splash') +conflicts=('bootsplash' 'gensplash') +install=fbsplash.install +source=(http://download.berlios.de/fbsplash/splashutils-${pkgver}.tar.bz2 \ + http://code.thewrecker.net/files/darch.tar.bz2 \ + fbsplash.inithooks \ + splash-functions-arch.sh \ + fbsplash.conf \ + fbsplash.initcpio_install \ + fbsplash.daemon fbsplash.bootsteps) +build() { + cd ${startdir}/src/splashutils-${pkgver} + + # Configure, make, and install + ./configure --prefix=/usr --sysconfdir=/etc --enable-fbcondecor --with-gpm --with-mng --with-png --with-ttf --with-ttf-kernel + make || return 1 + cp -f ${startdir}/splash-functions.sh ${startdir}/src/splashutils-1.5.4.3/scripts/splash-functions.sh + make DESTDIR=${startdir}/pkg install || return 1 + + # Create directories + mkdir -p ${startdir}/pkg/lib/splash/cache + mkdir -p ${startdir}/pkg/etc/splash + mkdir -p ${startdir}/pkg/etc/rc.d/functions.d + + # Install scripts + install -D -m644 ${startdir}/src/fbsplash.initcpio_install ${startdir}/pkg/lib/initcpio/install/fbsplash + install -D -m644 ${startdir}/src/fbsplash.conf ${startdir}/pkg/etc/conf.d/fbsplash.conf + install -D -m744 ${startdir}/src/fbsplash.daemon ${startdir}/pkg/etc/rc.d/fbsplash + install -D -m744 ${startdir}/src/splash-functions-arch.sh ${startdir}/pkg/sbin/splash-functions-arch.sh + install -D -m755 $startdir/src/fbsplash.bootsteps ${startdir}/pkg/etc/conf.d/fbsplash.bootsteps + + # install darch fbsplash theme + cp -r ${startdir}/src/darch ${startdir}/pkg/etc/splash/darch + + # install initscripts hooks + install -D -m744 ${startdir}/src/fbsplash.inithooks ${startdir}/pkg/etc/rc.d/functions.d/fbsplash.sh + +} +md5sums=('c722cd4148817b9c50381d9bdc1ea6ef' + '4ea33e99330abf4a9a468ac8c0ba48ca' + '33b3c7c2050670db0e8b2efd9e088ed9' + '8ffb29400a2518b16f3dbca653855268' + '82ef6f37c2795db1b4fec0e6f8443c66' + '21380586a5dafbf7045886ea4374ab65' + 'bb5154529e4b5fbc701cf4540c15a61a') diff --git a/abs/core/fbsplash/__changelog b/abs/core/fbsplash/__changelog new file mode 100644 index 0000000..d673fc0 --- /dev/null +++ b/abs/core/fbsplash/__changelog @@ -0,0 +1,4 @@ +modify splash-functions to not use chvt for verbose +modify fbsplash.inithooks to not display "setting up splash" +added default value for fbsplash.bootsteps + diff --git a/abs/core/fbsplash/darch.tar.bz2 b/abs/core/fbsplash/darch.tar.bz2 Binary files differnew file mode 100644 index 0000000..0faab98 --- /dev/null +++ b/abs/core/fbsplash/darch.tar.bz2 diff --git a/abs/core/fbsplash/extra/encrypt_hook.patch b/abs/core/fbsplash/extra/encrypt_hook.patch new file mode 100644 index 0000000..f059048 --- /dev/null +++ b/abs/core/fbsplash/extra/encrypt_hook.patch @@ -0,0 +1,24 @@ +--- /lib/initcpio/hooks/encrypt 2008-09-12 12:29:38.000000000 -0400 ++++ encrypt.1 2008-10-28 08:13:34.000000000 -0400 +@@ -1,6 +1,7 @@ + # vim: set ft=sh: + # TODO this one needs some work to work with lots of different + # encryption schemes ++. /sbin/splash-functions.sh + run_hook () + { + /sbin/modprobe -a -q dm-crypt >/dev/null 2>&1 +@@ -59,6 +60,7 @@ run_hook () + fi + fi + # Ask for a passphrase ++ splash_verbose + if [ ${dopassphrase} -gt 0 ]; then + echo "" + echo "A password is required to access the ${cryptname} volume:" +@@ -119,4 +121,5 @@ run_hook () + fi + nuke ${ckeyfile} + fi ++ splash_silent + } diff --git a/abs/core/fbsplash/fbsplash.bootsteps b/abs/core/fbsplash/fbsplash.bootsteps new file mode 100644 index 0000000..7273c0f --- /dev/null +++ b/abs/core/fbsplash/fbsplash.bootsteps @@ -0,0 +1 @@ +25 diff --git a/abs/core/fbsplash/fbsplash.conf b/abs/core/fbsplash/fbsplash.conf new file mode 100644 index 0000000..ddd88f8 --- /dev/null +++ b/abs/core/fbsplash/fbsplash.conf @@ -0,0 +1,8 @@ +# +# fbsplash.conf +# + +THEMES="linhes" +SPLASH_TTYS="1 2 3 4 5 6" + +#EOF diff --git a/abs/core/fbsplash/fbsplash.daemon b/abs/core/fbsplash/fbsplash.daemon new file mode 100644 index 0000000..e615500 --- /dev/null +++ b/abs/core/fbsplash/fbsplash.daemon @@ -0,0 +1,56 @@ +#!/bin/bash + +source /etc/rc.conf +source /etc/rc.d/functions + +source /sbin/splash-functions.sh +source /etc/conf.d/fbsplash.conf + +case "$1" in + start) + if [ "$(fbcondecor_supported)" = "true" ] + then + THEME="linhes" + if [ -f /proc/cmdline ]; then + OPTIONS=$(grep -o 'splash=[^ ]*' /proc/cmdline) + for i in $(echo "${OPTIONS#*=}" | sed -e 's/,/ /g') + do + case ${i%:*} in + theme) THEME=${i#*:} ;; + esac + done + fi + stat_busy "Setting fbcondecor console images" + for TTY in ${SPLASH_TTYS}; do + fbcondecor_set_theme ${TTY} ${THEME} + done + stat_done + fi + save_boot_steps + splash_exit + ;; + + kill) + if [ "$(fbcondecor_supported)" = "true" ] + then + stat_busy "Disabling fbcondecor console images" + for TTY in ${SPLASH_TTYS}; do + fbcondecor_remove_theme ${TTY} + done + stat_done + fi + ;; + + restart) + $0 kill + sleep 1 + $1 start + ;; + + *) + echo "usage: $0 {start|restart|kill}" +esac +exit 0 + +#EOF + diff --git a/abs/core/fbsplash/fbsplash.initcpio_install b/abs/core/fbsplash/fbsplash.initcpio_install new file mode 100644 index 0000000..3fdd7e9 --- /dev/null +++ b/abs/core/fbsplash/fbsplash.initcpio_install @@ -0,0 +1,29 @@ + +install() { + [ -x /sbin/fbcondecor_helper ] || return 1 + + source /etc/conf.d/fbsplash.conf + [ -z "${THEME}" ] && THEME="linhes" + + add_binary "/sbin/fbcondecor_helper" + + add_device "/dev/null" c 1 3 + add_device "/dev/console" c 5 1 + add_device "/dev/tty0" c 4 0 + + for DIR in /dev /dev/fb /dev/misc /dev/vc /lib/splash/proc /lib/splash/sys + do + add_dir ${DIR} + done + + for THEME in ${THEMES} + do + add_full_dir "/etc/splash/${THEME}" + done +} + +help() { + echo "This hook includes Fbsplash in the initramfs image." +} + +#EOF diff --git a/abs/core/fbsplash/fbsplash.inithooks b/abs/core/fbsplash/fbsplash.inithooks new file mode 100644 index 0000000..c396b92 --- /dev/null +++ b/abs/core/fbsplash/fbsplash.inithooks @@ -0,0 +1,91 @@ +# fbsplash function.d script # +# Author: Greg Helton <gt@fallendusk.org> # + +# Who is calling? # +CALLER=$0 + +# splash stuff # +. /etc/conf.d/fbsplash.conf +. /sbin/splash-functions.sh + +# Redefine the stat functions # +stat_bkgd() { + printf "${C_OTHER}${PREFIX_REG} ${C_MAIN}${1}${C_CLEAR} " + deltext + printf " ${C_OTHER}[${C_BKGD}BKGD${C_OTHER}]${C_CLEAR} " +} + +stat_busy() { + printf "${C_OTHER}${PREFIX_REG} ${C_MAIN}${1}${C_CLEAR} " + printf "${SAVE_POSITION}" + deltext + printf " ${C_OTHER}[${C_BUSY}BUSY${C_OTHER}]${C_CLEAR} " + # This checks to see if we just brought up the lo interface in rc.sysinit # + # if so, start the progress bar # + if [ "${1}" == 'Bringing up loopback interface' ]; then + splash rc_init + fi + # Load variables # + var_load STEP_NR MAX_STEPS RC_MULTI RC_SYSINIT RC_SHUTDOWN + # Only update the splash progress if we're in sysinit, multi, or shutdown. # + if [[ "${SPLASH_RC_MULTI}" == "1" || "${SPLASH_RC_SYSINIT}" == "1" || "${SPLASH_RC_SHUTDOWN}" == "1" ]]; then + ((SPLASH_STEP_NR++)) + SPLASH_PROGRESS=$((100*${SPLASH_STEP_NR}/${SPLASH_MAX_STEPS})) + SPLASH_CURRENT_PROGRESS=${SPLASH_PROGRESS} + splash_update_progress ${SPLASH_PROGRESS} + var_save STEP_NR CURRENT_PROGRESS + fi + if [ "${SPLASH_RC_SHUTDOWN}" == "1" ]; then + save_shutdown_steps + fi + +} + +stat_done() { + deltext + printf " ${C_OTHER}[${C_DONE}DONE${C_OTHER}]${C_CLEAR} \n" +} + +stat_fail() { + deltext + printf " ${C_OTHER}[${C_FAIL}FAIL${C_OTHER}]${C_CLEAR} \n" + splash_verbose +} + +start_daemon() { + /etc/rc.d/$1 start +} + +# rc.sysinit # +if [ "$CALLER" == '/etc/rc.sysinit' ]; then +# echo "fbsplash: Setting up splash..." + splash_cache_prep + SPLASH_MAX_STEPS=$(load_boot_steps) + SPLASH_STEP_NR=0 + SPLASH_RC_MULTI=0 + SPLASH_RC_SYSINIT=1 + SPLASH_RC_SHUTDOWN=0 + var_save MAX_STEPS STEP_NR RC_MULTI RC_SYSINIT RC_SHUTDOWN +fi + +# rc.multi # +if [ "$CALLER" == '/etc/rc.multi' ]; then + SPLASH_RC_MULTI=1 + SPLASH_RC_SYSINIT=0 + var_save RC_MULTI RC_SYSINIT +fi + +# rc.shutdown # +if [ "$CALLER" == '/etc/rc.shutdown' ]; then +# echo "fbsplash: Setting up splash..." + splash_cache_prep + SPLASH_MAX_STEPS=$(load_shutdown_steps) + SPLASH_SHUTDOWN_STEPS=1 + SPLASH_STEP_NR=0 + SPLASH_RC_MULTI=0 + SPLASH_RC_SYSINIT=0 + SPLASH_RC_SHUTDOWN=1 + var_save MAX_STEPS STEP_NR RC_MULTI RC_SYSINIT RC_SHUTDOWN DAEMON_STEPS + splash rc_init +fi + diff --git a/abs/core/fbsplash/fbsplash.install b/abs/core/fbsplash/fbsplash.install new file mode 100644 index 0000000..2899857 --- /dev/null +++ b/abs/core/fbsplash/fbsplash.install @@ -0,0 +1,33 @@ + +post_install() { + echo ">" + echo "> ATTENTION!!!:" + echo "----------------------------------------------" + echo "> fbsplash has been rewritten and no longer depends " + echo "> on using a special initscripts. " + echo "> Please read http://wiki.archlinux.org/fbsplash " + echo "> for more details on the changes. " + echo "----------------------------------------------" + if ! [ -e /etc/conf.d/fbsplash.bootsteps ]; then + echo "" + echo "Creating step count files..." + echo "Note: The first boot's percentage will be wrong. " + echo "The scripts will update with the right steps after first boot" + echo "" + touch /etc/conf.d/fbsplash.bootsteps + touch /etc/conf.d/fbsplash.shutdownsteps + echo 25 > /etc/conf.d/fbsplash.bootsteps + echo 20 > /etc/conf.d/fbsplash.shutdownsteps + fi + echo 20 > /etc/conf.d/fbsplash.shutdownsteps +} + +post_upgrade() { + post_install +} + +op=$1 +shift +$op $* + +#EOF diff --git a/abs/core/fbsplash/splash-functions-arch.sh b/abs/core/fbsplash/splash-functions-arch.sh new file mode 100644 index 0000000..977ccef --- /dev/null +++ b/abs/core/fbsplash/splash-functions-arch.sh @@ -0,0 +1,71 @@ +# ArchLinux specific splash functions # +# Author: Greg Helton <gt@fallendusk.org> # + +splash_init() { + splash_setup + splash_start +} + +splash_exit() { + splash_comm_send "exit" + splash_cache_cleanup +} + +splash_update_progress() { + local PROGRESS + PROGRESS=$(($1*65535/100)) + splash_comm_send "progress ${PROGRESS}" + splash_comm_send "repaint" +} + +var_save() { +for i in $@ ; + do + local var + eval var=\$SPLASH_${i} + echo "SPLASH_$i=$(echo ${var})" > ${spl_cachedir}/${i} + done +} + +var_load() { +for i in $@ ; + do + local var + eval var=\$SPLASH_${i} + if [[ -z "$(echo ${var})" && -f ${spl_cachedir}/${i} ]] ; then + source ${spl_cachedir}/${i} + fi + done +} + +save_boot_steps() { + var_load STEP_NR + echo $SPLASH_STEP_NR > /etc/conf.d/fbsplash.bootsteps +} + +load_boot_steps() { + BOOT_STEPS=$(cat /etc/conf.d/fbsplash.bootsteps) + # Fail safe, so we don't divide by 0 + if [ $BOOT_STEPS = 0 ]; then + BOOT_STEPS=1 + fi + printf $BOOT_STEPS +} + +save_shutdown_steps() { + var_load SHUTDOWN_STEPS + ((SPLASH_SHUTDOWN_STEPS++)) + echo $SPLASH_SHUTDOWN_STEPS > /etc/conf.d/fbsplash.shutdownsteps + var_save SHUTDOWN_STEPS +} + +load_shutdown_steps() { + SHUTDOWN_STEPS=$(cat /etc/conf.d/fbsplash.shutdownsteps) + # Fail safe, so we don't divide by 0 + if [ $SHUTDOWN_STEPS = 0 ]; then + SHUTDOWN_STEPS=1 + fi + printf $SHUTDOWN_STEPS +} + +# EOF # diff --git a/abs/core/fbsplash/splash-functions.sh b/abs/core/fbsplash/splash-functions.sh new file mode 100644 index 0000000..1c17663 --- /dev/null +++ b/abs/core/fbsplash/splash-functions.sh @@ -0,0 +1,618 @@ +# Distributed under the terms of the GNU General Public License v2 + +# Author: Michal Januszewski <spock@gentoo.org> +# Maintainer: Michal Januszewski <spock@gentoo.org> + +# This file is a part of splashutils. The functions contained in this +# file are meant to be used by hook scripts in splash themes or by +# initscript systems. The code will be kept distro-agnostic to facilitate +# portability. It should also contain POSIX compatible code. No bashisms +# allowed! + +# #################################################################### +# Change any settings ONLY if you are sure what you're doing. +# Don't cry if it breaks afterwards. +# #################################################################### + +# The splash scripts need a cache which can be guaranteed to be +# both readable and writable at all times, even when the root fs +# is mounted read-only. To that end, an in-RAM fs is used. Valid +# values for spl_cachetype are 'tmpfs' and 'ramfs'. spl_cachesize +# is a size limit in KB, and it should probably be left with the +# default value. +export spl_cachesize="4096" +export spl_cachetype="tmpfs" +export spl_cachedir="//lib/splash/cache" +export spl_tmpdir="//lib/splash/tmp" +export spl_fifo="${spl_cachedir}/.splash" +export spl_pidfile="${spl_cachedir}/daemon.pid" +export spl_util="//bin/splash_util.static" +export spl_daemon="//sbin/fbsplashd.static" +export spl_decor="//sbin/fbcondecor_ctl.static" +export spl_bindir="//lib/splash/bin" + +# This is the main function which handles all events. +# Accepted parameters: +# svc_start <name> +# svc_stop <name> +# svc_started <name> +# svc_stopped <name> +# svc_start_failed <name> +# svc_stop_failed <name> +# svc_input_begin <name> +# svc_input_end <name> +# rc_init <internal_runlevel> - used to distinguish between 'boot' and 'sysinit' +# rc_exit +# critical +splash() { + local event="$1" + shift + + # Reload the splash settings in rc_init. We could have set them wrong the + # first time splash_setup was called (when splash-functions.sh was first + # sourced) if /proc wasn't mounted. + if [ "${event}" = "rc_init" ]; then + splash_setup "force" + else + splash_setup + fi + + [ "${SPLASH_MODE_REQ}" = "off" ] && return + + # Prepare the cache here -- rc_init-pre might want to use it + if [ "${event}" = "rc_init" ]; then + if [ "${RUNLEVEL}" = "S" -a "$1" = "sysinit" ]; then + splash_cache_prep 'start' || return + elif [ "${RUNLEVEL}" = "6" -o "${RUNLEVEL}" = "0" ]; then + # Check if the splash cachedir is mounted readonly. If it is, + # we need to mount a tmpfs over it. + if ! touch "${spl_cachedir}/message" 2>/dev/null ; then + splash_cache_prep 'stop' || return + fi + fi + fi + + local args="" + + if [ "${event}" = "rc_init" -o "${event}" = "rc_exit" ]; then + args="$* ${RUNLEVEL}" + elif [ "${event}" = "svc_started" -o "${event}" = "svc_stopped" ]; then + if [ -z "$2" ]; then + # Backwards compatibility hack. Add a 0 to the arguments to simulate + # an error code. + args="$* 0" + else + args="$*" + + # Backwards compatibility: translate an error condition (non-zero + # error code) into an appropriate event. + if [ "$2" != "0" ]; then + if [ "${event}" = "svc_started" ]; then + event="svc_start_failed" + else + event="svc_stop_failed" + fi + fi + fi + else + args="$*" + fi + + splash_profile "pre ${event} ${args}" + + # Handle -pre event hooks + if [ -x "/etc/splash/${SPLASH_THEME}/scripts/${event}-pre" ]; then + /etc/splash/"${SPLASH_THEME}"/scripts/${event}-pre ${args} + fi + + case "$event" in + svc_start) splash_svc_start "$1";; + svc_stop) splash_svc_stop "$1";; + svc_started) splash_svc "$1" "start";; + svc_stopped) splash_svc "$1" "stop";; + svc_start_failed) splash_svc_fail "$1" "start";; + svc_stop_failed) splash_svc_fail "$1" "stop";; + svc_input_begin) splash_input_begin "$1";; + svc_input_end) splash_input_end "$1";; + rc_init) splash_init "$1" "${RUNLEVEL}";; + rc_exit) splash_exit "${RUNLEVEL}";; + critical) splash_verbose;; + esac + + splash_profile "post ${event} ${args}" + + # Handle -post event hooks + if [ -x "/etc/splash/${SPLASH_THEME}/scripts/${event}-post" ]; then + /etc/splash/"${SPLASH_THEME}"/scripts/${event}-post ${args} + fi + + return 0 +} + +splash_setup() { + # If it's already set up, let's not waste time on parsing the config + # files again + if [ "${SPLASH_THEME}" != "" -a "${SPLASH_TTY}" != "" -a "$1" != "force" ]; then + return 0 + fi + + export SPLASH_EFFECTS="" + export SPLASH_SANITY="" + export SPLASH_TEXTBOX="no" + export SPLASH_MODE_REQ="off" + export SPLASH_PROFILE="off" + export SPLASH_THEME="default" + export SPLASH_TTY="16" + export SPLASH_KDMODE="TEXT" + export SPLASH_AUTOVERBOSE="0" + export SPLASH_BOOT_MESSAGE="Booting the system (\$progress%)... Press F2 for verbose mode." + export SPLASH_SHUTDOWN_MESSAGE="Shutting down the system (\$progress%)... Press F2 for verbose mode." + export SPLASH_REBOOT_MESSAGE="Rebooting the system (\$progress%)... Press F2 for verbose mode." + export SPLASH_XSERVICE="xdm" + + [ -f /etc/splash/splash ] && . /etc/splash/splash + [ -f /etc/conf.d/splash ] && . /etc/conf.d/splash + [ -f /etc/conf.d/fbcondecor ] && . /etc/conf.d/fbcondecor + + if [ -f /proc/cmdline ]; then + options=$(grep -o 'splash=[^ ]*' /proc/cmdline) + + # Execute this loop over $options so that we can process multiple + # splash= arguments on the kernel command line. Useful for adjusting + # splash parameters from ISOLINUX. + for opt in ${options} ; do + options=${opt#*=} + + for i in $(echo "${options}" | sed -e 's/,/ /g') ; do + case ${i%:*} in + theme) SPLASH_THEME=${i#*:} ;; + tty) SPLASH_TTY=${i#*:} ;; + verbose) SPLASH_MODE_REQ="verbose" ;; + silent) SPLASH_MODE_REQ="silent" ;; + kdgraphics) SPLASH_KDMODE="GRAPHICS" ;; + profile) SPLASH_PROFILE="on" ;; + insane) SPLASH_SANITY="insane" ;; + esac + done + done + fi +} + +splash_get_boot_message() { + if [ "${RUNLEVEL}" = "6" ]; then + echo "${SPLASH_REBOOT_MESSAGE}" + elif [ "${RUNLEVEL}" = "0" ]; then + echo "${SPLASH_SHUTDOWN_MESSAGE}" + else + echo "${SPLASH_BOOT_MESSAGE}" + fi +} + +splash_start() { + if [ "${SPLASH_MODE_REQ}" = "verbose" ]; then + ${spl_decor} -c on 2>/dev/null + return 0 + elif [ "${SPLASH_MODE_REQ}" != "silent" ]; then + return 0 + fi + + # Display a warning if the system is not configured to display init messages + # on tty1. This can cause a lot of problems if it's not handled correctly, so + # we don't allow silent splash to run on incorrectly configured systems. + if [ "${SPLASH_MODE_REQ}" = "silent" -a "${SPLASH_SANITY}" != "insane" ]; then + if [ -z "$(grep -E '(^| )CONSOLE=/dev/tty1( |$)' /proc/cmdline)" -a \ + -z "$(grep -E '(^| )console=tty1( |$)' /proc/cmdline)" ]; then + clear + splash_warn "You don't appear to have a correct console= setting on your kernel" + splash_warn "command line. Silent splash will not be enabled. Please add" + splash_warn "console=tty1 or CONSOLE=/dev/tty1 to your kernel command line" + splash_warn "to avoid this message." + if [ -n "$(grep 'CONSOLE=/dev/tty1' /proc/cmdline)" -o \ + -n "$(grep 'console=tty1' /proc/cmdline)" ]; then + splash_warn "Note that CONSOLE=/dev/tty1 and console=tty1 are general parameters and" + splash_warn "not splash= settings." + fi + return 1 + fi + + if [ -n "$(grep -E '(^| )CONSOLE=/dev/tty1( |$)' /proc/cmdline)" ]; then + mount -n --bind / ${spl_tmpdir} + if [ ! -c "${spl_tmpdir}/dev/tty1" ]; then + umount -n ${spl_tmpdir} + splash_warn "The filesystem mounted on / doesn't contain the /dev/tty1 device" + splash_warn "which is required for the silent splash to function properly." + splash_warn "Silent splash will not be enabled. Please create the appropriate" + splash_warn "device node to avoid this message." + return 1 + fi + umount -n ${spl_tmpdir} + fi + fi + + rm -f "${spl_pidfile}" + + # Prepare the communications FIFO + rm -f "${spl_fifo}" 2>/dev/null + mkfifo "${spl_fifo}" + + local options="" + [ "${SPLASH_KDMODE}" = "GRAPHICS" ] && options="--kdgraphics" + [ -n "${SPLASH_EFFECTS}" ] && options="${options} --effects=${SPLASH_EFFECTS}" + [ "${SPLASH_TEXTBOX}" = "yes" ] && options="${options} --textbox" + + local ttype="bootup" + if [ "${RUNLEVEL}" = "6" ]; then + ttype="reboot" + elif [ "${RUNLEVEL}" = "0" ]; then + ttype="shutdown" + fi + + # Start the splash daemon + BOOT_MSG="$(splash_get_boot_message)" ${spl_daemon} --theme="${SPLASH_THEME}" --pidfile="${spl_pidfile}" --type=${ttype} ${options} + + # Set the silent TTY and boot message + splash_comm_send "set tty silent ${SPLASH_TTY}" + + if [ "${SPLASH_MODE_REQ}" = "silent" ]; then + splash_comm_send "set mode silent" + splash_comm_send "repaint" + ${spl_decor} -c on 2>/dev/null + fi + + splash_comm_send "set autoverbose ${SPLASH_AUTOVERBOSE}" + + splash_set_event_dev + + return 0 +} + +########################################################################### +# Cache-related functions +########################################################################### + +splash_cache_prep() { + # Mount an in-RAM filesystem at spl_cachedir + mount -ns -t "${spl_cachetype}" cachedir "${spl_cachedir}" \ + -o rw,mode=0644,size="${spl_cachesize}"k + + retval="$?" + + if [ ${retval} -ne 0 ]; then + splash_err "Unable to create splash cache - switching to verbose." + splash_verbose + return "${retval}" + fi +} + +# args: list of files to save when the cache is umounted +# Note that the 'profile' file is already handled and thus shouldn't +# be included in the list. +splash_cache_cleanup() { + # Don't try to clean anything up if the cachedir is not mounted. + [ -z "$(grep ${spl_cachedir} /proc/mounts)" ] && return; + + # Create the temp dir if necessary. + if [ ! -d "${spl_tmpdir}" ]; then + mkdir -p "${spl_tmpdir}" 2>/dev/null + [ "$?" != "0" ] && return + fi + + # Make sure the splash daemon is dead. + if [ -n "$(pgrep fbsplashd)" ]; then + sleep 1 + killall -9 "${spl_daemon##*/}" 2>/dev/null + fi + + # If /etc is not writable, don't update /etc/mtab. If it is + # writable, update it to avoid stale mtab entries (bug #121827). + local mntopt="" + [ -w /etc/mtab ] || mntopt="-n" + mount ${mntopt} --move "${spl_cachedir}" "${spl_tmpdir}" 2>/dev/null + + # Don't try to copy anything if the cachedir is not writable. + [ -w "${spl_cachedir}" ] || return + + if [ "${SPLASH_PROFILE}" != "off" ]; then + cp -a "${spl_tmpdir}/profile" "${spl_cachedir}" 2>/dev/null + fi + + while [ -n "$1" ]; do + cp -a "${spl_tmpdir}/$1" "${spl_cachedir}" 2>/dev/null + shift + done + + umount -l "${spl_tmpdir}" 2>/dev/null +} + +########################################################################### +# Common functions +########################################################################### + +# Sends data to the splash FIFO after making sure there's someone +# alive on the other end to receive it. +splash_comm_send() { + if [ -z "`pidof $(basename ${spl_daemon})`" ]; then + return 1 + else + splash_profile "comm $*" + echo "$*" > "${spl_fifo}" & + fi +} + +# Returns the current splash mode. +splash_get_mode() { + local ctty="${spl_bindir}/fgconsole" + local mode="$(${spl_util})" + + if [ "${mode}" = "silent" ]; then + echo "silent" + else + if [ -z "$(${spl_decor} -c getstate --tty=${ctty} 2>/dev/null | grep off)" ]; then + echo "verbose" + else + echo "off" + fi + fi +} + +# chvt <n> +# -------- +# Switches to the n-th tty. +chvt() { + local ntty=$1 + +# if [ -x /usr/bin/chvt ] ; then +# /usr/bin/chvt ${ntty} +# else + printf "\e[12;${ntty}]" +# fi +} + +# Switches to verbose mode. +splash_verbose() { +# chvt 1 +/bin/true +} + +# Switches to silent mode. +splash_silent() { + splash_comm_send "set mode silent" +} + +# Saves profiling information +splash_profile() { + if [ "${SPLASH_PROFILE}" = "on" ]; then + echo "$(cat /proc/uptime | cut -f1 -d' '): $*" >> "${spl_cachedir}/profile" + fi +} + +# Set the input device if it exists. This will make it possible to use F2 to +# switch from verbose to silent. +splash_set_event_dev() { + local t="$(grep -Hsi keyboard /sys/class/input/input*/name | sed -e 's#.*input\([0-9]*\)/name.*#event\1#')" + if [ -z "${t}" ]; then + t="$(grep -Hsi keyboard /sys/class/input/event*/device/driver/description | grep -o 'event[0-9]\+')" + if [ -z "${t}" ]; then + for i in /sys/class/input/input* ; do + if [ "$((0x$(cat $i/capabilities/ev) & 0x100002))" = "1048578" ]; then + t="$(echo $i | sed -e 's#.*input\([0-9]*\)#event\1#')" + fi + done + + if [ -z "${t}" ]; then + # Try an alternative method of finding the event device. The idea comes + # from Bombadil <bombadil(at)h3c.de>. We're couting on the keyboard controller + # being the first device handled by kbd listed in input/devices. + t="$(/bin/grep -s -m 1 '^H: Handlers=kbd' /proc/bus/input/devices | grep -o 'event[0-9]*')" + fi + fi + fi + [ -n "${t}" ] && splash_comm_send "set event dev /dev/input/${t}" +} + +########################################################################### +# Service +########################################################################### + +# args: <svc> <action> +splash_svc() { + local srv="$1" + local act="$2" + + if [ "${act}" = "start" ]; then + splash_svc_update "${srv}" "svc_started" + if [ "${srv}" = "gpm" ]; then + splash_comm_send "set gpm" + splash_comm_send "repaint" + fi + splash_comm_send "log Service '${srv}' started." + else + splash_svc_update "${srv}" "svc_stopped" + splash_comm_send "log Service '${srv}' stopped." + fi + + splash_update_progress "${srv}" +} + +# args: <svc> <action> +splash_svc_fail() { + local srv="$1" + local act="$2" + + if [ "${SPLASH_VERBOSE_ON_ERRORS}" = "yes" ]; then + splash_verbose + return 1 + fi + + if [ "${act}" = "start" ]; then + splash_svc_update "${srv}" "svc_start_failed" + splash_comm_send "log Service '${srv}' failed to start." + else + splash_svc_update "${srv}" "svc_stop_failed" + splash_comm_send "log Service '${srv}' failed to stop." + fi + + splash_update_progress "${srv}" +} + +# args: <svc> <state> +# +# Inform the splash daemon about service status changes. +splash_svc_update() { + splash_comm_send "update_svc $1 $2" +} + +# args: <svc> +splash_svc_start() { + local svc="$1" + + splash_svc_update "${svc}" "svc_start" + splash_comm_send "paint" +} + +# args: <svc> +splash_svc_stop() { + local svc="$1" + + splash_svc_update "${svc}" "svc_stop" + splash_comm_send "paint" +} + +# args: <svc> +splash_input_begin() { + local svc="$1" + + if [ "$(splash_get_mode)" = "silent" ]; then + splash_verbose + export SPL_SVC_INPUT_SILENT="${svc}" + fi +} + +# args: <svc> +splash_input_end() { + local svc="$1" + + if [ "${SPL_SVC_INPUT_SILENT}" = "${svc}" ]; then + splash_silent + unset SPL_SVC_INPUT_SILENT + fi +} + +########################################################################### +# Framebuffer Console Decorations functions +########################################################################### + +fbcondecor_supported() +{ + [ -e /dev/fbsplash -o -e /dev/fbcondecor ] +} + +# args: <theme> <tty> +fbcondecor_set_theme() +{ + local theme=$1 + local tty=$2 + + [ -x ${spl_decor} ] || return 1 + + ${spl_decor} --tty="${tty}" -t "${theme}" -c setcfg || return 1 + ${spl_decor} --tty="${tty}" -t "${theme}" -c setpic -q + ${spl_decor} --tty="${tty}" -c on +} + +########################################################################### +# Service list +########################################################################### + +# splash_svclist_get <type> +# ------------------------- +# type: +# - start - to get a list of services to be started during bootup +# - stop - to get a list of services to be stopped during shutdown/reboot +splash_svclist_get() { + if [ "$1" = "start" -a -r "${spl_cachedir}/svcs_start" ]; then + cat "${spl_cachedir}/svcs_start" + elif [ "$1" = "stop" -a -r "${spl_cachedir}/svcs_stop" ]; then + cat "${spl_cachedir}/svcs_stop" + fi +} + +splash_warn() { + echo "$*" +} + +splash_err() { + echo "$*" +} + +############################################################################ +# Functions to be overridden by distro-specific code +########################################################################### + +# args: <internal_runlevel> <runlevel> +# +# This function is called when an 'rc_init' event takes place, +# i.e. when the runlevel is changed. + +# It is normally used to initialize any internal splash-related +# variables (e.g. ones used to track the boot progress), calculate +# and save the service list and call `splash_start` in appropriate +# runlevels. +# +# Note that the splash cache is already intialized when this +# function is called. +splash_init() { + if [ "$2" = "6" -o "$2" = "0" -o "$2" = "S" -a "$1" = "sysinit" ]; then + splash_start + fi +} + +# args: <runlevel> +# +# This function is called when an 'rc_exit' event takes place, +# i.e. at the end of processes all initscript from a runlevel. +splash_exit() { + # If we're in sysinit or rebooting, do nothing. + [ "$1" = "S" -o "$1" = "6" -o "$1" = "0" ] && return 0 + + splash_comm_send "exit" + splash_cache_cleanup +} + +# args: <svc> +# +# This function is called whenever the progress variable should be +# updated. It should recalculate the progress and send it to the +# splash daemon. +splash_update_progress() { + # splash_comm_send "progress ${progress}" + # splash_comm_send "paint" + return +} + +# Export functions if we're running bash. +if [ -n "${BASH}" ]; then + export -f splash + export -f splash_setup + export -f splash_get_boot_message + export -f splash_start + export -f splash_cache_prep + export -f splash_cache_cleanup + export -f splash_comm_send + export -f splash_get_mode + export -f chvt + export -f splash_verbose + export -f splash_silent + export -f splash_profile + export -f splash_set_event_dev + export -f splash_svclist_get +fi + +# Load any supplementary splash functions. +for i in /sbin/splash-functions-*.sh ; do + [ -r "${i}" ] && . "${i}" +done + +splash_setup + +# vim:ts=4 |