1
0
mirror of https://github.com/dguglielmi/sunny-overlay.git synced 2025-12-06 16:02:39 +01:00

- Add media-gfx/splashutils for Gentoo tree

This commit is contained in:
2014-08-03 12:12:00 +02:00
parent abe86108f6
commit a8b93a603f
26 changed files with 3295 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
--- initrd.splash 2008-11-13 23:49:00.000000000 +0100
+++ initrd.splash.new 2010-07-27 21:35:24.647912782 +0200
@@ -26,7 +26,7 @@
init)
if [ -n "$2" ]; then
export BOOT_MSG="$2"
- elif [ "${CDROOT}" -eq '1' ]; then
+ elif [ "${CDROOT}" = '1' ]; then
export BOOT_MSG="Preparing the LiveCD environment... Press Alt+F1 for verbose mode."
else
export BOOT_MSG="Preparing the system for boot... Press Alt+F1 for verbose mode."

View File

@@ -0,0 +1,110 @@
diff --git a/core/src/daemon.c b/core/src/daemon.c
index e3463fc..eae23ec 100644
--- a/core/src/daemon.c
+++ b/core/src/daemon.c
@@ -306,6 +306,35 @@ void handler_alarm(int unused)
return;
}
+int process_switch_sig(int sig)
+{
+ /* Switch from silent to verbose. */
+ if (sig == SIGUSR1) {
+ pthread_mutex_lock(&mtx_paint);
+ pthread_mutex_lock(&mtx_tty);
+ ioctl(fd_tty[config.tty_s], VT_RELDISP, 1);
+ pthread_mutex_unlock(&mtx_tty);
+
+ ctty = CTTY_VERBOSE;
+ pthread_mutex_unlock(&mtx_paint);
+ return 1;
+ /* Switch back to silent. */
+ } else if (sig == SIGUSR2) {
+ pthread_mutex_lock(&mtx_paint);
+ pthread_mutex_lock(&mtx_tty);
+ ioctl(fd_tty[config.tty_s], VT_RELDISP, 2);
+ pthread_mutex_unlock(&mtx_tty);
+
+ ctty = CTTY_SILENT;
+ pthread_mutex_unlock(&mtx_paint);
+
+ switch_silent();
+ return 2;
+ }
+
+ return 0;
+}
+
/*
* Signal handler.
*
@@ -315,7 +344,7 @@ void handler_alarm(int unused)
*/
void* thf_sighandler(void *unusued)
{
- sigset_t sigset;
+ sigset_t sigset, sigset_switch;
int sig;
/* We don't handle SIGALRM. */
@@ -329,31 +358,39 @@ void* thf_sighandler(void *unusued)
sigaddset(&sigset, SIGTERM);
sigaddset(&sigset, SIGINT);
+ sigemptyset(&sigset_switch);
+ sigaddset(&sigset_switch, SIGUSR1);
+ sigaddset(&sigset_switch, SIGUSR2);
+
while (1) {
sigwait(&sigset, &sig);
- /* Switch from silent to verbose. */
- if (sig == SIGUSR1) {
- pthread_mutex_lock(&mtx_paint);
- pthread_mutex_lock(&mtx_tty);
- ioctl(fd_tty[config.tty_s], VT_RELDISP, 1);
- pthread_mutex_unlock(&mtx_tty);
-
- ctty = CTTY_VERBOSE;
- pthread_mutex_unlock(&mtx_paint);
- /* Switch back to silent. */
- } else if (sig == SIGUSR2) {
- pthread_mutex_lock(&mtx_paint);
- pthread_mutex_lock(&mtx_tty);
- ioctl(fd_tty[config.tty_s], VT_RELDISP, 2);
- pthread_mutex_unlock(&mtx_tty);
-
- ctty = CTTY_SILENT;
- pthread_mutex_unlock(&mtx_paint);
+ process_switch_sig(sig);
+
+ /* Internally generated terminate signal */
+ if (sig == SIGINT) {
+ struct timespec timeout;
+ timeout.tv_sec = 0;
+ timeout.tv_nsec = 0;
+ bool pending = true;
+
+ /*
+ * Process any remaining signals. There are no guarantees as to the
+ * order in which the signals are delivered, so we have to make sure
+ * all pending signals are processed before exiting.
+ */
+ while (pending) {
+ sig = sigtimedwait(&sigset_switch, NULL, &timeout);
+
+ if (sig == -1) {
+ /* No more pending signals. */
+ if (errno == EAGAIN)
+ pending = false;
+ } else {
+ process_switch_sig(sig);
+ }
+ }
- switch_silent();
- } else if (sig == SIGINT) {
- /* internally generated terminate signal */
do_cleanup();
pthread_exit(NULL);
} else if (sig == SIGTERM) {

View File

@@ -0,0 +1,55 @@
diff --git a/gentoo/splash.c b/gentoo/splash.c
index b6fa774..726315f 100644
--- a/gentoo/splash.c
+++ b/gentoo/splash.c
@@ -134,6 +134,19 @@ static void get_list(RC_STRINGLIST *list, const char *file)
}
}
+static void fix_rc_variable(char *s)
+{
+ do {
+ char *t = strstr(s, "\\$");
+
+ if (t) {
+ memmove(t, t+1, strlen(t));
+ } else {
+ break;
+ }
+ } while(1);
+}
+
/*
* Get splash settings from /etc/conf.d/splash
*/
@@ -189,21 +202,27 @@ static int splash_config_gentoo(fbspl_cfg_t *cfg, fbspl_type_t type)
switch(type) {
case fbspl_reboot:
t = rc_config_value(confd, "SPLASH_REBOOT_MESSAGE");
- if (t)
+ if (t) {
+ fix_rc_variable(t);
fbsplash_acc_message_set(t);
+ }
break;
case fbspl_shutdown:
t = rc_config_value(confd, "SPLASH_SHUTDOWN_MESSAGE");
- if (t)
+ if (t) {
+ fix_rc_variable(t);
fbsplash_acc_message_set(t);
+ }
break;
case fbspl_bootup:
default:
t = rc_config_value(confd, "SPLASH_BOOT_MESSAGE");
- if (t)
+ if (t) {
+ fix_rc_variable(t);
fbsplash_acc_message_set(t);
+ }
break;
}

View File

@@ -0,0 +1,36 @@
diff --git a/core/libs/Makefile.am b/core/libs/Makefile.am
index d070b29..c0a9258 100644
--- a/core/libs/Makefile.am
+++ b/core/libs/Makefile.am
@@ -53,7 +53,7 @@ libfreetype.a: klibc_compat.h
if ! $(MAKE) --question $(AM_MAKEFLAGS) CFLAGS="$(K_CFLAGS)" library ; then \
$(call infmsg,MAKE,libfreetype.a) ; \
fi ; \
- $(MAKE) $(AM_MAKEFLAGS) CFLAGS="-c $(K_CFLAGS)" CCexe="$(BUILD_CC)" library $(OUTPUT)
+ $(MAKE) $(AM_MAKEFLAGS) CFLAGS="-c $(K_CFLAGS)" CCexe="$(BUILD_CC)" ANSIFLAGS="" library $(OUTPUT)
$(Q)$(MKDIR_P) $(@D)
$(Q)cp -f libfreetype/.libs/libfreetype.a $@
@@ -62,18 +62,18 @@ libjpeg.a:
$(Q)cd libjpeg ; \
if test ! -e ./Makefile ; then \
$(call infmsg,CONF,libjpeg.a) ; \
- CC=$(KLCC) CFLAGS="$(K_CFLAGS) -I$(abs_top_builddir)/libs/libjpeg" $(LIBJPEG_SOURCE)/configure \
+ CC=$(KLCC) CFLAGS="$(K_CFLAGS) -I$(abs_top_builddir)/libs/libjpeg -include $(abs_top_srcdir)/libs/klibc_compat.h" $(LIBJPEG_SOURCE)/configure \
--host=$(host) --build=$(build_triplet) $(OUTPUT) ; \
echo "#define NO_GETENV 1" >> jconfig.h ; \
$(SED) -i "s#CFLAGS=.*#CFLAGS=$(K_CFLAGS) -I$(abs_top_builddir)/libs/libjpeg#" Makefile ; \
$(SED) -i "s:#define JMESSAGE.*::" $(LIBJPEG_SOURCE)/jerror.c ; \
fi ; \
- if ! $(MAKE) --question $(AM_MAKEFLAGS) CC="$(KLCC)" libjpeg.a ; then \
+ if ! $(MAKE) --question $(AM_MAKEFLAGS) CC="$(KLCC)" libjpeg.la ; then \
$(call infmsg,MAKE,libjpeg.a) ; \
fi ; \
- $(MAKE) $(AM_MAKEFLAGS) CC="$(KLCC)" libjpeg.a $(OUTPUT)
+ $(MAKE) $(AM_MAKEFLAGS) CC="$(KLCC)" libjpeg.la $(OUTPUT)
$(Q)$(MKDIR_P) $(@D)
- $(Q)cp -f libjpeg/libjpeg.a $@
+ $(Q)cp -f libjpeg/.libs/libjpeg.a $@
libpng.a: libz.a
$(Q)cd $(LIBPNG_SOURCE) ; \

View File

@@ -0,0 +1,96 @@
commit 1b760b583f1faa0d3114440a6746cbefa36dd797
Author: AlphatPC <AlphatPC@gmail.com>
Date: Sun May 8 17:18:03 2011 +0200
Use libpng accessor functions (for libpng-1.5 compat).
diff --git a/core/src/image.c b/core/src/image.c
index 6973575..4fb21a9 100644
--- a/core/src/image.c
+++ b/core/src/image.c
@@ -61,27 +61,27 @@ static int load_png(stheme_t *theme, char *filename, u8 **data, struct fb_cmap *
png_init_io(png_ptr, fp);
png_read_info(png_ptr, info_ptr);
- if (cmap && info_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
+ if (cmap && png_get_color_type(png_ptr, info_ptr) != PNG_COLOR_TYPE_PALETTE)
return -2;
- if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
- info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY ||
+ png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(png_ptr);
- if (info_ptr->bit_depth == 16)
+ if (png_get_bit_depth(png_ptr, info_ptr) == 16)
png_set_strip_16(png_ptr);
- if (!want_alpha && info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
+ if (!want_alpha && png_get_color_type(png_ptr, info_ptr) & PNG_COLOR_MASK_ALPHA)
png_set_strip_alpha(png_ptr);
#ifndef TARGET_KERNEL
- if (!(info_ptr->color_type & PNG_COLOR_MASK_ALPHA) & want_alpha) {
+ if (!(png_get_color_type(png_ptr, info_ptr) & PNG_COLOR_MASK_ALPHA) & want_alpha) {
png_set_add_alpha(png_ptr, 0xff, PNG_FILLER_AFTER);
}
#endif
png_read_update_info(png_ptr, info_ptr);
- if (!cmap && info_ptr->color_type != PNG_COLOR_TYPE_RGB && info_ptr->color_type != PNG_COLOR_TYPE_RGBA)
+ if (!cmap && png_get_color_type(png_ptr, info_ptr) != PNG_COLOR_TYPE_RGB && png_get_color_type(png_ptr, info_ptr) != PNG_COLOR_TYPE_RGBA)
return -3;
if (cmap) {
@@ -93,12 +93,12 @@ static int load_png(stheme_t *theme, char *filename, u8 **data, struct fb_cmap *
rowbytes = png_get_rowbytes(png_ptr, info_ptr);
- if ((width && *width && info_ptr->width != *width) || (height && *height && info_ptr->height != *height)) {
+ if ((width && *width && png_get_image_width(png_ptr, info_ptr) != *width) || (height && *height && png_get_image_height(png_ptr, info_ptr) != *height)) {
iprint(MSG_ERROR, "Image size mismatch: %s.\n", filename);
return -2;
} else {
- *width = info_ptr->width;
- *height = info_ptr->height;
+ *width = png_get_image_width(png_ptr, info_ptr);
+ *height = png_get_image_height(png_ptr, info_ptr);
}
*data = malloc(theme->xres * theme->yres * fbd.bytespp);
@@ -114,11 +114,11 @@ static int load_png(stheme_t *theme, char *filename, u8 **data, struct fb_cmap *
return -4;
}
- for (i = 0; i < info_ptr->height; i++) {
+ for (i = 0; i < png_get_image_height(png_ptr, info_ptr); i++) {
if (cmap) {
- row_pointer = *data + info_ptr->width * i;
+ row_pointer = *data + png_get_image_width(png_ptr, info_ptr) * i;
} else if (want_alpha) {
- row_pointer = *data + info_ptr->width * i * 4;
+ row_pointer = *data + png_get_image_width(png_ptr, info_ptr) * i * 4;
} else {
row_pointer = buf;
}
@@ -127,7 +127,7 @@ static int load_png(stheme_t *theme, char *filename, u8 **data, struct fb_cmap *
if (cmap) {
int h = 256 - cmap->len;
- t = *data + info_ptr->width * i;
+ t = *data + png_get_image_width(png_ptr, info_ptr) * i;
if (h) {
/* Move the colors up by 'h' offset. This is used because fbcon
@@ -139,8 +139,8 @@ static int load_png(stheme_t *theme, char *filename, u8 **data, struct fb_cmap *
/* We only need to convert the image if the alpha channel is not required */
} else if (!want_alpha) {
- u8 *tmp = *data + info_ptr->width * bytespp * i;
- rgba2fb((rgbacolor*)buf, tmp, tmp, info_ptr->width, i, 0, 0xff);
+ u8 *tmp = *data + png_get_image_width(png_ptr, info_ptr) * bytespp * i;
+ rgba2fb((rgbacolor*)buf, tmp, tmp, png_get_image_width(png_ptr, info_ptr), i, 0, 0xff);
}
}

View File

@@ -0,0 +1,27 @@
diff --git a/core/src/Makefile.am b/core/src/Makefile.am
index 20cb03e..fa6919d 100644
--- a/core/src/Makefile.am
+++ b/core/src/Makefile.am
@@ -119,7 +119,7 @@ libfbsplashrender_la_SOURCES = \
fbsplash.h
libfbsplashrender_la_CFLAGS = $(AM_CFLAGS)
libfbsplashrender_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(libfbsplashrender_version)
-libfbsplashrender_la_LIBADD = -lfbsplash
+libfbsplashrender_la_LIBADD = libfbsplash.la
libfbsplashrender_la_CFLAGS += $(JPEG_CFLAGS)
libfbsplashrender_la_LIBADD += $(JPEG_LIBS)
@@ -258,10 +258,10 @@ fbcondecor_helper_LDFLAGS += -static
endif
# Override automake's generation of target rules for building fbcondecor_helper.
-fbcondecor_helper: $(fbcondecor_helper_LDADD) $(fbcondecor_helper_OBJECTS)
+fbcondecor_helper: $(fbcondecor_helper_LDADD) $(fbcondecor_helper_OBJECTS) $(lib_LTLIBRARIES)
@$(call infmsg,LD,$@)
$(Q)$(MKDIR_P) $(@D)
- $(Q)$(KLCC) $(fbcondecor_helper_CFLAGS) $(fbcondecor_helper_LDFLAGS) $+ $(fbcondecor_helper_LDADD) -o $@
+ $(Q)$(KLCC) $(fbcondecor_helper_CFLAGS) $(fbcondecor_helper_LDFLAGS) $(fbcondecor_helper_OBJECTS) $(fbcondecor_helper_LDADD) -o $@
$(Q)$(STRIP) $@
# Override automake's generation of target rules for building fbcondecor_helper object files.

View File

@@ -0,0 +1,24 @@
commit 6f9aa3a3bc11e539613facf3caba5dcdb43c0117
Author: Michał Januszewski <spock@gentoo.org>
Date: Sun Nov 22 20:56:47 2009 +0100
gentoo: make sure the splash daemon works when boot goes through a named runlevel other than default
diff --git a/gentoo/splash.c b/gentoo/splash.c
index d831d0c..4b9a5b9 100644
--- a/gentoo/splash.c
+++ b/gentoo/splash.c
@@ -777,10 +777,12 @@ int rc_plugin_hook(RC_HOOK hook, const char *name)
hook != RC_HOOK_RUNLEVEL_START_OUT)
goto exit;
} else {
+ int pid;
+
/* We're starting/stopping a runlevel. Check whether we're
* actually booting/rebooting. */
if (rc_runlevel_starting() && strcmp(runlev, bootlevel) &&
- strcmp(runlev, defaultlevel) && strcmp(runlev, RC_LEVEL_SYSINIT))
+ strcmp(runlev, RC_LEVEL_SYSINIT) && fbsplash_check_daemon(&pid))
goto exit;
if (rc_runlevel_stopping() && strcmp(runlev, bootlevel) &&

View File

@@ -0,0 +1,55 @@
commit 7cf5fd02bbc6422ddbc9af7185cc47657148deb0
Author: Michał Januszewski <spock@gentoo.org>
Date: Sun Apr 4 16:19:40 2010 +0200
gentoo: only enable the effects that are actually selected.
diff --git a/gentoo/splash.c b/gentoo/splash.c
index 4b9a5b9..5220571 100644
--- a/gentoo/splash.c
+++ b/gentoo/splash.c
@@ -660,7 +660,7 @@ static int splash_start(const char *runlevel)
(config->type == fbspl_reboot) ? "reboot" : ((config->type == fbspl_shutdown) ? "shutdown" : "bootup"),
(config->kdmode == KD_GRAPHICS) ? "--kdgraphics" : "",
(config->textbox_visible) ? "--textbox" : "",
- (config->effects & (FBSPL_EFF_FADEOUT | FBSPL_EFF_FADEIN)) ? "--effects=fadeout,fadein" :
+ ((config->effects & (FBSPL_EFF_FADEOUT | FBSPL_EFF_FADEIN)) == (FBSPL_EFF_FADEOUT | FBSPL_EFF_FADEIN)) ? "--effects=fadeout,fadein" :
((config->effects & FBSPL_EFF_FADEOUT) ? "--effects=fadeout" :
((config->effects & FBSPL_EFF_FADEIN) ? "--effects=fadein" : "")));
@@ -716,11 +716,7 @@ static int splash_stop(const char *runlevel)
/* If we don't get a runlevel argument, then we're being executed
* because of a rc-abort event and we don't save any data. */
- if (runlevel == NULL) {
- return fbsplash_cache_cleanup(NULL);
- } else {
- return fbsplash_cache_cleanup(save);
- }
+ return fbsplash_cache_cleanup(save);
}
int rc_plugin_hook(RC_HOOK hook, const char *name)
commit d711147fc835cf408a9a4e7432fc565a6b952183
Author: Michał Januszewski <spock@gentoo.org>
Date: Sun Apr 4 16:57:23 2010 +0200
gentoo: add some comments in splash.conf
diff --git a/gentoo/splash.conf b/gentoo/splash.conf
index 4cf0a32..f056382 100644
--- a/gentoo/splash.conf
+++ b/gentoo/splash.conf
@@ -21,7 +21,10 @@ SPLASH_TEXTBOX="no"
SPLASH_AUTOVERBOSE="0"
# Name of the boot service starting X. Useful in cases when X is started
-# by a custom initscript, other than the usual 'xdm'.
+# by a custom initscript, other than the usual 'xdm'. If you are using a
+# custom X initscript and do not set this variable correctly, do not be
+# surprised if you end up at tty1 at the end of the boot process (instead of
+# in an X session).
# SPLASH_XSERVICE="xdm"
#########################################################################

View File

@@ -0,0 +1,29 @@
commit ae4b5cc9c2d904e18db51876d9bd292504714600
Author: Michał Januszewski <spock@gentoo.org>
Date: Mon Apr 6 20:59:48 2009 +0200
Prevent umounting of theme directories.
Some themes dynamically modify themselves during boot. In order to be
able to do that, they mount a tmpfs in their main directory. Prevent
openrc from umounting this directory when rebooting.
diff --git a/gentoo/splash.c b/gentoo/splash.c
index 048e0ec..d831d0c 100644
--- a/gentoo/splash.c
+++ b/gentoo/splash.c
@@ -968,10 +968,10 @@ do_start:
if (name && !strcmp(name, "localmount")) {
char *umounts = getenv("RC_NO_UMOUNTS");
- if (umounts)
- fprintf(rc_environ_fd, "RC_NO_UMOUNTS=%s:%s", umounts, FBSPLASH_CACHEDIR);
- else
- fprintf(rc_environ_fd, "RC_NO_UMOUNTS=%s", FBSPLASH_CACHEDIR);
+ if (umounts)
+ fprintf(rc_environ_fd, "RC_NO_UMOUNTS=%s:" FBSPLASH_CACHEDIR ":/etc/splash/%s", umounts, config->theme);
+ else
+ fprintf(rc_environ_fd, "RC_NO_UMOUNTS=" FBSPLASH_CACHEDIR ":/etc/splash/%s", config->theme);
}
i = splash_svc_handle(name, "svc_stop", false);
break;

View File

@@ -0,0 +1,21 @@
commit 7077483874a842c607d6e877696891ba4d5f1dd7
Author: Michał Januszewski <spock@gentoo.org>
Date: Sat Oct 9 21:07:37 2010 +0200
Fix a bug in splash-functions.sh.
This problem was reported in Gentoo bug #339767.
diff --git a/core/scripts/splash-functions.sh.in b/core/scripts/splash-functions.sh.in
index 1a89486..2c39c6a 100644
--- a/core/scripts/splash-functions.sh.in
+++ b/core/scripts/splash-functions.sh.in
@@ -341,7 +341,7 @@ splash_comm_send() {
# Returns the current splash mode.
splash_get_mode() {
- local ctty="${spl_bindir}/fgconsole"
+ local ctty="$({spl_bindir}/fgconsole)"
local mode="$(${spl_util})"
if [ "${mode}" = "silent" ]; then

View File

@@ -0,0 +1,13 @@
diff --git a/core/scripts/splash_geninitramfs.in b/core/scripts/splash_geninitramfs.in
index 9d75d21..ff9b75b 100644
--- a/core/scripts/splash_geninitramfs.in
+++ b/core/scripts/splash_geninitramfs.in
@@ -149,7 +149,7 @@ if [ "$mode" == "a" ]; then
fi
printv "o Creating directory structure.."
-mkdir -p ${imgdir}/{dev,dev/fb,dev/misc,dev/vc,$themedir,lib/splash/proc,root,sbin,lib/splash/sys}
+mkdir -p ${imgdir}/{dev,dev/fb,dev/misc,dev/vc,$themedir,@libdir@/splash/proc,root,sbin,@libdir@/splash/sys}
if [ $EUID == 0 ]; then
[[ ! -e "${imgdir}/dev/null" ]] && mknod "${imgdir}/dev/null" c 1 3

View File

@@ -0,0 +1,24 @@
diff -Naurp splashutils-1.5.4.3-orig//scripts/splash-functions.sh.in splashutils-1.5.4.3/scripts/splash-functions.sh.in
--- splashutils-1.5.4.3-orig//scripts/splash-functions.sh.in 2010-10-09 21:44:39.127691474 +0200
+++ splashutils-1.5.4.3/scripts/splash-functions.sh.in 2010-10-09 21:44:54.678690080 +0200
@@ -26,7 +26,7 @@ export spl_cachedir="@libdir@/splash/cac
export spl_tmpdir="@libdir@/splash/tmp"
export spl_fifo="${spl_cachedir}/.splash"
export spl_pidfile="${spl_cachedir}/daemon.pid"
-export spl_util="@bindir@/splash_util.static"
+export spl_util="@sbindir@/splash_util.static"
export spl_daemon="@sbindir@/fbsplashd.static"
export spl_decor="@sbindir@/fbcondecor_ctl.static"
export spl_bindir="@libdir@/splash/bin"
diff -Naurp splashutils-1.5.4.3-orig//src/Makefile.am splashutils-1.5.4.3/src/Makefile.am
--- splashutils-1.5.4.3-orig//src/Makefile.am 2010-10-09 21:44:39.121691920 +0200
+++ splashutils-1.5.4.3/src/Makefile.am 2010-10-09 21:45:10.934689775 +0200
@@ -166,7 +166,7 @@ if CONFIG_FBCON_DECOR
sbin_PROGRAMS += fbcondecor_ctl
endif
sbin_PROGRAMS += fbsplashd
-bin_PROGRAMS += splash_util
+sbin_PROGRAMS += fbsplashd splash_util
eexecsbin_PROGRAMS += fbsplashctl
fbcondecor_ctl_SOURCES = fbcon_decor_ctl.c fbcon_decor.h ../include/console_decor.h ../include/fbcondecor.h common.h fbsplash.h

View File

@@ -0,0 +1,43 @@
core/configure.ac | 6 ++++++
core/src/Makefile.am | 2 +-
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/core/configure.ac b/core/configure.ac
index c5fbb84..ae9e235 100644
--- a/core/configure.ac
+++ b/core/configure.ac
@@ -616,6 +616,7 @@ AS_IF(
AC_SUBST([PNG_CFLAGS])
AC_SUBST([PNG_LIBS])
+BZ2_LIBS=
AS_IF(
[test "x${config_ttf}" = "xyes"],
[
@@ -625,8 +626,13 @@ AS_IF(
,
[AC_MSG_ERROR([freetype was not found.])]
)
+ AC_CHECK_LIB([bz2], [BZ2_bzDecompress],
+ [BZ2_LIBS="${BZ2_LIBS} -lbz2"],
+ [AC_MSG_ERROR(['libbz2' library was not found.])]
+ )
]
)
+AC_SUBST([BZ2_LIBS])
AH_TOP([#ifndef __SPLASH_CONFIG_H
#define __SPLASH_CONFIG_H])
diff --git a/core/src/Makefile.am b/core/src/Makefile.am
index d6ce315..349b5e7 100644
--- a/core/src/Makefile.am
+++ b/core/src/Makefile.am
@@ -190,7 +190,7 @@ fbsplashctl_SOURCES = $(fbsplashd_SOURCES) $(splash_util_SOURCES) fbspla
fbsplashctl_CFLAGS = $(AM_CFLAGS) $(PTHREAD_STATIC_CFLAGS) $(RT_CFLAGS) $(libfbsplashrender_la_CFLAGS) -DUNIFIED_BUILD
fbsplashctl_CPPFLAGS = $(fbsplashd_CPPFLAGS) $(splash_util_CPPFLAGS)
fbsplashctl_LDFLAGS = $(AM_LDFLAGS) -all-static
-fbsplashctl_LDADD = libfbsplashrender.la libfbsplash.la $(PTHREAD_STATIC_LIBS) $(RT_LIBS) $(GPM_LIBS)
+fbsplashctl_LDADD = libfbsplashrender.la libfbsplash.la $(PTHREAD_STATIC_LIBS) $(RT_LIBS) $(GPM_LIBS) $(BZ2_LIBS)
if CONFIG_FBCON_DECOR
fbsplashctl_SOURCES += $(fbcondecor_ctl_SOURCES)

View File

@@ -0,0 +1,15 @@
=== modified file 'fbtruetype/Makefile'
--- fbtruetype/Makefile 2011-10-01 14:10:17 +0000
+++ fbtruetype/Makefile 2011-10-01 14:15:02 +0000
@@ -23,8 +23,8 @@
OBJECTS = fbtruetype.o messages.o console.o ttf.o luxisri.o
LDFLAGS += -L$(LIBDIR)
-LIBSS = $(LIBDIR)/libfreetype.a $(LIBDIR)/libz.a -lm
-LIBSD = -lfreetype -lm
+LIBSS = $(shell pkg-config freetype2 --libs --static) -lm
+LIBSD = $(shell pkg-config freetype2 --libs) -lm
CFLAGS += -I/usr/include/freetype2
COMPILE = $(CC) $(CFLAGS)

View File

@@ -0,0 +1,19 @@
commit 74dda8291efae78f00bb781148c8fd4fccaeb764
Author: Michał Januszewski <spock@gentoo.org>
Date: Tue Jun 14 23:23:33 2011 +0200
Fix typo in the Gentoo initscript.
diff --git a/gentoo/init-fbcondecor b/gentoo/init-fbcondecor
index b66f40a..ce921b6 100755
--- a/gentoo/init-fbcondecor
+++ b/gentoo/init-fbcondecor
@@ -12,7 +12,7 @@ start() {
splash_setup
if [ -z "${FBCONDECOR_TTYS}" ]; then
- FBCONDECOR_TTYS=$(seq 1 "${rc_tty_number:-${RC_TTY_NUMBER}:-12}")
+ FBCONDECOR_TTYS=$(seq 1 "${rc_tty_number:-${RC_TTY_NUMBER:-12}}")
fi
local err=0

View File

@@ -0,0 +1,381 @@
diff -ru a/core/src/common.h b/core/src/common.h
--- a/core/src/common.h 2013-01-11 06:35:35.000000000 +0200
+++ b/core/src/common.h 2013-01-11 06:34:08.000000000 +0200
@@ -34,6 +34,10 @@
#define PATH_PROC FBSPLASH_DIR"/proc"
#endif
+/* Maximum number of keyboard connected to a machine.
+ * The number is big (8) to be on the safe side */
+#define MAX_KBDS 8
+
/* Useful short-named types */
typedef u_int8_t u8;
typedef u_int16_t u16;
diff -ru a/core/src/daemon.c b/core/src/daemon.c
--- a/core/src/daemon.c 2013-01-11 06:35:35.000000000 +0200
+++ b/core/src/daemon.c 2013-01-11 06:34:08.000000000 +0200
@@ -20,6 +20,7 @@
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <sys/mman.h>
+#include <sys/select.h>
#include <pthread.h>
#include <errno.h>
#include <dirent.h>
@@ -29,6 +30,8 @@
#include "common.h"
#include "daemon.h"
+#define EV_BUF_SIZE 8
+
/* Threading structures */
pthread_mutex_t mtx_tty = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mtx_paint = PTHREAD_MUTEX_INITIALIZER;
@@ -41,7 +44,8 @@
int ctty = CTTY_VERBOSE;
/* File descriptors */
-int fd_evdev = -1;
+int fd_evdevs[MAX_KBDS];
+int evdev_count = 0;
#ifdef CONFIG_GPM
int fd_gpm = -1;
#endif
@@ -51,7 +55,6 @@
/* Misc settings */
char *notify[2];
-char *evdev = NULL;
/* Service list */
list svcs = { NULL, NULL };
@@ -400,56 +403,83 @@
}
}
+__u16 get_ev_key_pressed(int fd_evdev, int ev_buf_size,
+ struct input_event *ev_buf) {
+ size_t rb;
+ int i;
+ rb = read(fd_evdev, ev_buf, sizeof(struct input_event) * ev_buf_size);
+ if (rb < (int) sizeof(struct input_event))
+ return 0;
+
+ for (i = 0; i < (int) (rb / sizeof(struct input_event)); i++) {
+ if (ev_buf[i].type != EV_KEY || ev_buf[i].value != 0)
+ continue;
+ return ev_buf[i].code;
+ }
+}
+
/*
* Event device monitor thread.
*/
void* thf_switch_evdev(void *unused)
{
- int i, h, oldstate;
- size_t rb;
- struct input_event ev[8];
+ int i, h, oldstate, nfds, retval, fd_evdev;
+ fd_set rfds;
+ struct input_event ev_buf[EV_BUF_SIZE];
+ __u16 key_pressed = 0;
while (1) {
- rb = read(fd_evdev, ev, sizeof(struct input_event)*8);
- if (rb < (int) sizeof(struct input_event))
- continue;
+ nfds = 0, fd_evdev = -1;
+ FD_ZERO(&rfds);
+ for (i = 0;i < evdev_count;i++) {
+ FD_SET(fd_evdevs[i], &rfds);
+ nfds = max(nfds, fd_evdevs[i]);
+ }
- for (i = 0; i < (int) (rb / sizeof(struct input_event)); i++) {
- if (ev[i].type != EV_KEY || ev[i].value != 0)
- continue;
+ nfds++;
- switch (ev[i].code) {
- case KEY_F2:
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);
- pthread_mutex_lock(&mtx_paint);
- if (ctty == CTTY_SILENT) {
- h = config.tty_v;
- } else {
- h = config.tty_s;
+ retval = select(nfds, &rfds, NULL, NULL, NULL);
+ if (retval == -1)
+ perror("select()");
+ else if (retval) {
+ for (i = 0;i < evdev_count;i++) {
+ if (FD_ISSET(fd_evdevs[i], &rfds)) {
+ fd_evdev = fd_evdevs[i];
+ break;
}
- pthread_mutex_unlock(&mtx_paint);
- pthread_setcancelstate(oldstate, NULL);
+ }
+ key_pressed = get_ev_key_pressed(fd_evdev, EV_BUF_SIZE, ev_buf);
+ if (key_pressed == -1)
+ continue;
+ switch (key_pressed) {
+ case KEY_F2:
+ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);
+ pthread_mutex_lock(&mtx_paint);
+ h = (ctty == CTTY_SILENT) ? config.tty_v : config.tty_s;
+ pthread_mutex_unlock(&mtx_paint);
+ pthread_setcancelstate(oldstate, NULL);
+
+ /* Switch to the new tty. This ioctl has to be done on
+ * the silent tty. Sometimes init will mess with the
+ * settings of the verbose console which will prevent
+ * console switching from working properly.
+ *
+ * Don't worry about fd_tty[config.tty_s]
+ * not being protected by a mutex --
+ * this thread is always killed before any changes
+ * are made to fd_tty[config.tty_s].
+ */
+ ioctl(fd_tty[config.tty_s], VT_ACTIVATE, h);
+ break;
- /* Switch to the new tty. This ioctl has to be done on
- * the silent tty. Sometimes init will mess with the
- * settings of the verbose console which will prevent
- * console switching from working properly.
- *
- * Don't worry about fd_tty[config.tty_s] not being protected by a
- * mutex -- this thread is always killed before any changes
- * are made to fd_tty[config.tty_s].
- */
- ioctl(fd_tty[config.tty_s], VT_ACTIVATE, h);
- break;
-
- case KEY_F3:
- config.textbox_visible = !config.textbox_visible;
- invalidate_textbox(theme, config.textbox_visible);
- cmd_paint(NULL);
- break;
+ case KEY_F3:
+ config.textbox_visible = !config.textbox_visible;
+ invalidate_textbox(theme, config.textbox_visible);
+ cmd_paint(NULL);
+ break;
}
- }
- }
+ } /* end of else if (retval) */
+ } /* end of while(1) */
pthread_exit(NULL);
}
@@ -519,7 +549,7 @@
/* Do we have to start a monitor thread? */
if (update & UPD_MON) {
- if (fd_evdev != -1) {
+ if (evdev_count >= 0) {
if (pthread_create(&th_switchmon, NULL, &thf_switch_evdev, NULL)) {
iprint(MSG_ERROR, "Evdev monitor thread creation failed.\n");
exit(3);
diff -ru a/core/src/daemon.h b/core/src/daemon.h
--- a/core/src/daemon.h 2013-01-11 06:35:35.000000000 +0200
+++ b/core/src/daemon.h 2013-01-11 06:34:08.000000000 +0200
@@ -40,13 +40,13 @@
extern int fd_tty_s, fd_tty1, fd_tty0;
/*
- * Event device on which the daemon listens for F2 keypresses.
- * The proper device has to be detected by an external program and
+ * Event devices on which the daemon listens for F2 keypresses.
+ * The proper devices have to be detected by an external program and
* then enabled by sending an appropriate command to the splash
* daemon.
*/
-extern int fd_evdev;
-extern char *evdev;
+extern int fd_evdevs[];
+extern int evdev_count;
#ifdef CONFIG_GPM
#include <gpm.h>
diff -ru a/core/src/daemon_cmd.c b/core/src/daemon_cmd.c
--- a/core/src/daemon_cmd.c 2013-01-11 06:35:35.000000000 +0200
+++ b/core/src/daemon_cmd.c 2013-01-11 06:34:08.000000000 +0200
@@ -239,18 +239,35 @@
*/
int cmd_set_event_dev(void **args)
{
- if (evdev)
- free(evdev);
-
- evdev = strdup(args[0]);
+ char *evdevs;
+ char *evdev;
+ int i, j, fd_evdev = -1;
pthread_cancel(th_switchmon);
+ for (i = 0;i < evdev_count;i++) {
+ close(fd_evdevs[i]);
+ }
+ evdevs = strdup(args[1]);
+ evdev_count = *(int*)args[0];
+ j = 0;
+ for (i = 0;i < evdev_count;i++, evdevs = NULL) {
+ evdev = strtok(evdevs, ",");
+ fd_evdev = open(evdev, O_RDONLY);
+ if (fd_evdev != -1) {
+ fd_evdevs[j] = fd_evdev;
+ j++;
+ } else {
+ perror("failed to open event device");
+ }
+ }
+ if (j == 0) { /* all input devices failed to open */
+ evdev_count = -1;
+ free(evdevs);
+ return -1;
+ }
- if (fd_evdev != -1)
- close(fd_evdev);
-
- fd_evdev = open(evdev, O_RDONLY);
-
+ evdev_count = j;
+ free(evdevs);
switchmon_start(UPD_MON, config.tty_s);
return 0;
@@ -524,8 +541,8 @@
{ .cmd = "set event dev",
.handler = cmd_set_event_dev,
- .args = 1,
- .specs = "s"
+ .args = 2,
+ .specs = "ds"
},
{ .cmd = "set message",
@@ -628,7 +645,7 @@
continue;
for (j = 0; j < known_cmds[i].args; j++) {
- for (; buf[k] == ' '; buf[k] = 0, k++);
+ for (; buf[k] == ' '; buf[k] = '\0', k++);
if (!buf[k]) {
args[j] = NULL;
continue;
diff -ru a/core/src/libfbsplash.c b/core/src/libfbsplash.c
--- a/core/src/libfbsplash.c 2013-01-11 06:35:35.000000000 +0200
+++ b/core/src/libfbsplash.c 2013-01-11 06:34:08.000000000 +0200
@@ -588,6 +588,8 @@
return -1;
}
+#define EVDV_BUF_LEN 128
+
/**
* Try to set the event device for the splash daemon.
*
@@ -595,10 +597,14 @@
*/
int fbsplash_set_evdev(void)
{
- char buf[128];
+ char buf[EVDV_BUF_LEN];
+ char evdev_devs[EVDV_BUF_LEN * MAX_KBDS];
FILE *fp;
int i, j;
-
+ int kbd_count;
+ int max_chars, chars_left, dev_path_len;
+ char dev_path[] = PATH_DEV "/input/";
+ dev_path_len = strlen(dev_path);
char *evdev_cmds[] = {
"/bin/grep -Hsi keyboard " PATH_SYS "/class/input/input*/name | /bin/sed -e 's#.*input\\([0-9]*\\)/name.*#event\\1#'",
"/bin/grep -Hsi keyboard " PATH_SYS "/class/input/event*/device/driver/description | /bin/grep -o 'event[0-9]\\+'",
@@ -608,22 +614,43 @@
/* Try to activate the event device interface so that F2 can
* be used to switch from verbose to silent. */
- buf[0] = 0;
- for (i = 0; i < sizeof(evdev_cmds)/sizeof(char*); i++) {
+ buf[0] = '\0';
+ kbd_count = 0;
+ max_chars = sizeof(evdev_devs) / sizeof(char*);
+ chars_left = max_chars - 1;
+ evdev_devs[0] = '\0';
+ for (i = 0; i < sizeof(evdev_cmds) / sizeof(char*); i++) {
fp = popen(evdev_cmds[i], "r");
if (fp) {
- fgets(buf, 128, fp);
- if ((j = strlen(buf)) > 0) {
- if (buf[j-1] == '\n')
- buf[j-1] = 0;
- break;
+ while (fgets(buf, 128, fp) && kbd_count < MAX_KBDS) {
+ if ((j = strlen(buf)) > 0) {
+ if (buf[j-1] == '\n')
+ buf[j-1] = ',';
+ if (chars_left < (j + dev_path_len)) {
+ break;
+ }
+ kbd_count++;
+ strncat(evdev_devs, dev_path, chars_left);
+ chars_left -= dev_path_len;
+ strncat(evdev_devs, buf, chars_left);
+ chars_left -= j;
+ }
+ }
+ /* replace the last ',' with '\n' */
+ if (chars_left > 0 && evdev_devs[0] != '\0') {
+ j = strlen(evdev_devs);
+ if (j > 2) {
+ evdev_devs[j - 1] = '\n';
+ }
}
pclose(fp);
}
+ if (kbd_count > 0)
+ break;
}
- if (buf[0] != 0) {
- fbsplash_send("set event dev " PATH_DEV "/input/%s\n", buf);
+ if (evdev_devs[0] != '\0') {
+ fbsplash_send("set event dev %d %s", kbd_count, evdev_devs);
return 0;
} else {
return -1;
@@ -661,6 +688,8 @@
return 0;
}
+#define MAX_CMD 2048
+
/**
* Send stuff to the splash daemon using the splash FIFO.
*
@@ -668,7 +697,7 @@
*/
int fbsplash_send(const char *fmt, ...)
{
- char cmd[256];
+ char cmd[MAX_CMD];
va_list ap;
if (!fp_fifo) {
@@ -690,7 +719,7 @@
}
va_start(ap, fmt);
- vsnprintf(cmd, 256, fmt, ap);
+ vsnprintf(cmd, MAX_CMD, fmt, ap);
va_end(ap);
fprintf(fp_fifo, cmd);

View File

@@ -0,0 +1,53 @@
core/configure.ac | 6 ++++++
core/src/Makefile.am | 2 +-
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/core/configure.ac b/core/configure.ac
index c5fbb84..ae9e235 100644
--- a/core/configure.ac
+++ b/core/configure.ac
@@ -616,6 +616,7 @@ AS_IF(
AC_SUBST([PNG_CFLAGS])
AC_SUBST([PNG_LIBS])
+BZ2_LIBS=
AS_IF(
[test "x${config_ttf}" = "xyes"],
[
@@ -625,8 +626,13 @@ AS_IF(
,
[AC_MSG_ERROR([freetype was not found.])]
)
+ AC_CHECK_LIB([bz2], [BZ2_bzDecompress],
+ [BZ2_LIBS="${BZ2_LIBS} -lbz2"],
+ [AC_MSG_ERROR(['libbz2' library was not found.])]
+ )
]
)
+AC_SUBST([BZ2_LIBS])
AH_TOP([#ifndef __SPLASH_CONFIG_H
#define __SPLASH_CONFIG_H])
diff --git a/core/src/Makefile.am b/core/src/Makefile.am
index d6ce315..349b5e7 100644
--- a/core/src/Makefile.am
+++ b/core/src/Makefile.am
@@ -121,6 +121,9 @@
libfbsplashrender_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(libfbsplashrender_version)
libfbsplashrender_la_LIBADD = libfbsplash.la
+libfbsplashrender_la_CFLAGS += $(BZ2_CFLAGS)
+libfbsplashrender_la_LIBADD += $(BZ2_LIBS)
+
libfbsplashrender_la_CFLAGS += $(JPEG_CFLAGS)
libfbsplashrender_la_LIBADD += $(JPEG_LIBS)
@@ -190,7 +193,7 @@
fbsplashctl_CFLAGS = $(AM_CFLAGS) $(PTHREAD_STATIC_CFLAGS) $(RT_CFLAGS) $(libfbsplashrender_la_CFLAGS) -DUNIFIED_BUILD
fbsplashctl_CPPFLAGS = $(fbsplashd_CPPFLAGS) $(splash_util_CPPFLAGS)
fbsplashctl_LDFLAGS = $(AM_LDFLAGS) -all-static
-fbsplashctl_LDADD = libfbsplashrender.la libfbsplash.la $(PTHREAD_STATIC_LIBS) $(RT_LIBS) $(GPM_LIBS)
+fbsplashctl_LDADD = libfbsplashrender.la libfbsplash.la $(PTHREAD_STATIC_LIBS) $(RT_LIBS) $(GPM_LIBS) $(BZ2_LIBS)
if CONFIG_FBCON_DECOR
fbsplashctl_SOURCES += $(fbcondecor_ctl_SOURCES)

View File

@@ -0,0 +1,74 @@
commit a58099249acdce1fbdab19f5dfea0704c4c545f2
Author: Michał Januszewski <spock@gentoo.org>
Date: Sun Dec 28 13:32:16 2008 +0100
gentoo: make the splash plugin work with OpenRC 0.4.*
diff --git a/gentoo/splash.c b/gentoo/splash.c
index 26d0fa4..b6fa774 100644
--- a/gentoo/splash.c
+++ b/gentoo/splash.c
@@ -593,7 +593,7 @@ static int splash_start(const char *runlevel)
/* Get a list of services that we'll have to handle. */
/* We're rebooting/shutting down. */
- if (!strcmp(runlevel, RC_LEVEL_SHUTDOWN) || !strcmp(runlevel, RC_LEVEL_REBOOT)) {
+ if (!strcmp(runlevel, RC_LEVEL_SHUTDOWN)) {
if ((err = fbsplash_cache_prep()))
return err;
splash_svcs_stop(runlevel);
@@ -690,10 +690,14 @@ int rc_plugin_hook(RC_HOOK hook, const char *name)
int retval = 0;
runlev = rc_runlevel_get();
- if (!strcmp(runlev, RC_LEVEL_REBOOT))
- type = fbspl_reboot;
- else if (!strcmp(runlev, RC_LEVEL_SHUTDOWN))
- type = fbspl_shutdown;
+ if (!strcmp(runlev, RC_LEVEL_SHUTDOWN)) {
+ char *t = getenv("RUNLEVEL");
+ if (t && !strcmp(t, "6")) {
+ type = fbspl_reboot;
+ } else {
+ type = fbspl_shutdown;
+ }
+ }
/* Get boot and default levels from env variables exported by RC.
* If unavailable, use the default ones. */
@@ -716,7 +720,7 @@ int rc_plugin_hook(RC_HOOK hook, const char *name)
list = rc_stringlist_new();
get_list_fp(list, fp);
TAILQ_FOREACH(s, list, entries)
- rc_service_mark(s->value, RC_SERVICE_COLDPLUGGED);
+ rc_service_mark(s->value, RC_SERVICE_HOTPLUGGED);
pclose(fp);
rc_stringlist_free(list);
}
@@ -739,7 +743,7 @@ int rc_plugin_hook(RC_HOOK hook, const char *name)
goto exit;
if (rc_runlevel_stopping() && strcmp(runlev, bootlevel) &&
- strcmp(runlev, RC_LEVEL_REBOOT) && strcmp(runlev, RC_LEVEL_SHUTDOWN))
+ strcmp(runlev, RC_LEVEL_SHUTDOWN))
goto exit;
}
@@ -763,7 +767,7 @@ int rc_plugin_hook(RC_HOOK hook, const char *name)
case RC_HOOK_RUNLEVEL_STOP_IN:
/* Start the splash daemon on reboot. The theme hook is called
* from splash_start(). */
- if (strcmp(name, RC_LEVEL_REBOOT) == 0 || strcmp(name, RC_LEVEL_SHUTDOWN) == 0) {
+ if (strcmp(name, RC_LEVEL_SHUTDOWN) == 0) {
if ((i = splash_start(name))) {
fbsplash_set_verbose(0);
retval= i;
@@ -788,7 +792,7 @@ int rc_plugin_hook(RC_HOOK hook, const char *name)
case RC_HOOK_RUNLEVEL_STOP_OUT:
/* Make sure the progress indicator reaches 100%, even if
* something went wrong along the way. */
- if (strcmp(name, RC_LEVEL_REBOOT) == 0 || strcmp(name, RC_LEVEL_SHUTDOWN) == 0) {
+ if (strcmp(name, RC_LEVEL_SHUTDOWN) == 0) {
config->verbosity = FBSPL_VERB_QUIET;
i = fbsplash_check_daemon(&pid_daemon);
config->verbosity = FBSPL_VERB_NORMAL;

View File

@@ -0,0 +1,99 @@
commit 4bb63f7fb23b11591e2984ce87d4f36d80e29d65
Author: Michał Januszewski <spock@gentoo.org>
Date: Wed Mar 25 22:26:04 2009 +0100
gentoo: export the sysvinit RUNLEVEL variable for compatibility reasons
OpenRC 0.4.3+ no longer exports some sysvinit variables, including
RUNLEVEL. In order to avoid breaking themes and scripts which still
rely on this variable being present, we compute a suitable RUNLEVEL
value using the data available in OpenRC and then export it in
splash_call().
diff --git a/gentoo/splash.c b/gentoo/splash.c
index 726315f..048e0ec 100644
--- a/gentoo/splash.c
+++ b/gentoo/splash.c
@@ -41,7 +41,7 @@
#define SPLASH_CMD "export SPLASH_XRES='%d'; export SPLASH_YRES='%d';" \
"export SOFTLEVEL='%s'; export BOOTLEVEL='%s';" \
"export DEFAULTLEVEL='%s'; export svcdir=${RC_SVCDIR};" \
- ". /sbin/splash-functions.sh; %s %s %s"
+ "export RUNLEVEL='%s'; . /sbin/splash-functions.sh; %s %s %s"
static char *bootlevel = NULL;
static char *defaultlevel = NULL;
@@ -260,11 +260,32 @@ static int splash_config_gentoo(fbspl_cfg_t *cfg, fbspl_type_t type)
return 0;
}
+static const char *splash_sysvinit_runlevel(const char *runlevel)
+{
+ const char *runlev = runlevel ? runlevel : rc_runlevel_get();
+
+ if (!strcmp(runlev, RC_LEVEL_SHUTDOWN)) {
+ char *t = getenv("RC_REBOOT");
+ if (t && !strcmp(t, "YES")) {
+ return "6";
+ } else {
+ return "0";
+ }
+ } else if (!strcmp(runlev, RC_LEVEL_SYSINIT)) {
+ return "S";
+ } else if (!strcmp(runlev, RC_LEVEL_SINGLE)) {
+ return "1";
+ } else {
+ return "3";
+ }
+}
+
+
/*
* Call a function from /sbin/splash-functions.sh.
* This is rather slow, so use it only when really necessary.
*/
-static int splash_call(const char *cmd, const char *arg1, const char *arg2)
+static int splash_call(const char *cmd, const char *arg1, const char *arg2, const char *runlevel)
{
char *c;
int l;
@@ -285,7 +306,8 @@ static int splash_call(const char *cmd, const char *arg1, const char *arg2)
snprintf(c, l, SPLASH_CMD, xres, yres,
arg1 ? (strcmp(arg1, RC_LEVEL_SYSINIT) == 0 ? bootlevel : soft) : soft,
- bootlevel, defaultlevel, cmd, arg1 ? arg1 : "", arg2 ? arg2 : "");
+ bootlevel, defaultlevel, runlevel,
+ cmd, arg1 ? arg1 : "", arg2 ? arg2 : "");
l = system(c);
free(c);
return l;
@@ -316,15 +338,16 @@ static int splash_theme_hook(const char *name, const char *type, const char *arg
}
if (!strcmp(name, "rc_init") || !strcmp(name, "rc_exit")) {
- l = splash_call(buf, arg1, getenv("RUNLEVEL"));
+ const char *t = splash_sysvinit_runlevel(arg1);
+ l = splash_call(buf, arg1, t, t);
} else if (!strcmp(name, "svc_started") || !strcmp(name, "svc_stopped")) {
/*
* Set the 2nd parameter to 0 so that we don't break themes using the
* legacy interface in which these events contained an error code.
*/
- l = splash_call(buf, arg1, "0");
+ l = splash_call(buf, arg1, "0", splash_sysvinit_runlevel(NULL));
} else {
- l = splash_call(buf, arg1, NULL);
+ l = splash_call(buf, arg1, NULL, splash_sysvinit_runlevel(NULL));
}
free(buf);
return l;
@@ -710,8 +733,7 @@ int rc_plugin_hook(RC_HOOK hook, const char *name)
runlev = rc_runlevel_get();
if (!strcmp(runlev, RC_LEVEL_SHUTDOWN)) {
- char *t = getenv("RUNLEVEL");
- if (t && !strcmp(t, "6")) {
+ if (!strcmp(splash_sysvinit_runlevel(NULL), "6")) {
type = fbspl_reboot;
} else {
type = fbspl_shutdown;