$grub_plattform = "efi-amd64" if -d "/sys/firmware/efi";
-my $IPV4OCTET = "(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])";
+my $IPV4OCTET = "(?:25[0-5]|(?:2[0-4]|1[0-9]|[1-9])?[0-9])";
my $IPV4RE = "(?:(?:$IPV4OCTET\\.){3}$IPV4OCTET)";
+my $IPV6H16 = "(?:[0-9a-fA-F]{1,4})";
+my $IPV6LS32 = "(?:(?:$IPV4RE|$IPV6H16:$IPV6H16))";
+
+my $IPV6RE = "(?:" .
+ "(?:(?:" . "(?:$IPV6H16:){6})$IPV6LS32)|" .
+ "(?:(?:" . "::(?:$IPV6H16:){5})$IPV6LS32)|" .
+ "(?:(?:(?:" . "$IPV6H16)?::(?:$IPV6H16:){4})$IPV6LS32)|" .
+ "(?:(?:(?:(?:$IPV6H16:){0,1}$IPV6H16)?::(?:$IPV6H16:){3})$IPV6LS32)|" .
+ "(?:(?:(?:(?:$IPV6H16:){0,2}$IPV6H16)?::(?:$IPV6H16:){2})$IPV6LS32)|" .
+ "(?:(?:(?:(?:$IPV6H16:){0,3}$IPV6H16)?::(?:$IPV6H16:){1})$IPV6LS32)|" .
+ "(?:(?:(?:(?:$IPV6H16:){0,4}$IPV6H16)?::" . ")$IPV6LS32)|" .
+ "(?:(?:(?:(?:$IPV6H16:){0,5}$IPV6H16)?::" . ")$IPV6H16)|" .
+ "(?:(?:(?:(?:$IPV6H16:){0,6}$IPV6H16)?::" . ")))";
+
+my $IPRE = "(?:$IPV4RE|$IPV6RE)";
+
+
my $ipv4_mask_hash = {
'128.0.0.0' => 1,
'192.0.0.0' => 2,
my ($window, $cmdbox, $inbox, $htmlview);
my ($next, $next_fctn, $target_hd);
my ($progress, $progress_status);
-my ($ipaddress, $ipconf_entry_addr);
+my ($ipversion, $ipaddress, $ipconf_entry_addr);
my ($netmask, $ipconf_entry_mask);
my ($gateway, $ipconf_entry_gw);
my ($dnsserver, $ipconf_entry_dns);
my $fssetup = {
ext3 => {
mkfs => 'mkfs.ext3 -F',
+ mkfs_root_opt => '',
+ mkfs_data_opt => '-m 0',
root_mountopt => 'errors=remount-ro',
},
ext4 => {
mkfs => 'mkfs.ext4 -F',
+ mkfs_root_opt => '',
+ mkfs_data_opt => '-m 0',
root_mountopt => 'errors=remount-ro',
},
xfs => {
mkfs => 'mkfs.xfs -f',
+ mkfs_root_opt => '',
+ mkfs_data_opt => '',
root_mountopt => '',
},
};
sub create_filesystem {
- my ($dev, $name, $type, $start, $end, $fs, $fe, $opts) = @_;
-
- $opts = '' if !$opts;
+ my ($dev, $name, $type, $start, $end, $fs, $fe) = @_;
my $range = $end - $start;
my $rs = $start + $range*$fs;
my $max = 0;
my $fsdata = $fssetup->{$type} || die "internal error - unknown file system '$type'";
+ my $opts = $name eq 'root' ? $fsdata->{mkfs_root_opt} : $fsdata->{mkfs_data_opt};
update_progress (0, $rs, $re, "creating $name filesystem");
sub zfs_create_rpool {
my ($zfspoolname, $vdev) = @_;
- syscmd ("zpool create -f -o ashift=12 $zfspoolname $vdev") == 0 ||
+ syscmd ("zpool create -f -o ashift=12 -o cachefile=none $zfspoolname $vdev") == 0 ||
die "unable to create zfs root pool\n";
syscmd ("zfs create $zfspoolname/ROOT") == 0 ||
if ( -b $target_hd) {
create_filesystem ($rootdev, 'root', $filesys, 0.05, $maxper, 0, 0.5);
- create_filesystem ($datadev, 'data', $filesys, 0.05, $maxper, 0.5, 1, '-m 0');
+ create_filesystem ($datadev, 'data', $filesys, 0.05, $maxper, 0.5, 1);
} else {
- create_filesystem ($rootdev, 'root', $filesys, 0.05, $maxper, 0, 1, '-m 0');
+ create_filesystem ($rootdev, 'root', $filesys, 0.05, $maxper, 0, 1);
}
}
# configure interfaces
- my $ifaces =
- "auto lo\niface lo inet loopback\n\n" .
- "auto vmbr0\niface vmbr0 inet static\n" .
- "\taddress $ipaddress\n" .
- "\tnetmask $netmask\n" .
- "\tgateway $gateway\n" .
- "\tbridge_ports eth0\n" .
- "\tbridge_stp off\n" .
- "\tbridge_fd 0\n";
+ my $ifaces = "auto lo\niface lo inet loopback\n\n";
+
+ my $ntype = $ipversion == 4 ? 'inet' : 'inet6';
+
+ $ifaces .=
+ "auto vmbr0\niface vmbr0 $ntype static\n" .
+ "\taddress $ipaddress\n" .
+ "\tnetmask $netmask\n" .
+ "\tgateway $gateway\n" .
+ "\tbridge_ports eth0\n" .
+ "\tbridge_stp off\n" .
+ "\tbridge_fd 0\n";
write_config ($ifaces, "$targetdir/etc/network/interfaces");
$text =~ s/\s+$//;
if ($text =~ m!^($IPV4RE)$!) {
$ipaddress = $text;
+ $ipversion = 4;
+ } elsif ($text =~ m!^($IPV6RE)$!) {
+ $ipaddress = $text;
+ $ipversion = 6;
} else {
display_message ("IP address is not valid.");
$ipconf_entry_addr->grab_focus();
$text = $ipconf_entry_mask->get_text();
$text =~ s/^\s+//;
$text =~ s/\s+$//;
- if (defined($ipv4_mask_hash->{$text})) {
+ if (($ipversion == 6) && ($text =~ m/^(\d+)$/) && ($1 >= 8) && ($1 <= 126)) {
+ $netmask = $text;
+ } elsif (($ipversion == 4) && defined($ipv4_mask_hash->{$text})) {
$netmask = $text;
} else {
display_message ("Netmask is not valid.");
$text = $ipconf_entry_gw->get_text();
$text =~ s/^\s+//;
$text =~ s/\s+$//;
- if ($text =~ m!^($IPV4RE)$!) {
+ if (($ipversion == 4) && ($text =~ m!^($IPV4RE)$!)) {
+ $gateway = $text;
+ } elsif (($ipversion == 6) && ($text =~ m!^($IPV6RE)$!)) {
$gateway = $text;
} else {
display_message ("Gateway is not valid.");
$text = $ipconf_entry_dns->get_text();
$text =~ s/^\s+//;
$text =~ s/\s+$//;
- if ($text =~ m!^($IPV4RE)$!) {
+ if (($ipversion == 4) && ($text =~ m!^($IPV4RE)$!)) {
+ $dnsserver = $text;
+ } elsif (($ipversion == 6) && ($text =~ m!^($IPV6RE)$!)) {
$dnsserver = $text;
} else {
display_message ("DNS server is not valid.");