diff options
Diffstat (limited to 'mdk-stage1')
-rw-r--r-- | mdk-stage1/frontend.h | 4 | ||||
-rw-r--r-- | mdk-stage1/log.c | 17 | ||||
-rw-r--r-- | mdk-stage1/log.h | 2 | ||||
-rw-r--r-- | mdk-stage1/newt-frontend.c | 30 | ||||
-rw-r--r-- | mdk-stage1/stdio-frontend.c | 31 | ||||
-rw-r--r-- | mdk-stage1/tools.c | 18 |
6 files changed, 76 insertions, 26 deletions
diff --git a/mdk-stage1/frontend.h b/mdk-stage1/frontend.h index 9e8f1974e..9b2bc9f39 100644 --- a/mdk-stage1/frontend.h +++ b/mdk-stage1/frontend.h @@ -29,6 +29,10 @@ void info_message(char *msg, ...); /* blocking */ void wait_message(char *msg, ...); /* non-blocking */ void remove_wait_message(void); +void init_progression(char *msg, int size); +void update_progression(int current_size); +void end_progression(void); + enum return_type ask_yes_no(char *msg); enum return_type ask_from_list(char *msg, char ** elems, char ** choice); enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_comments, char ** choice); diff --git a/mdk-stage1/log.c b/mdk-stage1/log.c index 8faa166c0..d4a1c71c7 100644 --- a/mdk-stage1/log.c +++ b/mdk-stage1/log.c @@ -68,23 +68,6 @@ void log_perror(char *msg) log_message("%s: %s", msg, strerror(errno)); } -void log_progression(int divide_for_count) -{ - static int count = 0; - if (count <= 0) { - fprintf(logfile, "."); - fflush(logfile); - count = divide_for_count; - } - else - count--; -} - -void log_progression_done(void) -{ - fprintf(logfile, "done\n"); -} - void open_log(void) { diff --git a/mdk-stage1/log.h b/mdk-stage1/log.h index 7e206c881..65e0a2416 100644 --- a/mdk-stage1/log.h +++ b/mdk-stage1/log.h @@ -29,8 +29,6 @@ void log_message(const char * s, ...); void vlog_message(const char * s, va_list args); void vlog_message_nobs(const char * s, va_list args); void log_perror(char *msg); -void log_progression(int divide_for_count); -void log_progression_done(void); void open_log(void); void close_log(void); diff --git a/mdk-stage1/newt-frontend.c b/mdk-stage1/newt-frontend.c index 8a057f98e..f5bfae047 100644 --- a/mdk-stage1/newt-frontend.c +++ b/mdk-stage1/newt-frontend.c @@ -114,6 +114,36 @@ void remove_wait_message(void) } +static newtComponent form = NULL, scale = NULL; +static int size_progress; +static int actually_drawn; + +void init_progression(char *msg, int size) +{ + size_progress = size; + actually_drawn = 0; + newtCenteredWindow(70, 5, "Please wait..."); + form = newtForm(NULL, NULL, 0); + newtFormAddComponent(form, newtLabel(1, 1, msg)); + scale = newtScale(1, 3, 68, size); + newtFormAddComponent(form, scale); + newtDrawForm(form); + newtRefresh(); +} + +void update_progression(int current_size) +{ + newtScaleSet(scale, current_size); + newtRefresh(); +} + +void end_progression(void) +{ + newtPopWindow(); + newtFormDestroy(form); +} + + enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_comments, char ** choice) { char * items[50]; diff --git a/mdk-stage1/stdio-frontend.c b/mdk-stage1/stdio-frontend.c index bb6755176..ec448224a 100644 --- a/mdk-stage1/stdio-frontend.c +++ b/mdk-stage1/stdio-frontend.c @@ -106,6 +106,37 @@ void remove_wait_message(void) } +static int size_progress; +static int actually_drawn; + +void init_progression(char *msg, int size) +{ + size_progress = size; + actually_drawn = 0; + printf("%s\n[", msg); +} + +void update_progression(int current_size) +{ + while ((int)((current_size*40)/size_progress) > actually_drawn) { + printf("."); + actually_drawn++; + if (actually_drawn == 10) + printf("(25%%)"); + if (actually_drawn == 20) + printf("(50%%)"); + if (actually_drawn == 30) + printf("(75%%)"); + } + fflush(stdout); +} + +void end_progression(void) +{ + printf("]\n"); +} + + enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_comments, char ** choice) { char ** sav_elems = elems; diff --git a/mdk-stage1/tools.c b/mdk-stage1/tools.c index 930c1027f..c1e934ab0 100644 --- a/mdk-stage1/tools.c +++ b/mdk-stage1/tools.c @@ -193,12 +193,13 @@ enum return_type load_ramdisk(void) char * img_name; gzFile st2; char * ramdisk = "/dev/ram3"; /* warning, verify that this file exists in the initrd (and actually is a ramdisk device file) */ - int ram_fd; + int ram_fd, st2_fd; char buffer[4096]; char * stg2_name = get_param_valued("special_stage2"); char * begin_img = "/tmp/image/Mandrake/base/"; char * end_img = "_stage2.gz"; int gz_errnum; + struct stat statr; if (!stg2_name) stg2_name = "mdkinst"; @@ -213,7 +214,9 @@ enum return_type load_ramdisk(void) log_message("trying to load %s as a ramdisk", img_name); - st2 = gzopen(img_name, "r"); + st2_fd = open(img_name, O_RDONLY); /* to be able to see the progression */ + st2 = gzdopen(st2_fd, "r"); + if (!st2) { log_message("Opening compressed ramdisk: %s", gzerror(st2, &gz_errnum)); error_message("Could not open compressed ramdisk file."); @@ -226,8 +229,9 @@ enum return_type load_ramdisk(void) error_message("Could not open ramdisk device file."); return RETURN_ERROR; } - - wait_message("Loading Installation program into memory..."); + + stat(img_name, &statr); + init_progression("Loading Installation program into memory...", statr.st_size); while (!gzeof(st2)) { int actually = gzread(st2, buffer, sizeof(buffer)); @@ -241,11 +245,11 @@ enum return_type load_ramdisk(void) remove_wait_message(); return RETURN_ERROR; } - log_progression(100); + update_progression(lseek(st2_fd, 0L, SEEK_CUR)); } - log_progression_done(); - remove_wait_message(); + end_progression(); + gzclose(st2); close(ram_fd); |