From 9728339b038ee4b56c129292fe80771dc0d45ae7 Mon Sep 17 00:00:00 2001 From: "Anton V. Boyarshinov" Date: Tue, 30 Nov 2010 22:14:42 +0300 Subject: [PATCH] plymouth support improoved --- newt-frontend.c | 12 ++++----- stage1.c | 5 ++-- tools.c | 65 ++++++------------------------------------------- tools.h | 2 +- 4 files changed, 18 insertions(+), 66 deletions(-) diff --git a/newt-frontend.c b/newt-frontend.c index 497af1a..775fd08 100644 --- a/newt-frontend.c +++ b/newt-frontend.c @@ -58,13 +58,13 @@ void finish_frontend(void) void verror_message(char *msg, va_list ap) { - set_splash("verbose"); + splash_verbose(); newtWinMessagev("Error", "Ok", msg, ap); } void vinfo_message(char *msg, va_list ap) { - set_splash("verbose"); + splash_verbose(); newtWinMessagev("Notice", "Ok", msg, ap); } @@ -193,7 +193,7 @@ enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_ elems++; } items[i] = NULL; - set_splash("verbose"); + splash_verbose(); rc = newtWinMenu("Please choose...", msg, 52, 5, 5, 7, items, &answer, "Ok", "Cancel", NULL); if (rc == 2) @@ -209,7 +209,7 @@ enum return_type ask_from_list(char *msg, char ** elems, char ** choice) { int answer = 0, rc; - set_splash("verbose"); + splash_verbose(); rc = newtWinMenu("Please choose...", msg, 52, 5, 5, 7, elems, &answer, "Ok", "Cancel", NULL); if (rc == 2) @@ -224,7 +224,7 @@ enum return_type ask_from_list(char *msg, char ** elems, char ** choice) enum return_type ask_yes_no(char *msg) { int rc; - set_splash("verbose"); + splash_verbose(); rc = newtWinTernary("Please answer...", "Yes", "No", "Back", msg); if (rc == 1) @@ -384,7 +384,7 @@ enum return_type ask_from_entries(char *msg, char ** questions, char *** answers } else *(entries[j].value) = NULL; } - set_splash("verbose"); + splash_verbose(); rc = mynewtWinEntries("Please fill entries...", msg, 52, 5, 5, entry_size, callback_func, entries, "Ok", "Cancel", NULL); diff --git a/stage1.c b/stage1.c index a873b41..20d7130 100644 --- a/stage1.c +++ b/stage1.c @@ -181,6 +181,9 @@ static void spawn_splash(void) } close(fd); + char * av[] = { "/bin/plymouth", "plymouth", "show-splash", NULL }; + log_message( "%s: %s\n", av[0], av[2] ); + return spawn(av); #endif } @@ -345,7 +348,6 @@ void stage1() handle_env(env); spawn_shell(); spawn_splash(); - prepare_progress(); update_splash("welcome"); snprintf(buf, sizeof(buf), "Welcome to %s", version); init_frontend(buf); @@ -368,7 +370,6 @@ void stage1() update_splash("finish_frontend"); close_log(); - close_progress(); if (ret != RETURN_OK) fatal_error("could not select an installation method"); diff --git a/tools.c b/tools.c index 6390359..917f45d 100644 --- a/tools.c +++ b/tools.c @@ -314,68 +314,19 @@ enum return_type load_ramdisk_fd(int source_fd, int size) return RETURN_OK; } -int prepare_progress() + + +int splash_verbose() { - char readbuffer[4096]; - int size; - - if (splashfd > 0) return(0); - - splashfd = open(PROCSPLASH,O_RDWR); - if (splashfd < 0) { - log_message("Error open /proc/splash\n"); - return(-1); - } - size = read(splashfd, readbuffer, sizeof(readbuffer)); - if (strstr(readbuffer,"silent") && strstr(readbuffer,": on")) { - log_message("bootsplash detected and progress enabled"); - } else { - close(splashfd); - splashfd = -1; - } - if (splashcount == 0 ) { - char * splash_param = get_param_valued("splashcount"); - if (!splash_param) { - splashcount = -1; - return(0); - } - if (sscanf(splash_param,"%d",&splashcount) != 1) { - splashcount = -1; - return(0); - } - } - return(0); -} - -void close_progress() -{ - char s[16]; - if (splashfd < 0) - return; - close(splashfd); - snprintf(s, sizeof(s), "%i", splashcount); - add_to_env("SPLASHCOUNT", s); - snprintf(s, sizeof(s), "%i", splashstep); - add_to_env("SPLASHSTEP", s); - return; -} - -int set_splash(char * mode) -{ - if (splashfd < 0) - return 0; - return(write(splashfd, mode, strlen(mode))); + char * av[] = { "/bin/plymouth" , "plymouth" , "hide-splash", NULL }; + log_message( "%s: %s\n", av[0], av[2] ); + return spawn(av); } int update_splash( char * state ) { - char * av[4][64] = - { - { "/sbin/plymouth" }, - { "/sbin/plymouth" }, - { "--update" }, - state, - }; + char * av[] = { "/bin/plymouth" , "plymouth" , "--update" , state, NULL }; + log_message( "%s: %s\n", av[0], av[3] ); return spawn(av); } diff --git a/tools.h b/tools.h index ce98f69..8545d46 100644 --- a/tools.h +++ b/tools.h @@ -43,7 +43,7 @@ char ** list_directory(char * direct); int string_array_length(char ** a); int do_losetup(char * device, char * target); char * get_ramdisk_path(const char *); -int set_splash(char *); +int splash_verbose(); int update_splash(char * state); int prepare_progress(void); void close_progress(void);