#include <libintl.h>
#define _(x) dgettext("installer", x)
-#define INST_FILECOUNT 21000
+#define INST_FILECOUNT 30000
#define LICENSE_FILE "/cdrom/COPYING"
#define SOURCE_TEMPFILE "/tmp/downloads/image.iso"
extern char url[STRING_SIZE];
+FILE* flog = NULL;
+
static int newtChecklist(const char* title, const char* message,
unsigned int width, unsigned int height, unsigned int num_entries,
const char** entries, int* states) {
return ret;
}
-int write_lang_configs(char* lang) {
+int write_lang_configs(const char* lang) {
struct keyvalue *kv = initkeyvalues();
/* default stuff for main/settings. */
- replacekeyvalue(kv, "LANGUAGE", lang);
- replacekeyvalue(kv, "HOSTNAME", SNAME);
+ replacekeyvalue(kv, "LANGUAGE", (char*)lang);
+ replacekeyvalue(kv, "HOSTNAME", DISTRO_SNAME);
replacekeyvalue(kv, "THEME", "ipfire");
writekeyvalues(kv, "/harddisk" CONFIG_ROOT "/main/settings");
freekeyvalues(kv);
static struct config {
int unattended;
int serial_console;
+ int novga;
int require_networking;
int perform_download;
int disable_swap;
char download_url[STRING_SIZE];
char postinstall[STRING_SIZE];
- char* language;
+ const char* language;
} config = {
.unattended = 0,
.serial_console = 0,
+ .novga = 0,
.require_networking = 0,
.perform_download = 0,
.disable_swap = 0,
.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;
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;
FILE *copying;
setlocale(LC_ALL, "");
- sethostname(SNAME, 10);
+ sethostname(DISTRO_SNAME, 10);
/* Log file/terminal stuff. */
- FILE* flog = NULL;
if (argc >= 2) {
logfile = argv[1];
}
fprintf(flog, "Install program started.\n");
-
+ if (hw->efi)
+ fprintf(flog, "EFI mode enabled\n");
+
newtInit();
newtCls();
if (roottext)
newtDrawRootText(0, 0, roottext);
- snprintf(title, sizeof(title), "%s - %s", NAME, SLOGAN);
+ 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);
}
// Load common modules
- mysystem(logfile, "/sbin/modprobe vfat"); // USB key
+ mysystem(logfile, "/sbin/modprobe vfat"); // USB key
+ mysystem(logfile, "/sbin/modprobe ntfs3"); // USB key
hw_stop_all_raid_arrays(logfile);
if (!config.unattended) {
if (!config.unattended) {
snprintf(message, sizeof(message),
_("Welcome to the %s installation program.\n\n"
- "Selecting Cancel on any of the following screens will reboot the computer."), NAME);
+ "Selecting Cancel on any of the following screens will reboot the computer."), DISTRO_NAME);
newtWinMessage(title, _("Start installation"), message);
}
} else {
char reason[STRING_SIZE] = "-";
if (rc == 2)
- snprintf(reason, sizeof(STRING_SIZE), _("MD5 checksum mismatch"));
+ snprintf(reason, sizeof(STRING_SIZE), _("BLAKE2 checksum mismatch"));
snprintf(message, sizeof(message),
_("The installation image could not be downloaded.\n Reason: %s\n\n%s"),
assert(sourcedrive);
int r = hw_mount(sourcedrive, SOURCE_MOUNT_PATH, "iso9660", MS_RDONLY);
- if (r) {
+ if (r) r = hw_mount(sourcedrive, SOURCE_MOUNT_PATH, "ntfs3", MS_RDONLY);
+ if (r) r = hw_mount(sourcedrive, SOURCE_MOUNT_PATH, "vfat", MS_RDONLY);
+ if (r)
+ {
snprintf(message, sizeof(message), _("Could not mount %s to %s:\n %s\n"),
sourcedrive, SOURCE_MOUNT_PATH, strerror(errno));
errorbox(message);
// or if we are running in unattended mode, we will select
// the first disk and go with that one
} else if ((num_disks == 1) || (config.unattended && num_disks >= 1)) {
- selected_disks = hw_select_first_disk((const struct hw_disk**)disks);
+ 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
hw_free_disks(disks);
- struct hw_destination* destination = hw_make_destination(part_type, selected_disks, config.disable_swap);
-
- if (!destination) {
- errorbox(_("Your harddisk is too small."));
- goto EXIT;
- }
-
- 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, " 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
- 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;
- }
- }
-
// Filesystem selection
+ int filesystem = HW_FS_DEFAULT;
+
if (!config.unattended) {
struct filesystems {
int fstype;
{ HW_FS_EXT4, _("ext4 Filesystem") },
{ HW_FS_EXT4_WO_JOURNAL, _("ext4 Filesystem without journal") },
{ HW_FS_XFS, _("XFS Filesystem") },
- { HW_FS_REISERFS, _("ReiserFS Filesystem") },
+ { HW_FS_BTRFS, _("BTRFS Filesystem (EXPERIMENTAL)") },
{ 0, NULL },
};
unsigned int num_filesystems = sizeof(filesystems) / sizeof(*filesystems);
}
rc = newtWinMenu(_("Filesystem Selection"), _("Please choose your filesystem:"),
- 50, 5, 5, 6, fs_names, &fs_choice, _("OK"), _("Cancel"), NULL);
+ 50, 5, 5, 5, fs_names, &fs_choice, _("OK"), _("Cancel"), NULL);
if (rc == 2)
goto EXIT;
- destination->filesystem = filesystems[fs_choice].fstype;
+ filesystem = filesystems[fs_choice].fstype;
+ }
+
+ struct hw_destination* destination = hw_make_destination(hw, part_type,
+ selected_disks, config.disable_swap, filesystem);
+
+ if (!destination) {
+ errorbox(_("Your harddisk is too small."));
+ goto EXIT;
+ }
+
+ 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, "Memory : %lluMB\n", BYTES2MB(hw_memory()));
+
+ // Warn the user if there is not enough space to create 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;
+ }
}
// Setting up RAID if needed.
// Extract files...
snprintf(commandstring, STRING_SIZE,
- "/bin/tar -C /harddisk -xvf /cdrom/distro.img --lzma 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)) {
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..."));
fclose(f);
replace(DESTINATION_MOUNT_PATH "/etc/default/grub", "panic=10", "panic=10 console=ttyS0,115200n8");
+ }
- /* inittab */
- replace("/harddisk/etc/inittab", "1:2345:respawn:", "#1:2345:respawn:");
- replace("/harddisk/etc/inittab", "2:2345:respawn:", "#2:2345:respawn:");
- replace("/harddisk/etc/inittab", "3:2345:respawn:", "#3:2345:respawn:");
- replace("/harddisk/etc/inittab", "4:2345:respawn:", "#4:2345:respawn:");
- replace("/harddisk/etc/inittab", "5:2345:respawn:", "#5:2345:respawn:");
- replace("/harddisk/etc/inittab", "6:2345:respawn:", "#6:2345:respawn:");
- 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);
+ rc = hw_install_bootloader(hw, destination, logfile);
if (rc) {
errorbox(_("Unable to install the bootloader."));
goto EXIT;
}
// 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) {
"Please remove any installation mediums from this system and hit the reboot button. "
"Once the system has restarted you will be asked to setup networking and system passwords. "
"After that, you should point your web browser at https://%s:444 (or what ever you name "
- "your %s) for the web configuration console."), NAME, SNAME, NAME);
+ "your %s) for the web configuration console."), DISTRO_NAME, DISTRO_SNAME, DISTRO_NAME);
newtWinMessage(_("Congratulations!"), _("Reboot"), message);
}