plymouth support improoved

This commit is contained in:
Anton V. Boyarshinov 2010-11-30 22:14:42 +03:00
parent 5379a6c482
commit 9728339b03
4 changed files with 18 additions and 66 deletions

View File

@ -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);

View File

@ -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");

65
tools.c
View File

@ -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);
}

View File

@ -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);