]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
installer: Enable new partitioning code to be run in unattended mode
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 11 Oct 2014 16:59:31 +0000 (18:59 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 11 Oct 2014 16:59:31 +0000 (18:59 +0200)
The first disk of the system will automatically be used and
a standard installation will be done. After that is done, the
system will reboot into the freshly installed system and execute
setup.

config/syslinux/syslinux.cfg
src/installer/hw.c
src/installer/hw.h
src/installer/main.c
src/libsmooth/libsmooth.h
src/libsmooth/main.c

index 3c7ae87d23a07c488a398779a853bd8bdb6b03dc..cfb8113cf6e57fc4cda28c730bd91f45b044bebe 100644 (file)
@@ -58,7 +58,7 @@ Run an unattended installation.
                ENDTEXT
                KERNEL vmlinuz
                INITRD instroot
                ENDTEXT
                KERNEL vmlinuz
                INITRD instroot
-               APPEND unattended
+               APPEND installer.unattended
 MENU END
 
 MENU BEGIN tools
 MENU END
 
 MENU BEGIN tools
index e453e23cbe14debf38ff89e312cf67e45aa839a2..ecc4dc3924de5f81964bfa25e35eb48c622ddaa1 100644 (file)
@@ -323,6 +323,27 @@ struct hw_disk** hw_select_disks(struct hw_disk** disks, int* selection) {
        return ret;
 }
 
        return ret;
 }
 
+struct hw_disk** hw_select_first_disk(const struct hw_disk** disks) {
+       struct hw_disk** ret = hw_create_disks();
+       struct hw_disk** selected_disks = ret;
+
+       unsigned int num_disks = hw_count_disks(disks);
+       assert(num_disks > 0);
+
+       for (unsigned int i = 0; i < num_disks; i++) {
+               struct hw_disk *disk = disks[i];
+               disk->ref++;
+
+               *selected_disks++ = disk;
+               break;
+       }
+
+       // Set sentinel
+       *selected_disks = NULL;
+
+       return ret;
+}
+
 static unsigned long long hw_swap_size(struct hw_destination* dest) {
        unsigned long long memory = hw_memory();
 
 static unsigned long long hw_swap_size(struct hw_destination* dest) {
        unsigned long long memory = hw_memory();
 
index e4bb18b920c58ab7a8541aa0e5a043650ff5a99c..c5285d543edd97a7dc6f55f10e2bf500089c721f 100644 (file)
@@ -109,6 +109,7 @@ struct hw_disk** hw_find_disks(struct hw* hw, const char* sourcedrive);
 void hw_free_disks(struct hw_disk** disks);
 unsigned int hw_count_disks(struct hw_disk** disks);
 struct hw_disk** hw_select_disks(struct hw_disk** disks, int* selection);
 void hw_free_disks(struct hw_disk** disks);
 unsigned int hw_count_disks(struct hw_disk** disks);
 struct hw_disk** hw_select_disks(struct hw_disk** disks, int* selection);
+struct hw_disk** hw_select_first_disk(const struct hw_disk** disks);
 
 struct hw_destination* hw_make_destination(int part_type, struct hw_disk** disks);
 
 
 struct hw_destination* hw_make_destination(int part_type, struct hw_disk** disks);
 
index 513ebf41a2cce2fdc9f2fd1c9e362c9261ef0fe6..f197dc351c39a054ba1099717856769d9af4d6cc 100644 (file)
@@ -281,17 +281,16 @@ int main(int argc, char *argv[]) {
 
        snprintf(title, sizeof(title), "%s - %s", NAME, SLOGAN);
 
 
        snprintf(title, sizeof(title), "%s - %s", NAME, SLOGAN);
 
-       if (! (cmdfile = fopen("/proc/cmdline", "r")))
-       {
+       if (! (cmdfile = fopen("/proc/cmdline", "r"))) {
                fprintf(flog, "Couldn't open commandline: /proc/cmdline\n");
        } else {
                fgets(line, STRING_SIZE, cmdfile);
                fprintf(flog, "Couldn't open commandline: /proc/cmdline\n");
        } else {
                fgets(line, STRING_SIZE, cmdfile);
-               
+
                // check if we have to make an unattended install
                // check if we have to make an unattended install
-               if (strstr (line, "unattended") != NULL) {
+               if (strstr(line, "installer.unattended") != NULL) {
+                   splashWindow(title, _("Warning: Unattended installation will start in 10 seconds..."), 10);
                    unattended = 1;
                    unattended = 1;
-                   runcommandwithstatus("/bin/sleep 10", title, "WARNING: Unattended installation will start in 10 seconds...", NULL);
-               }               
+               }
                // check if we have to patch for serial console
                if (strstr (line, "console=ttyS0") != NULL) {
                    serialconsole = 1;
                // check if we have to patch for serial console
                if (strstr (line, "console=ttyS0") != NULL) {
                    serialconsole = 1;
@@ -314,7 +313,7 @@ int main(int argc, char *argv[]) {
                }
                langnames[NUM_LANGS] = NULL;
 
                }
                langnames[NUM_LANGS] = NULL;
 
-           rc = newtWinMenu(_("Language selection"), _("Select the language you wish to use for the installation."),
+               rc = newtWinMenu(_("Language selection"), _("Select the language you wish to use for the installation."),
                        50, 5, 5, 8, langnames, &choice, _("OK"), NULL);
 
                assert(choice <= NUM_LANGS);
                        50, 5, 5, 8, langnames, &choice, _("OK"), NULL);
 
                assert(choice <= NUM_LANGS);
@@ -406,8 +405,10 @@ int main(int argc, char *argv[]) {
                        goto EXIT;
 
                // exactly one disk has been found
                        goto EXIT;
 
                // exactly one disk has been found
-               } else if (num_disks == 1) {
-                       selected_disks = hw_select_disks(disks, NULL);
+               // or if we are running in unattended mode, we will select
+               // the first disk and go with that one
+               } else if ((num_disks == 1) || (unattended && num_disks >= 1)) {
+                       selected_disks = hw_select_first_disk(disks);
 
                // more than one usable disk has been found and
                // the user needs to choose what to do with them
 
                // more than one usable disk has been found and
                // the user needs to choose what to do with them
@@ -442,6 +443,11 @@ int main(int argc, char *argv[]) {
                        }
                }
 
                        }
                }
 
+               // Don't print the auto-selected harddisk setup in
+               // unattended mode.
+               if (unattended)
+                       break;
+
                num_selected_disks = hw_count_disks(selected_disks);
 
                if (num_selected_disks == 1) {
                num_selected_disks = hw_count_disks(selected_disks);
 
                if (num_selected_disks == 1) {
index d731e548af8172ceffa2fd1f1740e563f152b415..6003bc0651a158be7580a631c86e03ba2e92bd18 100644 (file)
@@ -52,6 +52,7 @@ int runcommandwithprogress(int width, int height, const char *title, const char
        int lines, char *text, ...);
 int runcommandwithstatus(const char *command, const char* title, const char *message, const char* output);
 int runhiddencommandwithstatus(const char *command, const char* title, const char *message, const char* output);
        int lines, char *text, ...);
 int runcommandwithstatus(const char *command, const char* title, const char *message, const char* output);
 int runhiddencommandwithstatus(const char *command, const char* title, const char *message, const char* output);
+int splashWindow(const char* title, const char* message, unsigned int timeout);
 int checkformodule(const char *module); 
 int replace(char filename1[], char *from, char *to);
 char* get_version(void);
 int checkformodule(const char *module); 
 int replace(char filename1[], char *from, char *to);
 char* get_version(void);
index 1d2a5002e5e3090f0d2f5cb08431dd7b8f7beb19..fedff109d5d85801a59836a7ad2d4c83b911ae38 100644 (file)
@@ -90,6 +90,16 @@ int runhiddencommandwithstatus(const char *command, const char* title, const cha
        return rc;
 }
 
        return rc;
 }
 
+int splashWindow(const char* title, const char* message, unsigned int timeout) {
+       statuswindow(60, 4, title, message);
+
+       // Wait so the user can read this message
+       sleep(timeout);
+       newtPopWindow();
+
+       return 0;
+}
+
 /* This one borrowed from redhat installer. */
 int runcommandwithprogress(int width, int height, const char *title, const char *command,
        int lines, char *text, ...) {
 /* This one borrowed from redhat installer. */
 int runcommandwithprogress(int width, int height, const char *title, const char *command,
        int lines, char *text, ...) {