summaryrefslogtreecommitdiffstats
path: root/installer
diff options
context:
space:
mode:
authorOliver Tappe2008-03-20 01:04:16 +0100
committerOliver Tappe2008-03-20 01:04:16 +0100
commita0ce0340d0f95514008cfac751fe58748bbadd88 (patch)
tree844bb9e015f2fbcd83de54c3a63dd027b1218211 /installer
parent* fixed several bugs with respect to the listing of plugins (as part of a system (diff)
downloadcore-a0ce0340d0f95514008cfac751fe58748bbadd88.tar.gz
core-a0ce0340d0f95514008cfac751fe58748bbadd88.tar.xz
core-a0ce0340d0f95514008cfac751fe58748bbadd88.zip
* Switched indent used in Perl-code and settings files from tabs to 4 spaces.
May need some manual corrections here and there, but should basically be ok. git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1658 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'installer')
-rw-r--r--installer/OpenSLX/OSExport/BlockDevice/AoE.pm72
-rw-r--r--installer/OpenSLX/OSExport/BlockDevice/Base.pm6
-rw-r--r--installer/OpenSLX/OSExport/BlockDevice/DNBD2.pm78
-rw-r--r--installer/OpenSLX/OSExport/BlockDevice/NBD.pm70
-rw-r--r--installer/OpenSLX/OSExport/Distro/Any.pm56
-rw-r--r--installer/OpenSLX/OSExport/Distro/Base.pm18
-rw-r--r--installer/OpenSLX/OSExport/Distro/Debian.pm50
-rw-r--r--installer/OpenSLX/OSExport/Distro/Fedora.pm62
-rw-r--r--installer/OpenSLX/OSExport/Distro/Gentoo.pm50
-rw-r--r--installer/OpenSLX/OSExport/Distro/SUSE.pm158
-rw-r--r--installer/OpenSLX/OSExport/Distro/Ubuntu.pm54
-rw-r--r--installer/OpenSLX/OSExport/Engine.pm492
-rw-r--r--installer/OpenSLX/OSExport/FileSystem/Base.pm104
-rw-r--r--installer/OpenSLX/OSExport/FileSystem/NFS.pm212
-rw-r--r--installer/OpenSLX/OSExport/FileSystem/SquashFS.pm412
-rw-r--r--installer/OpenSLX/OSSetup/Distro/Any_Clone.pm8
-rw-r--r--installer/OpenSLX/OSSetup/Distro/Base.pm428
-rw-r--r--installer/OpenSLX/OSSetup/Distro/Debian.pm134
-rw-r--r--installer/OpenSLX/OSSetup/Distro/Debian_3_1.pm40
-rw-r--r--installer/OpenSLX/OSSetup/Distro/Fedora.pm28
-rw-r--r--installer/OpenSLX/OSSetup/Distro/Gentoo.pm50
-rw-r--r--installer/OpenSLX/OSSetup/Distro/SUSE.pm68
-rw-r--r--installer/OpenSLX/OSSetup/Distro/Ubuntu.pm108
-rw-r--r--installer/OpenSLX/OSSetup/Engine.pm3026
-rw-r--r--installer/OpenSLX/OSSetup/MetaPackager/Base.pm14
-rw-r--r--installer/OpenSLX/OSSetup/MetaPackager/apt.pm166
-rw-r--r--installer/OpenSLX/OSSetup/MetaPackager/smart.pm148
-rw-r--r--installer/OpenSLX/OSSetup/MetaPackager/yum.pm110
-rw-r--r--installer/OpenSLX/OSSetup/MetaPackager/zypper.pm106
-rw-r--r--installer/OpenSLX/OSSetup/Packager/Base.pm14
-rw-r--r--installer/OpenSLX/OSSetup/Packager/dpkg.pm102
-rw-r--r--installer/OpenSLX/OSSetup/Packager/rpm.pm76
-rwxr-xr-xinstaller/slxos-export214
-rwxr-xr-xinstaller/slxos-setup256
34 files changed, 3495 insertions, 3495 deletions
diff --git a/installer/OpenSLX/OSExport/BlockDevice/AoE.pm b/installer/OpenSLX/OSExport/BlockDevice/AoE.pm
index 9a7450f5..d3916d6a 100644
--- a/installer/OpenSLX/OSExport/BlockDevice/AoE.pm
+++ b/installer/OpenSLX/OSExport/BlockDevice/AoE.pm
@@ -9,8 +9,8 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# AoE.pm
-# - provides ATA-over-Ethernet specific overrides of the
-# OpenSLX::OSExport::BlockDevice API.
+# - provides ATA-over-Ethernet specific overrides of the
+# OpenSLX::OSExport::BlockDevice API.
# -----------------------------------------------------------------------------
package OpenSLX::OSExport::BlockDevice::AoE;
@@ -36,71 +36,71 @@ use OpenSLX::Utils;
################################################################################
sub new
{
- my $class = shift;
- my $self = {'name' => 'aoe',};
- return bless $self, $class;
+ my $class = shift;
+ my $self = {'name' => 'aoe',};
+ return bless $self, $class;
}
sub initialize
{
- my $self = shift;
- my $engine = shift;
- my $fs = shift;
+ my $self = shift;
+ my $engine = shift;
+ my $fs = shift;
- $self->{'engine'} = $engine;
- $self->{'fs'} = $fs;
- return;
+ $self->{'engine'} = $engine;
+ $self->{'fs'} = $fs;
+ return;
}
sub getExportPort
{
- my $self = shift;
- my $openslxDB = shift;
+ my $self = shift;
+ my $openslxDB = shift;
- return $openslxDB->incrementGlobalCounter('next-nbd-server-port');
+ return $openslxDB->incrementGlobalCounter('next-nbd-server-port');
}
sub generateExportURI
{
- my $self = shift;
- my $export = shift;
+ my $self = shift;
+ my $export = shift;
- my $serverIP = $export->{server_ip} || '';
- my $server
- = length($serverIP) ? $serverIP : generatePlaceholderFor('serverip');
- $server .= ":$export->{port}" if length($export->{port});
+ my $serverIP = $export->{server_ip} || '';
+ my $server
+ = length($serverIP) ? $serverIP : generatePlaceholderFor('serverip');
+ $server .= ":$export->{port}" if length($export->{port});
- return "aoe://$server";
+ return "aoe://$server";
}
sub requiredBlockDeviceModules
{
- my $self = shift;
+ my $self = shift;
- return qw( aoe );
+ return qw( aoe );
}
sub requiredBlockDeviceTools
{
- my $self = shift;
+ my $self = shift;
- # TODO: is there any such tool?
+ # TODO: is there any such tool?
- return;
+ return;
}
sub showExportConfigInfo
{
- my $self = shift;
- my $export = shift;
-
- print(('#' x 80) . "\n");
- print _tr(
- "Please make sure you start a corresponding aoe-server:\n\t%s\n",
- "... (don't know how this is done yet)"
- );
- print(('#' x 80) . "\n");
- return;
+ my $self = shift;
+ my $export = shift;
+
+ print(('#' x 80) . "\n");
+ print _tr(
+ "Please make sure you start a corresponding aoe-server:\n\t%s\n",
+ "... (don't know how this is done yet)"
+ );
+ print(('#' x 80) . "\n");
+ return;
}
1;
diff --git a/installer/OpenSLX/OSExport/BlockDevice/Base.pm b/installer/OpenSLX/OSExport/BlockDevice/Base.pm
index 80868a80..d2395e30 100644
--- a/installer/OpenSLX/OSExport/BlockDevice/Base.pm
+++ b/installer/OpenSLX/OSExport/BlockDevice/Base.pm
@@ -9,14 +9,14 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# Base.pm
-# - provides empty base of the OpenSLX OSExport::BlockDevice API.
+# - provides empty base of the OpenSLX OSExport::BlockDevice API.
# -----------------------------------------------------------------------------
package OpenSLX::OSExport::BlockDevice::Base;
use strict;
use warnings;
-our $VERSION = 1.01; # API-version . implementation-version
+our $VERSION = 1.01; # API-version . implementation-version
use OpenSLX::Basics;
@@ -25,7 +25,7 @@ use OpenSLX::Basics;
################################################################################
sub new
{
- confess "Creating OpenSLX::OSExport::BlockDevice::Base-objects directly makes no sense!";
+ confess "Creating OpenSLX::OSExport::BlockDevice::Base-objects directly makes no sense!";
}
sub initialize
diff --git a/installer/OpenSLX/OSExport/BlockDevice/DNBD2.pm b/installer/OpenSLX/OSExport/BlockDevice/DNBD2.pm
index 8cd20904..8dcc340b 100644
--- a/installer/OpenSLX/OSExport/BlockDevice/DNBD2.pm
+++ b/installer/OpenSLX/OSExport/BlockDevice/DNBD2.pm
@@ -9,8 +9,8 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# DNBD2.pm
-# - provides DNBD2+Squashfs-specific overrides of the
-# OpenSLX::OSExport::BlockDevice API.
+# - provides DNBD2+Squashfs-specific overrides of the
+# OpenSLX::OSExport::BlockDevice API.
# -----------------------------------------------------------------------------
package OpenSLX::OSExport::BlockDevice::DNBD2;
@@ -30,73 +30,73 @@ use OpenSLX::Utils;
################################################################################
sub new
{
- my $class = shift;
- my $self = {'name' => 'dnbd2',};
- return bless $self, $class;
+ my $class = shift;
+ my $self = {'name' => 'dnbd2',};
+ return bless $self, $class;
}
sub initialize
{
- my $self = shift;
- my $engine = shift;
- my $fs = shift;
+ my $self = shift;
+ my $engine = shift;
+ my $fs = shift;
- $self->{'engine'} = $engine;
- $self->{'fs'} = $fs;
- return;
+ $self->{'engine'} = $engine;
+ $self->{'fs'} = $fs;
+ return;
}
sub getExportPort
{
- my $self = shift;
- my $openslxDB = shift;
+ my $self = shift;
+ my $openslxDB = shift;
- return $openslxDB->incrementGlobalCounter('next-nbd-server-port');
+ return $openslxDB->incrementGlobalCounter('next-nbd-server-port');
}
sub generateExportURI
{
- my $self = shift;
- my $export = shift;
+ my $self = shift;
+ my $export = shift;
- my $serverIP = $export->{server_ip} || '';
- my $server
- = length($serverIP) ? $serverIP : generatePlaceholderFor('serverip');
- $server .= ":$export->{port}" if length($export->{port});
+ my $serverIP = $export->{server_ip} || '';
+ my $server
+ = length($serverIP) ? $serverIP : generatePlaceholderFor('serverip');
+ $server .= ":$export->{port}" if length($export->{port});
- return "dnbd2://$server";
+ return "dnbd2://$server";
}
sub requiredBlockDeviceModules
{
- my $self = shift;
+ my $self = shift;
- return qw( dnbd2 );
+ return qw( dnbd2 );
}
sub requiredBlockDeviceTools
{
- my $self = shift;
+ my $self = shift;
- return qw( );
+ return qw( );
}
sub showExportConfigInfo
{
- my $self = shift;
- my $export = shift;
-
- print '#' x 80 , "\n",
- _tr(
- "Please make sure you start a corresponding dnbd2-server:\n\t%s\n",
- "dnbd2-server /etc/dnbd2/server.conf\n"
- ),
- "Create or modify a config file like /etc/dnbd2/server.conf, looking like:",
- "<server>\n",
- "$export->{port}\n",
- "$self->{fs}->{'export-path'}\n",
- '#' x 80, "\n";
- return;
+ my $self = shift;
+ my $export = shift;
+
+ print '#' x 80 , "\n",
+ _tr(
+ "Please make sure you start a corresponding dnbd2-server:\n\t%s\n",
+ "dnbd2-server /etc/dnbd2/server.conf\n"
+ ),
+ "Create or modify a config file like /etc/dnbd2/server.conf, looking like:",
+ "<server>\n",
+ "$export->{port}\n",
+ "$self->{fs}->{'export-path'}\n",
+ '#' x 80, "\n";
+ return;
}
1;
diff --git a/installer/OpenSLX/OSExport/BlockDevice/NBD.pm b/installer/OpenSLX/OSExport/BlockDevice/NBD.pm
index fff4b024..73694fbc 100644
--- a/installer/OpenSLX/OSExport/BlockDevice/NBD.pm
+++ b/installer/OpenSLX/OSExport/BlockDevice/NBD.pm
@@ -9,8 +9,8 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# NBD.pm
-# - provides NBD+Squashfs-specific overrides of the
-# OpenSLX::OSExport::BlockDevice API.
+# - provides NBD+Squashfs-specific overrides of the
+# OpenSLX::OSExport::BlockDevice API.
# -----------------------------------------------------------------------------
package OpenSLX::OSExport::BlockDevice::NBD;
@@ -30,69 +30,69 @@ use OpenSLX::Utils;
################################################################################
sub new
{
- my $class = shift;
- my $self = {'name' => 'nbd',};
- return bless $self, $class;
+ my $class = shift;
+ my $self = {'name' => 'nbd',};
+ return bless $self, $class;
}
sub initialize
{
- my $self = shift;
- my $engine = shift;
- my $fs = shift;
+ my $self = shift;
+ my $engine = shift;
+ my $fs = shift;
- $self->{'engine'} = $engine;
- $self->{'fs'} = $fs;
- return;
+ $self->{'engine'} = $engine;
+ $self->{'fs'} = $fs;
+ return;
}
sub getExportPort
{
- my $self = shift;
- my $openslxDB = shift;
+ my $self = shift;
+ my $openslxDB = shift;
- return $openslxDB->incrementGlobalCounter('next-nbd-server-port');
+ return $openslxDB->incrementGlobalCounter('next-nbd-server-port');
}
sub generateExportURI
{
- my $self = shift;
- my $export = shift;
+ my $self = shift;
+ my $export = shift;
- my $serverIP = $export->{server_ip} || '';
- my $server
- = length($serverIP) ? $serverIP : generatePlaceholderFor('serverip');
- $server .= ":$export->{port}" if length($export->{port});
+ my $serverIP = $export->{server_ip} || '';
+ my $server
+ = length($serverIP) ? $serverIP : generatePlaceholderFor('serverip');
+ $server .= ":$export->{port}" if length($export->{port});
- return "nbd://$server";
+ return "nbd://$server";
}
sub requiredBlockDeviceModules
{
- my $self = shift;
+ my $self = shift;
- return qw( nbd );
+ return qw( nbd );
}
sub requiredBlockDeviceTools
{
- my $self = shift;
+ my $self = shift;
- return qw( nbd-client );
+ return qw( nbd-client );
}
sub showExportConfigInfo
{
- my $self = shift;
- my $export = shift;
-
- print(('#' x 80) . "\n");
- print _tr(
- "Please make sure you start a corresponding nbd-server:\n\t%s\n",
- "nbd-server $export->{port} $self->{fs}->{'export-path'} -r"
- );
- print(('#' x 80) . "\n");
- return;
+ my $self = shift;
+ my $export = shift;
+
+ print(('#' x 80) . "\n");
+ print _tr(
+ "Please make sure you start a corresponding nbd-server:\n\t%s\n",
+ "nbd-server $export->{port} $self->{fs}->{'export-path'} -r"
+ );
+ print(('#' x 80) . "\n");
+ return;
}
1;
diff --git a/installer/OpenSLX/OSExport/Distro/Any.pm b/installer/OpenSLX/OSExport/Distro/Any.pm
index bf780bb9..59de2f32 100644
--- a/installer/OpenSLX/OSExport/Distro/Any.pm
+++ b/installer/OpenSLX/OSExport/Distro/Any.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# Any.pm
-# - provides generic overrides of the OpenSLX OSExport API.
+# - provides generic overrides of the OpenSLX OSExport API.
# -----------------------------------------------------------------------------
package OpenSLX::OSExport::Distro::Any;
@@ -25,41 +25,41 @@ use OpenSLX::Basics;
################################################################################
sub new
{
- my $class = shift;
- my $self = {
- 'base-name' => 'any',
- };
- return bless $self, $class;
+ my $class = shift;
+ my $self = {
+ 'base-name' => 'any',
+ };
+ return bless $self, $class;
}
sub initDistroInfo
{
- my $self = shift;
+ my $self = shift;
- $self->{'export-filter'} = "
- - /var/tmp/*
- - /var/spool/*
- - /var/run/*
- - /var/lock/*
- - /var/log/*
- - /var/lib/xdm
- - /var/lib/smart
- - /var/cache/yum
- - /var/cache/man/*
- - /usr/share/vmware/*
- - /tmp/*
- - /sys/*
- - /proc/*
- - /mnt/*
- - /media/*
+ $self->{'export-filter'} = "
+ - /var/tmp/*
+ - /var/spool/*
+ - /var/run/*
+ - /var/lock/*
+ - /var/log/*
+ - /var/lib/xdm
+ - /var/lib/smart
+ - /var/cache/yum
+ - /var/cache/man/*
+ - /usr/share/vmware/*
+ - /tmp/*
+ - /sys/*
+ - /proc/*
+ - /mnt/*
+ - /media/*
+ /lib/modules/*/misc/vmblock.o
+ /lib/modules/*/misc/vmnet.o
+ /lib/modules/*/misc/vmmon.o
- - /lib/klibc/events/*
- - /boot/initrd*
- - /boot/grub
- ";
- return;
+ - /lib/klibc/events/*
+ - /boot/initrd*
+ - /boot/grub
+ ";
+ return;
}
1; \ No newline at end of file
diff --git a/installer/OpenSLX/OSExport/Distro/Base.pm b/installer/OpenSLX/OSExport/Distro/Base.pm
index 29659f09..b6fc1fae 100644
--- a/installer/OpenSLX/OSExport/Distro/Base.pm
+++ b/installer/OpenSLX/OSExport/Distro/Base.pm
@@ -9,15 +9,15 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# Base.pm
-# - provides empty base of the distro-specific part of the OpenSLX
-# OSExport API.
+# - provides empty base of the distro-specific part of the OpenSLX
+# OSExport API.
# -----------------------------------------------------------------------------
package OpenSLX::OSExport::Distro::Base;
use strict;
use warnings;
-our $VERSION = 1.01; # API-version . implementation-version
+our $VERSION = 1.01; # API-version . implementation-version
use OpenSLX::Basics;
@@ -26,18 +26,18 @@ use OpenSLX::Basics;
################################################################################
sub new
{
- confess "Creating OpenSLX::OSExport::Distro::Base-objects directly makes no sense!";
+ confess "Creating OpenSLX::OSExport::Distro::Base-objects directly makes no sense!";
}
sub initialize
{
- my $self = shift;
- my $engine = shift;
+ my $self = shift;
+ my $engine = shift;
- $self->{'engine'} = $engine;
+ $self->{'engine'} = $engine;
- $self->initDistroInfo();
- return;
+ $self->initDistroInfo();
+ return;
}
sub initDistroInfo
diff --git a/installer/OpenSLX/OSExport/Distro/Debian.pm b/installer/OpenSLX/OSExport/Distro/Debian.pm
index 4da68ffb..d1ae7d88 100644
--- a/installer/OpenSLX/OSExport/Distro/Debian.pm
+++ b/installer/OpenSLX/OSExport/Distro/Debian.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# Debian.pm
-# - provides Debian-specific overrides of the OpenSLX OSExport API.
+# - provides Debian-specific overrides of the OpenSLX OSExport API.
# -----------------------------------------------------------------------------
package OpenSLX::OSExport::Distro::Debian;
@@ -25,35 +25,35 @@ use OpenSLX::Basics;
################################################################################
sub new
{
- my $class = shift;
- my $self = {
- 'base-name' => 'debian',
- };
- return bless $self, $class;
+ my $class = shift;
+ my $self = {
+ 'base-name' => 'debian',
+ };
+ return bless $self, $class;
}
sub initDistroInfo
{
- my $self = shift;
+ my $self = shift;
- $self->{'export-filter'} = "
- - /var/tmp/*
- - /var/spool/*
- - /var/run/*
- - /var/log/*
- - /var/lib/xdm
- - /var/cache/man/*
- - /usr/share/vmware/*
- - /tmp/*
- - /sys/*
- - /proc/*
- - /mnt/*
- - /media/*
- - /lib/klibc/events/*
- - /boot/initrd*
- - /boot/grub
- ";
- return;
+ $self->{'export-filter'} = "
+ - /var/tmp/*
+ - /var/spool/*
+ - /var/run/*
+ - /var/log/*
+ - /var/lib/xdm
+ - /var/cache/man/*
+ - /usr/share/vmware/*
+ - /tmp/*
+ - /sys/*
+ - /proc/*
+ - /mnt/*
+ - /media/*
+ - /lib/klibc/events/*
+ - /boot/initrd*
+ - /boot/grub
+ ";
+ return;
}
1; \ No newline at end of file
diff --git a/installer/OpenSLX/OSExport/Distro/Fedora.pm b/installer/OpenSLX/OSExport/Distro/Fedora.pm
index a643c91a..4e8c0bf0 100644
--- a/installer/OpenSLX/OSExport/Distro/Fedora.pm
+++ b/installer/OpenSLX/OSExport/Distro/Fedora.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# Fedora.pm
-# - provides Fedora-specific overrides of the OpenSLX OSExport API.
+# - provides Fedora-specific overrides of the OpenSLX OSExport API.
# -----------------------------------------------------------------------------
package OpenSLX::OSExport::Distro::Fedora;
@@ -25,41 +25,41 @@ use OpenSLX::Basics;
################################################################################
sub new
{
- my $class = shift;
- my $self = {
- 'base-name' => 'fedora',
- };
- return bless $self, $class;
+ my $class = shift;
+ my $self = {
+ 'base-name' => 'fedora',
+ };
+ return bless $self, $class;
}
sub initDistroInfo
{
- my $self = shift;
+ my $self = shift;
- # TODO: check and refine this!
- $self->{'export-filter'} = "
- - /var/tmp/*
- - /var/spool/*
- - /var/run/*
- - /var/lock/*
- - /var/log/*
- - /var/lib/xdm
- - /var/lib/smart
- - /var/cache/yum
- - /var/cache/man/*
- - /usr/share/vmware/*
- - /tmp/*
- - /sys/*
- - /proc/*
- - /mnt/*
- - /media/*
- - /lib/klibc/events/*
- - /boot/initrd*
- - /boot/grub
- - *.rpmsave
- - *.rpmnew
- ";
- return;
+ # TODO: check and refine this!
+ $self->{'export-filter'} = "
+ - /var/tmp/*
+ - /var/spool/*
+ - /var/run/*
+ - /var/lock/*
+ - /var/log/*
+ - /var/lib/xdm
+ - /var/lib/smart
+ - /var/cache/yum
+ - /var/cache/man/*
+ - /usr/share/vmware/*
+ - /tmp/*
+ - /sys/*
+ - /proc/*
+ - /mnt/*
+ - /media/*
+ - /lib/klibc/events/*
+ - /boot/initrd*
+ - /boot/grub
+ - *.rpmsave
+ - *.rpmnew
+ ";
+ return;
}
1; \ No newline at end of file
diff --git a/installer/OpenSLX/OSExport/Distro/Gentoo.pm b/installer/OpenSLX/OSExport/Distro/Gentoo.pm
index d46b6037..1df759dd 100644
--- a/installer/OpenSLX/OSExport/Distro/Gentoo.pm
+++ b/installer/OpenSLX/OSExport/Distro/Gentoo.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# Gentoo.pm
-# - provides Gentoo-specific overrides of the OpenSLX OSExport API.
+# - provides Gentoo-specific overrides of the OpenSLX OSExport API.
# -----------------------------------------------------------------------------
package OpenSLX::OSExport::Distro::Gentoo;
@@ -25,35 +25,35 @@ use OpenSLX::Basics;
################################################################################
sub new
{
- my $class = shift;
- my $self = {
- 'base-name' => 'gentoo',
- };
- return bless $self, $class;
+ my $class = shift;
+ my $self = {
+ 'base-name' => 'gentoo',
+ };
+ return bless $self, $class;
}
sub initDistroInfo
{
- my $self = shift;
+ my $self = shift;
- $self->{'export-filter'} = "
- - /var/tmp/*
- - /var/spool/*
- - /var/run/*
- - /var/log/*
- - /var/lib/xdm
- - /var/lib/init.d/*
- - /var/cache/man/*
- - /usr/share/vmware/*
- - /tmp/*
- - /sys/*
- - /proc/*
- - /mnt/*
- - /media/*
- - /boot/initrd*
- - /boot/grub
- ";
- return;
+ $self->{'export-filter'} = "
+ - /var/tmp/*
+ - /var/spool/*
+ - /var/run/*
+ - /var/log/*
+ - /var/lib/xdm
+ - /var/lib/init.d/*
+ - /var/cache/man/*
+ - /usr/share/vmware/*
+ - /tmp/*
+ - /sys/*
+ - /proc/*
+ - /mnt/*
+ - /media/*
+ - /boot/initrd*
+ - /boot/grub
+ ";
+ return;
}
1; \ No newline at end of file
diff --git a/installer/OpenSLX/OSExport/Distro/SUSE.pm b/installer/OpenSLX/OSExport/Distro/SUSE.pm
index 5d7ed615..7f5d5548 100644
--- a/installer/OpenSLX/OSExport/Distro/SUSE.pm
+++ b/installer/OpenSLX/OSExport/Distro/SUSE.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# SUSE.pm
-# - provides SUSE-specific overrides of the OpenSLX OSExport API.
+# - provides SUSE-specific overrides of the OpenSLX OSExport API.
# -----------------------------------------------------------------------------
package OpenSLX::OSExport::Distro::SUSE;
@@ -25,89 +25,89 @@ use OpenSLX::Basics;
################################################################################
sub new
{
- my $class = shift;
- my $self = {
- 'base-name' => 'suse',
- };
- return bless $self, $class;
+ my $class = shift;
+ my $self = {
+ 'base-name' => 'suse',
+ };
+ return bless $self, $class;
}
sub initDistroInfo
{
- my $self = shift;
+ my $self = shift;
- $self->{'export-filter'} = "
- - /var/tmp/*
- - /var/spool/*
- - /var/run/*
- - /var/mail
- - /var/log/*
- - /var/lock/*
- - /var/lib/zypp/*
- - /var/lib/zmd
- - /var/lib/xdm
- - /var/lib/vm*
- - /var/lib/suspend*
- - /var/lib/smart
- - /var/lib/sax
- - /var/lib/hardware/*
- - /var/lib/gdm/*
- - /var/lib/dhcp*
- - /var/lib/bluetooth/
- - /var/lib/YaST2/you/mnt/*
- - /var/lib/YaST2/backup_boot_sectors
- - /var/cache/sax
- - /var/cache/libx11/compose/*
- - /var/cache/beagle
- - /var/cache/yum
- - /var/cache/man/*
- - /var/adm/backup/rpmdb/*
- - /var/adm/mount/AP*
- - /var/adm/SuSEconfig
- - /usr/share/vmware/*
- - /usr/lib/zen-updater
- + /usr/lib/python*/*/*.o
- + /usr/lib/perl5/*/*/*/*.o
- + /usr/lib/gcc/*/*/*.o
- + /usr/lib/*.o
- + /usr/X11R6/lib/modules/drivers/*.o
- + /usr/X11R6/lib/modules/drivers/linux/*.o
- - /usr/bin/zen-*
- - /usr/bin/nw-manager
- - /usr/X11R6/bin/BackGround
- - /usr/bin/BackGround
- - /tmp/*
- - /sys/*
- - /proc/*
- - /opt/kde3/share/autostart/suseplugger.desktop
- - /opt/kde3/share/autostart/susewatcher.desktop
- - /opt/kde3/share/autostart/runupdater.desktop
- - /opt/kde3/share/autostart/profile_chooser-autostart.desktop
- - /opt/kde3/share/autostart/opensuseupdater.desktop
- - /opt/kde3/share/autostart/knetworkmanager-autostart.desktop
- - /opt/kde3/share/autostart/kerry.autostart.desktop
- - /opt/kde3/share/autostart/kinternet.desktop
- - /opt/kde3/share/autostart/beagled.desktop
- - /opt/kde3/share/autostart/SUSEgreeter.desktop
- - /opt/kde3/share/autostart/zen-updater-auto.desktop
- - /opt/gnome/share/autostart/beagle*.desktop
- - /mnt/*
- - /media/*
- + /media
- + /lib/modules/*/misc/vmblock.o
- + /lib/modules/*/misc/vmnet.o
- + /lib/modules/*/misc/vmmon.o
- - /etc/dhcpd.conf*
- - /etc/cron.*/*
- - /etc/sysconfig/network/ifcfg-*
- - /etc/X11/xdm/SuSEconfig.xdm
- - /boot/initrd*
- - /boot/grub
- - *.rpmsave
- - *.rpmnew
- - *.YaST2save
- ";
- return;
+ $self->{'export-filter'} = "
+ - /var/tmp/*
+ - /var/spool/*
+ - /var/run/*
+ - /var/mail
+ - /var/log/*
+ - /var/lock/*
+ - /var/lib/zypp/*
+ - /var/lib/zmd
+ - /var/lib/xdm
+ - /var/lib/vm*
+ - /var/lib/suspend*
+ - /var/lib/smart
+ - /var/lib/sax
+ - /var/lib/hardware/*
+ - /var/lib/gdm/*
+ - /var/lib/dhcp*
+ - /var/lib/bluetooth/
+ - /var/lib/YaST2/you/mnt/*
+ - /var/lib/YaST2/backup_boot_sectors
+ - /var/cache/sax
+ - /var/cache/libx11/compose/*
+ - /var/cache/beagle
+ - /var/cache/yum
+ - /var/cache/man/*
+ - /var/adm/backup/rpmdb/*
+ - /var/adm/mount/AP*
+ - /var/adm/SuSEconfig
+ - /usr/share/vmware/*
+ - /usr/lib/zen-updater
+ + /usr/lib/python*/*/*.o
+ + /usr/lib/perl5/*/*/*/*.o
+ + /usr/lib/gcc/*/*/*.o
+ + /usr/lib/*.o
+ + /usr/X11R6/lib/modules/drivers/*.o
+ + /usr/X11R6/lib/modules/drivers/linux/*.o
+ - /usr/bin/zen-*
+ - /usr/bin/nw-manager
+ - /usr/X11R6/bin/BackGround
+ - /usr/bin/BackGround
+ - /tmp/*
+ - /sys/*
+ - /proc/*
+ - /opt/kde3/share/autostart/suseplugger.desktop
+ - /opt/kde3/share/autostart/susewatcher.desktop
+ - /opt/kde3/share/autostart/runupdater.desktop
+ - /opt/kde3/share/autostart/profile_chooser-autostart.desktop
+ - /opt/kde3/share/autostart/opensuseupdater.desktop
+ - /opt/kde3/share/autostart/knetworkmanager-autostart.desktop
+ - /opt/kde3/share/autostart/kerry.autostart.desktop
+ - /opt/kde3/share/autostart/kinternet.desktop
+ - /opt/kde3/share/autostart/beagled.desktop
+ - /opt/kde3/share/autostart/SUSEgreeter.desktop
+ - /opt/kde3/share/autostart/zen-updater-auto.desktop
+ - /opt/gnome/share/autostart/beagle*.desktop
+ - /mnt/*
+ - /media/*
+ + /media
+ + /lib/modules/*/misc/vmblock.o
+ + /lib/modules/*/misc/vmnet.o
+ + /lib/modules/*/misc/vmmon.o
+ - /etc/dhcpd.conf*
+ - /etc/cron.*/*
+ - /etc/sysconfig/network/ifcfg-*
+ - /etc/X11/xdm/SuSEconfig.xdm
+ - /boot/initrd*
+ - /boot/grub
+ - *.rpmsave
+ - *.rpmnew
+ - *.YaST2save
+ ";
+ return;
}
1;
diff --git a/installer/OpenSLX/OSExport/Distro/Ubuntu.pm b/installer/OpenSLX/OSExport/Distro/Ubuntu.pm
index c26aa706..0f60b63f 100644
--- a/installer/OpenSLX/OSExport/Distro/Ubuntu.pm
+++ b/installer/OpenSLX/OSExport/Distro/Ubuntu.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# Ubuntu.pm
-# - provides Ubuntu-specific overrides of the OpenSLX OSExport API.
+# - provides Ubuntu-specific overrides of the OpenSLX OSExport API.
# -----------------------------------------------------------------------------
package OpenSLX::OSExport::Distro::Ubuntu;
@@ -25,37 +25,37 @@ use OpenSLX::Basics;
################################################################################
sub new
{
- my $class = shift;
- my $self = {
- 'base-name' => 'ubuntu',
- };
- return bless $self, $class;
+ my $class = shift;
+ my $self = {
+ 'base-name' => 'ubuntu',
+ };
+ return bless $self, $class;
}
sub initDistroInfo
{
- my $self = shift;
+ my $self = shift;
- $self->{'export-filter'} = "
- - /var/tmp/*
- - /var/spool/*
- - /var/run/*
- - /var/log/*
- - /var/lib/xdm
- - /var/cache/man/*
- - /usr/share/vmware/*
- - /tmp/*
- - /sys/*
- - /proc/*
- - /mnt/*
- - /media/*
- - /lib/klibc/events/*
- - /initrd*
- - /etc/cron.*/*
- - /boot/initrd*
- - /boot/grub
- ";
- return;
+ $self->{'export-filter'} = "
+ - /var/tmp/*
+ - /var/spool/*
+ - /var/run/*
+ - /var/log/*
+ - /var/lib/xdm
+ - /var/cache/man/*
+ - /usr/share/vmware/*
+ - /tmp/*
+ - /sys/*
+ - /proc/*
+ - /mnt/*
+ - /media/*
+ - /lib/klibc/events/*
+ - /initrd*
+ - /etc/cron.*/*
+ - /boot/initrd*
+ - /boot/grub
+ ";
+ return;
}
1; \ No newline at end of file
diff --git a/installer/OpenSLX/OSExport/Engine.pm b/installer/OpenSLX/OSExport/Engine.pm
index 743a46b9..7aba36da 100644
--- a/installer/OpenSLX/OSExport/Engine.pm
+++ b/installer/OpenSLX/OSExport/Engine.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# Engine.pm
-# - provides driver engine for the OSExport API.
+# - provides driver engine for the OSExport API.
# -----------------------------------------------------------------------------
package OpenSLX::OSExport::Engine;
@@ -38,30 +38,30 @@ our (
);
%supportedExportFileSystems = (
- 'nfs' => 'NFS',
- 'sqfs' => 'SquashFS',
+ 'nfs' => 'NFS',
+ 'sqfs' => 'SquashFS',
);
%supportedExportBlockDevices = (
- 'dnbd2' => 'DNBD2',
- 'nbd' => 'NBD',
- 'aoe' => 'AoE',
+ 'dnbd2' => 'DNBD2',
+ 'nbd' => 'NBD',
+ 'aoe' => 'AoE',
);
@supportedExportTypes = (
- 'nfs',
- 'sqfs-aoe',
- 'sqfs-dnbd2',
- 'sqfs-nbd',
+ 'nfs',
+ 'sqfs-aoe',
+ 'sqfs-dnbd2',
+ 'sqfs-nbd',
);
%supportedDistros = (
- '<any>' => {module => 'Any'},
- 'debian' => {module => 'Debian'},
- 'fedora' => {module => 'Fedora'},
- 'gentoo' => {module => 'Gentoo'},
- 'suse' => {module => 'SUSE'},
- 'ubuntu' => {module => 'Ubuntu'},
+ '<any>' => {module => 'Any'},
+ 'debian' => {module => 'Debian'},
+ 'fedora' => {module => 'Fedora'},
+ 'gentoo' => {module => 'Gentoo'},
+ 'suse' => {module => 'SUSE'},
+ 'ubuntu' => {module => 'Ubuntu'},
);
################################################################################
@@ -69,117 +69,117 @@ our (
################################################################################
sub new
{
- my $class = shift;
+ my $class = shift;
- my $self = {};
+ my $self = {};
- return bless $self, $class;
+ return bless $self, $class;
}
sub initializeFromExisting
{
- my $self = shift;
- my $exportName = shift;
+ my $self = shift;
+ my $exportName = shift;
- my $openslxDB = instantiateClass("OpenSLX::ConfigDB");
- $openslxDB->connect();
+ my $openslxDB = instantiateClass("OpenSLX::ConfigDB");
+ $openslxDB->connect();
- my $export = $openslxDB->fetchExportByFilter({'name' => $exportName});
- if (!defined $export) {
- die _tr("Export '%s' not found in DB, giving up!", $exportName);
- }
- my $vendorOS =
- $openslxDB->fetchVendorOSByFilter({'id' => $export->{vendor_os_id}});
+ my $export = $openslxDB->fetchExportByFilter({'name' => $exportName});
+ if (!defined $export) {
+ die _tr("Export '%s' not found in DB, giving up!", $exportName);
+ }
+ my $vendorOS =
+ $openslxDB->fetchVendorOSByFilter({'id' => $export->{vendor_os_id}});
- $openslxDB->disconnect();
+ $openslxDB->disconnect();
- $self->_initialize($vendorOS->{name}, $vendorOS->{id}, $export->{name},
- $export->{type});
- return;
+ $self->_initialize($vendorOS->{name}, $vendorOS->{id}, $export->{name},
+ $export->{type});
+ return;
}
sub initializeForNew
{
- my $self = shift;
- my $vendorOSName = shift;
- my $exportType = lc(shift);
+ my $self = shift;
+ my $vendorOSName = shift;
+ my $exportType = lc(shift);
- my $openslxDB = instantiateClass("OpenSLX::ConfigDB");
- $openslxDB->connect();
+ my $openslxDB = instantiateClass("OpenSLX::ConfigDB");
+ $openslxDB->connect();
- my $vendorOS = $openslxDB->fetchVendorOSByFilter({'name' => $vendorOSName});
- if (!defined $vendorOS) {
- die _tr("vendor-OS '%s' not found in DB, giving up!", $vendorOSName);
- }
+ my $vendorOS = $openslxDB->fetchVendorOSByFilter({'name' => $vendorOSName});
+ if (!defined $vendorOS) {
+ die _tr("vendor-OS '%s' not found in DB, giving up!", $vendorOSName);
+ }
- my $exportName = "${vendorOSName}::${exportType}";
+ my $exportName = "${vendorOSName}::${exportType}";
- $openslxDB->disconnect();
+ $openslxDB->disconnect();
- $self->_initialize($vendorOS->{name}, $vendorOS->{id}, $exportName,
- $exportType);
- return;
+ $self->_initialize($vendorOS->{name}, $vendorOS->{id}, $exportName,
+ $exportType);
+ return;
}
sub exportVendorOS
{
- my $self = shift;
-
- if (!$self->{'exporter'}->checkRequirements($self->{'vendor-os-path'})) {
- die _tr(
- "clients wouldn't be able to access the exported root-fs!\nplease "
- . "install the missing module(s) or use another export-type.");
- }
-
- $self->{'exporter'}->exportVendorOS($self->{'vendor-os-path'},);
- vlog(
- 0,
- _tr(
- "vendor-OS '%s' successfully exported to '%s'!",
- $self->{'vendor-os-path'},
- $self->{exporter}->{'export-path'}
- )
- );
- $self->_addExportToConfigDB();
- return;
+ my $self = shift;
+
+ if (!$self->{'exporter'}->checkRequirements($self->{'vendor-os-path'})) {
+ die _tr(
+ "clients wouldn't be able to access the exported root-fs!\nplease "
+ . "install the missing module(s) or use another export-type.");
+ }
+
+ $self->{'exporter'}->exportVendorOS($self->{'vendor-os-path'},);
+ vlog(
+ 0,
+ _tr(
+ "vendor-OS '%s' successfully exported to '%s'!",
+ $self->{'vendor-os-path'},
+ $self->{exporter}->{'export-path'}
+ )
+ );
+ $self->_addExportToConfigDB();
+ return;
}
sub purgeExport
{
- my $self = shift;
-
- if ($self->{'exporter'}->purgeExport()) {
- vlog(
- 0,
- _tr(
- "export '%s' successfully removed!",
- $self->{exporter}->{'export-path'}
- )
- );
- }
- $self->_removeExportFromConfigDB();
- return;
+ my $self = shift;
+
+ if ($self->{'exporter'}->purgeExport()) {
+ vlog(
+ 0,
+ _tr(
+ "export '%s' successfully removed!",
+ $self->{exporter}->{'export-path'}
+ )
+ );
+ }
+ $self->_removeExportFromConfigDB();
+ return;
}
sub generateExportURI
{
- my $self = shift;
+ my $self = shift;
- return $self->{exporter}->generateExportURI(@_);
+ return $self->{exporter}->generateExportURI(@_);
}
sub requiredFSMods
{
- my $self = shift;
+ my $self = shift;
- return $self->{exporter}->requiredFSMods();
+ return $self->{exporter}->requiredFSMods();
}
sub requiredFSTools
{
- my $self = shift;
+ my $self = shift;
- return $self->{exporter}->requiredFSTools();
+ return $self->{exporter}->requiredFSTools();
}
################################################################################
@@ -187,175 +187,175 @@ sub requiredFSTools
################################################################################
sub _initialize
{
- my $self = shift;
- my $vendorOSName = shift;
- my $vendorOSId = shift;
- my $exportName = shift;
- my $exportType = lc(shift);
-
- if ($vendorOSName eq '<<<default>>>') {
- die _tr("you can't do that with the default vendor-OS!\n");
- }
- if (!grep { $_ eq $exportType } @supportedExportTypes) {
- vlog(0,
- _tr("Sorry, export type '%s' is unsupported.\n", $exportType)
- . _tr("List of supported export types:\n\t")
- . join("\n\t", sort @supportedExportTypes));
- exit 1;
- }
- $exportType =~ m[^(\w+)(?:-(\w+))?$];
- my $exportFS = lc($1);
- my $exportBD = lc($2);
- vlog(2, "export-filesys='$exportFS' export-blockdev='$exportBD'");
-
- $self->{'vendor-os-name'} = $vendorOSName;
- $self->{'vendor-os-id'} = $vendorOSId;
- $self->{'export-name'} = $exportName;
- $self->{'export-type'} = $exportType;
- $vendorOSName =~ m[^(.+?\-[^-]+)];
- my $distroName = $1;
- $self->{'distro-name'} = $distroName;
-
- # load module for the requested distro:
- if (!exists $supportedDistros{lc($distroName)}) {
- # try without _x86_64:
- $distroName =~ s[_x86_64$][];
- if (!exists $supportedDistros{lc($distroName)}) {
- # try basic distro-type (e.g. debian or suse):
- $distroName =~ s[-.+$][];
- if (!exists $supportedDistros{lc($distroName)}) {
- # fallback to generic implementation:
- $distroName = '<any>';
- }
- }
- }
- my $distroModuleName = $supportedDistros{lc($distroName)}->{module};
- my $distro =
- instantiateClass("OpenSLX::OSExport::Distro::$distroModuleName");
- $distro->initialize($self);
- $self->{distro} = $distro;
-
- # load module for the requested export type:
- my $fsModuleName = $supportedExportFileSystems{$exportFS};
- my $exporter =
- instantiateClass("OpenSLX::OSExport::FileSystem::$fsModuleName");
- if (length($exportBD)) {
- my $blockModuleName = $supportedExportBlockDevices{$exportBD};
- my $blockDevice =
- instantiateClass("OpenSLX::OSExport::BlockDevice::$blockModuleName");
- $blockDevice->initialize($self, $exporter);
- $exporter->initialize($self, $blockDevice);
- } else {
- $exporter->initialize($self);
- }
- $self->{'exporter'} = $exporter;
-
- # setup source and target paths:
- $self->{'vendor-os-path'} =
- "$openslxConfig{'private-path'}/stage1/$vendorOSName";
- vlog(
- 1,
- _tr(
- "vendor-OS from '%s' will be exported to '%s'",
- $self->{'vendor-os-path'},
- $exporter->{'export-path'}
- )
- );
- return;
+ my $self = shift;
+ my $vendorOSName = shift;
+ my $vendorOSId = shift;
+ my $exportName = shift;
+ my $exportType = lc(shift);
+
+ if ($vendorOSName eq '<<<default>>>') {
+ die _tr("you can't do that with the default vendor-OS!\n");
+ }
+ if (!grep { $_ eq $exportType } @supportedExportTypes) {
+ vlog(0,
+ _tr("Sorry, export type '%s' is unsupported.\n", $exportType)
+ . _tr("List of supported export types:\n\t")
+ . join("\n\t", sort @supportedExportTypes));
+ exit 1;
+ }
+ $exportType =~ m[^(\w+)(?:-(\w+))?$];
+ my $exportFS = lc($1);
+ my $exportBD = lc($2);
+ vlog(2, "export-filesys='$exportFS' export-blockdev='$exportBD'");
+
+ $self->{'vendor-os-name'} = $vendorOSName;
+ $self->{'vendor-os-id'} = $vendorOSId;
+ $self->{'export-name'} = $exportName;
+ $self->{'export-type'} = $exportType;
+ $vendorOSName =~ m[^(.+?\-[^-]+)];
+ my $distroName = $1;
+ $self->{'distro-name'} = $distroName;
+
+ # load module for the requested distro:
+ if (!exists $supportedDistros{lc($distroName)}) {
+ # try without _x86_64:
+ $distroName =~ s[_x86_64$][];
+ if (!exists $supportedDistros{lc($distroName)}) {
+ # try basic distro-type (e.g. debian or suse):
+ $distroName =~ s[-.+$][];
+ if (!exists $supportedDistros{lc($distroName)}) {
+ # fallback to generic implementation:
+ $distroName = '<any>';
+ }
+ }
+ }
+ my $distroModuleName = $supportedDistros{lc($distroName)}->{module};
+ my $distro =
+ instantiateClass("OpenSLX::OSExport::Distro::$distroModuleName");
+ $distro->initialize($self);
+ $self->{distro} = $distro;
+
+ # load module for the requested export type:
+ my $fsModuleName = $supportedExportFileSystems{$exportFS};
+ my $exporter =
+ instantiateClass("OpenSLX::OSExport::FileSystem::$fsModuleName");
+ if (length($exportBD)) {
+ my $blockModuleName = $supportedExportBlockDevices{$exportBD};
+ my $blockDevice =
+ instantiateClass("OpenSLX::OSExport::BlockDevice::$blockModuleName");
+ $blockDevice->initialize($self, $exporter);
+ $exporter->initialize($self, $blockDevice);
+ } else {
+ $exporter->initialize($self);
+ }
+ $self->{'exporter'} = $exporter;
+
+ # setup source and target paths:
+ $self->{'vendor-os-path'} =
+ "$openslxConfig{'private-path'}/stage1/$vendorOSName";
+ vlog(
+ 1,
+ _tr(
+ "vendor-OS from '%s' will be exported to '%s'",
+ $self->{'vendor-os-path'},
+ $exporter->{'export-path'}
+ )
+ );
+ return;
}
sub _addExportToConfigDB
{
- my $self = shift;
-
- my $openslxDB = instantiateClass("OpenSLX::ConfigDB");
- $openslxDB->connect();
-
- my $export = $openslxDB->fetchExportByFilter(
- {
- 'name' => $self->{'export-name'},
- 'vendor_os_id' => $self->{'vendor-os-id'},
- }
- );
- if (defined $export) {
- vlog(
- 0,
- _tr(
- "No need to change export '%s' in OpenSLX-database.\n",
- $self->{'export-name'}
- )
- );
- $self->{exporter}->showExportConfigInfo($export);
- } else {
- $export = {
- 'vendor_os_id' => $self->{'vendor-os-id'},
- 'name' => $self->{'export-name'},
- 'type' => $self->{'export-type'},
- };
-
- my $id = $self->{exporter}->addExportToConfigDB($export, $openslxDB);
- vlog(
- 0,
- _tr(
- "Export '%s' has been added to DB (ID=%s)...\n",
- $self->{'export-name'}, $id
- )
- );
-
- $self->{exporter}->showExportConfigInfo($export) if $id;
- }
-
- my $system = $openslxDB->fetchSystemByFilter({
- 'name' => $self->{'export-name'},
- });
- if (!defined $system) {
- # now create a default system for that export, using the standard kernel:
- system("slxconfig add-system $self->{'export-name'}");
- }
-
- $openslxDB->disconnect();
- return;
+ my $self = shift;
+
+ my $openslxDB = instantiateClass("OpenSLX::ConfigDB");
+ $openslxDB->connect();
+
+ my $export = $openslxDB->fetchExportByFilter(
+ {
+ 'name' => $self->{'export-name'},
+ 'vendor_os_id' => $self->{'vendor-os-id'},
+ }
+ );
+ if (defined $export) {
+ vlog(
+ 0,
+ _tr(
+ "No need to change export '%s' in OpenSLX-database.\n",
+ $self->{'export-name'}
+ )
+ );
+ $self->{exporter}->showExportConfigInfo($export);
+ } else {
+ $export = {
+ 'vendor_os_id' => $self->{'vendor-os-id'},
+ 'name' => $self->{'export-name'},
+ 'type' => $self->{'export-type'},
+ };
+
+ my $id = $self->{exporter}->addExportToConfigDB($export, $openslxDB);
+ vlog(
+ 0,
+ _tr(
+ "Export '%s' has been added to DB (ID=%s)...\n",
+ $self->{'export-name'}, $id
+ )
+ );
+
+ $self->{exporter}->showExportConfigInfo($export) if $id;
+ }
+
+ my $system = $openslxDB->fetchSystemByFilter({
+ 'name' => $self->{'export-name'},
+ });
+ if (!defined $system) {
+ # now create a default system for that export, using the standard kernel:
+ system("slxconfig add-system $self->{'export-name'}");
+ }
+
+ $openslxDB->disconnect();
+ return;
}
sub _removeExportFromConfigDB
{
- my $self = shift;
-
- my $openslxDB = instantiateClass("OpenSLX::ConfigDB");
- $openslxDB->connect();
-
- # remove export from DB:
- my $exportName = $self->{'export-name'};
- my $export = $openslxDB->fetchExportByFilter({'name' => $exportName,});
- if (!defined $export) {
- vlog(
- 0,
- _tr(
- "Export '%s' doesn't exist in OpenSLX-database.\n", $exportName
- )
- );
- } else {
- # remove all systems using this export and then remove the
- # export itself:
- my @systemIDs =
- map { $_->{id} }
- $openslxDB->fetchSystemByFilter({'export_id' => $export->{id}}, 'id');
- vlog(
- 1,
- _tr(
- "removing systems '%s' from DB, since they belong to the export"
- . " being deleted.\n",
- join ',',
- @systemIDs
- )
- );
- $openslxDB->removeSystem(\@systemIDs);
- $openslxDB->removeExport($export->{id});
- vlog(0, _tr("Export '%s' has been removed from DB.\n", $exportName));
- }
-
- $openslxDB->disconnect();
- return;
+ my $self = shift;
+
+ my $openslxDB = instantiateClass("OpenSLX::ConfigDB");
+ $openslxDB->connect();
+
+ # remove export from DB:
+ my $exportName = $self->{'export-name'};
+ my $export = $openslxDB->fetchExportByFilter({'name' => $exportName,});
+ if (!defined $export) {
+ vlog(
+ 0,
+ _tr(
+ "Export '%s' doesn't exist in OpenSLX-database.\n", $exportName
+ )
+ );
+ } else {
+ # remove all systems using this export and then remove the
+ # export itself:
+ my @systemIDs =
+ map { $_->{id} }
+ $openslxDB->fetchSystemByFilter({'export_id' => $export->{id}}, 'id');
+ vlog(
+ 1,
+ _tr(
+ "removing systems '%s' from DB, since they belong to the export"
+ . " being deleted.\n",
+ join ',',
+ @systemIDs
+ )
+ );
+ $openslxDB->removeSystem(\@systemIDs);
+ $openslxDB->removeExport($export->{id});
+ vlog(0, _tr("Export '%s' has been removed from DB.\n", $exportName));
+ }
+
+ $openslxDB->disconnect();
+ return;
}
1;
diff --git a/installer/OpenSLX/OSExport/FileSystem/Base.pm b/installer/OpenSLX/OSExport/FileSystem/Base.pm
index a59cc944..1014d596 100644
--- a/installer/OpenSLX/OSExport/FileSystem/Base.pm
+++ b/installer/OpenSLX/OSExport/FileSystem/Base.pm
@@ -9,14 +9,14 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# Base.pm
-# - provides empty base of the OpenSLX OSExport::FileSystem API.
+# - provides empty base of the OpenSLX OSExport::FileSystem API.
# -----------------------------------------------------------------------------
package OpenSLX::OSExport::FileSystem::Base;
use strict;
use warnings;
-our $VERSION = 1.01; # API-version . implementation-version
+our $VERSION = 1.01; # API-version . implementation-version
use File::Basename;
@@ -28,7 +28,7 @@ use OpenSLX::Utils;
################################################################################
sub new
{
- confess "Creating OpenSLX::OSExport::FileSystem::Base-objects directly makes no sense!";
+ confess "Creating OpenSLX::OSExport::FileSystem::Base-objects directly makes no sense!";
}
sub initialize
@@ -45,16 +45,16 @@ sub purgeExport
sub checkRequirements
{
- return 1;
+ return 1;
}
sub addExportToConfigDB
{
- my $self = shift;
- my $export = shift;
- my $openslxDB = shift;
+ my $self = shift;
+ my $export = shift;
+ my $openslxDB = shift;
- return $openslxDB->addExport($export);
+ return $openslxDB->addExport($export);
}
sub generateExportURI
@@ -78,54 +78,54 @@ sub showExportConfigInfo
################################################################################
sub _pickKernelVersion
{
- my $self = shift;
- my $vendorOSPath = shift;
-
- my $kernel = followLink("$vendorOSPath/boot/vmlinuz");
- if (!-e $kernel) {
- # 'vmlinuz'-link doesn't exist, so we have to pick the kernel manually
- my $osSetupEngine = instantiateClass("OpenSLX::OSSetup::Engine");
- $osSetupEngine->initialize($self->{engine}->{'vendor-os-name'}, 'none');
- $kernel = $osSetupEngine->pickKernelFile("$vendorOSPath/boot");
- }
- my $kernelName = basename($kernel);
- if ($kernelName !~ m[-(.+)$]) {
- die _tr("unable to determine version of kernel '%s'!", $kernelName);
- }
- return $1;
+ my $self = shift;
+ my $vendorOSPath = shift;
+
+ my $kernel = followLink("$vendorOSPath/boot/vmlinuz");
+ if (!-e $kernel) {
+ # 'vmlinuz'-link doesn't exist, so we have to pick the kernel manually
+ my $osSetupEngine = instantiateClass("OpenSLX::OSSetup::Engine");
+ $osSetupEngine->initialize($self->{engine}->{'vendor-os-name'}, 'none');
+ $kernel = $osSetupEngine->pickKernelFile("$vendorOSPath/boot");
+ }
+ my $kernelName = basename($kernel);
+ if ($kernelName !~ m[-(.+)$]) {
+ die _tr("unable to determine version of kernel '%s'!", $kernelName);
+ }
+ return $1;
}
sub _locateKernelModule
{
- my $self = shift;
- my $vendorOSPath = shift;
- my $moduleName = shift;
- my $defaultPaths = shift;
-
- vlog(1, _tr("locating kernel-module '%s'", $moduleName));
- # check default paths first:
- foreach my $defPath (@$defaultPaths) {
- vlog(2, "trying $defPath/$moduleName");
- my $target = followLink("$defPath/$moduleName", $vendorOSPath);
- return $target unless !-e $target;
- }
- # use brute force to search for the newest incarnation of the module:
- use File::Find;
- my $location;
- my $locationAge = 9999999;
- vlog(2, "searching in $vendorOSPath/lib/modules");
- find sub {
- return unless $_ eq $moduleName;
- if (-M _ < $locationAge) {
- $locationAge = -M _;
- $location = $File::Find::name;
- vlog(2, "located at $location (age=$locationAge days)");
- }
- }, "$vendorOSPath/lib/modules";
- if (defined $location) {
- return followLink($location, $vendorOSPath);
- }
- return;
+ my $self = shift;
+ my $vendorOSPath = shift;
+ my $moduleName = shift;
+ my $defaultPaths = shift;
+
+ vlog(1, _tr("locating kernel-module '%s'", $moduleName));
+ # check default paths first:
+ foreach my $defPath (@$defaultPaths) {
+ vlog(2, "trying $defPath/$moduleName");
+ my $target = followLink("$defPath/$moduleName", $vendorOSPath);
+ return $target unless !-e $target;
+ }
+ # use brute force to search for the newest incarnation of the module:
+ use File::Find;
+ my $location;
+ my $locationAge = 9999999;
+ vlog(2, "searching in $vendorOSPath/lib/modules");
+ find sub {
+ return unless $_ eq $moduleName;
+ if (-M _ < $locationAge) {
+ $locationAge = -M _;
+ $location = $File::Find::name;
+ vlog(2, "located at $location (age=$locationAge days)");
+ }
+ }, "$vendorOSPath/lib/modules";
+ if (defined $location) {
+ return followLink($location, $vendorOSPath);
+ }
+ return;
}
1;
diff --git a/installer/OpenSLX/OSExport/FileSystem/NFS.pm b/installer/OpenSLX/OSExport/FileSystem/NFS.pm
index 9ab1ddfe..f14bc497 100644
--- a/installer/OpenSLX/OSExport/FileSystem/NFS.pm
+++ b/installer/OpenSLX/OSExport/FileSystem/NFS.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# NFS.pm
-# - provides NFS-specific overrides of the OpenSLX::OSExport::FileSystem API.
+# - provides NFS-specific overrides of the OpenSLX::OSExport::FileSystem API.
# -----------------------------------------------------------------------------
package OpenSLX::OSExport::FileSystem::NFS;
@@ -28,107 +28,107 @@ use OpenSLX::Utils;
################################################################################
sub new
{
- my $class = shift;
- my $self = {
- 'name' => 'nfs',
- };
- return bless $self, $class;
+ my $class = shift;
+ my $self = {
+ 'name' => 'nfs',
+ };
+ return bless $self, $class;
}
sub initialize
{
- my $self = shift;
- my $engine = shift;
+ my $self = shift;
+ my $engine = shift;
- $self->{'engine'} = $engine;
- my $exportBasePath = "$openslxConfig{'public-path'}/export";
- $self->{'export-path'} = "$exportBasePath/nfs/$engine->{'vendor-os-name'}";
- return;
+ $self->{'engine'} = $engine;
+ my $exportBasePath = "$openslxConfig{'public-path'}/export";
+ $self->{'export-path'} = "$exportBasePath/nfs/$engine->{'vendor-os-name'}";
+ return;
}
sub exportVendorOS
{
- my $self = shift;
- my $source = shift;
+ my $self = shift;
+ my $source = shift;
- my $target = $self->{'export-path'};
- $self->_copyViaRsync($source, $target);
- return;
+ my $target = $self->{'export-path'};
+ $self->_copyViaRsync($source, $target);
+ return;
}
sub purgeExport
{
- my $self = shift;
-
- my $target = $self->{'export-path'};
- if (system("rm -r $target")) {
- vlog(0, _tr("unable to remove export '%s'!", $target));
- return 0;
- }
- return 1;
+ my $self = shift;
+
+ my $target = $self->{'export-path'};
+ if (system("rm -r $target")) {
+ vlog(0, _tr("unable to remove export '%s'!", $target));
+ return 0;
+ }
+ return 1;
}
sub checkRequirements
{
- my $self = shift;
- my $vendorOSPath = shift;
-
- # determine most appropriate kernel version ...
- my $kernelVer = $self->_pickKernelVersion($vendorOSPath);
-
- # ... and check if that kernel-version provides all the required modules
- my $nfsMod = $self->_locateKernelModule(
- $vendorOSPath,
- 'nfs.ko',
- [
- "$vendorOSPath/lib/modules/$kernelVer/kernel/fs/nfs",
- "$vendorOSPath/lib/modules/$kernelVer/kernel/fs"
- ]
- );
- if (!defined $nfsMod) {
- warn _tr("unable to find nfs-module for kernel version '%s'.",
- $kernelVer);
- return;
- }
- return 1;
+ my $self = shift;
+ my $vendorOSPath = shift;
+
+ # determine most appropriate kernel version ...
+ my $kernelVer = $self->_pickKernelVersion($vendorOSPath);
+
+ # ... and check if that kernel-version provides all the required modules
+ my $nfsMod = $self->_locateKernelModule(
+ $vendorOSPath,
+ 'nfs.ko',
+ [
+ "$vendorOSPath/lib/modules/$kernelVer/kernel/fs/nfs",
+ "$vendorOSPath/lib/modules/$kernelVer/kernel/fs"
+ ]
+ );
+ if (!defined $nfsMod) {
+ warn _tr("unable to find nfs-module for kernel version '%s'.",
+ $kernelVer);
+ return;
+ }
+ return 1;
}
sub generateExportURI
{
- my $self = shift;
- my $export = shift;
- my $vendorOS = shift;
-
- my $serverIP = $export->{server_ip} || '';
- my $server
- = length($serverIP) ? $serverIP : generatePlaceholderFor('serverip');
- my $port = $export->{port} || '';
- $server .= ":$port" if length($port);
-
- my $exportPath = "$openslxConfig{'public-path'}/export";
- return "nfs://$server$exportPath/nfs/$vendorOS->{name}";
+ my $self = shift;
+ my $export = shift;
+ my $vendorOS = shift;
+
+ my $serverIP = $export->{server_ip} || '';
+ my $server
+ = length($serverIP) ? $serverIP : generatePlaceholderFor('serverip');
+ my $port = $export->{port} || '';
+ $server .= ":$port" if length($port);
+
+ my $exportPath = "$openslxConfig{'public-path'}/export";
+ return "nfs://$server$exportPath/nfs/$vendorOS->{name}";
}
sub requiredFSMods
{
- my $self = shift;
+ my $self = shift;
- return qw( nfs );
+ return qw( nfs );
}
sub showExportConfigInfo
{
- my $self = shift;
- my $export = shift;
+ my $self = shift;
+ my $export = shift;
- print (('#' x 80)."\n");
- print _tr("Please make sure the following line is contained in /etc/exports\nin order to activate the NFS-export of this vendor-OS:\n\t%s\n",
- "$self->{'export-path'}\t*(ro,no_root_squash,async,no_subtree_check)");
- print (('#' x 80)."\n");
+ print (('#' x 80)."\n");
+ print _tr("Please make sure the following line is contained in /etc/exports\nin order to activate the NFS-export of this vendor-OS:\n\t%s\n",
+ "$self->{'export-path'}\t*(ro,no_root_squash,async,no_subtree_check)");
+ print (('#' x 80)."\n");
# TODO : add something a bit more clever here...
-# my $exports = slurpFile("/etc/exports");
- return;
+# my $exports = slurpFile("/etc/exports");
+ return;
}
################################################################################
@@ -136,48 +136,48 @@ sub showExportConfigInfo
################################################################################
sub _copyViaRsync
{
- my $self = shift;
- my $source = shift;
- my $target = shift;
-
- if (system("mkdir -p $target")) {
- die _tr("unable to create directory '%s', giving up! (%s)\n",
- $target, $!);
- }
- my $includeExcludeList = $self->_determineIncludeExcludeList();
- vlog(1, _tr("using include-exclude-filter:\n%s\n", $includeExcludeList));
- my $rsyncFH;
- my $additionalRsyncOptions = $ENV{SLX_RSYNC_OPTIONS} || '';
- my $rsyncCmd
- = "rsync -av --delete-excluded --exclude-from=- $additionalRsyncOptions"
- . " $source/ $target";
- vlog(2, "executing: $rsyncCmd\n");
- open($rsyncFH, '|-', $rsyncCmd)
- or die _tr("unable to start rsync for source '%s', giving up! (%s)",
- $source, $!);
- print $rsyncFH $includeExcludeList;
- close($rsyncFH)
- or die _tr("unable to export to target '%s', giving up! (%s)",
- $target, $!);
- return;
+ my $self = shift;
+ my $source = shift;
+ my $target = shift;
+
+ if (system("mkdir -p $target")) {
+ die _tr("unable to create directory '%s', giving up! (%s)\n",
+ $target, $!);
+ }
+ my $includeExcludeList = $self->_determineIncludeExcludeList();
+ vlog(1, _tr("using include-exclude-filter:\n%s\n", $includeExcludeList));
+ my $rsyncFH;
+ my $additionalRsyncOptions = $ENV{SLX_RSYNC_OPTIONS} || '';
+ my $rsyncCmd
+ = "rsync -av --delete-excluded --exclude-from=- $additionalRsyncOptions"
+ . " $source/ $target";
+ vlog(2, "executing: $rsyncCmd\n");
+ open($rsyncFH, '|-', $rsyncCmd)
+ or die _tr("unable to start rsync for source '%s', giving up! (%s)",
+ $source, $!);
+ print $rsyncFH $includeExcludeList;
+ close($rsyncFH)
+ or die _tr("unable to export to target '%s', giving up! (%s)",
+ $target, $!);
+ return;
}
sub _determineIncludeExcludeList
{
- my $self = shift;
-
- # Rsync uses a first match strategy, so we mix the local specifications
- # in front of the filterset given by the package (as the local filters
- # should always overrule the vendor filters):
- my $distroName = $self->{engine}->{'distro-name'};
- my $localFilterFile
- = "$openslxConfig{'config-path'}/distro-info/$distroName/export-filter";
- my $includeExcludeList
- = slurpFile($localFilterFile, { failIfMissing => 0 });
- $includeExcludeList .= $self->{engine}->{distro}->{'export-filter'};
- $includeExcludeList =~ s[^\s+][]igms;
- # remove any leading whitespace, as rsync doesn't like it
- return $includeExcludeList;
+ my $self = shift;
+
+ # Rsync uses a first match strategy, so we mix the local specifications
+ # in front of the filterset given by the package (as the local filters
+ # should always overrule the vendor filters):
+ my $distroName = $self->{engine}->{'distro-name'};
+ my $localFilterFile
+ = "$openslxConfig{'config-path'}/distro-info/$distroName/export-filter";
+ my $includeExcludeList
+ = slurpFile($localFilterFile, { failIfMissing => 0 });
+ $includeExcludeList .= $self->{engine}->{distro}->{'export-filter'};
+ $includeExcludeList =~ s[^\s+][]igms;
+ # remove any leading whitespace, as rsync doesn't like it
+ return $includeExcludeList;
}
1;
diff --git a/installer/OpenSLX/OSExport/FileSystem/SquashFS.pm b/installer/OpenSLX/OSExport/FileSystem/SquashFS.pm
index 87407ca3..d9760642 100644
--- a/installer/OpenSLX/OSExport/FileSystem/SquashFS.pm
+++ b/installer/OpenSLX/OSExport/FileSystem/SquashFS.pm
@@ -9,8 +9,8 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# SquashFS.pm
-# - provides SquashFS-specific overrides of the OpenSLX::OSExport::ExportType
-# API.
+# - provides SquashFS-specific overrides of the OpenSLX::OSExport::ExportType
+# API.
# -----------------------------------------------------------------------------
package OpenSLX::OSExport::FileSystem::SquashFS;
@@ -30,153 +30,153 @@ use OpenSLX::Utils;
################################################################################
sub new
{
- my $class = shift;
- my $self = {'name' => 'sqfs',};
- return bless $self, $class;
+ my $class = shift;
+ my $self = {'name' => 'sqfs',};
+ return bless $self, $class;
}
sub initialize
{
- my $self = shift;
- my $engine = shift;
- my $blockDevice = shift || confess('need to pass in block-device!');
-
- $self->{'engine'} = $engine;
- $self->{'block-device'} = $blockDevice;
- my $exportBasePath = "$openslxConfig{'public-path'}/export";
- $self->{'export-path'} = "$exportBasePath/sqfs/$engine->{'vendor-os-name'}";
- return;
+ my $self = shift;
+ my $engine = shift;
+ my $blockDevice = shift || confess('need to pass in block-device!');
+
+ $self->{'engine'} = $engine;
+ $self->{'block-device'} = $blockDevice;
+ my $exportBasePath = "$openslxConfig{'public-path'}/export";
+ $self->{'export-path'} = "$exportBasePath/sqfs/$engine->{'vendor-os-name'}";
+ return;
}
sub exportVendorOS
{
- my $self = shift;
- my $source = shift;
-
- my $includeExcludeList = $self->_determineIncludeExcludeList();
- # in order to do the filtering as part of mksquashfs, we need to map
- # our internal (rsync-)filter format to regexes:
- $includeExcludeList =
- $self->_mapRsyncFilter2Regex($source, $includeExcludeList);
- vlog(1, _tr("using include-exclude-filter:\n%s\n", $includeExcludeList));
- my $target = $self->{'export-path'};
-
- my $sourceTime = (stat($source))[9] || 0;
- my $targetTime = (stat($target))[9] || 0;
- vlog(2, "source-time=$sourceTime target-time=$targetTime");
-
- if ($targetTime && $sourceTime < $targetTime) {
- vlog(
- 0,
- "!!! creation of squashfs skipped, as vendor-OS hasn't changed since last export!\n"
- . "!!! Use 'touch $source' to force an export."
- );
- } else {
- $self->_createSquashFS($source, $target, $includeExcludeList);
- }
- $self->_addBlockDeviceTagToExport($target);
- return;
+ my $self = shift;
+ my $source = shift;
+
+ my $includeExcludeList = $self->_determineIncludeExcludeList();
+ # in order to do the filtering as part of mksquashfs, we need to map
+ # our internal (rsync-)filter format to regexes:
+ $includeExcludeList =
+ $self->_mapRsyncFilter2Regex($source, $includeExcludeList);
+ vlog(1, _tr("using include-exclude-filter:\n%s\n", $includeExcludeList));
+ my $target = $self->{'export-path'};
+
+ my $sourceTime = (stat($source))[9] || 0;
+ my $targetTime = (stat($target))[9] || 0;
+ vlog(2, "source-time=$sourceTime target-time=$targetTime");
+
+ if ($targetTime && $sourceTime < $targetTime) {
+ vlog(
+ 0,
+ "!!! creation of squashfs skipped, as vendor-OS hasn't changed since last export!\n"
+ . "!!! Use 'touch $source' to force an export."
+ );
+ } else {
+ $self->_createSquashFS($source, $target, $includeExcludeList);
+ }
+ $self->_addBlockDeviceTagToExport($target);
+ return;
}
sub purgeExport
{
- my $self = shift;
-
- my $target = $self->{'export-path'};
- if ($self->_removeBlockDeviceTagFromExport($target)) {
- # no more tags, we can remove the image:
- if (slxsystem("rm $target")) {
- vlog(0, _tr("unable to remove export '%s'!", $target));
- return 0;
- }
- }
- return 1;
+ my $self = shift;
+
+ my $target = $self->{'export-path'};
+ if ($self->_removeBlockDeviceTagFromExport($target)) {
+ # no more tags, we can remove the image:
+ if (slxsystem("rm $target")) {
+ vlog(0, _tr("unable to remove export '%s'!", $target));
+ return 0;
+ }
+ }
+ return 1;
}
sub checkRequirements
{
- my $self = shift;
- my $vendorOSPath = shift;
-
- # determine most appropriate kernel version ...
- my $kernelVer = $self->_pickKernelVersion($vendorOSPath);
-
- # ... and check if that kernel-version provides all the required modules
- my @blockModNames = $self->{'block-device'}->requiredBlockDeviceModules();
- foreach my $blockModName (@blockModNames) {
- my $blockMod =
- $self->_locateKernelModule($vendorOSPath, "$blockModName.ko",
- ["$vendorOSPath/lib/modules/$kernelVer/kernel/drivers/block"]);
- if (!defined $blockMod) {
- warn _tr(
- "unable to find blockdevice-module '%s' for kernel version '%s'.",
- $blockModName, $kernelVer
- );
- return;
- }
- }
- my $squashfsMod = $self->_locateKernelModule(
- $vendorOSPath,
- 'squashfs.ko',
- [
- "$vendorOSPath/lib/modules/$kernelVer/kernel/fs/squashfs",
- "$vendorOSPath/lib/modules/$kernelVer/kernel/fs"
- ]
- );
- if (!defined $squashfsMod) {
- warn _tr("unable to find squashfs-module for kernel version '%s'.",
- $kernelVer);
- return;
- }
- return 1;
+ my $self = shift;
+ my $vendorOSPath = shift;
+
+ # determine most appropriate kernel version ...
+ my $kernelVer = $self->_pickKernelVersion($vendorOSPath);
+
+ # ... and check if that kernel-version provides all the required modules
+ my @blockModNames = $self->{'block-device'}->requiredBlockDeviceModules();
+ foreach my $blockModName (@blockModNames) {
+ my $blockMod =
+ $self->_locateKernelModule($vendorOSPath, "$blockModName.ko",
+ ["$vendorOSPath/lib/modules/$kernelVer/kernel/drivers/block"]);
+ if (!defined $blockMod) {
+ warn _tr(
+ "unable to find blockdevice-module '%s' for kernel version '%s'.",
+ $blockModName, $kernelVer
+ );
+ return;
+ }
+ }
+ my $squashfsMod = $self->_locateKernelModule(
+ $vendorOSPath,
+ 'squashfs.ko',
+ [
+ "$vendorOSPath/lib/modules/$kernelVer/kernel/fs/squashfs",
+ "$vendorOSPath/lib/modules/$kernelVer/kernel/fs"
+ ]
+ );
+ if (!defined $squashfsMod) {
+ warn _tr("unable to find squashfs-module for kernel version '%s'.",
+ $kernelVer);
+ return;
+ }
+ return 1;
}
sub addExportToConfigDB
{
- my $self = shift;
- my $export = shift;
- my $openslxDB = shift;
+ my $self = shift;
+ my $export = shift;
+ my $openslxDB = shift;
- $export->{port} = $self->{'block-device'}->getExportPort($openslxDB);
+ $export->{port} = $self->{'block-device'}->getExportPort($openslxDB);
- my $res = $openslxDB->addExport($export);
- return $res;
+ my $res = $openslxDB->addExport($export);
+ return $res;
}
sub generateExportURI
{
- my $self = shift;
- my $export = shift;
- my $vendorOS = shift;
+ my $self = shift;
+ my $export = shift;
+ my $vendorOS = shift;
- my $URI = $self->{'block-device'}->generateExportURI($export);
- $URI .= '/squashfs';
- return $URI;
+ my $URI = $self->{'block-device'}->generateExportURI($export);
+ $URI .= '/squashfs';
+ return $URI;
}
sub requiredFSMods
{
- my $self = shift;
+ my $self = shift;
- my @mods = $self->{'block-device'}->requiredBlockDeviceModules();
- push @mods, 'squashfs ';
- return @mods;
+ my @mods = $self->{'block-device'}->requiredBlockDeviceModules();
+ push @mods, 'squashfs ';
+ return @mods;
}
sub requiredFSTools
{
- my $self = shift;
+ my $self = shift;
- return $self->{'block-device'}->requiredBlockDeviceTools();
+ return $self->{'block-device'}->requiredBlockDeviceTools();
}
sub showExportConfigInfo
{
- my $self = shift;
- my $export = shift;
+ my $self = shift;
+ my $export = shift;
- $self->{'block-device'}->showExportConfigInfo($export);
- return;
+ $self->{'block-device'}->showExportConfigInfo($export);
+ return;
}
################################################################################
@@ -185,122 +185,122 @@ sub showExportConfigInfo
sub _createSquashFS
{
- my $self = shift;
- my $source = shift;
- my $target = shift;
- my $includeExcludeList = shift;
-
- system("rm -f $target");
- # mksquasfs isn't significantly faster if fs already exists, but it
- # causes the filesystem to grow somewhat, so we remove it in order to
- # get the smallest FS-file possible.
-
- my $baseDir = dirname($target);
- if (!-e $baseDir) {
- if (system("mkdir -p $baseDir")) {
- die _tr("unable to create directory '%s', giving up! (%s)\n",
- $baseDir, $!);
- }
- }
-
- # dump filter to a file ...
- my $filterFile = "/tmp/slx-nbdsquash-filter-$$";
- spitFile($filterFile, $includeExcludeList);
-
- # ... invoke mksquashfs ...
- vlog(0, _tr("invoking mksquashfs..."));
- my $mksquashfsBinary =
- "$openslxConfig{'base-path'}/share/squashfs/mksquashfs";
- my $res = system("$mksquashfsBinary $source $target -ff $filterFile");
- unlink($filterFile);
- # ... remove filter file if done
- if ($res) {
- die _tr(
- "unable to create squashfs for source '%s' as target '%s', giving up! (%s)",
- $source, $target, $!);
- }
+ my $self = shift;
+ my $source = shift;
+ my $target = shift;
+ my $includeExcludeList = shift;
+
+ system("rm -f $target");
+ # mksquasfs isn't significantly faster if fs already exists, but it
+ # causes the filesystem to grow somewhat, so we remove it in order to
+ # get the smallest FS-file possible.
+
+ my $baseDir = dirname($target);
+ if (!-e $baseDir) {
+ if (system("mkdir -p $baseDir")) {
+ die _tr("unable to create directory '%s', giving up! (%s)\n",
+ $baseDir, $!);
+ }
+ }
+
+ # dump filter to a file ...
+ my $filterFile = "/tmp/slx-nbdsquash-filter-$$";
+ spitFile($filterFile, $includeExcludeList);
+
+ # ... invoke mksquashfs ...
+ vlog(0, _tr("invoking mksquashfs..."));
+ my $mksquashfsBinary =
+ "$openslxConfig{'base-path'}/share/squashfs/mksquashfs";
+ my $res = system("$mksquashfsBinary $source $target -ff $filterFile");
+ unlink($filterFile);
+ # ... remove filter file if done
+ if ($res) {
+ die _tr(
+ "unable to create squashfs for source '%s' as target '%s', giving up! (%s)",
+ $source, $target, $!);
+ }
}
sub _determineIncludeExcludeList
{
- my $self = shift;
-
- # Rsync uses a first match strategy, so we mix the local specifications
- # in front of the filterset given by the package (as the local filters
- # should always overrule the vendor filters):
- my $distroName = $self->{engine}->{'distro-name'};
- my $localFilterFile =
- "$openslxConfig{'config-path'}/distro-info/$distroName/export-filter";
- my $includeExcludeList
- = slurpFile($localFilterFile, { failIfMissing => 0 });
- $includeExcludeList .= $self->{engine}->{distro}->{'export-filter'};
- $includeExcludeList =~ s[^\s+][]igms;
- # remove any leading whitespace, as rsync doesn't like it
- return $includeExcludeList;
+ my $self = shift;
+
+ # Rsync uses a first match strategy, so we mix the local specifications
+ # in front of the filterset given by the package (as the local filters
+ # should always overrule the vendor filters):
+ my $distroName = $self->{engine}->{'distro-name'};
+ my $localFilterFile =
+ "$openslxConfig{'config-path'}/distro-info/$distroName/export-filter";
+ my $includeExcludeList
+ = slurpFile($localFilterFile, { failIfMissing => 0 });
+ $includeExcludeList .= $self->{engine}->{distro}->{'export-filter'};
+ $includeExcludeList =~ s[^\s+][]igms;
+ # remove any leading whitespace, as rsync doesn't like it
+ return $includeExcludeList;
}
sub _mapRsyncFilter2Regex
{
- my $self = shift;
- my $sourcePath = shift;
- my $rsyncFilter = shift;
-
- return join(
- "\n",
- map {
- if ($_ =~ m[^([-+]\s*)(.+?)\s*$])
- {
- my $action = $1;
- my $regex = $2;
- $regex =~ s[\*\*][.+]g;
- # '**' matches everything
- $regex =~ s[\*][[^/]+]g;
- # '*' matches anything except slashes
- $regex =~ s[\?][[^/]?]g;
- # '*' matches any single char except slash
- $regex =~ s[\?][[^/]?]g;
- # '*' matches any single char except slash
- $regex =~ s[\.][\\.]g;
- # escape any dots
- if (substr($regex, 0, 1) eq '/') {
- # absolute path given, need to extend by source-path:
- "$action^$sourcePath$regex\$";
- } else {
- # filename pattern given, need to anchor to the end only:
- "$action$regex\$";
- }
- } else {
- $_;
- }
- }
- split "\n",
- $rsyncFilter
- );
+ my $self = shift;
+ my $sourcePath = shift;
+ my $rsyncFilter = shift;
+
+ return join(
+ "\n",
+ map {
+ if ($_ =~ m[^([-+]\s*)(.+?)\s*$])
+ {
+ my $action = $1;
+ my $regex = $2;
+ $regex =~ s[\*\*][.+]g;
+ # '**' matches everything
+ $regex =~ s[\*][[^/]+]g;
+ # '*' matches anything except slashes
+ $regex =~ s[\?][[^/]?]g;
+ # '*' matches any single char except slash
+ $regex =~ s[\?][[^/]?]g;
+ # '*' matches any single char except slash
+ $regex =~ s[\.][\\.]g;
+ # escape any dots
+ if (substr($regex, 0, 1) eq '/') {
+ # absolute path given, need to extend by source-path:
+ "$action^$sourcePath$regex\$";
+ } else {
+ # filename pattern given, need to anchor to the end only:
+ "$action$regex\$";
+ }
+ } else {
+ $_;
+ }
+ }
+ split "\n",
+ $rsyncFilter
+ );
}
sub _addBlockDeviceTagToExport
{
- my $self = shift;
- my $target = shift;
+ my $self = shift;
+ my $target = shift;
- my $tagName = "$target" . '@' . lc($self->{'block-device'}->{name});
- linkFile(basename($target), $tagName);
- return;
+ my $tagName = "$target" . '@' . lc($self->{'block-device'}->{name});
+ linkFile(basename($target), $tagName);
+ return;
}
sub _removeBlockDeviceTagFromExport
{
- my $self = shift;
- my $target = shift;
-
- my $tagName = "$target" . '@' . lc($self->{'block-device'}->{name});
- slxsystem("rm $tagName");
- # now find out whether or not there are any other tags left:
- my $vendorOSName = basename($target);
- opendir(DIR, dirname($target));
- my @tags = grep { /^$vendorOSName\@/ } readdir(DIR);
- return @tags ? 0 : 1;
- # return 1 if no more tags (i.e. it is safe to remove the image)
+ my $self = shift;
+ my $target = shift;
+
+ my $tagName = "$target" . '@' . lc($self->{'block-device'}->{name});
+ slxsystem("rm $tagName");
+ # now find out whether or not there are any other tags left:
+ my $vendorOSName = basename($target);
+ opendir(DIR, dirname($target));
+ my @tags = grep { /^$vendorOSName\@/ } readdir(DIR);
+ return @tags ? 0 : 1;
+ # return 1 if no more tags (i.e. it is safe to remove the image)
}
1;
diff --git a/installer/OpenSLX/OSSetup/Distro/Any_Clone.pm b/installer/OpenSLX/OSSetup/Distro/Any_Clone.pm
index 9f3f54cc..005c0355 100644
--- a/installer/OpenSLX/OSSetup/Distro/Any_Clone.pm
+++ b/installer/OpenSLX/OSSetup/Distro/Any_Clone.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# Any_Clone.pm
-# - provides generic clone-only overrides of the OpenSLX OSSetup API.
+# - provides generic clone-only overrides of the OpenSLX OSSetup API.
# -----------------------------------------------------------------------------
package OpenSLX::OSSetup::Distro::Any_Clone;
@@ -23,9 +23,9 @@ use base qw(OpenSLX::OSSetup::Distro::Base);
################################################################################
sub new
{
- my $class = shift;
- my $self = {};
- return bless $self, $class;
+ my $class = shift;
+ my $self = {};
+ return bless $self, $class;
}
1; \ No newline at end of file
diff --git a/installer/OpenSLX/OSSetup/Distro/Base.pm b/installer/OpenSLX/OSSetup/Distro/Base.pm
index 64d8d43b..d2931046 100644
--- a/installer/OpenSLX/OSSetup/Distro/Base.pm
+++ b/installer/OpenSLX/OSSetup/Distro/Base.pm
@@ -9,14 +9,14 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# Base.pm
-# - provides empty base of the OpenSLX OSSetup API.
+# - provides empty base of the OpenSLX OSSetup API.
# -----------------------------------------------------------------------------
package OpenSLX::OSSetup::Distro::Base;
use strict;
use warnings;
-our $VERSION = 1.01; # API-version . implementation-version
+our $VERSION = 1.01; # API-version . implementation-version
use Fcntl qw(:DEFAULT :flock);
use File::Basename;
@@ -28,88 +28,88 @@ use OpenSLX::Utils;
################################################################################
sub new
{
- confess "Creating OpenSLX::OSSetup::System::Base-objects directly makes no sense!";
+ confess "Creating OpenSLX::OSSetup::System::Base-objects directly makes no sense!";
}
sub initialize
{
- my $self = shift;
- my $engine = shift;
-
- $self->{'engine'} = $engine;
-
- if ($engine->{'distro-name'} =~ m[x86_64]) {
- # be careful to only try installing 64-bit systems if actually
- # running on a 64-bit host, as otherwise we are going to fail later,
- # anyway:
- my $arch = `uname -m`;
- if ($?) {
- die _tr("unable to determine architecture of host system (%s)\n", $!);
- }
- if ($arch !~ m[x86_64]) {
- die _tr("you can't install a 64-bit system on a 32-bit host, sorry!\n");
- }
- }
-
- $self->{'stage1a-binaries'} = {
- "$openslxConfig{'base-path'}/share/busybox/busybox" => 'bin',
- };
-
- $self->{'stage1b-faked-files'} = [
- '/etc/mtab',
- ];
-
- $self->{'stage1c-faked-files'} = [
- ];
-
- $self->{'clone-filter'} = "
- - /var/tmp/*
- - /var/opt/openslx
- - /var/lib/vmware
- + /var
- - /usr/lib/vmware/modules/*
- + /usr
- - /tmp/*
- + /tmp
- - /sys/*
- + /sys
- + /sbin
- - /root/*
- + /root
- - /proc/*
- + /proc
- - /opt/openslx
- + /opt
- - /media/*
- + /media
- - /mnt/*
- + /mnt
- + /lib64
- + /lib
- - /home/*
- + /home
- - /etc/vmware/installer.sh
- - /etc/shadow*
- - /etc/samba/secrets.tdb
- - /etc/resolv.conf.*
- - /etc/opt/openslx
- - /etc/exports*
- - /etc/dxs
- + /etc
- - /dev/*
- + /dev
- + /boot
- + /bin
- - /*
- - .svn
- - .*.cmd
- - *~
- - *lost+found*
- - *.old
- - *.bak
- ";
-
- return;
+ my $self = shift;
+ my $engine = shift;
+
+ $self->{'engine'} = $engine;
+
+ if ($engine->{'distro-name'} =~ m[x86_64]) {
+ # be careful to only try installing 64-bit systems if actually
+ # running on a 64-bit host, as otherwise we are going to fail later,
+ # anyway:
+ my $arch = `uname -m`;
+ if ($?) {
+ die _tr("unable to determine architecture of host system (%s)\n", $!);
+ }
+ if ($arch !~ m[x86_64]) {
+ die _tr("you can't install a 64-bit system on a 32-bit host, sorry!\n");
+ }
+ }
+
+ $self->{'stage1a-binaries'} = {
+ "$openslxConfig{'base-path'}/share/busybox/busybox" => 'bin',
+ };
+
+ $self->{'stage1b-faked-files'} = [
+ '/etc/mtab',
+ ];
+
+ $self->{'stage1c-faked-files'} = [
+ ];
+
+ $self->{'clone-filter'} = "
+ - /var/tmp/*
+ - /var/opt/openslx
+ - /var/lib/vmware
+ + /var
+ - /usr/lib/vmware/modules/*
+ + /usr
+ - /tmp/*
+ + /tmp
+ - /sys/*
+ + /sys
+ + /sbin
+ - /root/*
+ + /root
+ - /proc/*
+ + /proc
+ - /opt/openslx
+ + /opt
+ - /media/*
+ + /media
+ - /mnt/*
+ + /mnt
+ + /lib64
+ + /lib
+ - /home/*
+ + /home
+ - /etc/vmware/installer.sh
+ - /etc/shadow*
+ - /etc/samba/secrets.tdb
+ - /etc/resolv.conf.*
+ - /etc/opt/openslx
+ - /etc/exports*
+ - /etc/dxs
+ + /etc
+ - /dev/*
+ + /dev
+ + /boot
+ + /bin
+ - /*
+ - .svn
+ - .*.cmd
+ - *~
+ - *lost+found*
+ - *.old
+ - *.bak
+ ";
+
+ return;
}
sub fixPrerequiredFiles
@@ -118,118 +118,118 @@ sub fixPrerequiredFiles
sub startSession
{
- my $self = shift;
- my $osDir = shift;
-
- # ensure that the session will be finished even if the script crashes:
- addCleanupFunction(
- "slxos-setup::distro::chroot", sub { $self->finishSession(); }
- );
-
- # make sure there's a /dev/zero, /dev/null and /dev/urandom
+ my $self = shift;
+ my $osDir = shift;
+
+ # ensure that the session will be finished even if the script crashes:
+ addCleanupFunction(
+ "slxos-setup::distro::chroot", sub { $self->finishSession(); }
+ );
+
+ # make sure there's a /dev/zero, /dev/null and /dev/urandom
# /dev/urandom for passwd chroot
- if (!-e "$osDir/dev" && !mkdir("$osDir/dev")) {
- die _tr("unable to create folder '%s' (%s)\n", "$osDir/dev", $!);
- }
- if (!-e "$osDir/dev/zero" && slxsystem("mknod $osDir/dev/zero c 1 5")) {
- die _tr("unable to create node '%s' (%s)\n", "$osDir/dev/zero", $!);
- }
- if (!-e "$osDir/dev/null" && slxsystem("mknod $osDir/dev/null c 1 3")) {
- die _tr("unable to create node '%s' (%s)\n", "$osDir/dev/null", $!);
- }
- if (!-e "$osDir/dev/urandom" && slxsystem("mknod $osDir/dev/urandom c 1 9")) {
- die _tr("unable to create node '%s' (%s)\n", "$osDir/dev/urandom", $!);
+ if (!-e "$osDir/dev" && !mkdir("$osDir/dev")) {
+ die _tr("unable to create folder '%s' (%s)\n", "$osDir/dev", $!);
+ }
+ if (!-e "$osDir/dev/zero" && slxsystem("mknod $osDir/dev/zero c 1 5")) {
+ die _tr("unable to create node '%s' (%s)\n", "$osDir/dev/zero", $!);
+ }
+ if (!-e "$osDir/dev/null" && slxsystem("mknod $osDir/dev/null c 1 3")) {
+ die _tr("unable to create node '%s' (%s)\n", "$osDir/dev/null", $!);
+ }
+ if (!-e "$osDir/dev/urandom" && slxsystem("mknod $osDir/dev/urandom c 1 9")) {
+ die _tr("unable to create node '%s' (%s)\n", "$osDir/dev/urandom", $!);
}
- # fake proc, depending on what is needed ...
- if (!-e "$osDir/proc" && !mkdir("$osDir/proc")) {
- die _tr("unable to create folder '%s' (%s)\n", "$osDir/proc", $!);
- }
- if (!-e "$osDir/proc/cpuinfo" && slxsystem("cp /proc/cpuinfo $osDir/proc/")) {
- die _tr("unable to copy file '%s' (%s)\n", "/proc/cpuinfo", $!);
- }
- # TODO: alternatively, we could mount proc, but that causes problems
- # when we are not able to umount it properly (which may happen
- # if 'umount' is not available in the chroot!)
- #
- # mount /proc
-# if (!-e "$osDir/proc") {
-# slxsystem("mkdir -p $osDir/proc");
-# }
-# if (slxsystem("mount -t proc proc $osDir/proc 2>/dev/null")) {
-# die _tr("unable to mount '%s' (%s)\n", "$osDir/proc", $!);
-# }
-
- # enter chroot jail
- chrootInto($osDir);
- $ENV{PATH} = join(':', @{$self->getDefaultPathList()});
-
- return;
+ # fake proc, depending on what is needed ...
+ if (!-e "$osDir/proc" && !mkdir("$osDir/proc")) {
+ die _tr("unable to create folder '%s' (%s)\n", "$osDir/proc", $!);
+ }
+ if (!-e "$osDir/proc/cpuinfo" && slxsystem("cp /proc/cpuinfo $osDir/proc/")) {
+ die _tr("unable to copy file '%s' (%s)\n", "/proc/cpuinfo", $!);
+ }
+ # TODO: alternatively, we could mount proc, but that causes problems
+ # when we are not able to umount it properly (which may happen
+ # if 'umount' is not available in the chroot!)
+ #
+ # mount /proc
+# if (!-e "$osDir/proc") {
+# slxsystem("mkdir -p $osDir/proc");
+# }
+# if (slxsystem("mount -t proc proc $osDir/proc 2>/dev/null")) {
+# die _tr("unable to mount '%s' (%s)\n", "$osDir/proc", $!);
+# }
+
+ # enter chroot jail
+ chrootInto($osDir);
+ $ENV{PATH} = join(':', @{$self->getDefaultPathList()});
+
+ return;
}
sub getDefaultPathList
{
- my $self = shift;
-
- return [ qw(
- /sbin
- /usr/sbin
- /usr/local/sbin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/bin/X11
- /usr/X11R6/bin
- /opt/kde3/bin
- /opt/gnome/bin
- ) ];
+ my $self = shift;
+
+ return [ qw(
+ /sbin
+ /usr/sbin
+ /usr/local/sbin
+ /usr/local/bin
+ /usr/bin
+ /bin
+ /usr/bin/X11
+ /usr/X11R6/bin
+ /opt/kde3/bin
+ /opt/gnome/bin
+ ) ];
}
sub finishSession
{
- my $self = shift;
-
- removeCleanupFunction('slxos-setup::distro::chroot');
+ my $self = shift;
+
+ removeCleanupFunction('slxos-setup::distro::chroot');
- # unmount /proc
-# if (slxsystem('ash', '-c', 'umount /proc 2>/dev/null')) {
-# die _tr("unable to unmount '%s' (%s)\n", "/proc", $!);
-# }
+ # unmount /proc
+# if (slxsystem('ash', '-c', 'umount /proc 2>/dev/null')) {
+# die _tr("unable to unmount '%s' (%s)\n", "/proc", $!);
+# }
- return;
+ return;
}
sub updateDistroConfig
{
- if (slxsystem("ldconfig")) {
- die _tr("unable to run ldconfig (%s)", $!);
- }
+ if (slxsystem("ldconfig")) {
+ die _tr("unable to run ldconfig (%s)", $!);
+ }
}
sub pickKernelFile
{
- my $self = shift;
- my $kernelPath = shift;
-
- my $newestKernelFile;
- my $newestKernelFileSortKey = '';
- foreach my $kernelFile (glob("$kernelPath/vmlinuz-*")) {
- next unless $kernelFile =~ m{
- vmlinuz-(\d+)\.(\d+)\.(\d+)(?:\.(\d+))?-(\d+(?:\.\d+)?)
- }x;
- my $sortKey
- = sprintf("%02d.%02d.%02d.%02d-%2.1f", $1, $2, $3, $4||0, $5);
- if ($newestKernelFileSortKey lt $sortKey) {
- $newestKernelFile = $kernelFile;
- $newestKernelFileSortKey = $sortKey;
- }
- }
-
- if (!defined $newestKernelFile) {
- die _tr("unable to pick a kernel-file from path '%s'!", $kernelPath);
- }
- return $newestKernelFile;
+ my $self = shift;
+ my $kernelPath = shift;
+
+ my $newestKernelFile;
+ my $newestKernelFileSortKey = '';
+ foreach my $kernelFile (glob("$kernelPath/vmlinuz-*")) {
+ next unless $kernelFile =~ m{
+ vmlinuz-(\d+)\.(\d+)\.(\d+)(?:\.(\d+))?-(\d+(?:\.\d+)?)
+ }x;
+ my $sortKey
+ = sprintf("%02d.%02d.%02d.%02d-%2.1f", $1, $2, $3, $4||0, $5);
+ if ($newestKernelFileSortKey lt $sortKey) {
+ $newestKernelFile = $kernelFile;
+ $newestKernelFileSortKey = $sortKey;
+ }
+ }
+
+ if (!defined $newestKernelFile) {
+ die _tr("unable to pick a kernel-file from path '%s'!", $kernelPath);
+ }
+ return $newestKernelFile;
}
sub preSystemInstallationHook
@@ -242,54 +242,54 @@ sub postSystemInstallationHook
sub setPasswordForUser
{
- my $self = shift;
- my $username = shift;
- my $password = shift;
-
- my $hashedPassword = $self->hashPassword($password);
-
- my $writePasswordFunction = sub {
- # now read, change and write shadow-file in atomic manner:
- my $shadowFile = '/etc/shadow';
- if (!-e $shadowFile) {
- spitFile( $shadowFile, '');
- }
- slxsystem("cp -r $shadowFile $shadowFile~");
- my $shadowFH;
- open($shadowFH, '+<', $shadowFile)
- or croak _tr("could not open file '%s'! (%s)", $shadowFile, $!);
- flock($shadowFH, LOCK_EX)
- or croak _tr("could not lock file '%s'! (%s)", $shadowFile, $!);
- my $lastChanged = int(time()/24/60/60);
- my $newEntry
- = "$username:$hashedPassword:$lastChanged:0:99999:7:::";
- my $content = do { local $/; <$shadowFH> };
- if ($content =~ m{^$username:}ims) {
- $content =~ s{^$username:.+?$}{$newEntry}ms;
- } else {
- $content .= "$newEntry\n";
- }
- seek($shadowFH, 0, 0)
- or croak _tr("could not seek file '%s'! (%s)", $shadowFile, $!);
- print $shadowFH $content
- or croak _tr("could not write to file '%s'! (%s)", $shadowFile, $!);
- close($shadowFH)
- or croak _tr("could not close file '%s'! (%s)", $shadowFile, $!);
- unlink "$shadowFile~";
- };
- $self->{engine}->callChrootedFunctionForVendorOS($writePasswordFunction);
+ my $self = shift;
+ my $username = shift;
+ my $password = shift;
+
+ my $hashedPassword = $self->hashPassword($password);
+
+ my $writePasswordFunction = sub {
+ # now read, change and write shadow-file in atomic manner:
+ my $shadowFile = '/etc/shadow';
+ if (!-e $shadowFile) {
+ spitFile( $shadowFile, '');
+ }
+ slxsystem("cp -r $shadowFile $shadowFile~");
+ my $shadowFH;
+ open($shadowFH, '+<', $shadowFile)
+ or croak _tr("could not open file '%s'! (%s)", $shadowFile, $!);
+ flock($shadowFH, LOCK_EX)
+ or croak _tr("could not lock file '%s'! (%s)", $shadowFile, $!);
+ my $lastChanged = int(time()/24/60/60);
+ my $newEntry
+ = "$username:$hashedPassword:$lastChanged:0:99999:7:::";
+ my $content = do { local $/; <$shadowFH> };
+ if ($content =~ m{^$username:}ims) {
+ $content =~ s{^$username:.+?$}{$newEntry}ms;
+ } else {
+ $content .= "$newEntry\n";
+ }
+ seek($shadowFH, 0, 0)
+ or croak _tr("could not seek file '%s'! (%s)", $shadowFile, $!);
+ print $shadowFH $content
+ or croak _tr("could not write to file '%s'! (%s)", $shadowFile, $!);
+ close($shadowFH)
+ or croak _tr("could not close file '%s'! (%s)", $shadowFile, $!);
+ unlink "$shadowFile~";
+ };
+ $self->{engine}->callChrootedFunctionForVendorOS($writePasswordFunction);
}
sub hashPassword
{
- my $self = shift;
- my $password = shift;
-
- my $busyboxBin = $self->{engine}->{'busybox-binary'};
- my $hashedPassword = qx{$busyboxBin cryptpw -a md5 $password};
- chomp $hashedPassword;
-
- return $hashedPassword;
+ my $self = shift;
+ my $password = shift;
+
+ my $busyboxBin = $self->{engine}->{'busybox-binary'};
+ my $hashedPassword = qx{$busyboxBin cryptpw -a md5 $password};
+ chomp $hashedPassword;
+
+ return $hashedPassword;
}
1;
diff --git a/installer/OpenSLX/OSSetup/Distro/Debian.pm b/installer/OpenSLX/OSSetup/Distro/Debian.pm
index a514f10f..a9ba8281 100644
--- a/installer/OpenSLX/OSSetup/Distro/Debian.pm
+++ b/installer/OpenSLX/OSSetup/Distro/Debian.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# Debian.pm
-# - provides Debian-specific overrides of the OpenSLX OSSetup API.
+# - provides Debian-specific overrides of the OpenSLX OSSetup API.
# -----------------------------------------------------------------------------
package OpenSLX::OSSetup::Distro::Debian;
@@ -26,91 +26,91 @@ use OpenSLX::Utils;
################################################################################
sub new
{
- my $class = shift;
- my $self = {};
- return bless $self, $class;
+ my $class = shift;
+ my $self = {};
+ return bless $self, $class;
}
sub initialize
{
- my $self = shift;
- my $engine = shift;
+ my $self = shift;
+ my $engine = shift;
- $self->SUPER::initialize($engine);
- $self->{'packager-type'} = 'dpkg';
- $self->{'meta-packager-type'} = $ENV{SLX_META_PACKAGER} || 'apt';
- $self->{'stage1c-faked-files'} = [];
- return;
+ $self->SUPER::initialize($engine);
+ $self->{'packager-type'} = 'dpkg';
+ $self->{'meta-packager-type'} = $ENV{SLX_META_PACKAGER} || 'apt';
+ $self->{'stage1c-faked-files'} = [];
+ return;
}
sub preSystemInstallationHook
{
- my $self = shift;
-
- $self->SUPER::preSystemInstallationHook();
+ my $self = shift;
+
+ $self->SUPER::preSystemInstallationHook();
- # fake required /dev-entries
- my %devInfo = (
- mem => { type => 'c', major => '1', minor => '1' },
- null => { type => 'c', major => '1', minor => '3' },
- zero => { type => 'c', major => '1', minor => '5' },
- random => { type => 'c', major => '1', minor => '8' },
- urandom => { type => 'c', major => '1', minor => '9' },
- kmsg => { type => 'c', major => '1', minor => '11' },
- console => { type => 'c', major => '5', minor => '1' },
- ptmx => { type => 'c', major => '5', minor => '2' },
- );
- foreach my $dev (keys %devInfo) {
- my $info = $devInfo{$dev};
- if (!-e "/dev/$dev") {
- if (slxsystem(
- "mknod /dev/$dev $info->{type} $info->{major} $info->{minor}"
- )) {
- croak(_tr("unable to create dev-node '%s'! (%s)", $dev, $!));
- }
- }
- }
- foreach my $devDir ('pts', 'shm', '.udevdb', '.udev') {
- if (!-e "/dev/$devDir") {
- if (slxsystem("mkdir -p /dev/$devDir")) {
- croak(_tr("unable to create dev-dir '%s'! (%s)", $devDir, $!));
- }
- }
- }
+ # fake required /dev-entries
+ my %devInfo = (
+ mem => { type => 'c', major => '1', minor => '1' },
+ null => { type => 'c', major => '1', minor => '3' },
+ zero => { type => 'c', major => '1', minor => '5' },
+ random => { type => 'c', major => '1', minor => '8' },
+ urandom => { type => 'c', major => '1', minor => '9' },
+ kmsg => { type => 'c', major => '1', minor => '11' },
+ console => { type => 'c', major => '5', minor => '1' },
+ ptmx => { type => 'c', major => '5', minor => '2' },
+ );
+ foreach my $dev (keys %devInfo) {
+ my $info = $devInfo{$dev};
+ if (!-e "/dev/$dev") {
+ if (slxsystem(
+ "mknod /dev/$dev $info->{type} $info->{major} $info->{minor}"
+ )) {
+ croak(_tr("unable to create dev-node '%s'! (%s)", $dev, $!));
+ }
+ }
+ }
+ foreach my $devDir ('pts', 'shm', '.udevdb', '.udev') {
+ if (!-e "/dev/$devDir") {
+ if (slxsystem("mkdir -p /dev/$devDir")) {
+ croak(_tr("unable to create dev-dir '%s'! (%s)", $devDir, $!));
+ }
+ }
+ }
- # replace /usr/sbin/invoke-rc.d by a dummy, in order to avoid a whole lot
- # of initscripts being started. Wishful thinking: there should be another
- # way to stop Debian from doing this, as this is not really very supportive
- # of folder-based installations (then again: I may simply be too stupid
- # to find out how it is supposed to work ...)
- rename('/usr/sbin/invoke-rc.d', '/usr/sbin/_invoke-rc.d');
- spitFile('/usr/sbin/invoke-rc.d', "#! /bin/sh\nexit 0\n");
- chmod 0755, '/usr/sbin/invoke-rc.d';
+ # replace /usr/sbin/invoke-rc.d by a dummy, in order to avoid a whole lot
+ # of initscripts being started. Wishful thinking: there should be another
+ # way to stop Debian from doing this, as this is not really very supportive
+ # of folder-based installations (then again: I may simply be too stupid
+ # to find out how it is supposed to work ...)
+ rename('/usr/sbin/invoke-rc.d', '/usr/sbin/_invoke-rc.d');
+ spitFile('/usr/sbin/invoke-rc.d', "#! /bin/sh\nexit 0\n");
+ chmod 0755, '/usr/sbin/invoke-rc.d';
}
sub postSystemInstallationHook
{
- my $self = shift;
+ my $self = shift;
- # restore /usr/sbin/invoke-rc.d
- rename('/usr/sbin/_invoke-rc.d', '/usr/sbin/invoke-rc.d');
- $self->SUPER::postSystemInstallationHook();
+ # restore /usr/sbin/invoke-rc.d
+ rename('/usr/sbin/_invoke-rc.d', '/usr/sbin/invoke-rc.d');
+ $self->SUPER::postSystemInstallationHook();
}
sub setPasswordForUser
{
- my $self = shift;
- my $username = shift;
- my $password = shift;
-
- # activate shadow passwords
- my $activateShadowFunction = sub {
- slxsystem('/sbin/shadowconfig', 'on');
- };
- $self->{engine}->callChrootedFunctionForVendorOS($activateShadowFunction);
-
- # invoke default behaviour
- $self->SUPER::setPasswordForUser($username, $password);
+ my $self = shift;
+ my $username = shift;
+ my $password = shift;
+
+ # activate shadow passwords
+ my $activateShadowFunction = sub {
+ slxsystem('/sbin/shadowconfig', 'on');
+ };
+ $self->{engine}->callChrootedFunctionForVendorOS($activateShadowFunction);
+
+ # invoke default behaviour
+ $self->SUPER::setPasswordForUser($username, $password);
}
-
+
1; \ No newline at end of file
diff --git a/installer/OpenSLX/OSSetup/Distro/Debian_3_1.pm b/installer/OpenSLX/OSSetup/Distro/Debian_3_1.pm
index 87c14534..7f390bc1 100644
--- a/installer/OpenSLX/OSSetup/Distro/Debian_3_1.pm
+++ b/installer/OpenSLX/OSSetup/Distro/Debian_3_1.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# Debian_3_1.pm
-# - provides Debian-3.1-specific overrides of the OpenSLX OSSetup API.
+# - provides Debian-3.1-specific overrides of the OpenSLX OSSetup API.
# -----------------------------------------------------------------------------
package OpenSLX::OSSetup::Distro::Debian_3_1;
@@ -26,30 +26,30 @@ use OpenSLX::Utils;
################################################################################
sub preSystemInstallationHook
{
- my $self = shift;
-
- $self->SUPER::preSystemInstallationHook();
-
- # when the kernel package is being configured, it insists on trying to
- # create an initrd, which neither works nor makes sense in our environment.
- #
- # in order to circumvent this problem, we manually install initrd-tools
- # (which contains mkinitrd) ...
- $self->{engine}->{'meta-packager'}->installPackages('initrd-tools');
- # ... and replace /usr/sbin/mkinitrd with a dummy, in order to skip the
- # initrd-creation.
- rename('/usr/sbin/mkinitrd', '/usr/sbin/_mkinitrd');
- spitFile('/usr/sbin/mkinitrd', "#! /bin/sh\ntouch \$2\n");
- chmod 0755, '/usr/sbin/mkinitrd';
+ my $self = shift;
+
+ $self->SUPER::preSystemInstallationHook();
+
+ # when the kernel package is being configured, it insists on trying to
+ # create an initrd, which neither works nor makes sense in our environment.
+ #
+ # in order to circumvent this problem, we manually install initrd-tools
+ # (which contains mkinitrd) ...
+ $self->{engine}->{'meta-packager'}->installPackages('initrd-tools');
+ # ... and replace /usr/sbin/mkinitrd with a dummy, in order to skip the
+ # initrd-creation.
+ rename('/usr/sbin/mkinitrd', '/usr/sbin/_mkinitrd');
+ spitFile('/usr/sbin/mkinitrd', "#! /bin/sh\ntouch \$2\n");
+ chmod 0755, '/usr/sbin/mkinitrd';
}
sub postSystemInstallationHook
{
- my $self = shift;
+ my $self = shift;
- # restore /usr/sbin/mkinitrd
- rename('/usr/sbin/_mkinitrd', '/usr/sbin/mkinitrd');
- $self->SUPER::postSystemInstallationHook();
+ # restore /usr/sbin/mkinitrd
+ rename('/usr/sbin/_mkinitrd', '/usr/sbin/mkinitrd');
+ $self->SUPER::postSystemInstallationHook();
}
1; \ No newline at end of file
diff --git a/installer/OpenSLX/OSSetup/Distro/Fedora.pm b/installer/OpenSLX/OSSetup/Distro/Fedora.pm
index 7fe4973c..0bc9ebdc 100644
--- a/installer/OpenSLX/OSSetup/Distro/Fedora.pm
+++ b/installer/OpenSLX/OSSetup/Distro/Fedora.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# Fedora.pm
-# - provides Fedora-specific overrides of the OpenSLX OSSetup API.
+# - provides Fedora-specific overrides of the OpenSLX OSSetup API.
# -----------------------------------------------------------------------------
package OpenSLX::OSSetup::Distro::Fedora;
@@ -25,24 +25,24 @@ use OpenSLX::Basics;
################################################################################
sub new
{
- my $class = shift;
- my $self = {};
- return bless $self, $class;
+ my $class = shift;
+ my $self = {};
+ return bless $self, $class;
}
sub initialize
{
- my $self = shift;
- my $engine = shift;
+ my $self = shift;
+ my $engine = shift;
- $self->SUPER::initialize($engine);
- $self->{'packager-type'} = 'rpm';
- $self->{'meta-packager-type'} = $ENV{SLX_META_PACKAGER} || 'yum';
- $self->{'stage1c-faked-files'} = [
- '/etc/fstab',
- '/etc/mtab',
- ];
- return;
+ $self->SUPER::initialize($engine);
+ $self->{'packager-type'} = 'rpm';
+ $self->{'meta-packager-type'} = $ENV{SLX_META_PACKAGER} || 'yum';
+ $self->{'stage1c-faked-files'} = [
+ '/etc/fstab',
+ '/etc/mtab',
+ ];
+ return;
}
1; \ No newline at end of file
diff --git a/installer/OpenSLX/OSSetup/Distro/Gentoo.pm b/installer/OpenSLX/OSSetup/Distro/Gentoo.pm
index 4d1032f7..c49ba5d6 100644
--- a/installer/OpenSLX/OSSetup/Distro/Gentoo.pm
+++ b/installer/OpenSLX/OSSetup/Distro/Gentoo.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# SUSE.pm
-# - provides SUSE-specific overrides of the OpenSLX OSSetup API.
+# - provides SUSE-specific overrides of the OpenSLX OSSetup API.
# -----------------------------------------------------------------------------
package OpenSLX::OSSetup::Distro::Gentoo;
@@ -25,34 +25,34 @@ use OpenSLX::Basics;
################################################################################
sub new
{
- my $class = shift;
- my $self = {};
- return bless $self, $class;
+ my $class = shift;
+ my $self = {};
+ return bless $self, $class;
}
sub pickKernelFile
{
- my $self = shift;
- my $kernelPath = shift;
-
- my $newestKernelFile;
- my $newestKernelFileSortKey = '';
- foreach my $kernelFile (glob("$kernelPath/kernel-genkernel-x86-*")) {
- next unless $kernelFile =~ m{
- x86-(\d+)\.(\d+)\.(\d+)(?:\.(\d+))?-(\d+(?:\.\d+)?)
- }x;
- my $sortKey
- = sprintf("%02d.%02d.%02d.%02d-%2.1f", $1, $2, $3, $4||0, $5);
- if ($newestKernelFileSortKey lt $sortKey) {
- $newestKernelFile = $kernelFile;
- $newestKernelFileSortKey = $sortKey;
- }
- }
-
- if (!defined $newestKernelFile) {
- die _tr("unable to pick a kernel-file from path '%s'!", $kernelPath);
- }
- return $newestKernelFile;
+ my $self = shift;
+ my $kernelPath = shift;
+
+ my $newestKernelFile;
+ my $newestKernelFileSortKey = '';
+ foreach my $kernelFile (glob("$kernelPath/kernel-genkernel-x86-*")) {
+ next unless $kernelFile =~ m{
+ x86-(\d+)\.(\d+)\.(\d+)(?:\.(\d+))?-(\d+(?:\.\d+)?)
+ }x;
+ my $sortKey
+ = sprintf("%02d.%02d.%02d.%02d-%2.1f", $1, $2, $3, $4||0, $5);
+ if ($newestKernelFileSortKey lt $sortKey) {
+ $newestKernelFile = $kernelFile;
+ $newestKernelFileSortKey = $sortKey;
+ }
+ }
+
+ if (!defined $newestKernelFile) {
+ die _tr("unable to pick a kernel-file from path '%s'!", $kernelPath);
+ }
+ return $newestKernelFile;
}
1;
diff --git a/installer/OpenSLX/OSSetup/Distro/SUSE.pm b/installer/OpenSLX/OSSetup/Distro/SUSE.pm
index c6d81747..192ea3aa 100644
--- a/installer/OpenSLX/OSSetup/Distro/SUSE.pm
+++ b/installer/OpenSLX/OSSetup/Distro/SUSE.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# SUSE.pm
-# - provides SUSE-specific overrides of the OpenSLX OSSetup API.
+# - provides SUSE-specific overrides of the OpenSLX OSSetup API.
# -----------------------------------------------------------------------------
package OpenSLX::OSSetup::Distro::SUSE;
@@ -25,61 +25,61 @@ use OpenSLX::Basics;
################################################################################
sub new
{
- my $class = shift;
- my $self = {};
- return bless $self, $class;
+ my $class = shift;
+ my $self = {};
+ return bless $self, $class;
}
sub initialize
{
- my $self = shift;
- my $engine = shift;
+ my $self = shift;
+ my $engine = shift;
- $self->SUPER::initialize($engine);
- $self->{'packager-type'} = 'rpm';
- $self->{'meta-packager-type'} = $ENV{SLX_META_PACKAGER} || 'smart';
+ $self->SUPER::initialize($engine);
+ $self->{'packager-type'} = 'rpm';
+ $self->{'meta-packager-type'} = $ENV{SLX_META_PACKAGER} || 'smart';
- if ($engine->{'action-type'} eq 'install') {
- # Inform SUSE RPMs that we're performing an installation - this is
- # only important for installations taking place in stage 1c:
- $ENV{YAST_IS_RUNNING} = "instsys";
- }
+ if ($engine->{'action-type'} eq 'install') {
+ # Inform SUSE RPMs that we're performing an installation - this is
+ # only important for installations taking place in stage 1c:
+ $ENV{YAST_IS_RUNNING} = "instsys";
+ }
- return;
+ return;
}
sub fixPrerequiredFiles
{
- my $self = shift;
- my $stage1cDir = shift;
+ my $self = shift;
+ my $stage1cDir = shift;
- chown(0, 0, "$stage1cDir/etc/group", "$stage1cDir/etc/passwd",
- "$stage1cDir/etc/shadow");
- return;
+ chown(0, 0, "$stage1cDir/etc/group", "$stage1cDir/etc/passwd",
+ "$stage1cDir/etc/shadow");
+ return;
}
sub updateDistroConfig
{
- my $self = shift;
+ my $self = shift;
- # invoke SuSEconfig in order to allow it to update the configuration:
- if (slxsystem('SuSEconfig')) {
- die _tr("unable to run SuSEconfig (%s)", $!);
- }
- $self->SUPER::updateDistroConfig();
- return;
+ # invoke SuSEconfig in order to allow it to update the configuration:
+ if (slxsystem('SuSEconfig')) {
+ die _tr("unable to run SuSEconfig (%s)", $!);
+ }
+ $self->SUPER::updateDistroConfig();
+ return;
}
sub hashPassword
{
- my $self = shift;
- my $password = shift;
-
- my $busyboxBin = $self->{engine}->{'busybox-binary'};
- my $hashedPassword = qx{$busyboxBin cryptpw -a blowfish '$password'};
- chomp $hashedPassword;
+ my $self = shift;
+ my $password = shift;
+
+ my $busyboxBin = $self->{engine}->{'busybox-binary'};
+ my $hashedPassword = qx{$busyboxBin cryptpw -a blowfish '$password'};
+ chomp $hashedPassword;
- return $hashedPassword;
+ return $hashedPassword;
}
1;
diff --git a/installer/OpenSLX/OSSetup/Distro/Ubuntu.pm b/installer/OpenSLX/OSSetup/Distro/Ubuntu.pm
index 4ab5abbc..5e7e41ea 100644
--- a/installer/OpenSLX/OSSetup/Distro/Ubuntu.pm
+++ b/installer/OpenSLX/OSSetup/Distro/Ubuntu.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# Ubuntu.pm
-# - provides Ubuntu-specific overrides of the OpenSLX OSSetup API.
+# - provides Ubuntu-specific overrides of the OpenSLX OSSetup API.
# -----------------------------------------------------------------------------
package OpenSLX::OSSetup::Distro::Ubuntu;
@@ -26,75 +26,75 @@ use OpenSLX::Utils;
################################################################################
sub new
{
- my $class = shift;
- my $self = {};
- return bless $self, $class;
+ my $class = shift;
+ my $self = {};
+ return bless $self, $class;
}
sub initialize
{
- my $self = shift;
- my $engine = shift;
+ my $self = shift;
+ my $engine = shift;
- $self->SUPER::initialize($engine);
- $self->{'packager-type'} = 'dpkg';
- $self->{'meta-packager-type'} = $ENV{SLX_META_PACKAGER} || 'apt';
- $self->{'stage1c-faked-files'} = [];
- return;
+ $self->SUPER::initialize($engine);
+ $self->{'packager-type'} = 'dpkg';
+ $self->{'meta-packager-type'} = $ENV{SLX_META_PACKAGER} || 'apt';
+ $self->{'stage1c-faked-files'} = [];
+ return;
}
sub preSystemInstallationHook
{
- my $self = shift;
-
- $self->SUPER::preSystemInstallationHook();
+ my $self = shift;
+
+ $self->SUPER::preSystemInstallationHook();
- # fake required /dev-entries
- my %devInfo = (
- mem => { type => 'c', major => '1', minor => '1' },
- null => { type => 'c', major => '1', minor => '3' },
- zero => { type => 'c', major => '1', minor => '5' },
- random => { type => 'c', major => '1', minor => '8' },
- urandom => { type => 'c', major => '1', minor => '9' },
- kmsg => { type => 'c', major => '1', minor => '11' },
- console => { type => 'c', major => '5', minor => '1' },
- ptmx => { type => 'c', major => '5', minor => '2' },
- );
- foreach my $dev (keys %devInfo) {
- my $info = $devInfo{$dev};
- if (!-e "/dev/$dev") {
- if (slxsystem(
- "mknod /dev/$dev $info->{type} $info->{major} $info->{minor}"
- )) {
- croak(_tr("unable to create dev-node '%s'! (%s)", $dev, $!));
- }
- }
- }
- foreach my $devDir ('pts', 'shm', '.udevdb', '.udev') {
- if (!-e "/dev/$devDir") {
- if (slxsystem("mkdir -p /dev/$devDir")) {
- croak(_tr("unable to create dev-dir '%s'! (%s)", $devDir, $!));
- }
- }
- }
+ # fake required /dev-entries
+ my %devInfo = (
+ mem => { type => 'c', major => '1', minor => '1' },
+ null => { type => 'c', major => '1', minor => '3' },
+ zero => { type => 'c', major => '1', minor => '5' },
+ random => { type => 'c', major => '1', minor => '8' },
+ urandom => { type => 'c', major => '1', minor => '9' },
+ kmsg => { type => 'c', major => '1', minor => '11' },
+ console => { type => 'c', major => '5', minor => '1' },
+ ptmx => { type => 'c', major => '5', minor => '2' },
+ );
+ foreach my $dev (keys %devInfo) {
+ my $info = $devInfo{$dev};
+ if (!-e "/dev/$dev") {
+ if (slxsystem(
+ "mknod /dev/$dev $info->{type} $info->{major} $info->{minor}"
+ )) {
+ croak(_tr("unable to create dev-node '%s'! (%s)", $dev, $!));
+ }
+ }
+ }
+ foreach my $devDir ('pts', 'shm', '.udevdb', '.udev') {
+ if (!-e "/dev/$devDir") {
+ if (slxsystem("mkdir -p /dev/$devDir")) {
+ croak(_tr("unable to create dev-dir '%s'! (%s)", $devDir, $!));
+ }
+ }
+ }
- # replace /usr/sbin/invoke-rc.d by a dummy, in order to avoid a whole lot
- # of initscripts being started. Wishful thinking: there should be another
- # way to stop Ubuntu from doing this, as this is not really very supportive
- # of folder-based installations (then again: I may simply be too stupid
- # to find out how it is supposed to work ...)
- rename('/usr/sbin/invoke-rc.d', '/usr/sbin/_invoke-rc.d');
- spitFile('/usr/sbin/invoke-rc.d', "#! /bin/sh\nexit 0\n");
- chmod 0755, '/usr/sbin/invoke-rc.d';
+ # replace /usr/sbin/invoke-rc.d by a dummy, in order to avoid a whole lot
+ # of initscripts being started. Wishful thinking: there should be another
+ # way to stop Ubuntu from doing this, as this is not really very supportive
+ # of folder-based installations (then again: I may simply be too stupid
+ # to find out how it is supposed to work ...)
+ rename('/usr/sbin/invoke-rc.d', '/usr/sbin/_invoke-rc.d');
+ spitFile('/usr/sbin/invoke-rc.d', "#! /bin/sh\nexit 0\n");
+ chmod 0755, '/usr/sbin/invoke-rc.d';
}
sub postSystemInstallationHook
{
- my $self = shift;
+ my $self = shift;
- # restore /usr/sbin/invoke-rc.d
- rename('/usr/sbin/_invoke-rc.d', '/usr/sbin/invoke-rc.d');
- $self->SUPER::postSystemInstallationHook();
+ # restore /usr/sbin/invoke-rc.d
+ rename('/usr/sbin/_invoke-rc.d', '/usr/sbin/invoke-rc.d');
+ $self->SUPER::postSystemInstallationHook();
}
1; \ No newline at end of file
diff --git a/installer/OpenSLX/OSSetup/Engine.pm b/installer/OpenSLX/OSSetup/Engine.pm
index 59057336..9030beaa 100644
--- a/installer/OpenSLX/OSSetup/Engine.pm
+++ b/installer/OpenSLX/OSSetup/Engine.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# Engine.pm
-# - provides driver engine for the OSSetup API.
+# - provides driver engine for the OSSetup API.
# -----------------------------------------------------------------------------
package OpenSLX::OSSetup::Engine;
@@ -23,7 +23,7 @@ use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(
- %supportedDistros
+ %supportedDistros
);
use Config::General;
@@ -36,84 +36,84 @@ use OpenSLX::Utils;
use vars qw(%supportedDistros);
%supportedDistros = (
- 'debian-3.1' => {
- module => 'Debian_3_1', support => 'clone,install'
- },
- 'debian-4.0' => {
- module => 'Debian', support => 'clone,install'
- },
- 'debian-4.0_amd64' => {
- module => 'Debian', support => 'clone,install'
- },
- 'fedora-6' => {
- module => 'Fedora', support => 'clone,install'
- },
- 'fedora-6_x86_64' => {
- module => 'Fedora', support => 'clone,install'
- },
- 'gentoo-2006.X' => {
- module => 'Gentoo', support => 'clone'
- },
- 'gentoo-2007.X' => {
- module => 'Gentoo', support => 'clone'
- },
- 'mandriva-2007.0' => {
- module => 'Mandriva_2007_0', support => 'clone'
- },
- 'suse-9.3' => {
- module => 'SUSE', support => 'clone'
- },
- 'suse-10.0' => {
- module => 'SUSE', support => 'clone'
- },
- 'suse-10.0_x86_64' => {
- module => 'SUSE', support => 'clone'
- },
- 'suse-10.1' => {
- module => 'SUSE', support => 'clone,install'
- },
- 'suse-10.1_x86_64' => {
- module => 'SUSE', support => 'clone,install'
- },
- 'suse-10.2' => {
- module => 'SUSE', support => 'clone,install'
- },
- 'suse-10.2_x86_64' => {
- module => 'SUSE', support => 'clone,install'
- },
- 'suse-10.3' => {
- module => 'SUSE', support => 'clone'
- },
- 'suse-10.3_x86_64' => {
- module => 'SUSE', support => 'clone'
- },
- 'ubuntu-6.06' => {
- module => 'Ubuntu', support => 'clone'
- },
- 'ubuntu-6.10' => {
- module => 'Ubuntu', support => 'clone,install'
- },
- 'ubuntu-6.10_amd64' => {
- module => 'Ubuntu', support => 'clone,install'
- },
- 'ubuntu-7.04' => {
- module => 'Ubuntu', support => 'clone,install'
- },
- 'ubuntu-7.04_amd64' => {
- module => 'Ubuntu', support => 'clone,install'
- },
- 'ubuntu-7.10' => {
- module => 'Ubuntu', support => 'clone'
- },
- 'ubuntu-7.10_amd64' => {
- module => 'Ubuntu', support => 'clone'
- },
- 'ubuntu-8.04' => {
- module => 'Ubuntu', support => 'clone'
- },
- 'ubuntu-8.04_amd64' => {
- module => 'Ubuntu', support => 'clone'
- },
+ 'debian-3.1' => {
+ module => 'Debian_3_1', support => 'clone,install'
+ },
+ 'debian-4.0' => {
+ module => 'Debian', support => 'clone,install'
+ },
+ 'debian-4.0_amd64' => {
+ module => 'Debian', support => 'clone,install'
+ },
+ 'fedora-6' => {
+ module => 'Fedora', support => 'clone,install'
+ },
+ 'fedora-6_x86_64' => {
+ module => 'Fedora', support => 'clone,install'
+ },
+ 'gentoo-2006.X' => {
+ module => 'Gentoo', support => 'clone'
+ },
+ 'gentoo-2007.X' => {
+ module => 'Gentoo', support => 'clone'
+ },
+ 'mandriva-2007.0' => {
+ module => 'Mandriva_2007_0', support => 'clone'
+ },
+ 'suse-9.3' => {
+ module => 'SUSE', support => 'clone'
+ },
+ 'suse-10.0' => {
+ module => 'SUSE', support => 'clone'
+ },
+ 'suse-10.0_x86_64' => {
+ module => 'SUSE', support => 'clone'
+ },
+ 'suse-10.1' => {
+ module => 'SUSE', support => 'clone,install'
+ },
+ 'suse-10.1_x86_64' => {
+ module => 'SUSE', support => 'clone,install'
+ },
+ 'suse-10.2' => {
+ module => 'SUSE', support => 'clone,install'
+ },
+ 'suse-10.2_x86_64' => {
+ module => 'SUSE', support => 'clone,install'
+ },
+ 'suse-10.3' => {
+ module => 'SUSE', support => 'clone'
+ },
+ 'suse-10.3_x86_64' => {
+ module => 'SUSE', support => 'clone'
+ },
+ 'ubuntu-6.06' => {
+ module => 'Ubuntu', support => 'clone'
+ },
+ 'ubuntu-6.10' => {
+ module => 'Ubuntu', support => 'clone,install'
+ },
+ 'ubuntu-6.10_amd64' => {
+ module => 'Ubuntu', support => 'clone,install'
+ },
+ 'ubuntu-7.04' => {
+ module => 'Ubuntu', support => 'clone,install'
+ },
+ 'ubuntu-7.04_amd64' => {
+ module => 'Ubuntu', support => 'clone,install'
+ },
+ 'ubuntu-7.10' => {
+ module => 'Ubuntu', support => 'clone'
+ },
+ 'ubuntu-7.10_amd64' => {
+ module => 'Ubuntu', support => 'clone'
+ },
+ 'ubuntu-8.04' => {
+ module => 'Ubuntu', support => 'clone'
+ },
+ 'ubuntu-8.04_amd64' => {
+ module => 'Ubuntu', support => 'clone'
+ },
);
our $localHttpServerMasterPID;
@@ -124,594 +124,594 @@ our %localHttpServers;
################################################################################
sub new
{
- my $class = shift;
+ my $class = shift;
- my $self = {};
+ my $self = {};
- return bless $self, $class;
+ return bless $self, $class;
}
sub DESTROY
{
- my $self = shift;
-
- my $httpServerPID = $localHttpServerMasterPID || '0';
- if ($httpServerPID == $$) {
- # we are the master process, so we clean up all the servers that we
- # have started:
- while (my ($localURL, $serverInfo) = each %localHttpServers) {
- vlog(1, _tr("stopping local HTTP-server for URL '%s'.", $localURL));
- kill TERM => $serverInfo->{pid};
- }
- }
- return;
+ my $self = shift;
+
+ my $httpServerPID = $localHttpServerMasterPID || '0';
+ if ($httpServerPID == $$) {
+ # we are the master process, so we clean up all the servers that we
+ # have started:
+ while (my ($localURL, $serverInfo) = each %localHttpServers) {
+ vlog(1, _tr("stopping local HTTP-server for URL '%s'.", $localURL));
+ kill TERM => $serverInfo->{pid};
+ }
+ }
+ return;
}
sub initialize
{
- my $self = shift;
- my $vendorOSName = shift;
- my $actionType = shift;
-
- if ($vendorOSName eq '<<<default>>>') {
- die _tr("you can't do that with the default vendor-OS!\n");
- }
- if ($vendorOSName !~ m[^([^\-]+\-[^\-]+)(?:\-(.+))?]) {
- die _tr(
- "Given vendor-OS has unknown format, expected '<name>-<release>[-<selection>]'\n"
- );
- }
- my $distroName = $1;
- my $selectionName = $2 || 'default';
- $self->{'vendor-os-name'} = $vendorOSName;
- $self->{'action-type'} = $actionType;
- $self->{'distro-name'} = lc($distroName);
- $self->{'selection-name'} = $selectionName;
- $self->{'clone-source'} = '';
- if (!exists $supportedDistros{lc($distroName)}) {
- print _tr("Sorry, distro '%s' is unsupported.\n", $distroName);
- print _tr("List of supported distros:\n\t");
- print join("\n\t", sort keys %supportedDistros) . "\n";
- exit 1;
- }
- my $support = $supportedDistros{lc($distroName)}->{support};
- if ($support !~ m[install]i) {
- if ($actionType eq 'install') {
- print _tr(
- "Sorry, distro '%s' can not be installed, only cloned!\n",
- $distroName
- );
- exit 1;
- }
- elsif ($actionType eq 'update') {
- print _tr(
- "Sorry, vendor-OS '%s' has been cloned, don't know how to update it!\n",
- $distroName
- );
- exit 1;
- }
- elsif ($actionType eq 'shell') {
- print _tr(
- "Sorry, vendor-OS '%s' has been cloned, no support for chrooted shell available!\n",
- $distroName
- );
- exit 1;
- }
- }
-
- # load module for the requested distro:
- my $distro;
- my $distroClass = $supportedDistros{lc($distroName)}->{module};
- if ($actionType =~ m{^(install|update|shell)}) {
- $distro = instantiateClass("OpenSLX::OSSetup::Distro::$distroClass");
- }
- else {
- if (!eval {
- $distro = instantiateClass("OpenSLX::OSSetup::Distro::$distroClass")
- }) {
- vlog(2, "could not load distro module '$distroClass' ($@) ...");
- vlog(2, "falling back to module 'Any_Clone'");
- # allow fallback to generic clone module, such that we can clone
- # distro's for which there is no specific distro-module yet
- # (like for example for Gentoo):
- $distro = instantiateClass("OpenSLX::OSSetup::Distro::Any_Clone")
- }
- }
-
- $distro->initialize($self);
- $self->{distro} = $distro;
-
- if ($actionType =~ m{^(install|update|shell|plugin)}) {
- # setup path to distribution-specific info:
- my $sharedDistroInfoDir
- = "$openslxConfig{'base-path'}/share/distro-info/$self->{'distro-name'}";
- if (!-d $sharedDistroInfoDir) {
- die _tr(
- "unable to find shared distro-info in '%s'\n",
- $sharedDistroInfoDir
- );
- }
- $self->{'shared-distro-info-dir'} = $sharedDistroInfoDir;
- my $configDistroInfoDir =
- "$openslxConfig{'config-path'}/distro-info/$self->{'distro-name'}";
- if (!-d $configDistroInfoDir) {
- die _tr(
- "unable to find configurable distro-info in '%s'\n",
- $configDistroInfoDir
- );
- }
- $self->{'config-distro-info-dir'} = $configDistroInfoDir;
-
- my $busyboxName =
- $self->_hostIs64Bit()
- ? 'busybox.x86_64'
- : 'busybox.i586';
- $self->{'busybox-binary'}
- = "$openslxConfig{'base-path'}/share/busybox/$busyboxName";
-
- $self->_readDistroInfo();
- }
-
- if ($self->{'action-type'} eq 'install'
- && !exists $self->{'distro-info'}->{'selection'}->{$selectionName})
- {
- die(
- _tr(
- "selection '%s' is unknown to distro '%s'\n",
- $selectionName, $self->{'distro-name'}
- )
- . _tr("These selections are available:\n\t")
- . join("\n\t", sort keys %{$self->{'distro-info'}->{'selection'}})
- . "\n"
- );
- }
-
- $self->{'vendor-os-path'}
- = "$openslxConfig{'private-path'}/stage1/$self->{'vendor-os-name'}";
- vlog(1, "vendor-OS path is '$self->{'vendor-os-path'}'");
-
- if ($actionType =~ m{^(install|update|shell|plugin)}) {
- $self->_createPackager();
- $self->_createMetaPackager();
- }
-
- return;
+ my $self = shift;
+ my $vendorOSName = shift;
+ my $actionType = shift;
+
+ if ($vendorOSName eq '<<<default>>>') {
+ die _tr("you can't do that with the default vendor-OS!\n");
+ }
+ if ($vendorOSName !~ m[^([^\-]+\-[^\-]+)(?:\-(.+))?]) {
+ die _tr(
+ "Given vendor-OS has unknown format, expected '<name>-<release>[-<selection>]'\n"
+ );
+ }
+ my $distroName = $1;
+ my $selectionName = $2 || 'default';
+ $self->{'vendor-os-name'} = $vendorOSName;
+ $self->{'action-type'} = $actionType;
+ $self->{'distro-name'} = lc($distroName);
+ $self->{'selection-name'} = $selectionName;
+ $self->{'clone-source'} = '';
+ if (!exists $supportedDistros{lc($distroName)}) {
+ print _tr("Sorry, distro '%s' is unsupported.\n", $distroName);
+ print _tr("List of supported distros:\n\t");
+ print join("\n\t", sort keys %supportedDistros) . "\n";
+ exit 1;
+ }
+ my $support = $supportedDistros{lc($distroName)}->{support};
+ if ($support !~ m[install]i) {
+ if ($actionType eq 'install') {
+ print _tr(
+ "Sorry, distro '%s' can not be installed, only cloned!\n",
+ $distroName
+ );
+ exit 1;
+ }
+ elsif ($actionType eq 'update') {
+ print _tr(
+ "Sorry, vendor-OS '%s' has been cloned, don't know how to update it!\n",
+ $distroName
+ );
+ exit 1;
+ }
+ elsif ($actionType eq 'shell') {
+ print _tr(
+ "Sorry, vendor-OS '%s' has been cloned, no support for chrooted shell available!\n",
+ $distroName
+ );
+ exit 1;
+ }
+ }
+
+ # load module for the requested distro:
+ my $distro;
+ my $distroClass = $supportedDistros{lc($distroName)}->{module};
+ if ($actionType =~ m{^(install|update|shell)}) {
+ $distro = instantiateClass("OpenSLX::OSSetup::Distro::$distroClass");
+ }
+ else {
+ if (!eval {
+ $distro = instantiateClass("OpenSLX::OSSetup::Distro::$distroClass")
+ }) {
+ vlog(2, "could not load distro module '$distroClass' ($@) ...");
+ vlog(2, "falling back to module 'Any_Clone'");
+ # allow fallback to generic clone module, such that we can clone
+ # distro's for which there is no specific distro-module yet
+ # (like for example for Gentoo):
+ $distro = instantiateClass("OpenSLX::OSSetup::Distro::Any_Clone")
+ }
+ }
+
+ $distro->initialize($self);
+ $self->{distro} = $distro;
+
+ if ($actionType =~ m{^(install|update|shell|plugin)}) {
+ # setup path to distribution-specific info:
+ my $sharedDistroInfoDir
+ = "$openslxConfig{'base-path'}/share/distro-info/$self->{'distro-name'}";
+ if (!-d $sharedDistroInfoDir) {
+ die _tr(
+ "unable to find shared distro-info in '%s'\n",
+ $sharedDistroInfoDir
+ );
+ }
+ $self->{'shared-distro-info-dir'} = $sharedDistroInfoDir;
+ my $configDistroInfoDir =
+ "$openslxConfig{'config-path'}/distro-info/$self->{'distro-name'}";
+ if (!-d $configDistroInfoDir) {
+ die _tr(
+ "unable to find configurable distro-info in '%s'\n",
+ $configDistroInfoDir
+ );
+ }
+ $self->{'config-distro-info-dir'} = $configDistroInfoDir;
+
+ my $busyboxName =
+ $self->_hostIs64Bit()
+ ? 'busybox.x86_64'
+ : 'busybox.i586';
+ $self->{'busybox-binary'}
+ = "$openslxConfig{'base-path'}/share/busybox/$busyboxName";
+
+ $self->_readDistroInfo();
+ }
+
+ if ($self->{'action-type'} eq 'install'
+ && !exists $self->{'distro-info'}->{'selection'}->{$selectionName})
+ {
+ die(
+ _tr(
+ "selection '%s' is unknown to distro '%s'\n",
+ $selectionName, $self->{'distro-name'}
+ )
+ . _tr("These selections are available:\n\t")
+ . join("\n\t", sort keys %{$self->{'distro-info'}->{'selection'}})
+ . "\n"
+ );
+ }
+
+ $self->{'vendor-os-path'}
+ = "$openslxConfig{'private-path'}/stage1/$self->{'vendor-os-name'}";
+ vlog(1, "vendor-OS path is '$self->{'vendor-os-path'}'");
+
+ if ($actionType =~ m{^(install|update|shell|plugin)}) {
+ $self->_createPackager();
+ $self->_createMetaPackager();
+ }
+
+ return;
}
sub installVendorOS
{
- my $self = shift;
- my $vendorOSSettings = shift;
-
- my $installInfoFile = "$self->{'vendor-os-path'}/.openslx-install-info";
- if (-e $installInfoFile) {
- die _tr("vendor-OS '%s' already exists, giving up!\n",
- $self->{'vendor-os-path'});
- }
- $self->_createVendorOSPath();
-
- $self->_startLocalURLServersAsNeeded();
-
- my $baseSystemFile = "$self->{'vendor-os-path'}/.openslx-base-system";
- if (-e $baseSystemFile) {
- vlog(0, _tr("found existing base system, continuing...\n"));
- }
- else {
- # basic setup, stage1a-c:
- $self->_setupStage1A();
- callInSubprocess(
- sub {
- # some tasks that involve a chrooted environment:
- $self->_changePersonalityIfNeeded();
- $self->_setupStage1B();
- $self->_setupStage1C();
- }
- );
- $self->_stage1C_cleanupBasicVendorOS();
- # just touch the file, in order to indicate a basic system:
- slxsystem("touch $baseSystemFile");
- }
- callInSubprocess(
- sub {
- # another task that involves a chrooted environment:
- $self->_changePersonalityIfNeeded();
- $self->_setupStage1D();
- }
- );
-
- # create the install-info file, in order to indicate a proper installation:
- spitFile(
- $installInfoFile,
- "SLX_META_PACKAGER=$self->{distro}->{'meta-packager-type'}\n"
- );
-
- # base system info file is no longer needed, we have a full system now
- slxsystem("rm $baseSystemFile");
-
- $self->_applyVendorOSSettings($vendorOSSettings) unless !$vendorOSSettings;
-
- vlog(
- 0,
- _tr(
- "Vendor-OS '%s' installed succesfully.\n",
- $self->{'vendor-os-name'}
- )
- );
-
- $self->_touchVendorOS();
- $self->addInstalledVendorOSToConfigDB();
- return;
+ my $self = shift;
+ my $vendorOSSettings = shift;
+
+ my $installInfoFile = "$self->{'vendor-os-path'}/.openslx-install-info";
+ if (-e $installInfoFile) {
+ die _tr("vendor-OS '%s' already exists, giving up!\n",
+ $self->{'vendor-os-path'});
+ }
+ $self->_createVendorOSPath();
+
+ $self->_startLocalURLServersAsNeeded();
+
+ my $baseSystemFile = "$self->{'vendor-os-path'}/.openslx-base-system";
+ if (-e $baseSystemFile) {
+ vlog(0, _tr("found existing base system, continuing...\n"));
+ }
+ else {
+ # basic setup, stage1a-c:
+ $self->_setupStage1A();
+ callInSubprocess(
+ sub {
+ # some tasks that involve a chrooted environment:
+ $self->_changePersonalityIfNeeded();
+ $self->_setupStage1B();
+ $self->_setupStage1C();
+ }
+ );
+ $self->_stage1C_cleanupBasicVendorOS();
+ # just touch the file, in order to indicate a basic system:
+ slxsystem("touch $baseSystemFile");
+ }
+ callInSubprocess(
+ sub {
+ # another task that involves a chrooted environment:
+ $self->_changePersonalityIfNeeded();
+ $self->_setupStage1D();
+ }
+ );
+
+ # create the install-info file, in order to indicate a proper installation:
+ spitFile(
+ $installInfoFile,
+ "SLX_META_PACKAGER=$self->{distro}->{'meta-packager-type'}\n"
+ );
+
+ # base system info file is no longer needed, we have a full system now
+ slxsystem("rm $baseSystemFile");
+
+ $self->_applyVendorOSSettings($vendorOSSettings) unless !$vendorOSSettings;
+
+ vlog(
+ 0,
+ _tr(
+ "Vendor-OS '%s' installed succesfully.\n",
+ $self->{'vendor-os-name'}
+ )
+ );
+
+ $self->_touchVendorOS();
+ $self->addInstalledVendorOSToConfigDB();
+ return;
}
sub cloneVendorOS
{
- my $self = shift;
- my $source = shift;
-
- if (substr($source, -1, 1) ne '/') {
- # make sure source path ends with a slash, as otherwise, the
- # last folder would be copied (but we only want its contents).
- $source .= '/';
- }
-
- $self->{'clone-source'} = $source;
- my $lastCloneSource = '';
- my $cloneInfoFile = "$self->{'vendor-os-path'}/.openslx-clone-info";
- my $isReClone;
- if (-e $self->{'vendor-os-path'}) {
- my $installInfoFile = "$self->{'vendor-os-path'}/.openslx-install-info";
- if (-e $installInfoFile) {
- # oops, given vendor-os has been installed, not cloned, we complain:
- croak(
- _tr(
- "The vendor-OS '%s' exists but it is no clone, refusing to clobber!\nPlease delete the folder manually, if that's really what you want...\n",
- $self->{'vendor-os-path'}
- )
- );
- }
- elsif (-e $cloneInfoFile) {
- # check if last and current source match:
- my $cloneInfo = slurpFile($cloneInfoFile);
- if ($cloneInfo =~ m[^source\s*=\s*(.+?)\s*$]ims) {
- $lastCloneSource = $1;
- }
- if ($source ne $lastCloneSource) {
- # protect user from confusing sources (still allowed, though):
- my $yes = _tr('yes');
- my $no = _tr('no');
- print _tr(
- "Last time this vendor-OS was cloned, it has been cloned from '%s', now you specified a different source: '%s'\nWould you still like to proceed (%s/%s)? ",
- $lastCloneSource, $source, $yes, $no
- );
- my $answer = <STDIN>;
- exit 5 unless $answer =~ m[^\s*$yes]i;
- }
- $isReClone = 1;
- }
- else {
- # Neither the install-info nor the clone-info file exists. This
- # probably means that the folder has been created by an older
- # version of the tools. There's not much we can do, we simply
- # trust our user and assume that he knows what he's doing.
- }
- }
-
- $self->_createVendorOSPath();
-
- $self->_clone_fetchSource($source);
- if ($source ne $lastCloneSource) {
- spitFile($cloneInfoFile, "source=$source\n");
- }
- if ($isReClone) {
- vlog(
- 0,
- _tr(
- "Vendor-OS '%s' has been re-cloned succesfully.\n",
- $self->{'vendor-os-name'}
- )
- );
- }
- else {
- vlog(
- 0,
- _tr(
- "Vendor-OS '%s' has been cloned succesfully.\n",
- $self->{'vendor-os-name'}
- )
- );
- }
-
- $self->_touchVendorOS();
- $self->addInstalledVendorOSToConfigDB();
- return;
+ my $self = shift;
+ my $source = shift;
+
+ if (substr($source, -1, 1) ne '/') {
+ # make sure source path ends with a slash, as otherwise, the
+ # last folder would be copied (but we only want its contents).
+ $source .= '/';
+ }
+
+ $self->{'clone-source'} = $source;
+ my $lastCloneSource = '';
+ my $cloneInfoFile = "$self->{'vendor-os-path'}/.openslx-clone-info";
+ my $isReClone;
+ if (-e $self->{'vendor-os-path'}) {
+ my $installInfoFile = "$self->{'vendor-os-path'}/.openslx-install-info";
+ if (-e $installInfoFile) {
+ # oops, given vendor-os has been installed, not cloned, we complain:
+ croak(
+ _tr(
+ "The vendor-OS '%s' exists but it is no clone, refusing to clobber!\nPlease delete the folder manually, if that's really what you want...\n",
+ $self->{'vendor-os-path'}
+ )
+ );
+ }
+ elsif (-e $cloneInfoFile) {
+ # check if last and current source match:
+ my $cloneInfo = slurpFile($cloneInfoFile);
+ if ($cloneInfo =~ m[^source\s*=\s*(.+?)\s*$]ims) {
+ $lastCloneSource = $1;
+ }
+ if ($source ne $lastCloneSource) {
+ # protect user from confusing sources (still allowed, though):
+ my $yes = _tr('yes');
+ my $no = _tr('no');
+ print _tr(
+ "Last time this vendor-OS was cloned, it has been cloned from '%s', now you specified a different source: '%s'\nWould you still like to proceed (%s/%s)? ",
+ $lastCloneSource, $source, $yes, $no
+ );
+ my $answer = <STDIN>;
+ exit 5 unless $answer =~ m[^\s*$yes]i;
+ }
+ $isReClone = 1;
+ }
+ else {
+ # Neither the install-info nor the clone-info file exists. This
+ # probably means that the folder has been created by an older
+ # version of the tools. There's not much we can do, we simply
+ # trust our user and assume that he knows what he's doing.
+ }
+ }
+
+ $self->_createVendorOSPath();
+
+ $self->_clone_fetchSource($source);
+ if ($source ne $lastCloneSource) {
+ spitFile($cloneInfoFile, "source=$source\n");
+ }
+ if ($isReClone) {
+ vlog(
+ 0,
+ _tr(
+ "Vendor-OS '%s' has been re-cloned succesfully.\n",
+ $self->{'vendor-os-name'}
+ )
+ );
+ }
+ else {
+ vlog(
+ 0,
+ _tr(
+ "Vendor-OS '%s' has been cloned succesfully.\n",
+ $self->{'vendor-os-name'}
+ )
+ );
+ }
+
+ $self->_touchVendorOS();
+ $self->addInstalledVendorOSToConfigDB();
+ return;
}
sub updateVendorOS
{
- my $self = shift;
+ my $self = shift;
- if (!-e $self->{'vendor-os-path'}) {
- die _tr("can't update vendor-OS '%s', since it doesn't exist!\n",
- $self->{'vendor-os-path'});
- }
+ if (!-e $self->{'vendor-os-path'}) {
+ die _tr("can't update vendor-OS '%s', since it doesn't exist!\n",
+ $self->{'vendor-os-path'});
+ }
- $self->_startLocalURLServersAsNeeded();
+ $self->_startLocalURLServersAsNeeded();
- callInSubprocess(
- sub {
- $self->_changePersonalityIfNeeded();
- $self->_updateStage1D();
- }
- );
+ callInSubprocess(
+ sub {
+ $self->_changePersonalityIfNeeded();
+ $self->_updateStage1D();
+ }
+ );
- $self->_touchVendorOS();
- vlog(
- 0,
- _tr("Vendor-OS '%s' updated succesfully.\n", $self->{'vendor-os-name'})
- );
+ $self->_touchVendorOS();
+ vlog(
+ 0,
+ _tr("Vendor-OS '%s' updated succesfully.\n", $self->{'vendor-os-name'})
+ );
- $self->_installPlugins();
+ $self->_installPlugins();
- return;
+ return;
}
sub startChrootedShellForVendorOS
{
- my $self = shift;
-
- if (!-e $self->{'vendor-os-path'}) {
- die _tr(
- "can't start chrooted shell for vendor-OS '%s', since it doesn't exist!\n",
- $self->{'vendor-os-path'}
- );
- }
-
- $self->_startLocalURLServersAsNeeded();
-
- callInSubprocess(
- sub {
- $self->_changePersonalityIfNeeded();
- $self->_startChrootedShellInStage1D();
- }
- );
-
- $self->_touchVendorOS();
- vlog(
- 0,
- _tr(
- "Chrooted shell for vendor-OS '%s' has been closed.\n",
- $self->{'vendor-os-name'}
- )
- );
- return;
+ my $self = shift;
+
+ if (!-e $self->{'vendor-os-path'}) {
+ die _tr(
+ "can't start chrooted shell for vendor-OS '%s', since it doesn't exist!\n",
+ $self->{'vendor-os-path'}
+ );
+ }
+
+ $self->_startLocalURLServersAsNeeded();
+
+ callInSubprocess(
+ sub {
+ $self->_changePersonalityIfNeeded();
+ $self->_startChrootedShellInStage1D();
+ }
+ );
+
+ $self->_touchVendorOS();
+ vlog(
+ 0,
+ _tr(
+ "Chrooted shell for vendor-OS '%s' has been closed.\n",
+ $self->{'vendor-os-name'}
+ )
+ );
+ return;
}
sub callChrootedFunctionForVendorOS
{
- my $self = shift;
- my $function = shift;
- my $updateConfig = shift || 0;
-
- if (!-e $self->{'vendor-os-path'}) {
- die _tr(
- "can't call chrooted function for vendor-OS '%s', since it doesn't exist!\n",
- $self->{'vendor-os-path'}
- );
- }
-
- $self->_startLocalURLServersAsNeeded();
-
- callInSubprocess(
- sub {
- $self->_changePersonalityIfNeeded();
- $self->_callChrootedFunction({
- chrootDir => $self->{'vendor-os-path'},
- function => $function,
- updateConfig => $updateConfig,
- });
- }
- );
-
- $self->_touchVendorOS();
- vlog(
- 1,
- _tr(
- "Chrooted function for vendor-OS '%s' has finished.\n",
- $self->{'vendor-os-name'}
- )
- );
- return 1;
+ my $self = shift;
+ my $function = shift;
+ my $updateConfig = shift || 0;
+
+ if (!-e $self->{'vendor-os-path'}) {
+ die _tr(
+ "can't call chrooted function for vendor-OS '%s', since it doesn't exist!\n",
+ $self->{'vendor-os-path'}
+ );
+ }
+
+ $self->_startLocalURLServersAsNeeded();
+
+ callInSubprocess(
+ sub {
+ $self->_changePersonalityIfNeeded();
+ $self->_callChrootedFunction({
+ chrootDir => $self->{'vendor-os-path'},
+ function => $function,
+ updateConfig => $updateConfig,
+ });
+ }
+ );
+
+ $self->_touchVendorOS();
+ vlog(
+ 1,
+ _tr(
+ "Chrooted function for vendor-OS '%s' has finished.\n",
+ $self->{'vendor-os-name'}
+ )
+ );
+ return 1;
}
sub removeVendorOS
{
- my $self = shift;
-
- vlog(
- 0,
- _tr("removing vendor-OS folder '%s'...", $self->{'vendor-os-path'})
- );
- if (system("rm -r $self->{'vendor-os-path'}")) {
- vlog(
- 0,
- _tr("* unable to remove vendor-OS '%s'!", $self->{'vendor-os-path'})
- );
- }
- else {
- vlog(
- 0,
- _tr(
- "Vendor-OS '%s' removed succesfully.\n",
- $self->{'vendor-os-name'}
- )
- );
- }
- $self->removeVendorOSFromConfigDB();
- return;
+ my $self = shift;
+
+ vlog(
+ 0,
+ _tr("removing vendor-OS folder '%s'...", $self->{'vendor-os-path'})
+ );
+ if (system("rm -r $self->{'vendor-os-path'}")) {
+ vlog(
+ 0,
+ _tr("* unable to remove vendor-OS '%s'!", $self->{'vendor-os-path'})
+ );
+ }
+ else {
+ vlog(
+ 0,
+ _tr(
+ "Vendor-OS '%s' removed succesfully.\n",
+ $self->{'vendor-os-name'}
+ )
+ );
+ }
+ $self->removeVendorOSFromConfigDB();
+ return;
}
sub addInstalledVendorOSToConfigDB
{
- my $self = shift;
-
- if (!-e $self->{'vendor-os-path'}) {
- die _tr(
- "can't import vendor-OS '%s', since it doesn't exist!\n",
- $self->{'vendor-os-path'}
- );
- }
- my $openslxDB = instantiateClass("OpenSLX::ConfigDB");
- $openslxDB->connect();
-
- my @plugins;
-
- # insert new vendor-os if it doesn't already exist in DB:
- my $vendorOSName = $self->{'vendor-os-name'};
- my $vendorOS = $openslxDB->fetchVendorOSByFilter({'name' => $vendorOSName});
- if (defined $vendorOS) {
- if ($vendorOS->{'clone_source'}
- && $self->{'clone-source'} ne $vendorOS->{'clone_source'}) {
- $openslxDB->changeVendorOS(
- $vendorOS->{id},
- { 'clone_source' => $self->{'clone-source'} }
- );
- vlog(
- 0,
- _tr(
- "Vendor-OS '%s' has been updated in OpenSLX-database.\n",
- $vendorOSName
- )
- );
- }
- else {
- vlog(
- 0,
- _tr(
- "No need to change vendor-OS '%s' in OpenSLX-database.\n",
- $vendorOSName
- )
- );
- }
- # re-install plugins of this vendor-OS
- @plugins = $openslxDB->fetchInstalledPlugins($vendorOS->{id});
- }
- else {
- my $data = { 'name' => $vendorOSName };
- if (length($self->{'clone-source'})) {
- $data->{'clone_source'} = $self->{'clone-source'};
- }
- my $id = $openslxDB->addVendorOS($data);
-
- vlog(
- 0,
- _tr(
- "Vendor-OS '%s' has been added to DB (ID=%s).\n",
- $vendorOSName, $id
- )
- );
- # install plugins from default vendor-OS into this new one
- @plugins = $openslxDB->fetchInstalledPlugins(0);
- }
-
- $openslxDB->disconnect();
-
- # now that we have the list of plugins, we (re-)install all of them:
- $self->_installPlugins(\@plugins);
-
- return;
+ my $self = shift;
+
+ if (!-e $self->{'vendor-os-path'}) {
+ die _tr(
+ "can't import vendor-OS '%s', since it doesn't exist!\n",
+ $self->{'vendor-os-path'}
+ );
+ }
+ my $openslxDB = instantiateClass("OpenSLX::ConfigDB");
+ $openslxDB->connect();
+
+ my @plugins;
+
+ # insert new vendor-os if it doesn't already exist in DB:
+ my $vendorOSName = $self->{'vendor-os-name'};
+ my $vendorOS = $openslxDB->fetchVendorOSByFilter({'name' => $vendorOSName});
+ if (defined $vendorOS) {
+ if ($vendorOS->{'clone_source'}
+ && $self->{'clone-source'} ne $vendorOS->{'clone_source'}) {
+ $openslxDB->changeVendorOS(
+ $vendorOS->{id},
+ { 'clone_source' => $self->{'clone-source'} }
+ );
+ vlog(
+ 0,
+ _tr(
+ "Vendor-OS '%s' has been updated in OpenSLX-database.\n",
+ $vendorOSName
+ )
+ );
+ }
+ else {
+ vlog(
+ 0,
+ _tr(
+ "No need to change vendor-OS '%s' in OpenSLX-database.\n",
+ $vendorOSName
+ )
+ );
+ }
+ # re-install plugins of this vendor-OS
+ @plugins = $openslxDB->fetchInstalledPlugins($vendorOS->{id});
+ }
+ else {
+ my $data = { 'name' => $vendorOSName };
+ if (length($self->{'clone-source'})) {
+ $data->{'clone_source'} = $self->{'clone-source'};
+ }
+ my $id = $openslxDB->addVendorOS($data);
+
+ vlog(
+ 0,
+ _tr(
+ "Vendor-OS '%s' has been added to DB (ID=%s).\n",
+ $vendorOSName, $id
+ )
+ );
+ # install plugins from default vendor-OS into this new one
+ @plugins = $openslxDB->fetchInstalledPlugins(0);
+ }
+
+ $openslxDB->disconnect();
+
+ # now that we have the list of plugins, we (re-)install all of them:
+ $self->_installPlugins(\@plugins);
+
+ return;
}
sub removeVendorOSFromConfigDB
{
- my $self = shift;
-
- my $openslxDB = instantiateClass("OpenSLX::ConfigDB");
- $openslxDB->connect();
-
- my $vendorOSName = $self->{'vendor-os-name'};
- my $vendorOS = $openslxDB->fetchVendorOSByFilter({'name' => $vendorOSName});
- if (!defined $vendorOS) {
- vlog(
- 0,
- _tr(
- "Vendor-OS '%s' didn't exist in OpenSLX-database.\n",
- $vendorOSName
- )
- );
- }
- else {
- # remove all exports (and systems) using this vendor-OS and then
- # remove the vendor-OS itself:
- my @exports = $openslxDB->fetchExportByFilter(
- {'vendor_os_id' => $vendorOS->{id}});
- foreach my $export (@exports) {
- my $osExportEngine = instantiateClass("OpenSLX::OSExport::Engine");
- $osExportEngine->initializeFromExisting($export->{name});
- vlog(
- 0,
- _tr(
- "purging export '%s', since it belongs to the vendor-OS being deleted...",
- $export->{name}
- )
- );
- $osExportEngine->purgeExport();
- }
-
- $openslxDB->removeVendorOS($vendorOS->{id});
- vlog(
- 0,
- _tr("Vendor-OS '%s' has been removed from DB!\n", $vendorOSName)
- );
- }
-
- $openslxDB->disconnect();
- return;
+ my $self = shift;
+
+ my $openslxDB = instantiateClass("OpenSLX::ConfigDB");
+ $openslxDB->connect();
+
+ my $vendorOSName = $self->{'vendor-os-name'};
+ my $vendorOS = $openslxDB->fetchVendorOSByFilter({'name' => $vendorOSName});
+ if (!defined $vendorOS) {
+ vlog(
+ 0,
+ _tr(
+ "Vendor-OS '%s' didn't exist in OpenSLX-database.\n",
+ $vendorOSName
+ )
+ );
+ }
+ else {
+ # remove all exports (and systems) using this vendor-OS and then
+ # remove the vendor-OS itself:
+ my @exports = $openslxDB->fetchExportByFilter(
+ {'vendor_os_id' => $vendorOS->{id}});
+ foreach my $export (@exports) {
+ my $osExportEngine = instantiateClass("OpenSLX::OSExport::Engine");
+ $osExportEngine->initializeFromExisting($export->{name});
+ vlog(
+ 0,
+ _tr(
+ "purging export '%s', since it belongs to the vendor-OS being deleted...",
+ $export->{name}
+ )
+ );
+ $osExportEngine->purgeExport();
+ }
+
+ $openslxDB->removeVendorOS($vendorOS->{id});
+ vlog(
+ 0,
+ _tr("Vendor-OS '%s' has been removed from DB!\n", $vendorOSName)
+ );
+ }
+
+ $openslxDB->disconnect();
+ return;
}
sub pickKernelFile
{
- my $self = shift;
+ my $self = shift;
- return $self->{distro}->pickKernelFile(@_);
+ return $self->{distro}->pickKernelFile(@_);
}
sub distroName
{
- my $self = shift;
+ my $self = shift;
- return $self->{'distro-name'};
+ return $self->{'distro-name'};
}
sub metaPackager
{
- my $self = shift;
+ my $self = shift;
- return $self->{'meta-packager'};
+ return $self->{'meta-packager'};
}
sub getInstallablePackagesForSelection
{
- my $self = shift;
- my $selKey = shift;
+ my $self = shift;
+ my $selKey = shift;
- return if !$selKey;
+ return if !$selKey;
- my $selection = $self->{'distro-info'}->{selection}->{$selKey};
- return if !$selection;
-
- my @pkgs = split m{\s+}, $selection->{packages};
- my %installedPkgs;
- @installedPkgs{ $self->{'packager'}->getInstalledPackages() } = ();
- @pkgs = grep { !exists $installedPkgs{$_} } @pkgs;
+ my $selection = $self->{'distro-info'}->{selection}->{$selKey};
+ return if !$selection;
+
+ my @pkgs = split m{\s+}, $selection->{packages};
+ my %installedPkgs;
+ @installedPkgs{ $self->{'packager'}->getInstalledPackages() } = ();
+ @pkgs = grep { !exists $installedPkgs{$_} } @pkgs;
- return join ' ', @pkgs;
+ return join ' ', @pkgs;
}
sub busyboxBinary
{
- my $self = shift;
+ my $self = shift;
- return $self->{'busybox-binary'};
+ return $self->{'busybox-binary'};
}
################################################################################
@@ -719,1080 +719,1080 @@ sub busyboxBinary
################################################################################
sub _readDistroInfo
{
- my $self = shift;
-
- vlog(1, "reading configuration info for $self->{'vendor-os-name'}...");
-
- $self->{'distro-info'} = {
- 'package-subdir' => '',
- 'prereq-packages' => '',
- 'bootstrap-packages' => '',
- 'metapackager' => {},
- 'repository' => {},
- 'selection' => {},
- 'excludes' => {},
- };
-
- # merge user-provided configuration with distro defaults
- foreach my $file (
- "$self->{'shared-distro-info-dir'}/settings.default",
- "$self->{'config-distro-info-dir'}/settings"
- ) {
- if (-e $file) {
- vlog(2, "reading configuration file $file...");
- my $configObject = Config::General->new(
- -AllowMultiOptions => 0,
- -AutoTrue => 1,
- -ConfigFile => $file,
- -LowerCaseNames => 1,
- -SplitPolicy => 'equalsign',
- );
- my %config = $configObject->getall();
- mergeHash($self->{'distro-info'}, \%config);
- }
- }
-
- # fetch mirrors for all repositories:
- foreach my $repoKey (keys %{$self->{'distro-info'}->{repository}}) {
- my $repo = $self->{'distro-info'}->{repository}->{$repoKey};
- $repo->{key} = $repoKey;
- # if there is local URL, only that is used, otherwise we fetch the
- # configured mirrors:
- if (!$repo->{'local-url'}) {
- $repo->{urls} = $self->_fetchConfiguredMirrorsForRepository($repo);
- }
- }
-
- # expand all selections:
- my $seen = {};
- foreach my $selKey (keys %{$self->{'distro-info'}->{selection}}) {
- $self->_expandSelection($selKey, $seen);
- }
-
- # dump distro-info, if asked for:
- if ($openslxConfig{'verbose-level'} >= 2) {
- my $repository = $self->{'distro-info'}->{repository};
- foreach my $r (sort keys %$repository) {
- vlog(2, "repository '$r':");
- foreach my $k (sort keys %{$repository->{$r}}) {
- vlog(3, "\t$k = '$repository->{$r}->{$k}'");
- }
- }
- my $selection = $self->{'distro-info'}->{selection};
- foreach my $s (sort keys %$selection) {
- vlog(2, "selection '$s':");
- foreach my $k (sort keys %{$selection->{$s}}) {
- vlog(3, "\t$k = '$selection->{$s}->{$k}'");
- }
- }
- my $excludes = $self->{'distro-info'}->{excludes};
- foreach my $e (sort keys %$excludes) {
- vlog(2, "excludes for '$e':");
- foreach my $k (sort keys %{$excludes->{$e}}) {
- vlog(3, "\t$k = '$excludes->{$e}->{$k}'");
- }
- }
- }
- return;
+ my $self = shift;
+
+ vlog(1, "reading configuration info for $self->{'vendor-os-name'}...");
+
+ $self->{'distro-info'} = {
+ 'package-subdir' => '',
+ 'prereq-packages' => '',
+ 'bootstrap-packages' => '',
+ 'metapackager' => {},
+ 'repository' => {},
+ 'selection' => {},
+ 'excludes' => {},
+ };
+
+ # merge user-provided configuration with distro defaults
+ foreach my $file (
+ "$self->{'shared-distro-info-dir'}/settings.default",
+ "$self->{'config-distro-info-dir'}/settings"
+ ) {
+ if (-e $file) {
+ vlog(2, "reading configuration file $file...");
+ my $configObject = Config::General->new(
+ -AllowMultiOptions => 0,
+ -AutoTrue => 1,
+ -ConfigFile => $file,
+ -LowerCaseNames => 1,
+ -SplitPolicy => 'equalsign',
+ );
+ my %config = $configObject->getall();
+ mergeHash($self->{'distro-info'}, \%config);
+ }
+ }
+
+ # fetch mirrors for all repositories:
+ foreach my $repoKey (keys %{$self->{'distro-info'}->{repository}}) {
+ my $repo = $self->{'distro-info'}->{repository}->{$repoKey};
+ $repo->{key} = $repoKey;
+ # if there is local URL, only that is used, otherwise we fetch the
+ # configured mirrors:
+ if (!$repo->{'local-url'}) {
+ $repo->{urls} = $self->_fetchConfiguredMirrorsForRepository($repo);
+ }
+ }
+
+ # expand all selections:
+ my $seen = {};
+ foreach my $selKey (keys %{$self->{'distro-info'}->{selection}}) {
+ $self->_expandSelection($selKey, $seen);
+ }
+
+ # dump distro-info, if asked for:
+ if ($openslxConfig{'verbose-level'} >= 2) {
+ my $repository = $self->{'distro-info'}->{repository};
+ foreach my $r (sort keys %$repository) {
+ vlog(2, "repository '$r':");
+ foreach my $k (sort keys %{$repository->{$r}}) {
+ vlog(3, "\t$k = '$repository->{$r}->{$k}'");
+ }
+ }
+ my $selection = $self->{'distro-info'}->{selection};
+ foreach my $s (sort keys %$selection) {
+ vlog(2, "selection '$s':");
+ foreach my $k (sort keys %{$selection->{$s}}) {
+ vlog(3, "\t$k = '$selection->{$s}->{$k}'");
+ }
+ }
+ my $excludes = $self->{'distro-info'}->{excludes};
+ foreach my $e (sort keys %$excludes) {
+ vlog(2, "excludes for '$e':");
+ foreach my $k (sort keys %{$excludes->{$e}}) {
+ vlog(3, "\t$k = '$excludes->{$e}->{$k}'");
+ }
+ }
+ }
+ return;
}
sub _fetchConfiguredMirrorsForRepository
{
- my $self = shift;
- my $repoInfo = shift;
-
- my $configuredMirrorsFile
- = "$self->{'config-distro-info-dir'}/mirrors/$repoInfo->{key}";
- if (!-e $configuredMirrorsFile) {
- vlog(0,
- _tr(
- "repo '%s' has no configured mirrors, let's pick some ...",
- $repoInfo->{name}
- )
- );
- $self->_configureBestMirrorsForRepository($repoInfo);
- }
- vlog(2, "reading configured mirrors file '$configuredMirrorsFile'.");
- my $configObject = Config::General->new(
- -AllowMultiOptions => 0,
- -AutoTrue => 1,
- -ConfigFile => $configuredMirrorsFile,
- -LowerCaseNames => 1,
- -SplitPolicy => 'equalsign',
- );
- my %config = $configObject->getall();
-
- return $config{urls};
+ my $self = shift;
+ my $repoInfo = shift;
+
+ my $configuredMirrorsFile
+ = "$self->{'config-distro-info-dir'}/mirrors/$repoInfo->{key}";
+ if (!-e $configuredMirrorsFile) {
+ vlog(0,
+ _tr(
+ "repo '%s' has no configured mirrors, let's pick some ...",
+ $repoInfo->{name}
+ )
+ );
+ $self->_configureBestMirrorsForRepository($repoInfo);
+ }
+ vlog(2, "reading configured mirrors file '$configuredMirrorsFile'.");
+ my $configObject = Config::General->new(
+ -AllowMultiOptions => 0,
+ -AutoTrue => 1,
+ -ConfigFile => $configuredMirrorsFile,
+ -LowerCaseNames => 1,
+ -SplitPolicy => 'equalsign',
+ );
+ my %config = $configObject->getall();
+
+ return $config{urls};
}
sub _configureBestMirrorsForRepository
{
- my $self = shift;
- my $repoInfo = shift;
-
- my $configuredMirrorsFile
- = "$self->{'config-distro-info-dir'}/mirrors/$repoInfo->{key}";
-
- if (!-e "$self->{'config-distro-info-dir'}/mirrors") {
- mkdir "$self->{'config-distro-info-dir'}/mirrors";
- }
-
- my $allMirrorsFile
- = "$self->{'shared-distro-info-dir'}/mirrors/$repoInfo->{key}";
- my @allMirrors = string2Array(scalar slurpFile($allMirrorsFile));
-
- my $mirrorsToTryCount = $openslxConfig{'mirrors-to-try-count'} || 20;
- my $mirrorsToUseCount = $openslxConfig{'mirrors-to-use-count'} || 5;
- vlog(1,
- _tr(
- "selecting the '%s' best mirrors (from a set of '%s') for repo '%s' ...",
- $mirrorsToUseCount, $mirrorsToTryCount, $repoInfo->{key}
- )
- );
-
- # determine own top-level domain:
- my $topLevelDomain;
- if (defined $openslxConfig{'mirrors-preferred-top-level-domain'}) {
- $topLevelDomain
- = lc($openslxConfig{'mirrors-preferred-top-level-domain'});
- }
- else {
- my $FQDN = getFQDN();
- $FQDN =~ m{\.(\w+)$};
- $topLevelDomain = lc($1);
- }
-
- # select up to $mirrorsToTryCount "close" mirrors from the array ...
- my @tryMirrors
- = grep {
- my $uri = URI->new($_);
- my $host = $uri->host();
- $host =~ m{\.(\w+)$} && lc($1) eq $topLevelDomain;
- }
- @allMirrors;
-
- my $tryList = join("\n\t", @tryMirrors);
- vlog(1,
- _tr(
- "mirrors matching the preferred top level domain ('%s'):\n\t%s\n",
- $topLevelDomain, $tryList
- )
- );
-
- if (@tryMirrors > $mirrorsToTryCount) {
- # shrink array to $mirrorsToTryCount elements
- vlog(1, _tr("shrinking list to %s mirrors\n", $mirrorsToTryCount));
- $#tryMirrors = $mirrorsToTryCount;
- }
- elsif (@tryMirrors < $mirrorsToTryCount) {
- # we need more mirrors, try adding some others randomly:
- vlog(1,
- _tr(
- "filling list with %s more random mirrors:\n",
- $mirrorsToTryCount - @tryMirrors
- )
- );
-
- # fill @untriedMirrors with the mirrors not already contained
- # in @tryMirrors ...
- my @untriedMirrors
- = grep {
- my $mirror = $_;
- !grep { $mirror eq $_ } @tryMirrors;
- } @allMirrors;
-
- # ... and pick randomly until we have reached the limit or there are
- # no more unused mirrors left
- foreach my $count (@tryMirrors..$mirrorsToTryCount-1) {
- last if !@untriedMirrors;
- my $index = int(rand(scalar @untriedMirrors));
- my $randomMirror = splice(@untriedMirrors, $index, 1);
- push @tryMirrors, $randomMirror;
- vlog(1, "\t$randomMirror\n");
- }
- }
-
- # just make sure we are not going to try/use more mirros than we have
- # available
- if ($mirrorsToTryCount > @tryMirrors) {
- $mirrorsToTryCount = @tryMirrors;
- }
- if ($mirrorsToUseCount > $mirrorsToTryCount) {
- $mirrorsToUseCount = $mirrorsToTryCount;
- }
-
- # ... fetch a file from all of these mirrors and measure the time taken ...
- vlog(0,
- _tr(
- "testing %s mirrors to determine the fastest %s ...\n",
- $mirrorsToTryCount, $mirrorsToUseCount
- )
- );
- my %mirrorSpeed;
- my $veryGoodSpeedCount = 0;
- foreach my $mirror (@tryMirrors) {
- if ($veryGoodSpeedCount >= $mirrorsToUseCount) {
- # we already have enough mirrors with very good speed,
- # it makes no sense to test any others. We simply set the
- # time of the remaining mirrors to some large value, so they
- # won't get picked:
- $mirrorSpeed{$mirror} = 10000;
- next;
- }
-
- # test the current mirror and record the result
- my $time = $self->_speedTestMirror(
- $mirror, $repoInfo->{'file-for-speedtest'}
- );
- $mirrorSpeed{$mirror} = $time;
- if ($time <= 1) {
- $veryGoodSpeedCount++;
- }
- }
-
- # ... now select the best (fastest) $mirrorsToUseCount mirrors ...
- my @bestMirrors
- = (
- sort {
- $mirrorSpeed{$a} <=> $mirrorSpeed{$b};
- }
- @tryMirrors
- )[0..$mirrorsToUseCount-1];
-
- vlog(0,
- _tr(
- "picked these '%s' mirrors for repo '%s':\n\t%s\n",
- $mirrorsToUseCount, $repoInfo->{name}, join("\n\t", @bestMirrors)
- )
- );
-
- # ... and write them into the configuration file:
- my $configObject = Config::General->new(
- -AllowMultiOptions => 0,
- -AutoTrue => 1,
- -LowerCaseNames => 1,
- -SplitPolicy => 'equalsign',
- );
- $configObject->save_file($configuredMirrorsFile, {
- 'urls' => join("\n", @bestMirrors),
- });
- return;
+ my $self = shift;
+ my $repoInfo = shift;
+
+ my $configuredMirrorsFile
+ = "$self->{'config-distro-info-dir'}/mirrors/$repoInfo->{key}";
+
+ if (!-e "$self->{'config-distro-info-dir'}/mirrors") {
+ mkdir "$self->{'config-distro-info-dir'}/mirrors";
+ }
+
+ my $allMirrorsFile
+ = "$self->{'shared-distro-info-dir'}/mirrors/$repoInfo->{key}";
+ my @allMirrors = string2Array(scalar slurpFile($allMirrorsFile));
+
+ my $mirrorsToTryCount = $openslxConfig{'mirrors-to-try-count'} || 20;
+ my $mirrorsToUseCount = $openslxConfig{'mirrors-to-use-count'} || 5;
+ vlog(1,
+ _tr(
+ "selecting the '%s' best mirrors (from a set of '%s') for repo '%s' ...",
+ $mirrorsToUseCount, $mirrorsToTryCount, $repoInfo->{key}
+ )
+ );
+
+ # determine own top-level domain:
+ my $topLevelDomain;
+ if (defined $openslxConfig{'mirrors-preferred-top-level-domain'}) {
+ $topLevelDomain
+ = lc($openslxConfig{'mirrors-preferred-top-level-domain'});
+ }
+ else {
+ my $FQDN = getFQDN();
+ $FQDN =~ m{\.(\w+)$};
+ $topLevelDomain = lc($1);
+ }
+
+ # select up to $mirrorsToTryCount "close" mirrors from the array ...
+ my @tryMirrors
+ = grep {
+ my $uri = URI->new($_);
+ my $host = $uri->host();
+ $host =~ m{\.(\w+)$} && lc($1) eq $topLevelDomain;
+ }
+ @allMirrors;
+
+ my $tryList = join("\n\t", @tryMirrors);
+ vlog(1,
+ _tr(
+ "mirrors matching the preferred top level domain ('%s'):\n\t%s\n",
+ $topLevelDomain, $tryList
+ )
+ );
+
+ if (@tryMirrors > $mirrorsToTryCount) {
+ # shrink array to $mirrorsToTryCount elements
+ vlog(1, _tr("shrinking list to %s mirrors\n", $mirrorsToTryCount));
+ $#tryMirrors = $mirrorsToTryCount;
+ }
+ elsif (@tryMirrors < $mirrorsToTryCount) {
+ # we need more mirrors, try adding some others randomly:
+ vlog(1,
+ _tr(
+ "filling list with %s more random mirrors:\n",
+ $mirrorsToTryCount - @tryMirrors
+ )
+ );
+
+ # fill @untriedMirrors with the mirrors not already contained
+ # in @tryMirrors ...
+ my @untriedMirrors
+ = grep {
+ my $mirror = $_;
+ !grep { $mirror eq $_ } @tryMirrors;
+ } @allMirrors;
+
+ # ... and pick randomly until we have reached the limit or there are
+ # no more unused mirrors left
+ foreach my $count (@tryMirrors..$mirrorsToTryCount-1) {
+ last if !@untriedMirrors;
+ my $index = int(rand(scalar @untriedMirrors));
+ my $randomMirror = splice(@untriedMirrors, $index, 1);
+ push @tryMirrors, $randomMirror;
+ vlog(1, "\t$randomMirror\n");
+ }
+ }
+
+ # just make sure we are not going to try/use more mirros than we have
+ # available
+ if ($mirrorsToTryCount > @tryMirrors) {
+ $mirrorsToTryCount = @tryMirrors;
+ }
+ if ($mirrorsToUseCount > $mirrorsToTryCount) {
+ $mirrorsToUseCount = $mirrorsToTryCount;
+ }
+
+ # ... fetch a file from all of these mirrors and measure the time taken ...
+ vlog(0,
+ _tr(
+ "testing %s mirrors to determine the fastest %s ...\n",
+ $mirrorsToTryCount, $mirrorsToUseCount
+ )
+ );
+ my %mirrorSpeed;
+ my $veryGoodSpeedCount = 0;
+ foreach my $mirror (@tryMirrors) {
+ if ($veryGoodSpeedCount >= $mirrorsToUseCount) {
+ # we already have enough mirrors with very good speed,
+ # it makes no sense to test any others. We simply set the
+ # time of the remaining mirrors to some large value, so they
+ # won't get picked:
+ $mirrorSpeed{$mirror} = 10000;
+ next;
+ }
+
+ # test the current mirror and record the result
+ my $time = $self->_speedTestMirror(
+ $mirror, $repoInfo->{'file-for-speedtest'}
+ );
+ $mirrorSpeed{$mirror} = $time;
+ if ($time <= 1) {
+ $veryGoodSpeedCount++;
+ }
+ }
+
+ # ... now select the best (fastest) $mirrorsToUseCount mirrors ...
+ my @bestMirrors
+ = (
+ sort {
+ $mirrorSpeed{$a} <=> $mirrorSpeed{$b};
+ }
+ @tryMirrors
+ )[0..$mirrorsToUseCount-1];
+
+ vlog(0,
+ _tr(
+ "picked these '%s' mirrors for repo '%s':\n\t%s\n",
+ $mirrorsToUseCount, $repoInfo->{name}, join("\n\t", @bestMirrors)
+ )
+ );
+
+ # ... and write them into the configuration file:
+ my $configObject = Config::General->new(
+ -AllowMultiOptions => 0,
+ -AutoTrue => 1,
+ -LowerCaseNames => 1,
+ -SplitPolicy => 'equalsign',
+ );
+ $configObject->save_file($configuredMirrorsFile, {
+ 'urls' => join("\n", @bestMirrors),
+ });
+ return;
}
sub _speedTestMirror
{
- my $self = shift;
- my $mirror = shift;
- my $file = shift;
-
- vlog(0, _tr("\ttesting mirror '%s' ...\n", $mirror));
-
- # do an explicit DNS-lookup as we do not want to include the time that takes
- # in the speedtest
- my $uri = URI->new($mirror);
- my $hostName = $uri->host();
- if (!gethostbyname($hostName)) {
- # unable to resolve host, we pretend it took really long
- return 10000;
- }
-
- # now measure the time it takes to download the file
- my $wgetCmd
- = "$self->{'busybox-binary'} wget -q -O - $mirror/$file >/dev/null";
- my $start = time();
- if (slxsystem($wgetCmd)) {
- # just return any large number that is unlikely to be selected
- return 10000;
- }
- my $time = time() - $start;
- vlog(0, "\tfetched '$file' in $time seconds\n");
- return $time;
+ my $self = shift;
+ my $mirror = shift;
+ my $file = shift;
+
+ vlog(0, _tr("\ttesting mirror '%s' ...\n", $mirror));
+
+ # do an explicit DNS-lookup as we do not want to include the time that takes
+ # in the speedtest
+ my $uri = URI->new($mirror);
+ my $hostName = $uri->host();
+ if (!gethostbyname($hostName)) {
+ # unable to resolve host, we pretend it took really long
+ return 10000;
+ }
+
+ # now measure the time it takes to download the file
+ my $wgetCmd
+ = "$self->{'busybox-binary'} wget -q -O - $mirror/$file >/dev/null";
+ my $start = time();
+ if (slxsystem($wgetCmd)) {
+ # just return any large number that is unlikely to be selected
+ return 10000;
+ }
+ my $time = time() - $start;
+ vlog(0, "\tfetched '$file' in $time seconds\n");
+ return $time;
}
-
+
sub _expandSelection
{
- my $self = shift;
- my $selKey = shift;
- my $seen = shift;
-
- return if $seen->{$selKey};
- $seen->{$selKey} = 1;
-
- return if !exists $self->{'distro-info'}->{selection}->{$selKey};
- my $selection = $self->{'distro-info'}->{selection}->{$selKey};
-
- if ($selection->{base}) {
- # add all packages from base selection(s) to the current one:
- my $basePackages = '';
- for my $base (split ',', $selection->{base}) {
- my $baseSelection = $self->{'distro-info'}->{selection}->{$base}
- or die _tr(
- 'base-selection "%s" is unknown (referenced in "%s")!',
- $base, $selKey
- );
- $self->_expandSelection($base, $seen);
- $basePackages .= $baseSelection->{packages} || '';
- }
- my $packages = $selection->{packages} || '';
- $selection->{packages} = $basePackages . "\n" . $packages;
- }
- return;
+ my $self = shift;
+ my $selKey = shift;
+ my $seen = shift;
+
+ return if $seen->{$selKey};
+ $seen->{$selKey} = 1;
+
+ return if !exists $self->{'distro-info'}->{selection}->{$selKey};
+ my $selection = $self->{'distro-info'}->{selection}->{$selKey};
+
+ if ($selection->{base}) {
+ # add all packages from base selection(s) to the current one:
+ my $basePackages = '';
+ for my $base (split ',', $selection->{base}) {
+ my $baseSelection = $self->{'distro-info'}->{selection}->{$base}
+ or die _tr(
+ 'base-selection "%s" is unknown (referenced in "%s")!',
+ $base, $selKey
+ );
+ $self->_expandSelection($base, $seen);
+ $basePackages .= $baseSelection->{packages} || '';
+ }
+ my $packages = $selection->{packages} || '';
+ $selection->{packages} = $basePackages . "\n" . $packages;
+ }
+ return;
}
sub _applyVendorOSSettings
{
- my $self = shift;
- my $vendorOSSettings = shift;
-
- if (exists $vendorOSSettings->{'root-password'}) {
- # hashes password according to requirements of current distro and
- # writes it to /etc/shadow
- $self->{distro}->setPasswordForUser(
- 'root', $vendorOSSettings->{'root-password'}
- );
- }
-
- return;
+ my $self = shift;
+ my $vendorOSSettings = shift;
+
+ if (exists $vendorOSSettings->{'root-password'}) {
+ # hashes password according to requirements of current distro and
+ # writes it to /etc/shadow
+ $self->{distro}->setPasswordForUser(
+ 'root', $vendorOSSettings->{'root-password'}
+ );
+ }
+
+ return;
}
sub _createVendorOSPath
{
- my $self = shift;
+ my $self = shift;
- if (slxsystem("mkdir -p $self->{'vendor-os-path'}")) {
- die _tr("unable to create directory '%s', giving up! (%s)\n",
- $self->{'vendor-os-path'}, $!);
- }
- return;
+ if (slxsystem("mkdir -p $self->{'vendor-os-path'}")) {
+ die _tr("unable to create directory '%s', giving up! (%s)\n",
+ $self->{'vendor-os-path'}, $!);
+ }
+ return;
}
sub _touchVendorOS
{
- my $self = shift;
+ my $self = shift;
- # touch root folder, as we are using this folder to determine the
- # 'age' of the vendor-OS when trying to determine whether or not we
- # need to re-export this vendor-OS:
- slxsystem("touch $self->{'vendor-os-path'}");
- return;
+ # touch root folder, as we are using this folder to determine the
+ # 'age' of the vendor-OS when trying to determine whether or not we
+ # need to re-export this vendor-OS:
+ slxsystem("touch $self->{'vendor-os-path'}");
+ return;
}
sub _createPackager
{
- my $self = shift;
-
- my $packagerClass
- = "OpenSLX::OSSetup::Packager::$self->{distro}->{'packager-type'}";
- my $packager = instantiateClass($packagerClass);
- $packager->initialize($self);
- $self->{'packager'} = $packager;
- return;
+ my $self = shift;
+
+ my $packagerClass
+ = "OpenSLX::OSSetup::Packager::$self->{distro}->{'packager-type'}";
+ my $packager = instantiateClass($packagerClass);
+ $packager->initialize($self);
+ $self->{'packager'} = $packager;
+ return;
}
sub _createMetaPackager
{
- my $self = shift;
-
- my $metaPackagerType = $self->{distro}->{'meta-packager-type'};
-
- my $installInfoFile = "$self->{'vendor-os-path'}/.openslx-install-info";
- if (-e $installInfoFile) {
- # activate the meta-packager that was used when installing the os:
- my $installInfo = slurpFile($installInfoFile);
- if ($installInfo =~ m[SLX_META_PACKAGER=(\w+)]) {
- $metaPackagerType = $1;
- }
- }
-
- my $metaPackagerClass = "OpenSLX::OSSetup::MetaPackager::$metaPackagerType";
- my $metaPackager = instantiateClass($metaPackagerClass);
- $metaPackager->initialize($self);
- $self->{'meta-packager'} = $metaPackager;
- return;
+ my $self = shift;
+
+ my $metaPackagerType = $self->{distro}->{'meta-packager-type'};
+
+ my $installInfoFile = "$self->{'vendor-os-path'}/.openslx-install-info";
+ if (-e $installInfoFile) {
+ # activate the meta-packager that was used when installing the os:
+ my $installInfo = slurpFile($installInfoFile);
+ if ($installInfo =~ m[SLX_META_PACKAGER=(\w+)]) {
+ $metaPackagerType = $1;
+ }
+ }
+
+ my $metaPackagerClass = "OpenSLX::OSSetup::MetaPackager::$metaPackagerType";
+ my $metaPackager = instantiateClass($metaPackagerClass);
+ $metaPackager->initialize($self);
+ $self->{'meta-packager'} = $metaPackager;
+ return;
}
sub _sortRepositoryURLs
{
- my $self = shift;
- my $repoInfo = shift;
-
- my @URLs
- = defined $repoInfo->{'local-url'}
- ? $repoInfo->{'local-url'}
- : string2Array($repoInfo->{urls});
- if (!@URLs) {
- die(
- _tr(
- "repository '%s' has no URLs defined, unable to fetch anything!",
- $repoInfo->{name},
- )
- );
- }
-
- return \@URLs;
+ my $self = shift;
+ my $repoInfo = shift;
+
+ my @URLs
+ = defined $repoInfo->{'local-url'}
+ ? $repoInfo->{'local-url'}
+ : string2Array($repoInfo->{urls});
+ if (!@URLs) {
+ die(
+ _tr(
+ "repository '%s' has no URLs defined, unable to fetch anything!",
+ $repoInfo->{name},
+ )
+ );
+ }
+
+ return \@URLs;
}
sub _downloadBaseFiles
{
- my $self = shift;
- my $files = shift;
-
- my $pkgSubdir = $self->{'distro-info'}->{'package-subdir'};
- my @URLs = @{$self->{'baseURLs'}};
- my $maxTryCount = $openslxConfig{'ossetup-max-try-count'};
-
- my @foundFiles;
- foreach my $fileVariantStr (@$files) {
- my $tryCount = 0;
- next unless $fileVariantStr =~ m[\S];
- my $foundFile;
+ my $self = shift;
+ my $files = shift;
+
+ my $pkgSubdir = $self->{'distro-info'}->{'package-subdir'};
+ my @URLs = @{$self->{'baseURLs'}};
+ my $maxTryCount = $openslxConfig{'ossetup-max-try-count'};
+
+ my @foundFiles;
+ foreach my $fileVariantStr (@$files) {
+ my $tryCount = 0;
+ next unless $fileVariantStr =~ m[\S];
+ my $foundFile;
try_next_url:
- my $url = $URLs[$self->{'baseURL-index'}];
- $url .= "/$pkgSubdir" if length($pkgSubdir);
-
- foreach my $file (split '\s+', $fileVariantStr) {
- my $basefile = basename($file);
- vlog(2, "fetching <$file>...");
- if (slxsystem("wget", "-c", "-O", "$basefile", "$url/$file") == 0) {
- $foundFile = $basefile;
- last;
- }
- elsif (-e $basefile) {
- vlog(0, "removing left-over '$basefile' and trying again...");
- unlink $basefile;
- redo;
- }
- }
- if (!defined $foundFile) {
- if ($tryCount < $maxTryCount) {
- $tryCount++;
- $self->{'baseURL-index'}
- = ($self->{'baseURL-index'} + 1) % scalar(@URLs);
- vlog(
- 0,
- _tr(
- "switching to mirror '%s'.",
- $URLs[$self->{'baseURL-index'}]
- )
- );
- goto try_next_url;
- }
- die _tr("unable to fetch '%s' from any source!\n", $fileVariantStr);
- }
- push @foundFiles, $foundFile;
- }
- return @foundFiles;
+ my $url = $URLs[$self->{'baseURL-index'}];
+ $url .= "/$pkgSubdir" if length($pkgSubdir);
+
+ foreach my $file (split '\s+', $fileVariantStr) {
+ my $basefile = basename($file);
+ vlog(2, "fetching <$file>...");
+ if (slxsystem("wget", "-c", "-O", "$basefile", "$url/$file") == 0) {
+ $foundFile = $basefile;
+ last;
+ }
+ elsif (-e $basefile) {
+ vlog(0, "removing left-over '$basefile' and trying again...");
+ unlink $basefile;
+ redo;
+ }
+ }
+ if (!defined $foundFile) {
+ if ($tryCount < $maxTryCount) {
+ $tryCount++;
+ $self->{'baseURL-index'}
+ = ($self->{'baseURL-index'} + 1) % scalar(@URLs);
+ vlog(
+ 0,
+ _tr(
+ "switching to mirror '%s'.",
+ $URLs[$self->{'baseURL-index'}]
+ )
+ );
+ goto try_next_url;
+ }
+ die _tr("unable to fetch '%s' from any source!\n", $fileVariantStr);
+ }
+ push @foundFiles, $foundFile;
+ }
+ return @foundFiles;
}
sub _startLocalURLServersAsNeeded
{
- my $self = shift;
-
- $localHttpServerMasterPID ||= $$;
-
- my $port = 5080;
- my %portForURL;
- foreach my $repoInfo (values %{$self->{'distro-info'}->{repository}}) {
- my $localURL = $repoInfo->{'local-url'} || '';
- next if !$localURL;
- next if $localURL =~ m[^\w+:]; # anything with a protcol-spec is non-local
- if (!exists $localHttpServers{$localURL}) {
- my $pid
- = executeInSubprocess(
- $self->{'busybox-binary'}, "httpd", '-p', $port, '-h', '/', '-f'
- );
- vlog(1,
- _tr(
- "started local HTTP-server for URL '%s' on port '%s'.",
- $localURL, $port
- )
- );
- $repoInfo->{'local-url'} = "http://localhost:$port$localURL";
- $localHttpServers{$localURL}->{pid} = $pid;
- $localHttpServers{$localURL}->{url} = $repoInfo->{'local-url'};
- $port++;
- }
- else {
- $repoInfo->{'local-url'} = $localHttpServers{$localURL}->{url};
- }
- }
- return;
+ my $self = shift;
+
+ $localHttpServerMasterPID ||= $$;
+
+ my $port = 5080;
+ my %portForURL;
+ foreach my $repoInfo (values %{$self->{'distro-info'}->{repository}}) {
+ my $localURL = $repoInfo->{'local-url'} || '';
+ next if !$localURL;
+ next if $localURL =~ m[^\w+:]; # anything with a protcol-spec is non-local
+ if (!exists $localHttpServers{$localURL}) {
+ my $pid
+ = executeInSubprocess(
+ $self->{'busybox-binary'}, "httpd", '-p', $port, '-h', '/', '-f'
+ );
+ vlog(1,
+ _tr(
+ "started local HTTP-server for URL '%s' on port '%s'.",
+ $localURL, $port
+ )
+ );
+ $repoInfo->{'local-url'} = "http://localhost:$port$localURL";
+ $localHttpServers{$localURL}->{pid} = $pid;
+ $localHttpServers{$localURL}->{url} = $repoInfo->{'local-url'};
+ $port++;
+ }
+ else {
+ $repoInfo->{'local-url'} = $localHttpServers{$localURL}->{url};
+ }
+ }
+ return;
}
sub _setupStage1A
{
- my $self = shift;
-
- vlog(1, "setting up stage1a for $self->{'vendor-os-name'}...");
-
- # specify individual paths for the respective substages:
- $self->{stage1aDir} = "$self->{'vendor-os-path'}/stage1a";
- $self->{stage1bSubdir} = 'slxbootstrap';
- $self->{stage1cSubdir} = 'slxfinal';
-
- # we create *all* of the above folders by creating stage1cDir:
- my $stage1cDir
- = "$self->{'stage1aDir'}/$self->{'stage1bSubdir'}/$self->{'stage1cSubdir'}";
- if (slxsystem("mkdir -p $stage1cDir")) {
- die _tr("unable to create directory '%s', giving up! (%s)\n",
- $stage1cDir, $!);
- }
-
- $self->_stage1A_createBusyboxEnvironment();
- $self->_stage1A_copyPrerequiredFiles();
- $self->_stage1A_copyTrustedPackageKeys();
- $self->_stage1A_createRequiredFiles();
- return;
+ my $self = shift;
+
+ vlog(1, "setting up stage1a for $self->{'vendor-os-name'}...");
+
+ # specify individual paths for the respective substages:
+ $self->{stage1aDir} = "$self->{'vendor-os-path'}/stage1a";
+ $self->{stage1bSubdir} = 'slxbootstrap';
+ $self->{stage1cSubdir} = 'slxfinal';
+
+ # we create *all* of the above folders by creating stage1cDir:
+ my $stage1cDir
+ = "$self->{'stage1aDir'}/$self->{'stage1bSubdir'}/$self->{'stage1cSubdir'}";
+ if (slxsystem("mkdir -p $stage1cDir")) {
+ die _tr("unable to create directory '%s', giving up! (%s)\n",
+ $stage1cDir, $!);
+ }
+
+ $self->_stage1A_createBusyboxEnvironment();
+ $self->_stage1A_copyPrerequiredFiles();
+ $self->_stage1A_copyTrustedPackageKeys();
+ $self->_stage1A_createRequiredFiles();
+ return;
}
sub _stage1A_createBusyboxEnvironment
{
- my $self = shift;
-
- # copy busybox and all required binaries into stage1a-dir:
- vlog(1, "creating busybox-environment...");
- my $requiredLibs = copyBinaryWithRequiredLibs({
- 'binary' => $self->{'busybox-binary'},
- 'targetFolder' => "$self->{stage1aDir}/bin",
- 'libTargetFolder' => $self->{stage1aDir},
- 'targetName' => 'busybox',
- });
- my $libcFolder;
- foreach my $lib (split "\n", $requiredLibs) {
- if ($lib =~ m[/libc.so.\d\s*$]) {
- # note target folder of libc, as we need to copy the resolver libs
- # into the same place:
- $libcFolder = dirname($lib);
- }
- }
-
- # create all needed links to busybox:
- my $links
- = slurpFile("$openslxConfig{'base-path'}/share/busybox/busybox.links");
- foreach my $linkTarget (split "\n", $links) {
- linkFile('/bin/busybox', "$self->{stage1aDir}/$linkTarget");
- }
- if ($self->_hostIs64Bit()) {
- if (!-e "$self->{stage1aDir}/lib64") {
- linkFile('/lib', "$self->{stage1aDir}/lib64");
- }
- if (!-e "$self->{stage1aDir}/usr/lib64") {
- linkFile('/usr/lib', "$self->{stage1aDir}/usr/lib64");
- }
- }
-
- $self->_stage1A_setupResolver($libcFolder);
- return;
+ my $self = shift;
+
+ # copy busybox and all required binaries into stage1a-dir:
+ vlog(1, "creating busybox-environment...");
+ my $requiredLibs = copyBinaryWithRequiredLibs({
+ 'binary' => $self->{'busybox-binary'},
+ 'targetFolder' => "$self->{stage1aDir}/bin",
+ 'libTargetFolder' => $self->{stage1aDir},
+ 'targetName' => 'busybox',
+ });
+ my $libcFolder;
+ foreach my $lib (split "\n", $requiredLibs) {
+ if ($lib =~ m[/libc.so.\d\s*$]) {
+ # note target folder of libc, as we need to copy the resolver libs
+ # into the same place:
+ $libcFolder = dirname($lib);
+ }
+ }
+
+ # create all needed links to busybox:
+ my $links
+ = slurpFile("$openslxConfig{'base-path'}/share/busybox/busybox.links");
+ foreach my $linkTarget (split "\n", $links) {
+ linkFile('/bin/busybox', "$self->{stage1aDir}/$linkTarget");
+ }
+ if ($self->_hostIs64Bit()) {
+ if (!-e "$self->{stage1aDir}/lib64") {
+ linkFile('/lib', "$self->{stage1aDir}/lib64");
+ }
+ if (!-e "$self->{stage1aDir}/usr/lib64") {
+ linkFile('/usr/lib', "$self->{stage1aDir}/usr/lib64");
+ }
+ }
+
+ $self->_stage1A_setupResolver($libcFolder);
+ return;
}
sub _stage1A_setupResolver
{
- my $self = shift;
- my $libcFolder = shift;
-
- if (!defined $libcFolder) {
- warn _tr("unable to determine libc-target-folder, will use /lib!");
- $libcFolder = '/lib';
- }
-
- copyFile('/etc/resolv.conf', "$self->{stage1aDir}/etc");
- copyFile('/etc/nsswitch.conf', "$self->{stage1aDir}/etc");
- spitFile("$self->{stage1aDir}/etc/hosts", "127.0.0.1 localhost\n");
- copyFile("$libcFolder/libresolv*", "$self->{stage1aDir}$libcFolder");
- copyFile("$libcFolder/libnss_dns*", "$self->{stage1aDir}$libcFolder");
- copyFile("$libcFolder/libnss_files*", "$self->{stage1aDir}$libcFolder");
-
- my $stage1cDir
- = "$self->{'stage1aDir'}/$self->{'stage1bSubdir'}/$self->{'stage1cSubdir'}";
- copyFile('/etc/resolv.conf', "$stage1cDir/etc");
- return;
+ my $self = shift;
+ my $libcFolder = shift;
+
+ if (!defined $libcFolder) {
+ warn _tr("unable to determine libc-target-folder, will use /lib!");
+ $libcFolder = '/lib';
+ }
+
+ copyFile('/etc/resolv.conf', "$self->{stage1aDir}/etc");
+ copyFile('/etc/nsswitch.conf', "$self->{stage1aDir}/etc");
+ spitFile("$self->{stage1aDir}/etc/hosts", "127.0.0.1 localhost\n");
+ copyFile("$libcFolder/libresolv*", "$self->{stage1aDir}$libcFolder");
+ copyFile("$libcFolder/libnss_dns*", "$self->{stage1aDir}$libcFolder");
+ copyFile("$libcFolder/libnss_files*", "$self->{stage1aDir}$libcFolder");
+
+ my $stage1cDir
+ = "$self->{'stage1aDir'}/$self->{'stage1bSubdir'}/$self->{'stage1cSubdir'}";
+ copyFile('/etc/resolv.conf', "$stage1cDir/etc");
+ return;
}
sub _stage1A_copyPrerequiredFiles
{
- my $self = shift;
-
- return unless -d "$self->{'shared-distro-info-dir'}/prereqfiles";
-
- vlog(2, "copying folder with pre-required files...");
- my $stage1cDir
- = "$self->{'stage1aDir'}/$self->{'stage1bSubdir'}/$self->{'stage1cSubdir'}";
- my $cmd = qq[
- tar -cp -C $self->{'shared-distro-info-dir'}/prereqfiles . \\
- | tar -xp -C $stage1cDir
- ];
- if (slxsystem($cmd)) {
- die _tr(
- "unable to copy folder with pre-required files to folder '%s' (%s)\n",
- $stage1cDir, $!
- );
- }
- $self->{distro}->fixPrerequiredFiles($stage1cDir);
- return;
+ my $self = shift;
+
+ return unless -d "$self->{'shared-distro-info-dir'}/prereqfiles";
+
+ vlog(2, "copying folder with pre-required files...");
+ my $stage1cDir
+ = "$self->{'stage1aDir'}/$self->{'stage1bSubdir'}/$self->{'stage1cSubdir'}";
+ my $cmd = qq[
+ tar -cp -C $self->{'shared-distro-info-dir'}/prereqfiles . \\
+ | tar -xp -C $stage1cDir
+ ];
+ if (slxsystem($cmd)) {
+ die _tr(
+ "unable to copy folder with pre-required files to folder '%s' (%s)\n",
+ $stage1cDir, $!
+ );
+ }
+ $self->{distro}->fixPrerequiredFiles($stage1cDir);
+ return;
}
sub _stage1A_copyTrustedPackageKeys
{
- my $self = shift;
-
- vlog(2, "copying folder with trusted package keys...");
- my $stage1bDir = "$self->{'stage1aDir'}/$self->{'stage1bSubdir'}";
- foreach my $folder (
- $self->{'shared-distro-info-dir'}, $self->{'config-distro-info-dir'}
- ) {
- next unless -d "$folder/trusted-package-keys";
- my $cmd = qq[
- tar -cp -C $folder trusted-package-keys \\
- | tar -xp -C $stage1bDir
- ];
- if (slxsystem($cmd)) {
- die _tr(
- "unable to copy folder with trusted package keys to folder '%s' (%s)\n",
- "$stage1bDir/trusted-package-keys", $!
- );
- }
- slxsystem("chmod 444 $stage1bDir/trusted-package-keys/*");
-
- # install ultimately trusted keys (from distributor):
- my $stage1cDir = "$stage1bDir/$self->{'stage1cSubdir'}";
- my $keyDir = "$self->{'shared-distro-info-dir'}/trusted-package-keys";
- if (-e "$keyDir/pubring.gpg") {
- copyFile("$keyDir/pubring.gpg", "$stage1cDir/usr/lib/rpm/gnupg");
- }
- }
- return;
+ my $self = shift;
+
+ vlog(2, "copying folder with trusted package keys...");
+ my $stage1bDir = "$self->{'stage1aDir'}/$self->{'stage1bSubdir'}";
+ foreach my $folder (
+ $self->{'shared-distro-info-dir'}, $self->{'config-distro-info-dir'}
+ ) {
+ next unless -d "$folder/trusted-package-keys";
+ my $cmd = qq[
+ tar -cp -C $folder trusted-package-keys \\
+ | tar -xp -C $stage1bDir
+ ];
+ if (slxsystem($cmd)) {
+ die _tr(
+ "unable to copy folder with trusted package keys to folder '%s' (%s)\n",
+ "$stage1bDir/trusted-package-keys", $!
+ );
+ }
+ slxsystem("chmod 444 $stage1bDir/trusted-package-keys/*");
+
+ # install ultimately trusted keys (from distributor):
+ my $stage1cDir = "$stage1bDir/$self->{'stage1cSubdir'}";
+ my $keyDir = "$self->{'shared-distro-info-dir'}/trusted-package-keys";
+ if (-e "$keyDir/pubring.gpg") {
+ copyFile("$keyDir/pubring.gpg", "$stage1cDir/usr/lib/rpm/gnupg");
+ }
+ }
+ return;
}
sub _stage1A_createRequiredFiles
{
- my $self = shift;
-
- vlog(2, "creating required files...");
-
- # fake all files required by stage1b (by creating them empty):
- my $stage1bDir = "$self->{'stage1aDir'}/$self->{'stage1bSubdir'}";
- foreach my $fake (@{$self->{distro}->{'stage1b-faked-files'}}) {
- fakeFile("$stage1bDir/$fake");
- }
-
- # fake all files required by stage1c (by creating them empty):
- my $stage1cDir = "$stage1bDir/$self->{'stage1cSubdir'}";
- foreach my $fake (@{$self->{distro}->{'stage1c-faked-files'}}) {
- fakeFile("$stage1cDir/$fake");
- }
-
- mkdir "$stage1cDir/dev";
- if (!-e "$stage1cDir/dev/null"
- && slxsystem("mknod $stage1cDir/dev/null c 1 3"))
- {
- die _tr(
- "unable to create node '%s' (%s)\n", "$stage1cDir/dev/null", $!
- );
- }
- return;
+ my $self = shift;
+
+ vlog(2, "creating required files...");
+
+ # fake all files required by stage1b (by creating them empty):
+ my $stage1bDir = "$self->{'stage1aDir'}/$self->{'stage1bSubdir'}";
+ foreach my $fake (@{$self->{distro}->{'stage1b-faked-files'}}) {
+ fakeFile("$stage1bDir/$fake");
+ }
+
+ # fake all files required by stage1c (by creating them empty):
+ my $stage1cDir = "$stage1bDir/$self->{'stage1cSubdir'}";
+ foreach my $fake (@{$self->{distro}->{'stage1c-faked-files'}}) {
+ fakeFile("$stage1cDir/$fake");
+ }
+
+ mkdir "$stage1cDir/dev";
+ if (!-e "$stage1cDir/dev/null"
+ && slxsystem("mknod $stage1cDir/dev/null c 1 3"))
+ {
+ die _tr(
+ "unable to create node '%s' (%s)\n", "$stage1cDir/dev/null", $!
+ );
+ }
+ return;
}
sub _setupStage1B
{
- my $self = shift;
+ my $self = shift;
- vlog(1, "setting up stage1b for $self->{'vendor-os-name'}...");
- $self->_stage1B_chrootAndBootstrap();
- return;
+ vlog(1, "setting up stage1b for $self->{'vendor-os-name'}...");
+ $self->_stage1B_chrootAndBootstrap();
+ return;
}
sub _stage1B_chrootAndBootstrap
{
- my $self = shift;
-
- # give packager a chance to copy required files into stage1a-folder:
- $self->{packager}->prepareBootstrap($self->{stage1aDir});
-
- $self->_callChrootedFunction({
- chrootDir => $self->{stage1aDir},
- function => sub {
- # chdir into slxbootstrap, as we want to drop packages into there:
- chdir "/$self->{stage1bSubdir}"
- or die _tr(
- "unable to chdir into '%s' (%s)\n",
- "/$self->{stage1bSubdir}", $!
- );
-
- # fetch prerequired packages and use them to bootstrap the packager:
- $self->{'baseURLs'} = $self->_sortRepositoryURLs(
- $self->{'distro-info'}->{repository}->{base}
- );
- $self->{'baseURL-index'} = 0;
- my @pkgs = string2Array($self->{'distro-info'}->{'prereq-packages'});
- vlog(
- 2,
- "downloading these prereq packages:\n\t" . join("\n\t", @pkgs)
- );
- my @prereqPkgs = $self->_downloadBaseFiles(\@pkgs);
- $self->{'prereq-packages'} = \@prereqPkgs;
- $self->{packager}->bootstrap(\@prereqPkgs);
-
- @pkgs = string2Array($self->{'distro-info'}->{'bootstrap-packages'});
- push(
- @pkgs,
- string2Array(
- $self->{'distro-info'}->{'metapackager'}
- ->{$self->{distro}->{'meta-packager-type'}}->{packages}
- )
- );
- vlog(
- 2,
- "downloading bootstrap packages:\n\t" . join("\n\t", @pkgs)
- );
- my @bootstrapPkgs = $self->_downloadBaseFiles(\@pkgs);
- $self->{'bootstrap-packages'} = \@bootstrapPkgs;
- },
- });
- return;
+ my $self = shift;
+
+ # give packager a chance to copy required files into stage1a-folder:
+ $self->{packager}->prepareBootstrap($self->{stage1aDir});
+
+ $self->_callChrootedFunction({
+ chrootDir => $self->{stage1aDir},
+ function => sub {
+ # chdir into slxbootstrap, as we want to drop packages into there:
+ chdir "/$self->{stage1bSubdir}"
+ or die _tr(
+ "unable to chdir into '%s' (%s)\n",
+ "/$self->{stage1bSubdir}", $!
+ );
+
+ # fetch prerequired packages and use them to bootstrap the packager:
+ $self->{'baseURLs'} = $self->_sortRepositoryURLs(
+ $self->{'distro-info'}->{repository}->{base}
+ );
+ $self->{'baseURL-index'} = 0;
+ my @pkgs = string2Array($self->{'distro-info'}->{'prereq-packages'});
+ vlog(
+ 2,
+ "downloading these prereq packages:\n\t" . join("\n\t", @pkgs)
+ );
+ my @prereqPkgs = $self->_downloadBaseFiles(\@pkgs);
+ $self->{'prereq-packages'} = \@prereqPkgs;
+ $self->{packager}->bootstrap(\@prereqPkgs);
+
+ @pkgs = string2Array($self->{'distro-info'}->{'bootstrap-packages'});
+ push(
+ @pkgs,
+ string2Array(
+ $self->{'distro-info'}->{'metapackager'}
+ ->{$self->{distro}->{'meta-packager-type'}}->{packages}
+ )
+ );
+ vlog(
+ 2,
+ "downloading bootstrap packages:\n\t" . join("\n\t", @pkgs)
+ );
+ my @bootstrapPkgs = $self->_downloadBaseFiles(\@pkgs);
+ $self->{'bootstrap-packages'} = \@bootstrapPkgs;
+ },
+ });
+ return;
}
sub _setupStage1C
{
- my $self = shift;
+ my $self = shift;
- vlog(1, "setting up stage1c for $self->{'vendor-os-name'}...");
- $self->_stage1C_chrootAndInstallBasicVendorOS();
- return;
+ vlog(1, "setting up stage1c for $self->{'vendor-os-name'}...");
+ $self->_stage1C_chrootAndInstallBasicVendorOS();
+ return;
}
sub _stage1C_chrootAndInstallBasicVendorOS
{
- my $self = shift;
-
- my $stage1bDir = "/$self->{stage1bSubdir}";
- chrootInto($stage1bDir);
-
- my $stage1cDir = "/$self->{stage1cSubdir}";
-
- # import any additional trusted package keys to rpm-DB:
- my $keyDir = "/trusted-package-keys";
- my $keyDirDH;
- if (opendir($keyDirDH, $keyDir)) {
- my @keyFiles
- = map { "$keyDir/$_" }
- grep { $_ !~ m[^(\.\.?|pubring.gpg)$] }
- readdir($keyDirDH);
- closedir($keyDirDH);
- $self->{packager}->importTrustedPackageKeys(\@keyFiles, $stage1cDir);
- }
-
- # install bootstrap packages
- $self->{packager}->installPackages(
- $self->{'bootstrap-packages'}, $stage1cDir
- );
- return;
+ my $self = shift;
+
+ my $stage1bDir = "/$self->{stage1bSubdir}";
+ chrootInto($stage1bDir);
+
+ my $stage1cDir = "/$self->{stage1cSubdir}";
+
+ # import any additional trusted package keys to rpm-DB:
+ my $keyDir = "/trusted-package-keys";
+ my $keyDirDH;
+ if (opendir($keyDirDH, $keyDir)) {
+ my @keyFiles
+ = map { "$keyDir/$_" }
+ grep { $_ !~ m[^(\.\.?|pubring.gpg)$] }
+ readdir($keyDirDH);
+ closedir($keyDirDH);
+ $self->{packager}->importTrustedPackageKeys(\@keyFiles, $stage1cDir);
+ }
+
+ # install bootstrap packages
+ $self->{packager}->installPackages(
+ $self->{'bootstrap-packages'}, $stage1cDir
+ );
+ return;
}
sub _stage1C_cleanupBasicVendorOS
{
- my $self = shift;
-
- my $stage1cDir
- = "$self->{'stage1aDir'}/$self->{'stage1bSubdir'}/$self->{'stage1cSubdir'}";
- if (slxsystem("mv $stage1cDir/* $self->{'vendor-os-path'}/")) {
- die _tr(
- "unable to move final setup to '%s' (%s)\n",
- $self->{'vendor-os-path'}, $!
- );
- }
- if (slxsystem("rm -rf $self->{stage1aDir}")) {
- die _tr(
- "unable to remove temporary folder '%s' (%s)\n",
- $self->{stage1aDir}, $!
- );
- }
- return;
+ my $self = shift;
+
+ my $stage1cDir
+ = "$self->{'stage1aDir'}/$self->{'stage1bSubdir'}/$self->{'stage1cSubdir'}";
+ if (slxsystem("mv $stage1cDir/* $self->{'vendor-os-path'}/")) {
+ die _tr(
+ "unable to move final setup to '%s' (%s)\n",
+ $self->{'vendor-os-path'}, $!
+ );
+ }
+ if (slxsystem("rm -rf $self->{stage1aDir}")) {
+ die _tr(
+ "unable to remove temporary folder '%s' (%s)\n",
+ $self->{stage1aDir}, $!
+ );
+ }
+ return;
}
sub _setupStage1D
{
- my $self = shift;
-
- vlog(1, "setting up stage1d for $self->{'vendor-os-name'}...");
-
- $self->_callChrootedFunction({
- chrootDir => $self->{'vendor-os-path'},
- function => sub {
- $self->_stage1D_setupPackageSources();
- $self->_stage1D_updateBasicVendorOS();
- $self->{distro}->preSystemInstallationHook();
- $self->_stage1D_installPackageSelection();
- $self->{distro}->postSystemInstallationHook();
- },
- updateConfig => 1,
- });
- return;
+ my $self = shift;
+
+ vlog(1, "setting up stage1d for $self->{'vendor-os-name'}...");
+
+ $self->_callChrootedFunction({
+ chrootDir => $self->{'vendor-os-path'},
+ function => sub {
+ $self->_stage1D_setupPackageSources();
+ $self->_stage1D_updateBasicVendorOS();
+ $self->{distro}->preSystemInstallationHook();
+ $self->_stage1D_installPackageSelection();
+ $self->{distro}->postSystemInstallationHook();
+ },
+ updateConfig => 1,
+ });
+ return;
}
sub _updateStage1D
{
- my $self = shift;
-
- vlog(1, "updating $self->{'vendor-os-name'}...");
-
- $self->_callChrootedFunction({
- chrootDir => $self->{'vendor-os-path'},
- function => sub {
- $self->_stage1D_updateBasicVendorOS();
- },
- updateConfig => 1,
- });
- return;
+ my $self = shift;
+
+ vlog(1, "updating $self->{'vendor-os-name'}...");
+
+ $self->_callChrootedFunction({
+ chrootDir => $self->{'vendor-os-path'},
+ function => sub {
+ $self->_stage1D_updateBasicVendorOS();
+ },
+ updateConfig => 1,
+ });
+ return;
}
sub _startChrootedShellInStage1D
{
- my $self = shift;
-
- vlog(0, "starting chrooted shell for $self->{'vendor-os-name'}");
- vlog(0, "---------------------------------------");
- vlog(0, "- please type 'exit' if you are done! -");
- vlog(0, "---------------------------------------");
-
- $self->_callChrootedFunction({
- chrootDir => $self->{'vendor-os-path'},
- function => sub {
- # will hang until user exits manually:
- slxsystem($openslxConfig{'default-shell'});
- },
- updateConfig => 1,
- });
- return;
+ my $self = shift;
+
+ vlog(0, "starting chrooted shell for $self->{'vendor-os-name'}");
+ vlog(0, "---------------------------------------");
+ vlog(0, "- please type 'exit' if you are done! -");
+ vlog(0, "---------------------------------------");
+
+ $self->_callChrootedFunction({
+ chrootDir => $self->{'vendor-os-path'},
+ function => sub {
+ # will hang until user exits manually:
+ slxsystem($openslxConfig{'default-shell'});
+ },
+ updateConfig => 1,
+ });
+ return;
}
sub _callChrootedFunction
{
- my $self = shift;
- my $params = shift;
-
- checkParams($params, {
- 'chrootDir' => '!',
- 'function' => '!',
- 'updateConfig' => '?',
- });
-
- $self->{'distro'}->startSession($params->{chrootDir});
-
- # invoke given function:
- $params->{function}->();
-
- if ($params->{updateConfig}) {
- $self->{'distro'}->updateDistroConfig();
- }
- $self->{'distro'}->finishSession();
- return;
+ my $self = shift;
+ my $params = shift;
+
+ checkParams($params, {
+ 'chrootDir' => '!',
+ 'function' => '!',
+ 'updateConfig' => '?',
+ });
+
+ $self->{'distro'}->startSession($params->{chrootDir});
+
+ # invoke given function:
+ $params->{function}->();
+
+ if ($params->{updateConfig}) {
+ $self->{'distro'}->updateDistroConfig();
+ }
+ $self->{'distro'}->finishSession();
+ return;
}
sub _stage1D_setupPackageSources
{
- my $self = shift;
-
- vlog(1, "setting up package sources for meta packager...");
- my $selectionName = $self->{'selection-name'};
- my $pkgExcludes
- = $self->{'distro-info'}->{excludes}->{$selectionName}->{packages};
- my $excludeList = join ' ', string2Array($pkgExcludes);
- $self->{'meta-packager'}->initPackageSources();
- my ($rk, $repo);
- while (($rk, $repo) = each %{$self->{'distro-info'}->{repository}}) {
- vlog(2, "setting up package source $rk...");
- $self->{'meta-packager'}->setupPackageSource(
- $rk, $repo, $excludeList, $self->_sortRepositoryURLs($repo)
- );
- }
- return;
+ my $self = shift;
+
+ vlog(1, "setting up package sources for meta packager...");
+ my $selectionName = $self->{'selection-name'};
+ my $pkgExcludes
+ = $self->{'distro-info'}->{excludes}->{$selectionName}->{packages};
+ my $excludeList = join ' ', string2Array($pkgExcludes);
+ $self->{'meta-packager'}->initPackageSources();
+ my ($rk, $repo);
+ while (($rk, $repo) = each %{$self->{'distro-info'}->{repository}}) {
+ vlog(2, "setting up package source $rk...");
+ $self->{'meta-packager'}->setupPackageSource(
+ $rk, $repo, $excludeList, $self->_sortRepositoryURLs($repo)
+ );
+ }
+ return;
}
sub _stage1D_updateBasicVendorOS
{
- my $self = shift;
+ my $self = shift;
- vlog(1, "updating basic vendor-os...");
- $self->{'meta-packager'}->updateBasicVendorOS();
- return;
+ vlog(1, "updating basic vendor-os...");
+ $self->{'meta-packager'}->updateBasicVendorOS();
+ return;
}
sub _stage1D_installPackageSelection
{
- my $self = shift;
-
- my $selectionName = $self->{'selection-name'};
-
- vlog(1, "installing package selection <$selectionName>...");
- my $selection = $self->{'distro-info'}->{selection}->{$selectionName};
- my @pkgs = string2Array($selection->{packages});
- my @installedPkgs = $self->{'packager'}->getInstalledPackages();
- @pkgs = grep {
- my $pkg = $_;
- if (grep { $_ eq $pkg; } @installedPkgs) {
- vlog(1, "package '$pkg' filtered, it is already installed.");
- 0;
- }
- else {
- 1;
- }
- } @pkgs;
- if (!@pkgs) {
- vlog(
- 0,
- _tr(
- "No packages listed for selection '%s', nothing to do.",
- $selectionName
- )
- );
- }
- else {
- vlog(1, "installing these packages:\n" . join("\n\t", @pkgs));
- $self->{'meta-packager'}->installPackages(join(' ', @pkgs), 1);
- }
- return;
+ my $self = shift;
+
+ my $selectionName = $self->{'selection-name'};
+
+ vlog(1, "installing package selection <$selectionName>...");
+ my $selection = $self->{'distro-info'}->{selection}->{$selectionName};
+ my @pkgs = string2Array($selection->{packages});
+ my @installedPkgs = $self->{'packager'}->getInstalledPackages();
+ @pkgs = grep {
+ my $pkg = $_;
+ if (grep { $_ eq $pkg; } @installedPkgs) {
+ vlog(1, "package '$pkg' filtered, it is already installed.");
+ 0;
+ }
+ else {
+ 1;
+ }
+ } @pkgs;
+ if (!@pkgs) {
+ vlog(
+ 0,
+ _tr(
+ "No packages listed for selection '%s', nothing to do.",
+ $selectionName
+ )
+ );
+ }
+ else {
+ vlog(1, "installing these packages:\n" . join("\n\t", @pkgs));
+ $self->{'meta-packager'}->installPackages(join(' ', @pkgs), 1);
+ }
+ return;
}
sub _clone_fetchSource
{
- my $self = shift;
- my $source = shift;
-
- vlog(
- 0,
- _tr(
- "Cloning vendor-OS from '%s' to '%s'...\n", $source,
- $self->{'vendor-os-path'}
- )
- );
- my $excludeIncludeList = $self->_clone_determineIncludeExcludeList();
- vlog(1, "using exclude-include-filter:\n$excludeIncludeList\n");
- my $additionalRsyncOptions = $ENV{SLX_RSYNC_OPTIONS} || '';
- my $rsyncCmd
- = "rsync -av --delete --exclude-from=- $additionalRsyncOptions"
- . " $source $self->{'vendor-os-path'}";
- vlog(2, "executing: $rsyncCmd\n");
- my $rsyncFH;
- open($rsyncFH, '|-', $rsyncCmd)
- or croak(
- _tr(
- "unable to start rsync for source '%s', giving up! (%s)\n",
- $source, $!
- )
- );
- print $rsyncFH $excludeIncludeList;
- close($rsyncFH)
- or croak _tr(
- "unable to clone from source '%s', giving up! (%s)\n", $source, $!
- );
- return;
+ my $self = shift;
+ my $source = shift;
+
+ vlog(
+ 0,
+ _tr(
+ "Cloning vendor-OS from '%s' to '%s'...\n", $source,
+ $self->{'vendor-os-path'}
+ )
+ );
+ my $excludeIncludeList = $self->_clone_determineIncludeExcludeList();
+ vlog(1, "using exclude-include-filter:\n$excludeIncludeList\n");
+ my $additionalRsyncOptions = $ENV{SLX_RSYNC_OPTIONS} || '';
+ my $rsyncCmd
+ = "rsync -av --delete --exclude-from=- $additionalRsyncOptions"
+ . " $source $self->{'vendor-os-path'}";
+ vlog(2, "executing: $rsyncCmd\n");
+ my $rsyncFH;
+ open($rsyncFH, '|-', $rsyncCmd)
+ or croak(
+ _tr(
+ "unable to start rsync for source '%s', giving up! (%s)\n",
+ $source, $!
+ )
+ );
+ print $rsyncFH $excludeIncludeList;
+ close($rsyncFH)
+ or croak _tr(
+ "unable to clone from source '%s', giving up! (%s)\n", $source, $!
+ );
+ return;
}
sub _clone_determineIncludeExcludeList
{
- my $self = shift;
+ my $self = shift;
- my $localFilterFile
- = "$openslxConfig{'config-path'}/distro-info/clone-filter";
- my $includeExcludeList
- = slurpFile($localFilterFile, { failIfMissing => 0 });
- $includeExcludeList .= $self->{distro}->{'clone-filter'};
- $includeExcludeList =~ s[^\s+][]igms;
+ my $localFilterFile
+ = "$openslxConfig{'config-path'}/distro-info/clone-filter";
+ my $includeExcludeList
+ = slurpFile($localFilterFile, { failIfMissing => 0 });
+ $includeExcludeList .= $self->{distro}->{'clone-filter'};
+ $includeExcludeList =~ s[^\s+][]igms;
- # remove any leading whitespace, as rsync doesn't like it
- return $includeExcludeList;
+ # remove any leading whitespace, as rsync doesn't like it
+ return $includeExcludeList;
}
sub _installPlugins
{
- my $self = shift;
- my $plugins = shift;
-
- my $isReInstall = 0;
-
- if (!$plugins) {
- $plugins = [];
- my $openslxDB = instantiateClass("OpenSLX::ConfigDB");
- $openslxDB->connect();
- # fetch plugins from existing vendor-OS
- my $vendorOS = $openslxDB->fetchVendorOSByFilter({
- 'name' => $self->{'vendor-os-name'}
- });
- if ($vendorOS) {
- push @$plugins, $openslxDB->fetchInstalledPlugins($vendorOS->{id});
- $isReInstall = 1;
- }
- $openslxDB->disconnect();
- }
-
- return if ! @$plugins;
-
- require OpenSLX::OSPlugin::Engine;
- vlog(
- 0,
- $isReInstall
- ? _tr("reinstalling plugins...\n")
- : _tr("installing default plugins...\n")
- );
- for my $pluginInfo (@$plugins) {
- my $pluginName = $pluginInfo->{plugin_name};
- my $pluginEngine = OpenSLX::OSPlugin::Engine->new();
- vlog(0, _tr("\t%s\n", $pluginName));
- $pluginEngine->initialize(
- $pluginName, $self->{'vendor-os-name'}, $pluginInfo->{attrs}
- );
- $pluginEngine->installPlugin();
- }
- vlog(0, _tr("done with plugins.\n"));
-
- return;
+ my $self = shift;
+ my $plugins = shift;
+
+ my $isReInstall = 0;
+
+ if (!$plugins) {
+ $plugins = [];
+ my $openslxDB = instantiateClass("OpenSLX::ConfigDB");
+ $openslxDB->connect();
+ # fetch plugins from existing vendor-OS
+ my $vendorOS = $openslxDB->fetchVendorOSByFilter({
+ 'name' => $self->{'vendor-os-name'}
+ });
+ if ($vendorOS) {
+ push @$plugins, $openslxDB->fetchInstalledPlugins($vendorOS->{id});
+ $isReInstall = 1;
+ }
+ $openslxDB->disconnect();
+ }
+
+ return if ! @$plugins;
+
+ require OpenSLX::OSPlugin::Engine;
+ vlog(
+ 0,
+ $isReInstall
+ ? _tr("reinstalling plugins...\n")
+ : _tr("installing default plugins...\n")
+ );
+ for my $pluginInfo (@$plugins) {
+ my $pluginName = $pluginInfo->{plugin_name};
+ my $pluginEngine = OpenSLX::OSPlugin::Engine->new();
+ vlog(0, _tr("\t%s\n", $pluginName));
+ $pluginEngine->initialize(
+ $pluginName, $self->{'vendor-os-name'}, $pluginInfo->{attrs}
+ );
+ $pluginEngine->installPlugin();
+ }
+ vlog(0, _tr("done with plugins.\n"));
+
+ return;
}
-
+
################################################################################
### utility methods
################################################################################
sub _changePersonalityIfNeeded
{
- my $self = shift;
-
- my $distroName = $self->{'distro-name'};
- if ($self->_hostIs64Bit() && $distroName !~ m[_64]) {
- # trying to handle a 32-bit vendor-OS on a 64-bit machine, so we change
- # the personality accordingly (from 64-bit to 32-bit):
- $self->_loadPerlHeader('syscall.ph')
- or die _tr("unable to load perl header '%s'\n", 'syscall.ph');
- $self->_loadPerlHeader('linux/personality.ph')
- || $self->_loadPerlHeader('sys/personality.ph')
- or die _tr("unable to load perl header '%s'\n", 'personality.ph');
-
- syscall &SYS_personality, PER_LINUX32();
- }
- return;
+ my $self = shift;
+
+ my $distroName = $self->{'distro-name'};
+ if ($self->_hostIs64Bit() && $distroName !~ m[_64]) {
+ # trying to handle a 32-bit vendor-OS on a 64-bit machine, so we change
+ # the personality accordingly (from 64-bit to 32-bit):
+ $self->_loadPerlHeader('syscall.ph')
+ or die _tr("unable to load perl header '%s'\n", 'syscall.ph');
+ $self->_loadPerlHeader('linux/personality.ph')
+ || $self->_loadPerlHeader('sys/personality.ph')
+ or die _tr("unable to load perl header '%s'\n", 'personality.ph');
+
+ syscall &SYS_personality, PER_LINUX32();
+ }
+ return;
}
sub _loadPerlHeader
{
- my $self = shift;
- my $phFile = shift;
-
- if (!eval { require $phFile }) {
- # perl-header has not been provided by host-OS, so we create it
- # manually from C-header (via h2ph):
- (my $hFile = $phFile) =~ s{\.ph$}{.h};
- return if !-e "/usr/include/$hFile";
- my $libDir = "$openslxConfig{'base-path'}/lib";
- slxsystem("cd /usr/include && h2ph -d $libDir $hFile") == 0
- or die _tr("unable to create %s! (%s)", $phFile, $!);
- }
- return eval { require $phFile; 1 };
+ my $self = shift;
+ my $phFile = shift;
+
+ if (!eval { require $phFile }) {
+ # perl-header has not been provided by host-OS, so we create it
+ # manually from C-header (via h2ph):
+ (my $hFile = $phFile) =~ s{\.ph$}{.h};
+ return if !-e "/usr/include/$hFile";
+ my $libDir = "$openslxConfig{'base-path'}/lib";
+ slxsystem("cd /usr/include && h2ph -d $libDir $hFile") == 0
+ or die _tr("unable to create %s! (%s)", $phFile, $!);
+ }
+ return eval { require $phFile; 1 };
}
sub _hostIs64Bit
{
- my $self = shift;
+ my $self = shift;
- $self->{arch} = `uname -m` unless defined $self->{arch};
- return ($self->{arch} =~ m[64]);
+ $self->{arch} = `uname -m` unless defined $self->{arch};
+ return ($self->{arch} =~ m[64]);
}
1;
diff --git a/installer/OpenSLX/OSSetup/MetaPackager/Base.pm b/installer/OpenSLX/OSSetup/MetaPackager/Base.pm
index 517e9f9a..af789888 100644
--- a/installer/OpenSLX/OSSetup/MetaPackager/Base.pm
+++ b/installer/OpenSLX/OSSetup/MetaPackager/Base.pm
@@ -9,14 +9,14 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# Base.pm
-# - provides empty base of the OpenSLX OSSetup::MetaPackager API.
+# - provides empty base of the OpenSLX OSSetup::MetaPackager API.
# -----------------------------------------------------------------------------
package OpenSLX::OSSetup::MetaPackager::Base;
use strict;
use warnings;
-our $VERSION = 1.01; # API-version . implementation-version
+our $VERSION = 1.01; # API-version . implementation-version
use OpenSLX::Basics;
@@ -25,16 +25,16 @@ use OpenSLX::Basics;
################################################################################
sub new
{
- confess "Creating OpenSLX::OSSetup::MetaPackager::Base-objects directly makes no sense!";
+ confess "Creating OpenSLX::OSSetup::MetaPackager::Base-objects directly makes no sense!";
}
sub initialize
{
- my $self = shift;
- my $engine = shift;
+ my $self = shift;
+ my $engine = shift;
- $self->{'engine'} = $engine;
- return;
+ $self->{'engine'} = $engine;
+ return;
}
sub initPackageSources
diff --git a/installer/OpenSLX/OSSetup/MetaPackager/apt.pm b/installer/OpenSLX/OSSetup/MetaPackager/apt.pm
index a8a4f91e..ecb87a35 100644
--- a/installer/OpenSLX/OSSetup/MetaPackager/apt.pm
+++ b/installer/OpenSLX/OSSetup/MetaPackager/apt.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# apt.pm
-# - provides apt-get-specific overrides of the OpenSLX::OSSetup::MetaPackager API.
+# - provides apt-get-specific overrides of the OpenSLX::OSSetup::MetaPackager API.
# -----------------------------------------------------------------------------
package OpenSLX::OSSetup::MetaPackager::apt;
@@ -26,117 +26,117 @@ use OpenSLX::Utils;
################################################################################
sub new
{
- my $class = shift;
- my $self = {
- 'name' => 'apt',
- };
- return bless $self, $class;
+ my $class = shift;
+ my $self = {
+ 'name' => 'apt',
+ };
+ return bless $self, $class;
}
sub initPackageSources
{
- my $self = shift;
-
- $ENV{LC_ALL} = 'POSIX';
-
- # remove any existing sources
- slxsystem('rm -f /etc/apt/sources.list');
-
- # create default timezone if there isn't any
- if (!-e '/etc/timezone') {
- spitFile('/etc/timezone', "$openslxConfig{'default-timezone'}\n");
- }
-
- # create kernel config if there isn't any
- if (!-e '/etc/kernel-img.conf') {
- my $kernelConfig = unshiftHereDoc(<<" END-OF-HERE");
- # Kernel image management overrides
- # See kernel-img.conf(5) for details
- do_symlinks = yes
- relative_links = yes
- do_bootloader = no
- do_bootfloppy = no
- do_initrd = yes
- link_in_boot = yes
- END-OF-HERE
- spitFile('/etc/kernel-img.conf', $kernelConfig);
- }
-
- return 1;
+ my $self = shift;
+
+ $ENV{LC_ALL} = 'POSIX';
+
+ # remove any existing sources
+ slxsystem('rm -f /etc/apt/sources.list');
+
+ # create default timezone if there isn't any
+ if (!-e '/etc/timezone') {
+ spitFile('/etc/timezone', "$openslxConfig{'default-timezone'}\n");
+ }
+
+ # create kernel config if there isn't any
+ if (!-e '/etc/kernel-img.conf') {
+ my $kernelConfig = unshiftHereDoc(<<" END-OF-HERE");
+ # Kernel image management overrides
+ # See kernel-img.conf(5) for details
+ do_symlinks = yes
+ relative_links = yes
+ do_bootloader = no
+ do_bootfloppy = no
+ do_initrd = yes
+ link_in_boot = yes
+ END-OF-HERE
+ spitFile('/etc/kernel-img.conf', $kernelConfig);
+ }
+
+ return 1;
}
sub setupPackageSource
{
- my $self = shift;
- my $repoName = shift;
- my $repoInfo = shift;
- my $excludeList = shift;
- my $repoURLs = shift;
+ my $self = shift;
+ my $repoName = shift;
+ my $repoInfo = shift;
+ my $excludeList = shift;
+ my $repoURLs = shift;
- my $baseURL = shift @$repoURLs;
- my $distribution = $repoInfo->{'distribution'};
- my $components = $repoInfo->{'components'};
+ my $baseURL = shift @$repoURLs;
+ my $distribution = $repoInfo->{'distribution'};
+ my $components = $repoInfo->{'components'};
- my $sourcesList = "deb $baseURL $distribution $components\n";
+ my $sourcesList = "deb $baseURL $distribution $components\n";
- foreach my $mirrorURL (@$repoURLs) {
- $sourcesList .= "deb $mirrorURL $distribution $components\n";
- }
+ foreach my $mirrorURL (@$repoURLs) {
+ $sourcesList .= "deb $mirrorURL $distribution $components\n";
+ }
- appendFile('/etc/apt/sources.list', $sourcesList);
+ appendFile('/etc/apt/sources.list', $sourcesList);
- return;
+ return;
}
sub installPackages
{
- my $self = shift;
- my $packages = shift;
- my $doRefresh = shift || 0;
-
- $packages =~ tr{\n}{ };
-
- if ($doRefresh && slxsystem("apt-get -y update")) {
- die _tr("unable to update repository info (%s)\n", $!);
- }
- if ('/var/cache/debconf/slx-defaults.dat') {
- $ENV{DEBCONF_DB_FALLBACK}
- = "'File{/var/cache/debconf/slx-defaults.dat}'";
- }
- $ENV{DEBIAN_FRONTEND} = 'noninteractive';
- if (slxsystem("apt-get -y install $packages")) {
- die _tr("unable to install selection (%s)\n", $!);
- }
- delete $ENV{DEBCONF_DB_FALLBACK};
- delete $ENV{DEBIAN_FRONTEND};
-
- return 1;
+ my $self = shift;
+ my $packages = shift;
+ my $doRefresh = shift || 0;
+
+ $packages =~ tr{\n}{ };
+
+ if ($doRefresh && slxsystem("apt-get -y update")) {
+ die _tr("unable to update repository info (%s)\n", $!);
+ }
+ if ('/var/cache/debconf/slx-defaults.dat') {
+ $ENV{DEBCONF_DB_FALLBACK}
+ = "'File{/var/cache/debconf/slx-defaults.dat}'";
+ }
+ $ENV{DEBIAN_FRONTEND} = 'noninteractive';
+ if (slxsystem("apt-get -y install $packages")) {
+ die _tr("unable to install selection (%s)\n", $!);
+ }
+ delete $ENV{DEBCONF_DB_FALLBACK};
+ delete $ENV{DEBIAN_FRONTEND};
+
+ return 1;
}
sub removePackages
{
- my $self = shift;
- my $pkgSelection = shift;
+ my $self = shift;
+ my $pkgSelection = shift;
- if (slxsystem("apt-get -y remove $pkgSelection")) {
- die _tr("unable to remove selection (%s)\n", $!);
- }
+ if (slxsystem("apt-get -y remove $pkgSelection")) {
+ die _tr("unable to remove selection (%s)\n", $!);
+ }
- return 1;
+ return 1;
}
sub updateBasicVendorOS
{
- my $self = shift;
+ my $self = shift;
- if (slxsystem("apt-get -y update")) {
- die _tr("unable to update repository info (%s)\n", $!);
- }
- if (slxsystem("apt-get -y upgrade")) {
- die _tr("unable to update this vendor-os (%s)\n", $!);
- }
+ if (slxsystem("apt-get -y update")) {
+ die _tr("unable to update repository info (%s)\n", $!);
+ }
+ if (slxsystem("apt-get -y upgrade")) {
+ die _tr("unable to update this vendor-os (%s)\n", $!);
+ }
- return 1;
+ return 1;
}
1; \ No newline at end of file
diff --git a/installer/OpenSLX/OSSetup/MetaPackager/smart.pm b/installer/OpenSLX/OSSetup/MetaPackager/smart.pm
index 27995e01..fc178cb7 100644
--- a/installer/OpenSLX/OSSetup/MetaPackager/smart.pm
+++ b/installer/OpenSLX/OSSetup/MetaPackager/smart.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# smart.pm
-# - provides smart-specific overrides of the OpenSLX::OSSetup::MetaPackager API.
+# - provides smart-specific overrides of the OpenSLX::OSSetup::MetaPackager API.
# -----------------------------------------------------------------------------
package OpenSLX::OSSetup::MetaPackager::smart;
@@ -26,102 +26,102 @@ use OpenSLX::Utils;
################################################################################
sub new
{
- my $class = shift;
- my $self = {
- 'name' => 'smart',
- };
- return bless $self, $class;
+ my $class = shift;
+ my $self = {
+ 'name' => 'smart',
+ };
+ return bless $self, $class;
}
sub initPackageSources
{
- my $self = shift;
+ my $self = shift;
- $ENV{LC_ALL} = 'POSIX';
+ $ENV{LC_ALL} = 'POSIX';
- # remove any existing channels
- slxsystem("rm -f /etc/smart/channels/*");
- if (slxsystem("smart channel -y --remove-all")) {
- die _tr("unable to remove existing channels (%s)\n", $!);
- }
- return 1;
+ # remove any existing channels
+ slxsystem("rm -f /etc/smart/channels/*");
+ if (slxsystem("smart channel -y --remove-all")) {
+ die _tr("unable to remove existing channels (%s)\n", $!);
+ }
+ return 1;
}
sub setupPackageSource
{
- my $self = shift;
- my $repoName = shift;
- my $repoInfo = shift;
- my $excludeList = shift;
- my $repoURLs = shift;
-
- my $repoSubdir = '';
- if ($repoInfo->{'repo-subdir'}) {
- $repoSubdir = "/$repoInfo->{'repo-subdir'}";
- }
- my $baseURL = shift @$repoURLs;
- my $repoDescr
- = qq[$repoName name="$repoInfo->{name}" baseurl=$baseURL$repoSubdir];
- $repoDescr .= " type=rpm-md";
- if (slxsystem("smart channel -y --add $repoDescr")) {
- die _tr("unable to add channel '%s' (%s)\n", $repoName, $!);
- }
-
- my $mirrorDescr;
- foreach my $mirrorURL (@$repoURLs) {
- $mirrorDescr .= " --add $baseURL$repoSubdir $mirrorURL$repoSubdir";
- }
- if (defined $mirrorDescr) {
- if (slxsystem("smart mirror $mirrorDescr")) {
- die _tr(
- "unable to add mirrors for channel '%s' (%s)\n",
- $repoName, $!
- );
- }
- }
- return 1;
+ my $self = shift;
+ my $repoName = shift;
+ my $repoInfo = shift;
+ my $excludeList = shift;
+ my $repoURLs = shift;
+
+ my $repoSubdir = '';
+ if ($repoInfo->{'repo-subdir'}) {
+ $repoSubdir = "/$repoInfo->{'repo-subdir'}";
+ }
+ my $baseURL = shift @$repoURLs;
+ my $repoDescr
+ = qq[$repoName name="$repoInfo->{name}" baseurl=$baseURL$repoSubdir];
+ $repoDescr .= " type=rpm-md";
+ if (slxsystem("smart channel -y --add $repoDescr")) {
+ die _tr("unable to add channel '%s' (%s)\n", $repoName, $!);
+ }
+
+ my $mirrorDescr;
+ foreach my $mirrorURL (@$repoURLs) {
+ $mirrorDescr .= " --add $baseURL$repoSubdir $mirrorURL$repoSubdir";
+ }
+ if (defined $mirrorDescr) {
+ if (slxsystem("smart mirror $mirrorDescr")) {
+ die _tr(
+ "unable to add mirrors for channel '%s' (%s)\n",
+ $repoName, $!
+ );
+ }
+ }
+ return 1;
}
sub installPackages
{
- my $self = shift;
- my $packages = shift;
- my $doRefresh = shift || 0;
-
- $packages =~ tr{\n}{ };
-
- if ($doRefresh && slxsystem("smart update")) {
- die _tr("unable to update channel info (%s)\n", $!);
- }
- if (slxsystem("smart install -y $packages")) {
- die _tr("unable to install selection (%s)\n", $!);
- }
- return 1;
+ my $self = shift;
+ my $packages = shift;
+ my $doRefresh = shift || 0;
+
+ $packages =~ tr{\n}{ };
+
+ if ($doRefresh && slxsystem("smart update")) {
+ die _tr("unable to update channel info (%s)\n", $!);
+ }
+ if (slxsystem("smart install -y $packages")) {
+ die _tr("unable to install selection (%s)\n", $!);
+ }
+ return 1;
}
sub removePackages
{
- my $self = shift;
- my $pkgSelection = shift;
+ my $self = shift;
+ my $pkgSelection = shift;
- if (slxsystem("smart remove -y $pkgSelection")) {
- die _tr("unable to remove selection (%s)\n", $!);
- }
- return 1;
+ if (slxsystem("smart remove -y $pkgSelection")) {
+ die _tr("unable to remove selection (%s)\n", $!);
+ }
+ return 1;
}
sub updateBasicVendorOS
{
- my $self = shift;
-
- if (slxsystem("smart upgrade -y --update")) {
- if ($! == 2) {
- # file not found => smart isn't installed
- die _tr("unable to update this vendor-os, as it seems to lack an installation of smart!\n");
- }
- die _tr("unable to update this vendor-os (%s)\n", $!);
- }
- return 1;
+ my $self = shift;
+
+ if (slxsystem("smart upgrade -y --update")) {
+ if ($! == 2) {
+ # file not found => smart isn't installed
+ die _tr("unable to update this vendor-os, as it seems to lack an installation of smart!\n");
+ }
+ die _tr("unable to update this vendor-os (%s)\n", $!);
+ }
+ return 1;
}
1; \ No newline at end of file
diff --git a/installer/OpenSLX/OSSetup/MetaPackager/yum.pm b/installer/OpenSLX/OSSetup/MetaPackager/yum.pm
index eef310fe..a48f6c36 100644
--- a/installer/OpenSLX/OSSetup/MetaPackager/yum.pm
+++ b/installer/OpenSLX/OSSetup/MetaPackager/yum.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# yum.pm
-# - provides yum-specific overrides of the OpenSLX::OSSetup::MetaPackager API.
+# - provides yum-specific overrides of the OpenSLX::OSSetup::MetaPackager API.
# -----------------------------------------------------------------------------
package OpenSLX::OSSetup::MetaPackager::yum;
@@ -26,90 +26,90 @@ use OpenSLX::Utils;
################################################################################
sub new
{
- my $class = shift;
- my $self = {
- 'name' => 'yum',
- };
- return bless $self, $class;
+ my $class = shift;
+ my $self = {
+ 'name' => 'yum',
+ };
+ return bless $self, $class;
}
sub initPackageSources
{
- my $self = shift;
+ my $self = shift;
- $ENV{LC_ALL} = 'POSIX';
+ $ENV{LC_ALL} = 'POSIX';
- slxsystem("rm -f /etc/yum.repos.d/*");
- slxsystem("mkdir -p /etc/yum.repos.d");
+ slxsystem("rm -f /etc/yum.repos.d/*");
+ slxsystem("mkdir -p /etc/yum.repos.d");
- return 1;
+ return 1;
}
sub setupPackageSource
{
- my $self = shift;
- my $repoName = shift;
- my $repoInfo = shift;
- my $excludeList = shift;
- my $repoURLs = shift;
-
- my $repoSubdir;
- if (length($repoInfo->{'repo-subdir'})) {
- $repoSubdir = "/$repoInfo->{'repo-subdir'}";
- }
- my $baseURL = shift @$repoURLs;
-
- my $repoDescr
- = "[$repoName]\nname=$repoInfo->{name}\nbaseurl=$baseURL$repoSubdir\n";
-
- foreach my $mirrorURL (@$repoURLs) {
- $repoDescr .= " $mirrorURL$repoSubdir\n";
- }
- my $repoFile = "/etc/yum.repos.d/$repoName.repo";
- spitFile($repoFile, "$repoDescr\nexclude=$excludeList\n");
-
- return 1;
+ my $self = shift;
+ my $repoName = shift;
+ my $repoInfo = shift;
+ my $excludeList = shift;
+ my $repoURLs = shift;
+
+ my $repoSubdir;
+ if (length($repoInfo->{'repo-subdir'})) {
+ $repoSubdir = "/$repoInfo->{'repo-subdir'}";
+ }
+ my $baseURL = shift @$repoURLs;
+
+ my $repoDescr
+ = "[$repoName]\nname=$repoInfo->{name}\nbaseurl=$baseURL$repoSubdir\n";
+
+ foreach my $mirrorURL (@$repoURLs) {
+ $repoDescr .= " $mirrorURL$repoSubdir\n";
+ }
+ my $repoFile = "/etc/yum.repos.d/$repoName.repo";
+ spitFile($repoFile, "$repoDescr\nexclude=$excludeList\n");
+
+ return 1;
}
sub installPackages
{
- my $self = shift;
- my $packages = shift;
+ my $self = shift;
+ my $packages = shift;
- $packages =~ tr{\n}{ };
+ $packages =~ tr{\n}{ };
- if (slxsystem("yum -y install $packages")) {
- die _tr("unable to install selection (%s)\n", $!);
- }
+ if (slxsystem("yum -y install $packages")) {
+ die _tr("unable to install selection (%s)\n", $!);
+ }
- return 1;
+ return 1;
}
sub removePackages
{
- my $self = shift;
- my $pkgSelection = shift;
+ my $self = shift;
+ my $pkgSelection = shift;
- if (slxsystem("yum -y remove $pkgSelection")) {
- die _tr("unable to remove selection (%s)\n", $!);
- }
+ if (slxsystem("yum -y remove $pkgSelection")) {
+ die _tr("unable to remove selection (%s)\n", $!);
+ }
- return 1;
+ return 1;
}
sub updateBasicVendorOS
{
- my $self = shift;
+ my $self = shift;
- if (slxsystem("yum -y update")) {
- if ($! == 2) {
- # file not found => yum isn't installed
- die _tr("unable to update this vendor-os, as it seems to lack an installation of yum!\n");
- }
- die _tr("unable to update this vendor-os (%s)\n", $!);
- }
+ if (slxsystem("yum -y update")) {
+ if ($! == 2) {
+ # file not found => yum isn't installed
+ die _tr("unable to update this vendor-os, as it seems to lack an installation of yum!\n");
+ }
+ die _tr("unable to update this vendor-os (%s)\n", $!);
+ }
- return 1;
+ return 1;
}
1; \ No newline at end of file
diff --git a/installer/OpenSLX/OSSetup/MetaPackager/zypper.pm b/installer/OpenSLX/OSSetup/MetaPackager/zypper.pm
index 9a732af0..04d16bad 100644
--- a/installer/OpenSLX/OSSetup/MetaPackager/zypper.pm
+++ b/installer/OpenSLX/OSSetup/MetaPackager/zypper.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# zypper.pm
-# - provides zypper-specific overrides of the OpenSLX::OSSetup::MetaPackager API.
+# - provides zypper-specific overrides of the OpenSLX::OSSetup::MetaPackager API.
# -----------------------------------------------------------------------------
package OpenSLX::OSSetup::MetaPackager::zypper;
@@ -26,88 +26,88 @@ use OpenSLX::Utils;
################################################################################
sub new
{
- my $class = shift;
- my $self = {
- 'name' => 'zypper',
- };
- return bless $self, $class;
+ my $class = shift;
+ my $self = {
+ 'name' => 'zypper',
+ };
+ return bless $self, $class;
}
sub initPackageSources
{
- my $self = shift;
+ my $self = shift;
- $ENV{LC_ALL} = 'POSIX';
+ $ENV{LC_ALL} = 'POSIX';
- # remove any existing channels
- slxsystem("rm -f /etc/zypp/repos.d/*");
+ # remove any existing channels
+ slxsystem("rm -f /etc/zypp/repos.d/*");
- return 1;
+ return 1;
}
sub setupPackageSource
{
- my $self = shift;
- my $repoName = shift;
- my $repoInfo = shift;
- my $excludeList = shift;
- my $repoURLs = shift;
-
- my $repoSubdir = '';
- if (length($repoInfo->{'repo-subdir'})) {
- $repoSubdir = "/$repoInfo->{'repo-subdir'}";
- }
- my $baseURL = shift @$repoURLs;
- if (slxsystem("zypper addrepo -n $baseURL$repoSubdir $repoName")) {
- die _tr("unable to add repo '%s' (%s)\n", $repoName, $!);
- }
-
- return 1;
+ my $self = shift;
+ my $repoName = shift;
+ my $repoInfo = shift;
+ my $excludeList = shift;
+ my $repoURLs = shift;
+
+ my $repoSubdir = '';
+ if (length($repoInfo->{'repo-subdir'})) {
+ $repoSubdir = "/$repoInfo->{'repo-subdir'}";
+ }
+ my $baseURL = shift @$repoURLs;
+ if (slxsystem("zypper addrepo -n $baseURL$repoSubdir $repoName")) {
+ die _tr("unable to add repo '%s' (%s)\n", $repoName, $!);
+ }
+
+ return 1;
}
sub installPackages
{
- my $self = shift;
- my $packages = shift;
- my $doRefresh = shift || 0;
+ my $self = shift;
+ my $packages = shift;
+ my $doRefresh = shift || 0;
- $packages =~ tr{\n}{ };
+ $packages =~ tr{\n}{ };
- if ($doRefresh && slxsystem("zypper --non-interactive refresh")) {
- die _tr("unable to update repo info (%s)\n", $!);
- }
- if (slxsystem("zypper --non-interactive install $packages")) {
- die _tr("unable to install selection (%s)\n", $!);
- }
+ if ($doRefresh && slxsystem("zypper --non-interactive refresh")) {
+ die _tr("unable to update repo info (%s)\n", $!);
+ }
+ if (slxsystem("zypper --non-interactive install $packages")) {
+ die _tr("unable to install selection (%s)\n", $!);
+ }
- return 1;
+ return 1;
}
sub removePackages
{
- my $self = shift;
- my $pkgSelection = shift;
+ my $self = shift;
+ my $pkgSelection = shift;
- if (slxsystem("zypper --non-interactive remove $pkgSelection")) {
- die _tr("unable to remove selection (%s)\n", $!);
- }
+ if (slxsystem("zypper --non-interactive remove $pkgSelection")) {
+ die _tr("unable to remove selection (%s)\n", $!);
+ }
- return 1;
+ return 1;
}
sub updateBasicVendorOS
{
- my $self = shift;
+ my $self = shift;
- if (slxsystem("zypper --non-interactive update")) {
- if ($! == 2) {
- # file not found => zypper isn't installed
- die _tr("unable to update this vendor-os, as it seems to lack an installation of zypper!\n");
- }
- die _tr("unable to update this vendor-os (%s)\n", $!);
- }
+ if (slxsystem("zypper --non-interactive update")) {
+ if ($! == 2) {
+ # file not found => zypper isn't installed
+ die _tr("unable to update this vendor-os, as it seems to lack an installation of zypper!\n");
+ }
+ die _tr("unable to update this vendor-os (%s)\n", $!);
+ }
- return 1;
+ return 1;
}
1; \ No newline at end of file
diff --git a/installer/OpenSLX/OSSetup/Packager/Base.pm b/installer/OpenSLX/OSSetup/Packager/Base.pm
index 55211183..747ba7e4 100644
--- a/installer/OpenSLX/OSSetup/Packager/Base.pm
+++ b/installer/OpenSLX/OSSetup/Packager/Base.pm
@@ -9,14 +9,14 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# Base.pm
-# - provides empty base of the OpenSLX OSSetup::Packager API.
+# - provides empty base of the OpenSLX OSSetup::Packager API.
# -----------------------------------------------------------------------------
package OpenSLX::OSSetup::Packager::Base;
use strict;
use warnings;
-our $VERSION = 1.01; # API-version . implementation-version
+our $VERSION = 1.01; # API-version . implementation-version
use OpenSLX::Basics;
@@ -25,16 +25,16 @@ use OpenSLX::Basics;
################################################################################
sub new
{
- confess "Creating OpenSLX::OSSetup::Packager::Base-objects directly makes no sense!";
+ confess "Creating OpenSLX::OSSetup::Packager::Base-objects directly makes no sense!";
}
sub initialize
{
- my $self = shift;
- my $engine = shift;
+ my $self = shift;
+ my $engine = shift;
- $self->{'engine'} = $engine;
- return;
+ $self->{'engine'} = $engine;
+ return;
}
sub prepareBootstrap
diff --git a/installer/OpenSLX/OSSetup/Packager/dpkg.pm b/installer/OpenSLX/OSSetup/Packager/dpkg.pm
index 573c2054..94aff9c6 100644
--- a/installer/OpenSLX/OSSetup/Packager/dpkg.pm
+++ b/installer/OpenSLX/OSSetup/Packager/dpkg.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# rpm.pm
-# - provides rpm-specific overrides of the OpenSLX::OSSetup::Packager API.
+# - provides rpm-specific overrides of the OpenSLX::OSSetup::Packager API.
# -----------------------------------------------------------------------------
package OpenSLX::OSSetup::Packager::dpkg;
@@ -26,77 +26,77 @@ use OpenSLX::Utils;
################################################################################
sub new
{
- my $class = shift;
- my $self = {
- 'name' => 'dpkg',
- };
- return bless $self, $class;
+ my $class = shift;
+ my $self = {
+ 'name' => 'dpkg',
+ };
+ return bless $self, $class;
}
sub prepareBootstrap
{
- my $self = shift;
- my $stage1aDir = shift;
-
- copyBinaryWithRequiredLibs({
- 'binary' => '/usr/bin/perl',
- 'targetFolder' => "$stage1aDir/usr/bin",
- 'libTargetFolder' => $stage1aDir,
- });
+ my $self = shift;
+ my $stage1aDir = shift;
+
+ copyBinaryWithRequiredLibs({
+ 'binary' => '/usr/bin/perl',
+ 'targetFolder' => "$stage1aDir/usr/bin",
+ 'libTargetFolder' => $stage1aDir,
+ });
}
sub bootstrap
{
- my $self = shift;
- my $pkgs = shift;
+ my $self = shift;
+ my $pkgs = shift;
- my $debootstrapPkg = $pkgs->[0];
- chdir '..';
- vlog(2, "unpacking debootstrap ...");
- if (slxsystem("ash", "-c", "ar x slxbootstrap/$debootstrapPkg")) {
- die _tr("unable to unarchive package '%s' (%s)", $debootstrapPkg, $!);
- }
- if (slxsystem("ash", "-c", "tar xzf data.tar.gz")) {
- die _tr("unable to untar 'data.tar.gz (%s)", $!);
- }
- if (slxsystem("ash", "-c", "rm -f debian-binary *.tar.gz")) {
- die _tr("unable to cleanup package '%s' (%s)", $debootstrapPkg, $!);
- }
- my $arch = $self->{engine}->{'distro-info'}->{arch};
- my $releaseName = $self->{engine}->{'distro-info'}->{'release-name'};
- my $baseURL = $self->{engine}->{baseURLs}->[0];
- my $debootstrapCmd = unshiftHereDoc(<<" END-OF-HERE");
- /usr/sbin/debootstrap --arch $arch $releaseName \\
- /slxbootstrap/slxfinal $baseURL
- END-OF-HERE
- if (slxsystem("ash", "-c", ". $debootstrapCmd")) {
- die _tr("unable to run debootstrap (%s)", $!);
- }
- return;
+ my $debootstrapPkg = $pkgs->[0];
+ chdir '..';
+ vlog(2, "unpacking debootstrap ...");
+ if (slxsystem("ash", "-c", "ar x slxbootstrap/$debootstrapPkg")) {
+ die _tr("unable to unarchive package '%s' (%s)", $debootstrapPkg, $!);
+ }
+ if (slxsystem("ash", "-c", "tar xzf data.tar.gz")) {
+ die _tr("unable to untar 'data.tar.gz (%s)", $!);
+ }
+ if (slxsystem("ash", "-c", "rm -f debian-binary *.tar.gz")) {
+ die _tr("unable to cleanup package '%s' (%s)", $debootstrapPkg, $!);
+ }
+ my $arch = $self->{engine}->{'distro-info'}->{arch};
+ my $releaseName = $self->{engine}->{'distro-info'}->{'release-name'};
+ my $baseURL = $self->{engine}->{baseURLs}->[0];
+ my $debootstrapCmd = unshiftHereDoc(<<" END-OF-HERE");
+ /usr/sbin/debootstrap --arch $arch $releaseName \\
+ /slxbootstrap/slxfinal $baseURL
+ END-OF-HERE
+ if (slxsystem("ash", "-c", ". $debootstrapCmd")) {
+ die _tr("unable to run debootstrap (%s)", $!);
+ }
+ return;
}
sub installPackages
{
- my $self = shift;
- my $pkgs = shift;
- my $finalPath = shift;
+ my $self = shift;
+ my $pkgs = shift;
+ my $finalPath = shift;
- return unless defined $pkgs && @$pkgs;
+ return unless defined $pkgs && @$pkgs;
- if (slxsystem("dpkg", "--root=$finalPath", "--install", @$pkgs)) {
- die _tr("error during package-installation (%s)\n", $!);
- }
- return;
+ if (slxsystem("dpkg", "--root=$finalPath", "--install", @$pkgs)) {
+ die _tr("error during package-installation (%s)\n", $!);
+ }
+ return;
}
sub getInstalledPackages
{
- my $self = shift;
+ my $self = shift;
- my $rpmCmd = 'dpkg-query --showformat "\${package}\n" --show';
- my $pkgList = qx{$rpmCmd};
- return split "\n", $pkgList;
+ my $rpmCmd = 'dpkg-query --showformat "\${package}\n" --show';
+ my $pkgList = qx{$rpmCmd};
+ return split "\n", $pkgList;
}
1;
diff --git a/installer/OpenSLX/OSSetup/Packager/rpm.pm b/installer/OpenSLX/OSSetup/Packager/rpm.pm
index db1e7e1f..8a86a3d2 100644
--- a/installer/OpenSLX/OSSetup/Packager/rpm.pm
+++ b/installer/OpenSLX/OSSetup/Packager/rpm.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# rpm.pm
-# - provides rpm-specific overrides of the OpenSLX::OSSetup::Packager API.
+# - provides rpm-specific overrides of the OpenSLX::OSSetup::Packager API.
# -----------------------------------------------------------------------------
package OpenSLX::OSSetup::Packager::rpm;
@@ -25,65 +25,65 @@ use OpenSLX::Basics;
################################################################################
sub new
{
- my $class = shift;
- my $self = {
- 'name' => 'rpm',
- };
- return bless $self, $class;
+ my $class = shift;
+ my $self = {
+ 'name' => 'rpm',
+ };
+ return bless $self, $class;
}
sub bootstrap
{
- my $self = shift;
- my $pkgs = shift;
+ my $self = shift;
+ my $pkgs = shift;
- foreach my $pkg (@$pkgs) {
- vlog(2, "unpacking package $pkg...");
- if (slxsystem("ash", "-c", "rpm2cpio $pkg | cpio -i -d -u")) {
- die _tr("unable to unpack package <%s> (%s)", $pkg, $!);
- }
- }
- return;
+ foreach my $pkg (@$pkgs) {
+ vlog(2, "unpacking package $pkg...");
+ if (slxsystem("ash", "-c", "rpm2cpio $pkg | cpio -i -d -u")) {
+ die _tr("unable to unpack package <%s> (%s)", $pkg, $!);
+ }
+ }
+ return;
}
sub importTrustedPackageKeys
{
- my $self = shift;
- my $keyFiles = shift;
- my $finalPath = shift;
+ my $self = shift;
+ my $keyFiles = shift;
+ my $finalPath = shift;
- return unless defined $keyFiles;
+ return unless defined $keyFiles;
- foreach my $keyFile (@$keyFiles) {
- vlog(2, "importing package key $keyFile...");
- if (slxsystem("rpm", "--root=$finalPath", "--import", "$keyFile")) {
- die _tr("unable to import package key <%s> (%s)\n", $keyFile, $!);
- }
- }
- return;
+ foreach my $keyFile (@$keyFiles) {
+ vlog(2, "importing package key $keyFile...");
+ if (slxsystem("rpm", "--root=$finalPath", "--import", "$keyFile")) {
+ die _tr("unable to import package key <%s> (%s)\n", $keyFile, $!);
+ }
+ }
+ return;
}
sub installPackages
{
- my $self = shift;
- my $pkgs = shift;
- my $finalPath = shift;
+ my $self = shift;
+ my $pkgs = shift;
+ my $finalPath = shift;
- return unless defined $pkgs && scalar(@$pkgs);
+ return unless defined $pkgs && scalar(@$pkgs);
- if (slxsystem("rpm", "--root=$finalPath", "-ivh", @$pkgs)) {
- die _tr("error during package-installation (%s)\n", $!);
- }
- return;
+ if (slxsystem("rpm", "--root=$finalPath", "-ivh", @$pkgs)) {
+ die _tr("error during package-installation (%s)\n", $!);
+ }
+ return;
}
sub getInstalledPackages
{
- my $self = shift;
+ my $self = shift;
- my $rpmCmd = 'rpm -qa --queryformat="%{NAME}\n"';
- my $pkgList = `$rpmCmd`;
- return split "\n", $pkgList;
+ my $rpmCmd = 'rpm -qa --queryformat="%{NAME}\n"';
+ my $pkgList = `$rpmCmd`;
+ return split "\n", $pkgList;
}
1;
diff --git a/installer/slxos-export b/installer/slxos-export
index a801077d..3d14a383 100755
--- a/installer/slxos-export
+++ b/installer/slxos-export
@@ -38,21 +38,21 @@ use OpenSLX::Utils;
my %option;
GetOptions(
- 'help|?' => \$option{helpReq},
- 'man' => \$option{manReq},
- 'version' => \$option{versionReq},
+ 'help|?' => \$option{helpReq},
+ 'man' => \$option{manReq},
+ 'version' => \$option{versionReq},
)
or pod2usage(2);
pod2usage(-msg => $abstract, -verbose => 0, -exitval => 1) if $option{helpReq};
if ($option{manReq}) {
- # avoid dubious problem with perldoc in combination with UTF-8 that
- # leads to strange dashes and single-quotes being used
- $ENV{LC_ALL} = 'POSIX';
- pod2usage(-verbose => 2);
+ # avoid dubious problem with perldoc in combination with UTF-8 that
+ # leads to strange dashes and single-quotes being used
+ $ENV{LC_ALL} = 'POSIX';
+ pod2usage(-verbose => 2);
}
if ($option{versionReq}) {
- system('slxversion');
- exit 1;
+ system('slxversion');
+ exit 1;
}
openslxInit();
@@ -60,109 +60,109 @@ openslxInit();
my $action = shift @ARGV || '';
if ($action =~ m[^list-ex]i) {
- print _tr("List of exported vendor-OSes (exports):\n");
- foreach my $type (sort keys %supportedExportFileSystems) {
- # list all image files, followed by the block devices using it:
- my @files = map {
- my $image = decode('utf8', $_);
- $image =~ s[^.+/][];
- $image;
- }
- sort glob("$openslxConfig{'public-path'}/export/$type/*");
- my %imageFiles;
- foreach my $file (@files) {
- if ($file =~ m[^(.+)@(.+)$]) {
- # it's a link referring to a block device using this image,
- # we collect the name of the block device:
- push @{$imageFiles{$1}}, $2;
- } else {
- # it's an image file, we setup an empty array of block devices:
- $imageFiles{$file} = [];
- }
- }
- print join(
- '',
- map {
- my $devices = join(',', @{$imageFiles{$_}});
- my $name = "${_}::$type";
- if (length($devices)) {
- "\t$name".substr(' ' x 30, length($name))."($devices)\n";
- } else {
- "\t$name\n";
- }
- }
- grep {
- # filter out RSYNC_TMP folders:
- $_ !~ m[###];
- }
- sort keys %imageFiles
- );
- }
+ print _tr("List of exported vendor-OSes (exports):\n");
+ foreach my $type (sort keys %supportedExportFileSystems) {
+ # list all image files, followed by the block devices using it:
+ my @files = map {
+ my $image = decode('utf8', $_);
+ $image =~ s[^.+/][];
+ $image;
+ }
+ sort glob("$openslxConfig{'public-path'}/export/$type/*");
+ my %imageFiles;
+ foreach my $file (@files) {
+ if ($file =~ m[^(.+)@(.+)$]) {
+ # it's a link referring to a block device using this image,
+ # we collect the name of the block device:
+ push @{$imageFiles{$1}}, $2;
+ } else {
+ # it's an image file, we setup an empty array of block devices:
+ $imageFiles{$file} = [];
+ }
+ }
+ print join(
+ '',
+ map {
+ my $devices = join(',', @{$imageFiles{$_}});
+ my $name = "${_}::$type";
+ if (length($devices)) {
+ "\t$name".substr(' ' x 30, length($name))."($devices)\n";
+ } else {
+ "\t$name\n";
+ }
+ }
+ grep {
+ # filter out RSYNC_TMP folders:
+ $_ !~ m[###];
+ }
+ sort keys %imageFiles
+ );
+ }
} elsif ($action =~ m[^list-in]i) {
- my @vendorOSDirs
- = grep { -d $_ } glob("$openslxConfig{'private-path'}/stage1/*");
- print _tr("List of installed vendor-OSes:\n");
- print join(
- '',
- map {
- my $vendorOS = decode('utf8', $_);
- $vendorOS =~ s[^.+/][];
- "\t$vendorOS\n";
- }
- sort @vendorOSDirs
- );
+ my @vendorOSDirs
+ = grep { -d $_ } glob("$openslxConfig{'private-path'}/stage1/*");
+ print _tr("List of installed vendor-OSes:\n");
+ print join(
+ '',
+ map {
+ my $vendorOS = decode('utf8', $_);
+ $vendorOS =~ s[^.+/][];
+ "\t$vendorOS\n";
+ }
+ sort @vendorOSDirs
+ );
} elsif ($action =~ m[^list-ty]i) {
- print _tr("List of supported export types:\n\t");
- print join("\n\t", sort @supportedExportTypes) . "\n";
+ print _tr("List of supported export types:\n\t");
+ print join("\n\t", sort @supportedExportTypes) . "\n";
} elsif ($action =~ m[^export]i) {
- if (scalar(@ARGV) != 2) {
- print STDERR _tr(
- "You need to specify exactly one vendor-os-name and one export-type!\n"
- );
- pod2usage(2);
- }
- my $vendorOSName = shift @ARGV;
- my $exportType = shift @ARGV;
-
- # we chdir into the script's folder such that all relative paths have
- # a known starting point:
- chdir($FindBin::RealBin)
- or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!);
-
- # create OSExport-engine for given export type and start it:
- my $engine = OpenSLX::OSExport::Engine->new;
- $engine->initializeForNew($vendorOSName, $exportType);
- if (!-e $engine->{'vendor-os-path'}) {
- die _tr("vendor-OS '%s' doesn't exist, giving up!\n",
- $engine->{'vendor-os-path'});
- }
- $engine->exportVendorOS();
+ if (scalar(@ARGV) != 2) {
+ print STDERR _tr(
+ "You need to specify exactly one vendor-os-name and one export-type!\n"
+ );
+ pod2usage(2);
+ }
+ my $vendorOSName = shift @ARGV;
+ my $exportType = shift @ARGV;
+
+ # we chdir into the script's folder such that all relative paths have
+ # a known starting point:
+ chdir($FindBin::RealBin)
+ or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!);
+
+ # create OSExport-engine for given export type and start it:
+ my $engine = OpenSLX::OSExport::Engine->new;
+ $engine->initializeForNew($vendorOSName, $exportType);
+ if (!-e $engine->{'vendor-os-path'}) {
+ die _tr("vendor-OS '%s' doesn't exist, giving up!\n",
+ $engine->{'vendor-os-path'});
+ }
+ $engine->exportVendorOS();
} elsif ($action =~ m[^remove]i) {
- if (scalar(@ARGV) != 1) {
- print STDERR _tr("You need to specify exactly one export-name!\n");
- pod2usage(2);
- }
- my $exportName = shift @ARGV;
-
- # we chdir into the script's folder such that all relative paths have
- # a known starting point:
- chdir($FindBin::RealBin)
- or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!);
-
- # create OSExport-engine for given export type and start it:
- my $engine = OpenSLX::OSExport::Engine->new;
- $engine->initializeFromExisting($exportName);
- $engine->purgeExport();
+ if (scalar(@ARGV) != 1) {
+ print STDERR _tr("You need to specify exactly one export-name!\n");
+ pod2usage(2);
+ }
+ my $exportName = shift @ARGV;
+
+ # we chdir into the script's folder such that all relative paths have
+ # a known starting point:
+ chdir($FindBin::RealBin)
+ or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!);
+
+ # create OSExport-engine for given export type and start it:
+ my $engine = OpenSLX::OSExport::Engine->new;
+ $engine->initializeFromExisting($exportName);
+ $engine->purgeExport();
} else {
- vlog(0, _tr(unshiftHereDoc(<<' END-OF-HERE'), $0));
- You need to specify exactly one action:
- export
- list-exported
- list-installed
- list-types
- remove
- Try '%s --help' for more info.
- END-OF-HERE
+ vlog(0, _tr(unshiftHereDoc(<<' END-OF-HERE'), $0));
+ You need to specify exactly one action:
+ export
+ list-exported
+ list-installed
+ list-types
+ remove
+ Try '%s --help' for more info.
+ END-OF-HERE
}
=head1 NAME
diff --git a/installer/slxos-setup b/installer/slxos-setup
index 1d17048d..d46030a7 100755
--- a/installer/slxos-setup
+++ b/installer/slxos-setup
@@ -30,7 +30,7 @@ use lib "$FindBin::RealBin";
use lib "$FindBin::RealBin/../lib";
use lib "$FindBin::RealBin/../config-db";
- # development path to config-db
+ # development path to config-db
use OpenSLX::Basics;
use OpenSLX::OSSetup::Engine;
@@ -39,24 +39,24 @@ use OpenSLX::Utils;
my %option;
GetOptions(
- 'help|?' => \$option{helpReq},
- 'man' => \$option{manReq},
- 'version' => \$option{versionReq},
+ 'help|?' => \$option{helpReq},
+ 'man' => \$option{manReq},
+ 'version' => \$option{versionReq},
) or pod2usage(2);
pod2usage(-msg => $abstract, -verbose => 0, -exitval => 1) if $option{helpReq};
if ($option{manReq}) {
- # avoid dubious problem with perldoc in combination with UTF-8 that
- # leads to strange dashes and single-quotes being used
- $ENV{LC_ALL} = 'POSIX';
- pod2usage(-verbose => 2)
+ # avoid dubious problem with perldoc in combination with UTF-8 that
+ # leads to strange dashes and single-quotes being used
+ $ENV{LC_ALL} = 'POSIX';
+ pod2usage(-verbose => 2)
}
if ($option{versionReq}) {
- system('slxversion');
- exit 1;
+ system('slxversion');
+ exit 1;
}
if ($> != 0) {
- die _tr("Sorry, this script can only be executed by the superuser!\n");
+ die _tr("Sorry, this script can only be executed by the superuser!\n");
}
openslxInit();
@@ -66,130 +66,130 @@ my $action = shift @ARGV || '';
# create ossetup-engine for given distro and start it:
my $engine = OpenSLX::OSSetup::Engine->new;
if ($action =~ m[^import]i) {
- my $vendorOSName = shift @ARGV;
- if (!defined $vendorOSName) {
- print STDERR _tr("You need to give the name of the vendor-os you'd like to import!\n");
- pod2usage(2);
- }
- # we chdir into the script's folder such that all relative paths have
- # a known starting point:
- chdir($FindBin::RealBin)
- or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!);
- $engine->initialize($vendorOSName, 'import');
- if (!-e $engine->{'vendor-os-path'}) {
- die _tr("'%s' doesn't exist, giving up!\n", $engine->{'vendor-os-path'});
- }
- $engine->addInstalledVendorOSToConfigDB();
+ my $vendorOSName = shift @ARGV;
+ if (!defined $vendorOSName) {
+ print STDERR _tr("You need to give the name of the vendor-os you'd like to import!\n");
+ pod2usage(2);
+ }
+ # we chdir into the script's folder such that all relative paths have
+ # a known starting point:
+ chdir($FindBin::RealBin)
+ or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!);
+ $engine->initialize($vendorOSName, 'import');
+ if (!-e $engine->{'vendor-os-path'}) {
+ die _tr("'%s' doesn't exist, giving up!\n", $engine->{'vendor-os-path'});
+ }
+ $engine->addInstalledVendorOSToConfigDB();
} elsif ($action =~ m[^update]i) {
- my $vendorOSName = shift @ARGV;
- if (!defined $vendorOSName) {
- print STDERR _tr("You need to give the name of the vendor-os you'd like to update!\n");
- pod2usage(2);
- }
- # we chdir into the script's folder such that all relative paths have
- # a known starting point:
- chdir($FindBin::RealBin)
- or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!);
- $engine->initialize($vendorOSName, 'update');
- $engine->updateVendorOS();
+ my $vendorOSName = shift @ARGV;
+ if (!defined $vendorOSName) {
+ print STDERR _tr("You need to give the name of the vendor-os you'd like to update!\n");
+ pod2usage(2);
+ }
+ # we chdir into the script's folder such that all relative paths have
+ # a known starting point:
+ chdir($FindBin::RealBin)
+ or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!);
+ $engine->initialize($vendorOSName, 'update');
+ $engine->updateVendorOS();
} elsif ($action =~ m[^shell]i) {
- my $vendorOSName = shift @ARGV;
- if (!defined $vendorOSName) {
- print STDERR _tr("You need to give the name of the vendor-os you'd like to start of shell for!\n");
- pod2usage(2);
- }
- # we chdir into the script's folder such that all relative paths have
- # a known starting point:
- chdir($FindBin::RealBin)
- or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!);
- $engine->initialize($vendorOSName, 'shell');
- $engine->startChrootedShellForVendorOS();
+ my $vendorOSName = shift @ARGV;
+ if (!defined $vendorOSName) {
+ print STDERR _tr("You need to give the name of the vendor-os you'd like to start of shell for!\n");
+ pod2usage(2);
+ }
+ # we chdir into the script's folder such that all relative paths have
+ # a known starting point:
+ chdir($FindBin::RealBin)
+ or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!);
+ $engine->initialize($vendorOSName, 'shell');
+ $engine->startChrootedShellForVendorOS();
} elsif ($action =~ m[^install]i) {
- my $vendorOSName = shift @ARGV;
- if (!defined $vendorOSName) {
- print STDERR _tr("You need to give the name of the vendor-os you'd like to install!\n");
- pod2usage(2);
- }
- # we chdir into the script's folder such that all relative paths have
- # a known starting point:
- chdir($FindBin::RealBin)
- or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!);
- $engine->initialize($vendorOSName, 'install');
- my $rootPassword = readPassword("root-password for new system> ");
- $engine->installVendorOS({ 'root-password' => $rootPassword });
+ my $vendorOSName = shift @ARGV;
+ if (!defined $vendorOSName) {
+ print STDERR _tr("You need to give the name of the vendor-os you'd like to install!\n");
+ pod2usage(2);
+ }
+ # we chdir into the script's folder such that all relative paths have
+ # a known starting point:
+ chdir($FindBin::RealBin)
+ or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!);
+ $engine->initialize($vendorOSName, 'install');
+ my $rootPassword = readPassword("root-password for new system> ");
+ $engine->installVendorOS({ 'root-password' => $rootPassword });
} elsif ($action =~ m[^clone]i) {
- my $source = shift @ARGV;
- my $vendorOSName = shift @ARGV;
- if (!defined $source || !defined $vendorOSName) {
- print STDERR _tr("You need to specify exactly one source and one vendor-OS-name!\n");
- pod2usage(2);
- }
- # we chdir into the script's folder such that all relative paths have
- # a known starting point:
- chdir($FindBin::RealBin)
- or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!);
- $engine->initialize($vendorOSName, 'clone');
- $engine->cloneVendorOS($source);
+ my $source = shift @ARGV;
+ my $vendorOSName = shift @ARGV;
+ if (!defined $source || !defined $vendorOSName) {
+ print STDERR _tr("You need to specify exactly one source and one vendor-OS-name!\n");
+ pod2usage(2);
+ }
+ # we chdir into the script's folder such that all relative paths have
+ # a known starting point:
+ chdir($FindBin::RealBin)
+ or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!);
+ $engine->initialize($vendorOSName, 'clone');
+ $engine->cloneVendorOS($source);
} elsif ($action =~ m[^remove]i) {
- my $vendorOSName = shift @ARGV;
- if (!defined $vendorOSName) {
- print STDERR _tr("You need to specify exactly one vendor-OS-name!\n");
- pod2usage(2);
- }
- # we chdir into the script's folder such that all relative paths have
- # a known starting point:
- chdir($FindBin::RealBin)
- or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!);
- $engine->initialize($vendorOSName, 'remove');
- $engine->removeVendorOS();
+ my $vendorOSName = shift @ARGV;
+ if (!defined $vendorOSName) {
+ print STDERR _tr("You need to specify exactly one vendor-OS-name!\n");
+ pod2usage(2);
+ }
+ # we chdir into the script's folder such that all relative paths have
+ # a known starting point:
+ chdir($FindBin::RealBin)
+ or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!);
+ $engine->initialize($vendorOSName, 'remove');
+ $engine->removeVendorOS();
} elsif ($action =~ m[^list-se]i) {
- my $vendorOSName = shift @ARGV;
- if (!defined $vendorOSName) {
- print STDERR _tr("You need to specify exactly one vendor-OS-name!\n");
- pod2usage(2);
- }
- # we chdir into the script's folder such that all relative paths have
- # a known starting point:
- chdir($FindBin::RealBin)
- or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!);
- $engine->initialize($vendorOSName, 'install');
- print _tr("List of supported selections for '%s':\n", $vendorOSName);
- print join('', map { "\t$_\n" }
- sort keys %{$engine->{'distro-info'}->{selection}});
+ my $vendorOSName = shift @ARGV;
+ if (!defined $vendorOSName) {
+ print STDERR _tr("You need to specify exactly one vendor-OS-name!\n");
+ pod2usage(2);
+ }
+ # we chdir into the script's folder such that all relative paths have
+ # a known starting point:
+ chdir($FindBin::RealBin)
+ or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!);
+ $engine->initialize($vendorOSName, 'install');
+ print _tr("List of supported selections for '%s':\n", $vendorOSName);
+ print join('', map { "\t$_\n" }
+ sort keys %{$engine->{'distro-info'}->{selection}});
} elsif ($action =~ m[^list-su]i) {
- print _tr("List of supported distros:\n");
- print join('', map {
- "\t$_"
- .(' 'x(20-length($_)))
- ."\t($supportedDistros{$_}->{support})\n"
- }
- sort keys %supportedDistros);
+ print _tr("List of supported distros:\n");
+ print join('', map {
+ "\t$_"
+ .(' 'x(20-length($_)))
+ ."\t($supportedDistros{$_}->{support})\n"
+ }
+ sort keys %supportedDistros);
} elsif ($action =~ m[^list-in]i) {
- print _tr("List of installed vendor-OSes:\n");
- print join(
- '',
- map {
- my $vendorOS = decode('utf8', $_);
- $vendorOS =~ s[^.+/][];
- "\t$vendorOS\n";
- }
- grep { -d $_ }
- sort glob("$openslxConfig{'private-path'}/stage1/*")
- );
+ print _tr("List of installed vendor-OSes:\n");
+ print join(
+ '',
+ map {
+ my $vendorOS = decode('utf8', $_);
+ $vendorOS =~ s[^.+/][];
+ "\t$vendorOS\n";
+ }
+ grep { -d $_ }
+ sort glob("$openslxConfig{'private-path'}/stage1/*")
+ );
} else {
- vlog(0, _tr(unshiftHereDoc(<<' END-OF-HERE'), $0));
- You need to specify exactly one action:
- clone
- import-into-db
- install
- list-installed
- list-selections
- list-supported
- remove
- shell
- update
- Try '%s --help' for more info.
- END-OF-HERE
+ vlog(0, _tr(unshiftHereDoc(<<' END-OF-HERE'), $0));
+ You need to specify exactly one action:
+ clone
+ import-into-db
+ install
+ list-installed
+ list-selections
+ list-supported
+ remove
+ shell
+ update
+ Try '%s --help' for more info.
+ END-OF-HERE
}
@@ -289,9 +289,9 @@ cloned, imported or updated. It corresponds to a folder in the OpenSLX-
stage1-path (usually /var/opt/openslx/stage1).
The general format of a vendor-os-name is:
- <distro-name>-<release-version>
+ <distro-name>-<release-version>
or
- <distro-name>-<release-version>-<selection>
+ <distro-name>-<release-version>-<selection>
The distro-name is something like 'suse' or 'fedora', and the release-version
is a numerical version, e.g. '10.1' or '6'.