]> git.proxmox.com Git - pve-installer.git/blobdiff - proxinstall
merge installer into single package
[pve-installer.git] / proxinstall
index 03f6ec7b047026e5a570667111fe925a8bf26159..7bd4892adf5f0821d47b878ab82c324eeeefe0b8 100755 (executable)
@@ -25,38 +25,22 @@ use POSIX ":sys_wait_h";
 
 use ProxmoxInstallerSetup;
 
-my $setup = ProxmoxInstallerSetup::setup();
-
-my $opt_testmode;
-
 if (!$ENV{G_SLICE} ||  $ENV{G_SLICE} ne "always-malloc") {
     die "do not use slice allocator (run with 'G_SLICE=always-malloc ./proxinstall ...')\n";
 }
 
+my $opt_testmode;
 if (!GetOptions('testmode=s' => \$opt_testmode)) {
     die "usage error\n";
     exit (-1);
 }
 
+my ($setup, $cd_info) = ProxmoxInstallerSetup::setup();
+
 my $zfstestpool = "test_rpool";
 my $zfspoolname = $opt_testmode ? $zfstestpool : 'rpool';
 my $zfsrootvolname = "$setup->{product}-1";
 
-my $product_cfg = {
-    pve => {
-       fullname => 'Proxmox VE',
-       port => '8006',
-    },
-    pmg => {
-       fullname => 'Proxmox Mail Gateway',
-       port => '8006',
-    },
-    pbs => {
-       fullname => 'Proxmox Backup Server',
-       port => '8007',
-    },
-};
-
 my $storage_cfg_zfs = <<__EOD__;
 dir: local
        path /var/lib/vz
@@ -109,8 +93,10 @@ sub file_read_firstline {
 
 my $logfd = IO::File->new(">/tmp/install.log");
 
-my $proxmox_libdir = $opt_testmode ?
-    Cwd::cwd() . "/testdir/var/lib/pve-installer" : "/var/lib/pve-installer";
+my $proxmox_libdir = $opt_testmode
+    ? Cwd::cwd() . "/testdir/var/lib/proxmox-installer"
+    : "/var/lib/proxmox-installer"
+    ;
 my $proxmox_cddir = $opt_testmode ? "../pve-cd-builder/tmp/data-gz/" : "/cdrom";
 my $proxmox_pkgdir = "${proxmox_cddir}/proxmox/packages/";
 
@@ -1224,11 +1210,11 @@ my sub chroot_chmod {
        die "chroot: unable to change permission mode for '$path'\n";
 }
 
-sub prepare_systemd_boot_esp {
+sub prepare_proxmox_boot_esp {
     my ($espdev, $targetdir) = @_;
 
-    syscmd("chroot $targetdir pve-efiboot-tool init $espdev") == 0 ||
-       die "unable to init ESP and install systemd-boot loader on '$espdev'\n";
+    syscmd("chroot $targetdir proxmox-boot-tool init $espdev") == 0 ||
+       die "unable to init ESP and install proxmox-boot loader on '$espdev'\n";
 }
 
 sub prepare_grub_efi_boot_esp {
@@ -1362,20 +1348,21 @@ sub extract_data {
                $disksize = $size;
            }
 
-           &$udevadm_trigger_block();
+           $udevadm_trigger_block->();
 
            btrfs_create($btrfs_partitions, $btrfs_mode);
 
        } elsif ($use_zfs) {
 
-           my ($devlist, $bootdevlist, $vdev) = get_zfs_raid_setup();
+           my ($devlist, $vdev) = get_zfs_raid_setup();
 
            foreach my $hd (@$devlist) {
-               &$clean_disk(@$hd[1]);
+               $clean_disk->(@$hd[1]);
            }
 
+           # install esp/boot part on all, we can only win!
            my $disksize;
-           foreach my $hd (@$bootdevlist) {
+           for my $hd (@$devlist) {
                my $devname = @$hd[1];
                my $logical_bsize = @$hd[4];
 
@@ -1393,7 +1380,7 @@ sub extract_data {
                $disksize = $size;
            }
 
-           &$udevadm_trigger_block();
+           $udevadm_trigger_block->();
 
            foreach my $di (@$bootdevinfo) {
                my $devname = $di->{devname};
@@ -1820,19 +1807,19 @@ _EOD
 
                foreach my $di (@$bootdevinfo) {
                    my $dev = $di->{devname};
-                   if (!$native_4k_disk_bootable) {
-                       eval {
-                           syscmd("chroot $targetdir /usr/sbin/grub-install --target i386-pc --no-floppy --bootloader-id='proxmox' $dev") == 0 ||
-                                   die "unable to install the i386-pc boot loader on '$dev'\n";
-                       };
-                       push @$bootloader_err_list, $@ if $@;
-                   }
+                   if ($use_zfs) {
+                       prepare_proxmox_boot_esp($di->{esp}, $targetdir);
+                   } else {
+                       if (!$native_4k_disk_bootable) {
+                           eval {
+                               syscmd("chroot $targetdir /usr/sbin/grub-install --target i386-pc --no-floppy --bootloader-id='proxmox' $dev") == 0 ||
+                                       die "unable to install the i386-pc boot loader on '$dev'\n";
+                           };
+                           push @$bootloader_err_list, $@ if $@;
+                       }
 
                    eval {
                        if (my $esp = $di->{esp}) {
-                           if ($use_zfs) {
-                               prepare_systemd_boot_esp($esp, $targetdir);
-                           } else {
                                prepare_grub_efi_boot_esp($dev, $esp, $targetdir);
                            }
                        }
@@ -1991,14 +1978,18 @@ sub display_html {
 
     $filename = $steps[$step_number]->{html} if !$filename;
 
-    my $path = "${proxmox_libdir}/html/$filename";
-
-    my $url = "file://$path";
+    my $htmldir = "${proxmox_libdir}/html";
+    my $path;
+    if (-f "$htmldir/$setup->{product}/$filename") {
+       $path = "$htmldir/$setup->{product}/$filename";
+    } elsif (-f "$htmldir/common/$filename") {
+       $path = "$htmldir/common/$filename";
+    } else {
+       # FIXME: die now already?
+    }
 
     my $data = file_get_contents($path);
 
-    my $product = $product_cfg->{$setup->{product}};
-
     if ($filename eq 'license.htm') {
        my $license = eval { decode('utf8', file_get_contents("${proxmox_cddir}/EULA")) };
        if (my $err = $@) {
@@ -2011,16 +2002,18 @@ sub display_html {
     } elsif ($filename eq 'success.htm') {
        my $addr = $ipversion == 6 ? "[${ipaddress}]" : "$ipaddress";
        $data =~ s/__IPADDR__/$addr/g;
-       $data =~ s/__PORT__/$product->{port}/g;
+       $data =~ s/__PORT__/$setup->{port}/g;
 
        my $autoreboot_msg = $config_options->{autoreboot}
            ? "Automatic reboot scheduled in $autoreboot_seconds seconds."
            : '';
        $data =~ s/__AUTOREBOOT_MSG__/$autoreboot_msg/;
     }
-    $data =~ s/__FULL_PRODUCT_NAME__/$product->{fullname}/g;
+    $data =~ s/__FULL_PRODUCT_NAME__/$setup->{fullname}/g;
 
-    $htmlview->load_html($data, $url);
+    # HACK: always set base-path to common path, all resources are there.
+    # NOTE: we could also use an overlayfs with lower=common upper=$product & work=/run/$tmp
+    $htmlview->load_html($data,  "file://$htmldir/common/");
 
     $last_display_change = time();
 }
@@ -2509,8 +2502,8 @@ sub create_ack_view {
     });
     $vbox->pack_start($reboot_checkbox, 0, 0, 2);
 
-    my $ack_template = "${proxmox_libdir}/html/ack_template.htm";
-    my $ack_html = "${proxmox_libdir}/html/$steps[$step_number]->{html}";
+    my $ack_template = "${proxmox_libdir}/html/common/ack_template.htm";
+    my $ack_html = "${proxmox_libdir}/html/$setup->{product}/$steps[$step_number]->{html}";
     my $html_data = file_get_contents($ack_template);
 
     my %config_values = (
@@ -2554,9 +2547,14 @@ sub get_device_desc {
        my $text = "$devname (";
        if ($size >= 1024) {
            $size = int($size/1024); # size in GB
-           $text .= "${size}GB";
+           if ($size >= 1024) {
+               $size = int($size/1024); # size in GB
+               $text .= "${size}TiB";
+           } else {
+               $text .= "${size}GiB";
+           }
        } else {
-           $text .= "${size}MB";
+           $text .= "${size}MiB";
        }
 
        $text .= ", $model" if $model;
@@ -3340,7 +3338,6 @@ sub legacy_bios_4k_check {
 }
 
 sub get_zfs_raid_setup {
-
     my $filesys = $config_options->{filesys};
 
     my $devlist = &$get_raid_devlist();
@@ -3348,11 +3345,8 @@ sub get_zfs_raid_setup {
     my $diskcount = scalar(@$devlist);
     die "$filesys needs at least one device\n" if $diskcount < 1;
 
-    my $bootdevlist = [];
-
     my $cmd= '';
     if ($filesys eq 'zfs (RAID0)') {
-       push @$bootdevlist, @$devlist[0];
        foreach my $hd (@$devlist) {
            legacy_bios_4k_check(@$hd[4]);
            $cmd .= " @$hd[1]";
@@ -3366,14 +3360,11 @@ sub get_zfs_raid_setup {
            zfs_mirror_size_check($expected_size, @$hd[2]);
            legacy_bios_4k_check(@$hd[4]);
            $cmd .= " @$hd[1]";
-           push @$bootdevlist, $hd;
        }
     } elsif ($filesys eq 'zfs (RAID10)') {
        die "zfs (RAID10) needs at least 4 device\n" if $diskcount < 4;
        die "zfs (RAID10) needs an even number of devices\n" if $diskcount & 1;
 
-       push @$bootdevlist, @$devlist[0], @$devlist[1];
-
        for (my $i = 0; $i < $diskcount; $i+=2) {
            my $hd1 = @$devlist[$i];
            my $hd2 = @$devlist[$i+1];
@@ -3394,13 +3385,12 @@ sub get_zfs_raid_setup {
            zfs_mirror_size_check($expected_size, @$hd[2]);
            legacy_bios_4k_check(@$hd[4]);
            $cmd .= " @$hd[1]";
-           push @$bootdevlist, $hd;
        }
     } else {
        die "unknown zfs mode '$filesys'\n";
     }
 
-    return ($devlist, $bootdevlist, $cmd);
+    return ($devlist, $cmd);
 }
 
 sub get_btrfs_raid_setup {
@@ -3580,10 +3570,8 @@ sub create_intro_view {
     cleanup_view();
 
     if (int($total_memory) < 1024) {
-       my $product = $product_cfg->{$setup->{product}};
-
        display_error("Less than 1 GiB of usable memory detected, installation will probably fail.\n\n".
-           "See 'System Requirements' in the $product->{fullname} documentation.");
+           "See 'System Requirements' in the $setup->{fullname} documentation.");
     }
 
     if ($setup->{product} eq 'pve') {