]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - src/installer/main.c
Merge remote-tracking branch 'mfischer/slang' into next
[people/pmueller/ipfire-2.x.git] / src / installer / main.c
index 1bdeda28f33077e542cdae64fefdd66314df856f..c420de3a18572760fa1a1eff837213f8be276153 100644 (file)
@@ -216,46 +216,62 @@ static char* get_system_release() {
 }
 
 static char* center_string(const char* str, int width) {
+       if (!str)
+               return NULL;
+
+       char* string = NULL;
        unsigned int str_len = strlen(str);
 
-       unsigned int indent_length = (width - str_len) / 2;
-       char indent[indent_length + 1];
+       if (str_len == width) {
+               string = strdup(str);
 
-       for (unsigned int i = 0; i < indent_length; i++) {
-               indent[i] = ' ';
-       }
-       indent[indent_length] = '\0';
+       } else if (str_len > width) {
+               string = strdup(str);
+               string[width - 1] = '\0';
 
-       char* string = NULL;
-       if (asprintf(&string, "%s%s", indent, str) < 0)
-               return NULL;
+       } else {
+               unsigned int indent_length = (width - str_len) / 2;
+               char indent[indent_length + 1];
+
+               for (unsigned int i = 0; i < indent_length; i++) {
+                       indent[i] = ' ';
+               }
+               indent[indent_length] = '\0';
+
+               if (asprintf(&string, "%s%s", indent, str) < 0)
+                       return NULL;
+       }
 
        return string;
 }
 
-#define DEFAULT_LANG "en_US.utf8"
-#define NUM_LANGS 10
+#define DEFAULT_LANG "en.utf8"
+#define NUM_LANGS 13
 
 static struct lang {
        const char* code;
        char* name;
 } languages[NUM_LANGS + 1] = {
-       { "da.utf8",    "Danish (Dansk)" },
-       { "nl_NL.utf8", "Dutch (Nederlands)" },
-       { "en_US.utf8", "English" },
-       { "fr_FR.utf8", "French (Français)" },
-       { "de_DE.utf8", "German (Deutsch)" },
-       { "pl_PL.utf8", "Polish (Polski)" },
-       { "pt_BR.utf8", "Portuguese (Brasil)" },
-       { "ru_RU.utf8", "Russian (Русский)" },
-       { "es_ES.utf8", "Spanish (Español)" },
-       { "tr_TR.utf8", "Turkish (Türkçe)" },
+       { "fa.utf8",    "فارسی (Persian)" },
+       { "da.utf8",    "Dansk (Danish)" },
+       { "es.utf8",    "Español (Spanish)" },
+       { "en.utf8",    "English" },
+       { "fr.utf8",    "Français (French)" },
+       { "hr.utf8",    "Hrvatski (Croatian)" },
+       { "it.utf8",    "Italiano (Italian)" },
+       { "de.utf8",    "Deutsch (German)" },
+       { "nl.utf8",    "Nederlands (Dutch)" },
+       { "pl.utf8",    "Polski (Polish)" },
+       { "pt.utf8",    "Portuguese (Brasil)" },
+       { "ru.utf8",    "Русский (Russian)" },
+       { "tr.utf8",    "Türkçe (Turkish)" },
        { NULL, NULL },
 };
 
 static struct config {
        int unattended;
        int serial_console;
+       int novga;
        int require_networking;
        int perform_download;
        int disable_swap;
@@ -265,6 +281,7 @@ static struct config {
 } config = {
        .unattended = 0,
        .serial_console = 0,
+       .novga = 0,
        .require_networking = 0,
        .perform_download = 0,
        .disable_swap = 0,
@@ -294,6 +311,10 @@ static void parse_command_line(struct config* c) {
                        if ((strcmp(key, "console") == 0) && (strncmp(val, "ttyS", 4) == 0))
                                c->serial_console = 1;
 
+                       // novga
+                       else if (strcmp(key, "novga") == 0)
+                               c->novga = 1;
+
                        // enable networking?
                        else if (strcmp(token, "installer.net") == 0)
                                c->require_networking = 1;
@@ -374,7 +395,8 @@ int main(int argc, char *argv[]) {
 
        // Draw title
        char* roottext = center_string(system_release, screen_cols);
-       newtDrawRootText(0, 0, roottext);
+       if (roottext)
+               newtDrawRootText(0, 0, roottext);
 
        snprintf(title, sizeof(title), "%s - %s", NAME, SLOGAN);
 
@@ -420,7 +442,8 @@ int main(int argc, char *argv[]) {
        else
                helpline = center_string(_("<Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen"), screen_cols);
 
-       newtPushHelpLine(helpline);
+       if (helpline)
+               newtPushHelpLine(helpline);
 
        if (!config.unattended) {
                snprintf(message, sizeof(message),
@@ -808,6 +831,19 @@ int main(int argc, char *argv[]) {
                replace("/harddisk/etc/inittab", "#7:2345:respawn:", "7:2345:respawn:");
        }
 
+       /* novga */
+       if (config.novga) {
+               /* grub */
+               FILE* f = fopen(DESTINATION_MOUNT_PATH "/etc/default/grub", "a");
+               if (!f) {
+                       errorbox(_("Unable to open /etc/default/grub for writing."));
+                       goto EXIT;
+               }
+
+               fprintf(f, "GRUB_GFXMODE=\"none\"\n");
+               fclose(f);
+       }
+
        rc = hw_install_bootloader(destination, logfile);
        if (rc) {
                errorbox(_("Unable to install the bootloader."));
@@ -816,8 +852,11 @@ int main(int argc, char *argv[]) {
 
        newtPopWindow();
 
-       /* Set marker that the user has already accepted the gpl */
-       mysystem(logfile, "/usr/bin/touch /harddisk/var/ipfire/main/gpl_accepted");
+       /* Set marker that the user has already accepted the GPL if the license has been shown
+        * in the installation process. In unatteded mode, the user will be presented the
+        * license when he or she logs on to the web user interface for the first time. */
+       if (!config.unattended)
+               mysystem(logfile, "/usr/bin/touch /harddisk/var/ipfire/main/gpl_accepted");
 
        /* Copy restore file from cdrom */
        char* backup_file = hw_find_backup_file(logfile, SOURCE_MOUNT_PATH);