]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - src/installer/main.c
installer: Bind-mount /sys/firmware/efi/efivars into chroot
[people/pmueller/ipfire-2.x.git] / src / installer / main.c
index c7075aa71da60719ba260982e2b8d8d746faf58c..fabc0ef524824a63c3f467f0d7e291f635f9d33a 100644 (file)
@@ -23,7 +23,7 @@
 #include <libintl.h>
 #define _(x) dgettext("installer", x)
 
-#define INST_FILECOUNT 21000
+#define INST_FILECOUNT 28000
 #define LICENSE_FILE   "/cdrom/COPYING"
 #define SOURCE_TEMPFILE "/tmp/downloads/image.iso"
 
@@ -290,18 +290,23 @@ static struct config {
        .language = DEFAULT_LANG,
 };
 
-static void parse_command_line(struct config* c) {
+static void parse_command_line(FILE* flog, struct config* c) {
        char buffer[STRING_SIZE];
        char cmdline[STRING_SIZE];
 
        FILE* f = fopen("/proc/cmdline", "r");
-       if (!f)
+       if (!f) {
+               fprintf(flog, "Could not open /proc/cmdline: %m");
                return;
+       }
 
        int r = fread(&cmdline, 1, sizeof(cmdline) - 1, f);
        if (r > 0) {
-               char* token = strtok(cmdline, " ");
+               // Remove the trailing newline
+               if (cmdline[r-1] == '\n')
+                       cmdline[r-1] = '\0';
 
+               char* token = strtok(cmdline, " ");
                while (token) {
                        strncpy(buffer, token, sizeof(buffer));
                        char* val = buffer;
@@ -383,7 +388,9 @@ int main(int argc, char *argv[]) {
        }
 
        fprintf(flog, "Install program started.\n");
-               
+       if (hw->efi)
+               fprintf(flog, "EFI mode enabled\n");
+
        newtInit();
        newtCls();
 
@@ -401,7 +408,7 @@ int main(int argc, char *argv[]) {
        snprintf(title, sizeof(title), "%s - %s", DISTRO_NAME, DISTRO_SLOGAN);
 
        // Parse parameters from the kernel command line
-       parse_command_line(&config);
+       parse_command_line(flog, &config);
 
        if (config.unattended) {
                splashWindow(title, _("Warning: Unattended installation will start in 10 seconds..."), 10);
@@ -673,7 +680,8 @@ int main(int argc, char *argv[]) {
 
        hw_free_disks(disks);
 
-       struct hw_destination* destination = hw_make_destination(part_type, selected_disks, config.disable_swap);
+       struct hw_destination* destination = hw_make_destination(hw, part_type,
+               selected_disks, config.disable_swap);
 
        if (!destination) {
                errorbox(_("Your harddisk is too small."));
@@ -683,9 +691,9 @@ int main(int argc, char *argv[]) {
        fprintf(flog, "Destination drive: %s\n", destination->path);
        fprintf(flog, "  bootldr: %s (%lluMB)\n", destination->part_bootldr, BYTES2MB(destination->size_bootldr));
        fprintf(flog, "  boot   : %s (%lluMB)\n", destination->part_boot, BYTES2MB(destination->size_boot));
+       fprintf(flog, "  ESP    : %s (%lluMB)\n", destination->part_boot_efi, BYTES2MB(destination->size_boot_efi));
        fprintf(flog, "  swap   : %s (%lluMB)\n", destination->part_swap, BYTES2MB(destination->size_swap));
        fprintf(flog, "  root   : %s (%lluMB)\n", destination->part_root, BYTES2MB(destination->size_root));
-       fprintf(flog, "  data   : %s (%lluMB)\n", destination->part_data, BYTES2MB(destination->size_data));
        fprintf(flog, "Memory   : %lluMB\n", BYTES2MB(hw_memory()));
 
        // Warn the user if there is not enough space to create a swap partition
@@ -778,7 +786,7 @@ int main(int argc, char *argv[]) {
 
        // Extract files...
        snprintf(commandstring, STRING_SIZE,
-               "/bin/tar -C /harddisk -xvf /cdrom/distro.img --xz 2>/dev/null");
+               "/bin/tar --acls --xattrs --xattrs-include='*' -C /harddisk -xvf /cdrom/distro.img --zstd 2>/dev/null");
 
        if (runcommandwithprogress(60, 4, title, commandstring, INST_FILECOUNT,
                        _("Installing the system..."), logfile)) {
@@ -803,6 +811,13 @@ int main(int argc, char *argv[]) {
                goto EXIT;
        }
 
+       /* trigger udev to add disk-by-uuid entries */
+       snprintf(commandstring, STRING_SIZE, "/usr/sbin/chroot /harddisk /sbin/udevadm trigger");
+       if (runcommandwithstatus(commandstring, title, _("Trigger udev to redetect partitions..."), logfile)) {
+               errorbox(_("Error triggering udev to redetect partitions."));
+               goto EXIT;
+       }
+
        // Installing bootloader...
        statuswindow(60, 4, title, _("Installing the bootloader..."));
 
@@ -835,7 +850,7 @@ int main(int argc, char *argv[]) {
                fclose(f);
        }
 
-       rc = hw_install_bootloader(destination, logfile);
+       rc = hw_install_bootloader(hw, destination, logfile);
        if (rc) {
                errorbox(_("Unable to install the bootloader."));
                goto EXIT;
@@ -894,7 +909,7 @@ int main(int argc, char *argv[]) {
        }
 
        // Umount source drive and eject
-       hw_umount(SOURCE_MOUNT_PATH);
+       hw_umount(SOURCE_MOUNT_PATH, NULL);
 
        // Free downloaded ISO image
        if (strcmp(sourcedrive, SOURCE_TEMPFILE) == 0) {