]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
installer: Allow to disable creation of swap space on command line
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 26 Oct 2014 15:00:03 +0000 (16:00 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 26 Oct 2014 15:00:03 +0000 (16:00 +0100)
src/installer/hw.c
src/installer/hw.h
src/installer/main.c

index e14a47016e951e9993e867dcb8e082b87bda2cb5..d74526050037e48a1458fa04403430b631903221 100644 (file)
@@ -440,7 +440,7 @@ static int hw_device_has_p_suffix(const struct hw_destination* dest) {
        return 0;
 }
 
        return 0;
 }
 
-static int hw_calculate_partition_table(struct hw_destination* dest) {
+static int hw_calculate_partition_table(struct hw_destination* dest, int disable_swap) {
        char path[DEV_SIZE];
        int part_idx = 1;
 
        char path[DEV_SIZE];
        int part_idx = 1;
 
@@ -493,9 +493,14 @@ static int hw_calculate_partition_table(struct hw_destination* dest) {
        }
 
        dest->size_boot = hw_boot_size(dest);
        }
 
        dest->size_boot = hw_boot_size(dest);
-       dest->size_swap = hw_swap_size(dest);
        dest->size_root = hw_root_size(dest);
 
        dest->size_root = hw_root_size(dest);
 
+       // Should we use swap?
+       if (disable_swap)
+               dest->size_swap = 0;
+       else
+               dest->size_swap = hw_swap_size(dest);
+
        // Determine the size of the data partition.
        unsigned long long used_space = dest->size_bootldr + dest->size_boot
                + dest->size_swap + dest->size_root;
        // Determine the size of the data partition.
        unsigned long long used_space = dest->size_bootldr + dest->size_boot
                + dest->size_swap + dest->size_root;
@@ -540,7 +545,7 @@ static int hw_calculate_partition_table(struct hw_destination* dest) {
        return 0;
 }
 
        return 0;
 }
 
-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, int disable_swap) {
        struct hw_destination* dest = malloc(sizeof(*dest));
 
        if (part_type == HW_PART_TYPE_NORMAL) {
        struct hw_destination* dest = malloc(sizeof(*dest));
 
        if (part_type == HW_PART_TYPE_NORMAL) {
@@ -560,7 +565,7 @@ struct hw_destination* hw_make_destination(int part_type, struct hw_disk** disks
        // Is this a RAID device?
        dest->is_raid = (part_type > HW_PART_TYPE_NORMAL);
 
        // Is this a RAID device?
        dest->is_raid = (part_type > HW_PART_TYPE_NORMAL);
 
-       int r = hw_calculate_partition_table(dest);
+       int r = hw_calculate_partition_table(dest, disable_swap);
        if (r)
                return NULL;
 
        if (r)
                return NULL;
 
index 83753fdc0dec1d937e7a0193a6a1c6f38cb96900..f16b39cb6a04a0b86e50ec73573166092f62a3ea 100644 (file)
@@ -111,7 +111,8 @@ unsigned int hw_count_disks(const 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_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,
+       int disable_swap);
 
 unsigned long long hw_memory();
 
 
 unsigned long long hw_memory();
 
index 1d8abb81ba39279daeddb4f871151614e651b00a..d3e1c6e3edcedf32a9a2b7ab1e7a4ac44e5eb7bf 100644 (file)
@@ -231,12 +231,14 @@ static struct config {
        int serial_console;
        int require_networking;
        int perform_download;
        int serial_console;
        int require_networking;
        int perform_download;
+       int disable_swap;
        char download_url[STRING_SIZE];
 } config = {
        .unattended = 0,
        .serial_console = 0,
        .require_networking = 0,
        .perform_download = 0,
        char download_url[STRING_SIZE];
 } config = {
        .unattended = 0,
        .serial_console = 0,
        .require_networking = 0,
        .perform_download = 0,
+       .disable_swap = 0,
        .download_url = DOWNLOAD_URL,
 };
 
        .download_url = DOWNLOAD_URL,
 };
 
@@ -269,6 +271,10 @@ static void parse_command_line(struct config* c) {
                        else if (strcmp(token, "installer.unattended") == 0)
                                c->unattended = 1;
 
                        else if (strcmp(token, "installer.unattended") == 0)
                                c->unattended = 1;
 
+                       // disable swap
+                       else if (strcmp(token, "installer.disable-swap") == 0)
+                               c->disable_swap = 1;
+
                        // download url
                        else if (strcmp(key, "installer.download-url") == 0) {
                                strncpy(c->download_url, val, sizeof(c->download_url));
                        // download url
                        else if (strcmp(key, "installer.download-url") == 0) {
                                strncpy(c->download_url, val, sizeof(c->download_url));
@@ -601,7 +607,7 @@ int main(int argc, char *argv[]) {
 
        hw_free_disks(disks);
 
 
        hw_free_disks(disks);
 
-       struct hw_destination* destination = hw_make_destination(part_type, selected_disks);
+       struct hw_destination* destination = hw_make_destination(part_type, selected_disks, config.disable_swap);
 
        if (!destination) {
                errorbox(_("Your harddisk is too small."));
 
        if (!destination) {
                errorbox(_("Your harddisk is too small."));
@@ -617,19 +623,21 @@ int main(int argc, char *argv[]) {
        fprintf(flog, "Memory   : %lluMB\n", BYTES2MB(hw_memory()));
 
        // Warn the user if there is not enough space to create a swap partition
        fprintf(flog, "Memory   : %lluMB\n", BYTES2MB(hw_memory()));
 
        // Warn the user if there is not enough space to create a swap partition
-       if (!config.unattended && !*destination->part_swap) {
-               rc = newtWinChoice(title, _("OK"), _("Cancel"),
-                       _("Your harddisk is very small, but you can continue without a swap partition."));
+       if (!config.unattended) {
+               if (!config.disable_swap && !*destination->part_swap) {
+                       rc = newtWinChoice(title, _("OK"), _("Cancel"),
+                               _("Your harddisk is very small, but you can continue without a swap partition."));
 
 
-               if (rc != 1)
-                       goto EXIT;
+                       if (rc != 1)
+                               goto EXIT;
+               }
        }
 
        // Filesystem selection
        if (!config.unattended) {
                struct filesystems {
                        int fstype;
        }
 
        // Filesystem selection
        if (!config.unattended) {
                struct filesystems {
                        int fstype;
-                       const char* description;
+                       char* description;
                } filesystems[] = {
                        { HW_FS_EXT4,            _("ext4 Filesystem") },
                        { HW_FS_EXT4_WO_JOURNAL, _("ext4 Filesystem without journal") },
                } filesystems[] = {
                        { HW_FS_EXT4,            _("ext4 Filesystem") },
                        { HW_FS_EXT4_WO_JOURNAL, _("ext4 Filesystem without journal") },
@@ -645,7 +653,7 @@ int main(int argc, char *argv[]) {
                        if (HW_FS_DEFAULT == filesystems[i].fstype)
                                fs_choice = i;
 
                        if (HW_FS_DEFAULT == filesystems[i].fstype)
                                fs_choice = i;
 
-                       fs_names[i] = &filesystems[i].description;
+                       fs_names[i] = filesystems[i].description;
                }
 
                rc = newtWinMenu(_("Filesystem Selection"), _("Please choose your filesystem:"),
                }
 
                rc = newtWinMenu(_("Filesystem Selection"), _("Please choose your filesystem:"),