summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--installer/OpenSLX/OSSetup/Distro/Debian.pm38
-rw-r--r--installer/OpenSLX/OSSetup/Distro/Debian_3_1.pm21
-rw-r--r--installer/OpenSLX/OSSetup/Distro/Debian_4_0.pm21
-rw-r--r--installer/OpenSLX/OSSetup/Distro/Fedora.pm41
-rw-r--r--installer/OpenSLX/OSSetup/Distro/Fedora_6.pm17
-rw-r--r--installer/OpenSLX/OSSetup/Distro/Fedora_6_x86_64.pm17
-rw-r--r--installer/OpenSLX/OSSetup/Distro/SUSE.pm65
-rw-r--r--installer/OpenSLX/OSSetup/Distro/SUSE_10_1.pm40
-rw-r--r--installer/OpenSLX/OSSetup/Distro/SUSE_10_1_x86_64.pm40
-rw-r--r--installer/OpenSLX/OSSetup/Distro/SUSE_10_2.pm40
-rw-r--r--installer/OpenSLX/OSSetup/Distro/SUSE_10_2_x86_64.pm40
-rw-r--r--installer/OpenSLX/OSSetup/Distro/Ubuntu.pm45
-rw-r--r--installer/OpenSLX/OSSetup/Distro/Ubuntu_6_10.pm65
-rw-r--r--installer/OpenSLX/OSSetup/Engine.pm257
-rw-r--r--installer/OpenSLX/OSSetup/MetaPackager/apt.pm72
-rw-r--r--installer/OpenSLX/OSSetup/Packager/Base.pm10
-rw-r--r--installer/OpenSLX/OSSetup/Packager/dpkg.pm98
-rw-r--r--installer/OpenSLX/OSSetup/Packager/rpm.pm2
-rw-r--r--lib/OpenSLX/Basics.pm127
-rw-r--r--lib/OpenSLX/Utils.pm73
20 files changed, 728 insertions, 401 deletions
diff --git a/installer/OpenSLX/OSSetup/Distro/Debian.pm b/installer/OpenSLX/OSSetup/Distro/Debian.pm
new file mode 100644
index 00000000..48391f55
--- /dev/null
+++ b/installer/OpenSLX/OSSetup/Distro/Debian.pm
@@ -0,0 +1,38 @@
+# Copyright (c) 2006, 2007 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# Debian.pm
+# - provides Debian-specific overrides of the OpenSLX OSSetup API.
+# -----------------------------------------------------------------------------
+package OpenSLX::OSSetup::Distro::Debian;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::OSSetup::Distro::Base);
+
+use OpenSLX::Basics;
+
+################################################################################
+### implementation
+################################################################################
+sub initialize
+{
+ 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;
+}
+
+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 30882c8d..c9476d25 100644
--- a/installer/OpenSLX/OSSetup/Distro/Debian_3_1.pm
+++ b/installer/OpenSLX/OSSetup/Distro/Debian_3_1.pm
@@ -16,7 +16,7 @@ package OpenSLX::OSSetup::Distro::Debian_3_1;
use strict;
use warnings;
-use base qw(OpenSLX::OSSetup::Distro::Base);
+use base qw(OpenSLX::OSSetup::Distro::Debian);
use OpenSLX::Basics;
@@ -32,25 +32,6 @@ sub new
return bless $self, $class;
}
-sub initialize
-{
- 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;
-}
-
-sub fixPrerequiredFiles
-{
- my $self = shift;
- my $stage1cDir = shift;
- return;
-}
-
sub initDistroInfo
{
my $self = shift;
diff --git a/installer/OpenSLX/OSSetup/Distro/Debian_4_0.pm b/installer/OpenSLX/OSSetup/Distro/Debian_4_0.pm
index 23ca8a77..2326f342 100644
--- a/installer/OpenSLX/OSSetup/Distro/Debian_4_0.pm
+++ b/installer/OpenSLX/OSSetup/Distro/Debian_4_0.pm
@@ -16,7 +16,7 @@ package OpenSLX::OSSetup::Distro::Debian_4_0;
use strict;
use warnings;
-use base qw(OpenSLX::OSSetup::Distro::Base);
+use base qw(OpenSLX::OSSetup::Distro::Debian);
use OpenSLX::Basics;
@@ -32,25 +32,6 @@ sub new
return bless $self, $class;
}
-sub initialize
-{
- 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;
-}
-
-sub fixPrerequiredFiles
-{
- my $self = shift;
- my $stage1cDir = shift;
- return;
-}
-
sub initDistroInfo
{
my $self = shift;
diff --git a/installer/OpenSLX/OSSetup/Distro/Fedora.pm b/installer/OpenSLX/OSSetup/Distro/Fedora.pm
new file mode 100644
index 00000000..5206a07e
--- /dev/null
+++ b/installer/OpenSLX/OSSetup/Distro/Fedora.pm
@@ -0,0 +1,41 @@
+# Copyright (c) 2006, 2007 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# Fedora.pm
+# - provides Fedora-specific overrides of the OpenSLX OSSetup API.
+# -----------------------------------------------------------------------------
+package OpenSLX::OSSetup::Distro::Fedora;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::OSSetup::Distro::Base);
+
+use OpenSLX::Basics;
+
+################################################################################
+### implementation
+################################################################################
+sub initialize
+{
+ 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;
+}
+
+1; \ No newline at end of file
diff --git a/installer/OpenSLX/OSSetup/Distro/Fedora_6.pm b/installer/OpenSLX/OSSetup/Distro/Fedora_6.pm
index 6b384ebd..4417136a 100644
--- a/installer/OpenSLX/OSSetup/Distro/Fedora_6.pm
+++ b/installer/OpenSLX/OSSetup/Distro/Fedora_6.pm
@@ -16,7 +16,7 @@ package OpenSLX::OSSetup::Distro::Fedora_6;
use strict;
use warnings;
-use base qw(OpenSLX::OSSetup::Distro::Base);
+use base qw(OpenSLX::OSSetup::Distro::Fedora);
use OpenSLX::Basics;
@@ -32,21 +32,6 @@ sub new
return bless $self, $class;
}
-sub initialize
-{
- 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;
-}
-
sub initDistroInfo
{
my $self = shift;
diff --git a/installer/OpenSLX/OSSetup/Distro/Fedora_6_x86_64.pm b/installer/OpenSLX/OSSetup/Distro/Fedora_6_x86_64.pm
index a4addcdb..8cd64775 100644
--- a/installer/OpenSLX/OSSetup/Distro/Fedora_6_x86_64.pm
+++ b/installer/OpenSLX/OSSetup/Distro/Fedora_6_x86_64.pm
@@ -16,7 +16,7 @@ package OpenSLX::OSSetup::Distro::Fedora_6_x86_64;
use strict;
use warnings;
-use base qw(OpenSLX::OSSetup::Distro::Base);
+use base qw(OpenSLX::OSSetup::Distro::Fedora);
use OpenSLX::Basics;
@@ -32,21 +32,6 @@ sub new
return bless $self, $class;
}
-sub initialize
-{
- 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;
-}
-
sub initDistroInfo
{
my $self = shift;
diff --git a/installer/OpenSLX/OSSetup/Distro/SUSE.pm b/installer/OpenSLX/OSSetup/Distro/SUSE.pm
new file mode 100644
index 00000000..065fbf2c
--- /dev/null
+++ b/installer/OpenSLX/OSSetup/Distro/SUSE.pm
@@ -0,0 +1,65 @@
+# Copyright (c) 2006, 2007 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# SUSE.pm
+# - provides SUSE-specific overrides of the OpenSLX OSSetup API.
+# -----------------------------------------------------------------------------
+package OpenSLX::OSSetup::Distro::SUSE;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::OSSetup::Distro::Base);
+
+use OpenSLX::Basics;
+
+################################################################################
+### implementation
+################################################################################
+sub initialize
+{
+ my $self = shift;
+ my $engine = shift;
+
+ $self->SUPER::initialize($engine);
+ $self->{'packager-type'} = 'rpm';
+ $self->{'meta-packager-type'} = $ENV{SLX_META_PACKAGER} || 'smart';
+ $ENV{YAST_IS_RUNNING} = "instsys";
+ return;
+}
+
+sub fixPrerequiredFiles
+{
+ my $self = shift;
+ my $stage1cDir = shift;
+
+ chown(0, 0, "$stage1cDir/etc/group", "$stage1cDir/etc/passwd",
+ "$stage1cDir/etc/shadow");
+ return;
+}
+
+sub updateDistroConfig
+{
+ my $self = shift;
+
+ # make sure there's a /dev/zero, as SuSEconfig requires it:
+ if (!-e "/dev/zero" && slxsystem("mknod /dev/zero c 1 5")) {
+ die _tr("unable to create node '%s' (%s)\n", "/dev/zero", $!);
+ }
+ # 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;
+}
+
+
+1;
diff --git a/installer/OpenSLX/OSSetup/Distro/SUSE_10_1.pm b/installer/OpenSLX/OSSetup/Distro/SUSE_10_1.pm
index b25b167d..27125f41 100644
--- a/installer/OpenSLX/OSSetup/Distro/SUSE_10_1.pm
+++ b/installer/OpenSLX/OSSetup/Distro/SUSE_10_1.pm
@@ -16,7 +16,7 @@ package OpenSLX::OSSetup::Distro::SUSE_10_1;
use strict;
use warnings;
-use base qw(OpenSLX::OSSetup::Distro::Base);
+use base qw(OpenSLX::OSSetup::Distro::SUSE);
use OpenSLX::Basics;
@@ -32,44 +32,6 @@ sub new
return bless $self, $class;
}
-sub initialize
-{
- my $self = shift;
- my $engine = shift;
-
- $self->SUPER::initialize($engine);
- $self->{'packager-type'} = 'rpm';
- $self->{'meta-packager-type'} = $ENV{SLX_META_PACKAGER} || 'smart';
- $ENV{YAST_IS_RUNNING} = "instsys";
- return;
-}
-
-sub fixPrerequiredFiles
-{
- my $self = shift;
- my $stage1cDir = shift;
-
- chown(0, 0, "$stage1cDir/etc/group", "$stage1cDir/etc/passwd",
- "$stage1cDir/etc/shadow");
- return;
-}
-
-sub updateDistroConfig
-{
- my $self = shift;
-
- # make sure there's a /dev/zero, as SuSEconfig requires it:
- if (!-e "/dev/zero" && slxsystem("mknod /dev/zero c 1 5")) {
- die _tr("unable to create node '%s' (%s)\n", "/dev/zero", $!);
- }
- # 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 initDistroInfo
{
my $self = shift;
diff --git a/installer/OpenSLX/OSSetup/Distro/SUSE_10_1_x86_64.pm b/installer/OpenSLX/OSSetup/Distro/SUSE_10_1_x86_64.pm
index 91210146..5f73887d 100644
--- a/installer/OpenSLX/OSSetup/Distro/SUSE_10_1_x86_64.pm
+++ b/installer/OpenSLX/OSSetup/Distro/SUSE_10_1_x86_64.pm
@@ -16,7 +16,7 @@ package OpenSLX::OSSetup::Distro::SUSE_10_1_x86_64;
use strict;
use warnings;
-use base qw(OpenSLX::OSSetup::Distro::Base);
+use base qw(OpenSLX::OSSetup::Distro::SUSE);
use OpenSLX::Basics;
@@ -32,44 +32,6 @@ sub new
return bless $self, $class;
}
-sub initialize
-{
- my $self = shift;
- my $engine = shift;
-
- $self->SUPER::initialize($engine);
- $self->{'packager-type'} = 'rpm';
- $self->{'meta-packager-type'} = $ENV{SLX_META_PACKAGER} || 'smart';
- $ENV{YAST_IS_RUNNING} = "instsys";
- return;
-}
-
-sub fixPrerequiredFiles
-{
- my $self = shift;
- my $stage1cDir = shift;
-
- chown(0, 0, "$stage1cDir/etc/group", "$stage1cDir/etc/passwd",
- "$stage1cDir/etc/shadow");
- return;
-}
-
-sub updateDistroConfig
-{
- my $self = shift;
-
- # make sure there's a /dev/zero, as SuSEconfig requires it:
- if (!-e "/dev/zero" && slxsystem("mknod /dev/zero c 1 5")) {
- die _tr("unable to create node '%s' (%s)\n", "/dev/zero", $!);
- }
- # 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 initDistroInfo
{
my $self = shift;
diff --git a/installer/OpenSLX/OSSetup/Distro/SUSE_10_2.pm b/installer/OpenSLX/OSSetup/Distro/SUSE_10_2.pm
index 71f4b57b..0513050f 100644
--- a/installer/OpenSLX/OSSetup/Distro/SUSE_10_2.pm
+++ b/installer/OpenSLX/OSSetup/Distro/SUSE_10_2.pm
@@ -16,7 +16,7 @@ package OpenSLX::OSSetup::Distro::SUSE_10_2;
use strict;
use warnings;
-use base qw(OpenSLX::OSSetup::Distro::Base);
+use base qw(OpenSLX::OSSetup::Distro::SUSE);
use OpenSLX::Basics;
@@ -30,44 +30,6 @@ sub new
return bless $self, $class;
}
-sub initialize
-{
- my $self = shift;
- my $engine = shift;
-
- $self->SUPER::initialize($engine);
- $self->{'packager-type'} = 'rpm';
- $self->{'meta-packager-type'} = $ENV{SLX_META_PACKAGER} || 'smart';
- $ENV{YAST_IS_RUNNING} = "instsys";
- return;
-}
-
-sub fixPrerequiredFiles
-{
- my $self = shift;
- my $stage1cDir = shift;
-
- chown(0, 0, "$stage1cDir/etc/group", "$stage1cDir/etc/passwd",
- "$stage1cDir/etc/shadow");
- return;
-}
-
-sub updateDistroConfig
-{
- my $self = shift;
-
- # make sure there's a /dev/zero, as SuSEconfig requires it:
- if (!-e "/dev/zero" && slxsystem("mknod /dev/zero c 1 5")) {
- die _tr("unable to create node '%s' (%s)\n", "/dev/zero", $!);
- }
- # 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 initDistroInfo
{
my $self = shift;
diff --git a/installer/OpenSLX/OSSetup/Distro/SUSE_10_2_x86_64.pm b/installer/OpenSLX/OSSetup/Distro/SUSE_10_2_x86_64.pm
index 85715e40..2b6d4d7b 100644
--- a/installer/OpenSLX/OSSetup/Distro/SUSE_10_2_x86_64.pm
+++ b/installer/OpenSLX/OSSetup/Distro/SUSE_10_2_x86_64.pm
@@ -16,7 +16,7 @@ package OpenSLX::OSSetup::Distro::SUSE_10_2_x86_64;
use strict;
use warnings;
-use base qw(OpenSLX::OSSetup::Distro::Base);
+use base qw(OpenSLX::OSSetup::Distro::SUSE);
use OpenSLX::Basics;
@@ -32,44 +32,6 @@ sub new
return bless $self, $class;
}
-sub initialize
-{
- my $self = shift;
- my $engine = shift;
-
- $self->SUPER::initialize($engine);
- $self->{'packager-type'} = 'rpm';
- $self->{'meta-packager-type'} = $ENV{SLX_META_PACKAGER} || 'smart';
- $ENV{YAST_IS_RUNNING} = "instsys";
- return;
-}
-
-sub fixPrerequiredFiles
-{
- my $self = shift;
- my $stage1cDir = shift;
-
- chown(0, 0, "$stage1cDir/etc/group", "$stage1cDir/etc/passwd",
- "$stage1cDir/etc/shadow");
- return;
-}
-
-sub updateDistroConfig
-{
- my $self = shift;
-
- # make sure there's a /dev/zero, as SuSEconfig requires it:
- if (!-e "/dev/zero" && slxsystem("mknod /dev/zero c 1 5")) {
- die _tr("unable to create node '%s' (%s)\n", "/dev/zero", $!);
- }
- # 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 initDistroInfo
{
my $self = shift;
diff --git a/installer/OpenSLX/OSSetup/Distro/Ubuntu.pm b/installer/OpenSLX/OSSetup/Distro/Ubuntu.pm
new file mode 100644
index 00000000..17c30662
--- /dev/null
+++ b/installer/OpenSLX/OSSetup/Distro/Ubuntu.pm
@@ -0,0 +1,45 @@
+# Copyright (c) 2006, 2007 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# Ubuntu.pm
+# - provides Ubuntu-specific overrides of the OpenSLX OSSetup API.
+# -----------------------------------------------------------------------------
+package OpenSLX::OSSetup::Distro::Ubuntu;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::OSSetup::Distro::Base);
+
+use OpenSLX::Basics;
+
+################################################################################
+### implementation
+################################################################################
+sub initialize
+{
+ 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;
+}
+
+sub fixPrerequiredFiles
+{
+ my $self = shift;
+ my $stage1cDir = shift;
+ return;
+}
+
+1; \ No newline at end of file
diff --git a/installer/OpenSLX/OSSetup/Distro/Ubuntu_6_10.pm b/installer/OpenSLX/OSSetup/Distro/Ubuntu_6_10.pm
new file mode 100644
index 00000000..4225b9aa
--- /dev/null
+++ b/installer/OpenSLX/OSSetup/Distro/Ubuntu_6_10.pm
@@ -0,0 +1,65 @@
+# Copyright (c) 2006, 2007 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# Ubuntu_6_10.pm
+# - provides Ubuntu-6.10-specific overrides of the OpenSLX OSSetup API.
+# -----------------------------------------------------------------------------
+package OpenSLX::OSSetup::Distro::Ubuntu_6_10;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::OSSetup::Distro::Ubuntu);
+
+use OpenSLX::Basics;
+
+################################################################################
+### implementation
+################################################################################
+sub new
+{
+ my $class = shift;
+ my $self = {
+ 'base-name' => 'ubuntu-6.10',
+ };
+ return bless $self, $class;
+}
+
+sub initDistroInfo
+{
+ my $self = shift;
+ $self->{config}->{'repository'} = {
+ 'base' => {
+ 'urls' => "
+ ",
+ 'name' => 'Ubuntu 6.10',
+ 'repo-subdir' => 'dists/edgy',
+ },
+ };
+
+ $self->{config}->{'package-subdir'} = 'pool';
+
+ $self->{config}->{'prereq-packages'} = "
+ main/d/debootstrap/debootstrap_0.3.3.0ubuntu7_all.deb
+ ";
+
+ $self->{config}->{'bootstrap-prereq-packages'} = "
+ ";
+
+ $self->{config}->{'bootstrap-packages'} = "
+ ";
+
+ $self->{config}->{'selection'} = {
+ 'default' => "kmail",
+ };
+ return;
+}
+
+1; \ No newline at end of file
diff --git a/installer/OpenSLX/OSSetup/Engine.pm b/installer/OpenSLX/OSSetup/Engine.pm
index e5b76f3d..575e25f5 100644
--- a/installer/OpenSLX/OSSetup/Engine.pm
+++ b/installer/OpenSLX/OSSetup/Engine.pm
@@ -79,7 +79,7 @@ use vars qw(%supportedDistros);
module => 'Ubuntu_6_06', support => 'clone'
},
'ubuntu-6.10' => {
- module => 'Ubuntu_6_10', support => 'clone'
+ module => 'Ubuntu_6_10', support => 'clone,install'
},
'ubuntu-7.04' => {
module => 'Ubuntu_7_04', support => 'clone'
@@ -167,7 +167,7 @@ sub initialize
my $distro;
my $distroClass = $supportedDistros{lc($distroName)}->{module};
if ($actionType =~ m{^(install|update|shell)}) {
- $distro = instantiateClass($distroClass);
+ $distro = instantiateClass("OpenSLX::OSSetup::Distro::$distroClass");
}
else {
if (!eval {
@@ -203,7 +203,7 @@ sub initialize
);
}
$self->{'config-distro-info-dir'} = $configDistroInfoDir;
- $self->readDistroInfo();
+ $self->_readDistroInfo();
}
if (!$self->{'action-type'} eq 'install'
@@ -225,8 +225,8 @@ sub initialize
vlog(1, "vendor-OS path is '$self->{'vendor-os-path'}'");
if ($actionType =~ m{^(install|update|shell)}) {
- $self->createPackager();
- $self->createMetaPackager();
+ $self->_createPackager();
+ $self->_createMetaPackager();
}
return;
}
@@ -240,9 +240,9 @@ sub installVendorOS
die _tr("vendor-OS '%s' already exists, giving up!\n",
$self->{'vendor-os-path'});
}
- $self->createVendorOSPath();
+ $self->_createVendorOSPath();
- $self->startLocalURLServersAsNeeded();
+ $self->_startLocalURLServersAsNeeded();
my $baseSystemFile = "$self->{'vendor-os-path'}/.openslx-base-system";
if (-e $baseSystemFile) {
@@ -250,24 +250,24 @@ sub installVendorOS
}
else {
# basic setup, stage1a-c:
- $self->setupStage1A();
+ $self->_setupStage1A();
callInSubprocess(
sub {
# some tasks that involve a chrooted environment:
- $self->changePersonalityIfNeeded();
- $self->setupStage1B();
- $self->setupStage1C();
+ $self->_changePersonalityIfNeeded();
+ $self->_setupStage1B();
+ $self->_setupStage1C();
}
);
- $self->stage1C_cleanupBasicVendorOS();
+ $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();
+ $self->_changePersonalityIfNeeded();
+ $self->_setupStage1D();
}
);
@@ -285,7 +285,7 @@ sub installVendorOS
)
);
- $self->touchVendorOS();
+ $self->_touchVendorOS();
$self->addInstalledVendorOSToConfigDB();
return;
}
@@ -343,7 +343,7 @@ sub cloneVendorOS
}
}
- $self->createVendorOSPath();
+ $self->_createVendorOSPath();
$self->clone_fetchSource($source);
if ($source ne $lastCloneSource) {
@@ -368,7 +368,7 @@ sub cloneVendorOS
);
}
- $self->touchVendorOS();
+ $self->_touchVendorOS();
$self->addInstalledVendorOSToConfigDB();
return;
}
@@ -382,16 +382,16 @@ sub updateVendorOS
$self->{'vendor-os-path'});
}
- $self->startLocalURLServersAsNeeded();
+ $self->_startLocalURLServersAsNeeded();
callInSubprocess(
sub {
- $self->changePersonalityIfNeeded();
- $self->updateStage1D();
+ $self->_changePersonalityIfNeeded();
+ $self->_updateStage1D();
}
);
- $self->touchVendorOS();
+ $self->_touchVendorOS();
vlog(
0,
_tr("Vendor-OS '%s' updated succesfully.\n", $self->{'vendor-os-name'})
@@ -410,16 +410,16 @@ sub startChrootedShellForVendorOS
);
}
- $self->startLocalURLServersAsNeeded();
+ $self->_startLocalURLServersAsNeeded();
callInSubprocess(
sub {
- $self->changePersonalityIfNeeded();
- $self->startChrootedShellInStage1D();
+ $self->_changePersonalityIfNeeded();
+ $self->_startChrootedShellInStage1D();
}
);
- $self->touchVendorOS();
+ $self->_touchVendorOS();
vlog(
0,
_tr(
@@ -442,16 +442,16 @@ sub callChrootedFunctionForVendorOS
);
}
- $self->startLocalURLServersAsNeeded();
+ $self->_startLocalURLServersAsNeeded();
callInSubprocess(
sub {
- $self->changePersonalityIfNeeded();
- $self->callChrootedFunctionInStage1D($function);
+ $self->_changePersonalityIfNeeded();
+ $self->_callChrootedFunctionInStage1D($function);
}
);
- $self->touchVendorOS();
+ $self->_touchVendorOS();
vlog(
0,
_tr(
@@ -607,7 +607,7 @@ sub pickKernelFile
################################################################################
### implementation methods
################################################################################
-sub readDistroInfo
+sub _readDistroInfo
{
my $self = shift;
@@ -685,7 +685,7 @@ sub readDistroInfo
return;
}
-sub createVendorOSPath
+sub _createVendorOSPath
{
my $self = shift;
@@ -696,7 +696,7 @@ sub createVendorOSPath
return;
}
-sub touchVendorOS
+sub _touchVendorOS
{
my $self = shift;
@@ -707,7 +707,7 @@ sub touchVendorOS
return;
}
-sub createPackager
+sub _createPackager
{
my $self = shift;
@@ -719,7 +719,7 @@ sub createPackager
return;
}
-sub createMetaPackager
+sub _createMetaPackager
{
my $self = shift;
@@ -741,7 +741,7 @@ sub createMetaPackager
return;
}
-sub sortRepositoryURLs
+sub _sortRepositoryURLs
{
my $self = shift;
my $repoInfo = shift;
@@ -769,7 +769,7 @@ sub sortRepositoryURLs
return \@URLs;
}
-sub downloadBaseFiles
+sub _downloadBaseFiles
{
my $self = shift;
my $files = shift;
@@ -823,7 +823,7 @@ sub downloadBaseFiles
return @foundFiles;
}
-sub startLocalURLServersAsNeeded
+sub _startLocalURLServersAsNeeded
{
my $self = shift;
@@ -835,7 +835,7 @@ sub startLocalURLServersAsNeeded
next if $localURL =~ m[^\w+:];
if (!exists $self->{'local-http-servers'}->{$localURL}) {
my $busyboxName =
- $self->hostIs64Bit()
+ $self->_hostIs64Bit()
? 'busybox.x86_64'
: 'busybox.i586';
my $busybox =
@@ -859,7 +859,7 @@ sub startLocalURLServersAsNeeded
return;
}
-sub setupStage1A
+sub _setupStage1A
{
my $self = shift;
@@ -878,47 +878,32 @@ sub setupStage1A
$stage1cDir, $!);
}
- $self->stage1A_createBusyboxEnvironment();
- $self->stage1A_copyPrerequiredFiles();
- $self->stage1A_copyTrustedPackageKeys();
- $self->stage1A_createRequiredFiles();
+ $self->_stage1A_createBusyboxEnvironment();
+ $self->_stage1A_copyPrerequiredFiles();
+ $self->_stage1A_copyTrustedPackageKeys();
+ $self->_stage1A_createRequiredFiles();
return;
}
-sub stage1A_createBusyboxEnvironment
+sub _stage1A_createBusyboxEnvironment
{
my $self = shift;
# copy busybox and all required binaries into stage1a-dir:
vlog(1, "creating busybox-environment...");
- my $busyboxName = $self->hostIs64Bit() ? 'busybox.x86_64' : 'busybox.i586';
- copyFile(
- "$openslxConfig{'base-path'}/share/busybox/$busyboxName",
- "$self->{stage1aDir}/bin", 'busybox'
- );
-
- # determine all required libraries and copy those, too:
- vlog(1, _tr("calling slxldd for $busyboxName"));
- my $slxlddCmd
- = "slxldd $openslxConfig{'base-path'}/share/busybox/$busyboxName";
- vlog(2, "executing: $slxlddCmd");
- my $requiredLibsStr = `$slxlddCmd`;
- if ($?) {
- die _tr(
- "slxldd couldn't determine the libs required by busybox! (%s)", $?
- );
- }
- chomp $requiredLibsStr;
- vlog(2, "slxldd results:\n$requiredLibsStr");
+ my $busyboxName = $self->_hostIs64Bit() ? 'busybox.x86_64' : 'busybox.i586';
+ my $requiredLibs = copyBinaryWithRequiredLibs({
+ 'binary' => "$openslxConfig{'base-path'}/share/busybox/$busyboxName",
+ 'targetFolder' => "$self->{stage1aDir}/bin",
+ 'libTargetFolder' => "$self->{stage1aDir}",
+ 'targetName' => 'busybox',
+ });
my $libcFolder;
- foreach my $lib (split "\n", $requiredLibsStr) {
- vlog(3, "copying lib '$lib'");
- my $libDir = dirname($lib);
- copyFile($lib, "$self->{stage1aDir}$libDir");
+ 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 = $libDir;
+ $libcFolder = dirname($lib);
}
}
@@ -928,7 +913,7 @@ sub stage1A_createBusyboxEnvironment
foreach my $linkTarget (split "\n", $links) {
linkFile('/bin/busybox', "$self->{stage1aDir}/$linkTarget");
}
- if ($self->hostIs64Bit()) {
+ if ($self->_hostIs64Bit()) {
if (!-e "$self->{stage1aDir}/lib64") {
linkFile('/lib', "$self->{stage1aDir}/lib64");
}
@@ -937,11 +922,11 @@ sub stage1A_createBusyboxEnvironment
}
}
- $self->stage1A_setupResolver($libcFolder);
+ $self->_stage1A_setupResolver($libcFolder);
return;
}
-sub stage1A_setupResolver
+sub _stage1A_setupResolver
{
my $self = shift;
my $libcFolder = shift;
@@ -951,9 +936,11 @@ sub stage1A_setupResolver
$libcFolder = '/lib';
}
- copyFile('/etc/resolv.conf', "$self->{stage1aDir}/etc");
- copyFile("$libcFolder/libresolv*", "$self->{stage1aDir}$libcFolder");
- copyFile("$libcFolder/libnss_dns*", "$self->{stage1aDir}$libcFolder");
+ copyFile('/etc/resolv.conf', "$self->{stage1aDir}/etc");
+ spitFile("$self->{stage1aDir}/etc/hosts", '127.0.0.1 localhost');
+ 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'}";
@@ -961,7 +948,7 @@ sub stage1A_setupResolver
return;
}
-sub stage1A_copyPrerequiredFiles
+sub _stage1A_copyPrerequiredFiles
{
my $self = shift;
@@ -984,7 +971,7 @@ sub stage1A_copyPrerequiredFiles
return;
}
-sub stage1A_copyTrustedPackageKeys
+sub _stage1A_copyTrustedPackageKeys
{
my $self = shift;
@@ -1016,7 +1003,7 @@ sub stage1A_copyTrustedPackageKeys
return;
}
-sub stage1A_createRequiredFiles
+sub _stage1A_createRequiredFiles
{
my $self = shift;
@@ -1045,19 +1032,22 @@ sub stage1A_createRequiredFiles
return;
}
-sub setupStage1B
+sub _setupStage1B
{
my $self = shift;
vlog(1, "setting up stage1b for $self->{'vendor-os-name'}...");
- $self->stage1B_chrootAndBootstrap();
+ $self->_stage1B_chrootAndBootstrap();
return;
}
-sub stage1B_chrootAndBootstrap
+sub _stage1B_chrootAndBootstrap
{
my $self = shift;
+ # give packager a chance to copy required files into stage1a-folder:
+ $self->{packager}->prepareBootstrap($self->{stage1aDir});
+
chrootInto($self->{stage1aDir});
# chdir into slxbootstrap, as we want to drop packages into there:
@@ -1066,18 +1056,17 @@ sub stage1B_chrootAndBootstrap
"unable to chdir into '%s' (%s)\n", "/$self->{stage1bSubdir}", $!
);
- # fetch prerequired packages:
- $self->{'baseURLs'}
- = $self->sortRepositoryURLs(
- $self->{'distro-info'}->{repository}->{base}
- );
+ # 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'});
- my @prereqPkgs = $self->downloadBaseFiles(\@pkgs);
- $self->{packager}->unpackPackages(\@prereqPkgs);
+ my @prereqPkgs = $self->_downloadBaseFiles(\@pkgs);
+ $self->{packager}->bootstrap(\@prereqPkgs);
@pkgs = string2Array($self->{'distro-info'}->{'bootstrap-prereq-packages'});
- my @bootstrapPrereqPkgs = $self->downloadBaseFiles(\@pkgs);
+ my @bootstrapPrereqPkgs = $self->_downloadBaseFiles(\@pkgs);
$self->{'bootstrap-prereq-packages'} = \@bootstrapPrereqPkgs;
@pkgs = string2Array($self->{'distro-info'}->{'bootstrap-packages'});
@@ -1088,22 +1077,22 @@ sub stage1B_chrootAndBootstrap
->{$self->{distro}->{'meta-packager-type'}}
)
);
- my @bootstrapPkgs = $self->downloadBaseFiles(\@pkgs);
+ my @bootstrapPkgs = $self->_downloadBaseFiles(\@pkgs);
my @allPkgs = (@prereqPkgs, @bootstrapPrereqPkgs, @bootstrapPkgs);
$self->{'bootstrap-packages'} = \@allPkgs;
return;
}
-sub setupStage1C
+sub _setupStage1C
{
my $self = shift;
vlog(1, "setting up stage1c for $self->{'vendor-os-name'}...");
- $self->stage1C_chrootAndInstallBasicVendorOS();
+ $self->_stage1C_chrootAndInstallBasicVendorOS();
return;
}
-sub stage1C_chrootAndInstallBasicVendorOS
+sub _stage1C_chrootAndInstallBasicVendorOS
{
my $self = shift;
@@ -1121,14 +1110,14 @@ sub stage1C_chrootAndInstallBasicVendorOS
# import any additional trusted package keys to rpm-DB:
my $keyDir = "/trusted-package-keys";
my $keyDirDH;
- opendir($keyDirDH, $keyDir)
- or die _tr("unable to opendir '%s' (%s)\n", $keyDir, $!);
- my @keyFiles
- = map { "$keyDir/$_" }
- grep { $_ !~ m[^(\.\.?|pubring.gpg)$] }
- readdir($keyDirDH);
- closedir($keyDirDH);
- $self->{packager}->importTrustedPackageKeys(\@keyFiles, $stage1cDir);
+ if (opendir($keyDirDH, $keyDir)) {
+ my @keyFiles
+ = map { "$keyDir/$_" }
+ grep { $_ !~ m[^(\.\.?|pubring.gpg)$] }
+ readdir($keyDirDH);
+ closedir($keyDirDH);
+ $self->{packager}->importTrustedPackageKeys(\@keyFiles, $stage1cDir);
+ }
# install all other bootstrap packages
$self->{packager}->installPackages(
@@ -1137,7 +1126,7 @@ sub stage1C_chrootAndInstallBasicVendorOS
return;
}
-sub stage1C_cleanupBasicVendorOS
+sub _stage1C_cleanupBasicVendorOS
{
my $self = shift;
@@ -1158,7 +1147,7 @@ sub stage1C_cleanupBasicVendorOS
return;
}
-sub setupStage1D
+sub _setupStage1D
{
my $self = shift;
@@ -1166,13 +1155,13 @@ sub setupStage1D
chrootInto($self->{'vendor-os-path'});
- $self->stage1D_setupPackageSources();
- $self->stage1D_updateBasicVendorOS();
- $self->stage1D_installPackageSelection();
+ $self->_stage1D_setupPackageSources();
+ $self->_stage1D_updateBasicVendorOS();
+ $self->_stage1D_installPackageSelection();
return;
}
-sub updateStage1D
+sub _updateStage1D
{
my $self = shift;
@@ -1180,11 +1169,11 @@ sub updateStage1D
chrootInto($self->{'vendor-os-path'});
- $self->stage1D_updateBasicVendorOS();
+ $self->_stage1D_updateBasicVendorOS();
return;
}
-sub startChrootedShellInStage1D
+sub _startChrootedShellInStage1D
{
my $self = shift;
@@ -1205,7 +1194,7 @@ sub startChrootedShellInStage1D
return;
}
-sub callChrootedFunctionInStage1D
+sub _callChrootedFunctionInStage1D
{
my $self = shift;
my $function = shift;
@@ -1222,7 +1211,7 @@ sub callChrootedFunctionInStage1D
return;
}
-sub stage1D_setupPackageSources
+sub _stage1D_setupPackageSources
{
my $self = shift;
@@ -1239,7 +1228,7 @@ sub stage1D_setupPackageSources
return;
}
-sub stage1D_updateBasicVendorOS
+sub _stage1D_updateBasicVendorOS
{
my $self = shift;
@@ -1251,7 +1240,7 @@ sub stage1D_updateBasicVendorOS
return;
}
-sub stage1D_installPackageSelection
+sub _stage1D_installPackageSelection
{
my $self = shift;
@@ -1288,7 +1277,7 @@ sub stage1D_installPackageSelection
return;
}
-sub clone_fetchSource
+sub _clone_fetchSource
{
my $self = shift;
my $source = shift;
@@ -1321,7 +1310,7 @@ sub clone_fetchSource
return;
}
-sub clone_determineIncludeExcludeList
+sub _clone_determineIncludeExcludeList
{
my $self = shift;
@@ -1339,12 +1328,12 @@ sub clone_determineIncludeExcludeList
################################################################################
### utility methods
################################################################################
-sub changePersonalityIfNeeded
+sub _changePersonalityIfNeeded
{
my $self = shift;
my $distroName = $self->{distro}->{'base-name'};
- if ($self->hostIs64Bit() && $distroName !~ m[_64]) {
+ 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):
my $syscallPH = 'syscall.ph';
@@ -1359,7 +1348,7 @@ sub changePersonalityIfNeeded
return;
}
-sub hostIs64Bit
+sub _hostIs64Bit
{
my $self = shift;
@@ -1367,41 +1356,7 @@ sub hostIs64Bit
return ($self->{arch} =~ m[64]);
}
-################################################################################
-### utility functions
-################################################################################
-sub string2Array
-{
- my $string = shift || '';
-
- my @lines = split m[\n], $string;
- for my $line (@lines) {
- # remove leading and trailing whitespace:
- $line =~ s{^\s*(.*?)\s*$}{$1};
- }
-
- # drop empty lines and comments:
- return grep { length($_) > 0 && $_ !~ m[^\s*#]; } @lines;
-}
-
-sub chrootInto
-{
- my $osDir = shift;
-
- vlog(2, "chrooting into $osDir...");
- chdir $osDir
- or die _tr("unable to chdir into '%s' (%s)\n", $osDir, $!);
-
- # ...do chroot
- chroot "."
- or die _tr("unable to chroot into '%s' (%s)\n", $osDir, $!);
-
- $ENV{PATH} = "/bin:/sbin:/usr/bin:/usr/sbin";
- return;
-}
-
1;
-################################################################################
=pod
diff --git a/installer/OpenSLX/OSSetup/MetaPackager/apt.pm b/installer/OpenSLX/OSSetup/MetaPackager/apt.pm
new file mode 100644
index 00000000..65a1d8e7
--- /dev/null
+++ b/installer/OpenSLX/OSSetup/MetaPackager/apt.pm
@@ -0,0 +1,72 @@
+# Copyright (c) 2006, 2007 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# apt.pm
+# - provides apt-get-specific overrides of the OpenSLX::OSSetup::MetaPackager API.
+# -----------------------------------------------------------------------------
+package OpenSLX::OSSetup::MetaPackager::apt;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::OSSetup::MetaPackager::Base);
+
+use OpenSLX::Basics;
+use OpenSLX::Utils;
+
+################################################################################
+### implementation
+################################################################################
+sub new
+{
+ my $class = shift;
+ my $self = {
+ 'name' => 'apt',
+ };
+ return bless $self, $class;
+}
+
+sub initPackageSources
+{
+ my $self = shift;
+
+ return;
+}
+
+sub setupPackageSource
+{
+ my $self = shift;
+ my $repoName = shift;
+ my $repoInfo = shift;
+ my $excludeList = shift;
+
+ my $repoSubdir = '';
+ if (length($repoInfo->{'repo-subdir'})) {
+ $repoSubdir = "/$repoInfo->{'repo-subdir'}";
+ }
+ return;
+}
+
+sub installSelection
+{
+ my $self = shift;
+ my $pkgSelection = shift;
+
+ return;
+}
+
+sub updateBasicVendorOS
+{
+ my $self = shift;
+
+ return;
+}
+
+1; \ No newline at end of file
diff --git a/installer/OpenSLX/OSSetup/Packager/Base.pm b/installer/OpenSLX/OSSetup/Packager/Base.pm
index 3aa8921e..c33b690b 100644
--- a/installer/OpenSLX/OSSetup/Packager/Base.pm
+++ b/installer/OpenSLX/OSSetup/Packager/Base.pm
@@ -31,13 +31,17 @@ sub new
sub initialize
{
my $self = shift;
- my $distro = shift;
+ my $engine = shift;
- $self->{'distro'} = $distro;
+ $self->{'engine'} = $engine;
return;
}
-sub unpackPackages
+sub prepareBootstrap
+{
+}
+
+sub bootstrap
{
}
diff --git a/installer/OpenSLX/OSSetup/Packager/dpkg.pm b/installer/OpenSLX/OSSetup/Packager/dpkg.pm
new file mode 100644
index 00000000..cdd55e56
--- /dev/null
+++ b/installer/OpenSLX/OSSetup/Packager/dpkg.pm
@@ -0,0 +1,98 @@
+# Copyright (c) 2006, 2007 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# rpm.pm
+# - provides rpm-specific overrides of the OpenSLX::OSSetup::Packager API.
+# -----------------------------------------------------------------------------
+package OpenSLX::OSSetup::Packager::dpkg;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::OSSetup::Packager::Base);
+
+use OpenSLX::Basics;
+use OpenSLX::Utils;
+
+################################################################################
+### implementation
+################################################################################
+sub new
+{
+ 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,
+ });
+
+}
+
+sub bootstrap
+{
+ 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 $debootstrapCmd = <<" END-OF-HERE";
+ /usr/sbin/debootstrap --arch i386 edgy /slxbootstrap/slxfinal http://localhost:5080/srv/ftp/pub/ubuntu
+ END-OF-HERE
+ if (slxsystem("ash", "-c", "/bin/ash $debootstrapCmd")) {
+ die _tr("unable to run debootstrap (%s)", $!);
+ }
+ return;
+}
+
+sub installPackages
+{
+ my $self = shift;
+ my $pkgs = shift;
+ my $finalPath = shift;
+
+ return unless defined $pkgs && scalar(@$pkgs);
+
+ if (slxsystem("rpm", "--root=$finalPath", "-ivh", @$pkgs)) {
+ die _tr("error during package-installation (%s)\n", $!);
+ }
+ return;
+}
+
+sub getInstalledPackages
+{
+ my $self = shift;
+
+ my $rpmCmd = 'rpm -qa --queryformat="%{NAME}\n"';
+ my $pkgList = `$rpmCmd`;
+ return split "\n", $pkgList;
+}
+
+1;
diff --git a/installer/OpenSLX/OSSetup/Packager/rpm.pm b/installer/OpenSLX/OSSetup/Packager/rpm.pm
index ef254084..0fd502a0 100644
--- a/installer/OpenSLX/OSSetup/Packager/rpm.pm
+++ b/installer/OpenSLX/OSSetup/Packager/rpm.pm
@@ -32,7 +32,7 @@ sub new
return bless $self, $class;
}
-sub unpackPackages
+sub bootstrap
{
my $self = shift;
my $pkgs = shift;
diff --git a/lib/OpenSLX/Basics.pm b/lib/OpenSLX/Basics.pm
index 45a37986..e1ca36fb 100644
--- a/lib/OpenSLX/Basics.pm
+++ b/lib/OpenSLX/Basics.pm
@@ -28,7 +28,7 @@ $VERSION = 1.01;
&warn &die &croak &carp &confess &cluck
&callInSubprocess &executeInSubprocess &slxsystem
&vlog
- &checkFlags
+ &checkParams
&instantiateClass
&addCleanupFunction &removeCleanupFunction
);
@@ -469,19 +469,111 @@ sub _doThrowOrWarn
return;
}
-# ------------------------------------------------------------------------------
-sub checkFlags
+=item checkParams()
+
+Utility function that can be used by any method that accepts param-hashes
+to check if the given parameters actually match the expectations.
+
+Each individual parameter has a specification that describes the expectation
+that the calling function has towards this param. The following specifications
+are supported:
+
+* '!' - the parameter is required
+* '?' - the parameter is optional
+* 'm{regex}' - the parameter must match the given regex
+* '!class=...' - the parameter is required and must be an object of the given class
+* '?class=...' - if the parameter has been given, it must be an object of the given class
+
+The function will confess for any unknown, missing, or non-matching param.
+
+If accepted as useful, this function could be moved to a utility module of
+the framework in order to be available to all other OTRS-modules.
+
+=cut
+
+sub checkParams
{
- my $flags = shift || confess 'need to pass in flags-hashref!';
- my $knownFlags = shift || confess 'need to pass in knownFlags-arrayref!';
-
- my %known;
- @known{@$knownFlags} = ();
- foreach my $flag (keys %$flags) {
- next if exists $known{$flag};
- cluck("flag '$flag' not known!");
- }
- return;
+ my $params = shift or confess('need to pass in params-hashref!');
+ my $paramsSpec = shift or confess('need to pass in params-spec-hashref!');
+
+ # print a warning for any unknown parameters that have been given:
+ my @unknownParams
+ = grep { !exists $paramsSpec->{$_}; }
+ keys %$params;
+ if (@unknownParams) {
+ my $unknownParamsStr = join ',', @unknownParams;
+ confess("Enocuntered unknown params: '$unknownParamsStr'!\n");
+ }
+
+ # check if all required params have been specified:
+ foreach my $param (keys %$paramsSpec) {
+ my $spec = $paramsSpec->{$param};
+ if (ref($spec) eq 'HASH') {
+ # Handle nested specs by recursion:
+ my $subParams = $params->{$param};
+ if (!defined $subParams) {
+ confess("Required param '$param' is missing!");
+ }
+ checkParams($subParams, $spec);
+ }
+ elsif (ref($spec) eq 'ARRAY') {
+ # Handle nested spec arrays by looped recursion:
+ my $subParams = $params->{$param};
+ if (!defined $subParams) {
+ confess("Required param '$param' is missing!");
+ }
+ elsif (ref($subParams) ne 'ARRAY') {
+ confess("Value for param '$param' must be an array-ref!");
+ }
+ foreach my $subParam (@$subParams) {
+ checkParams($subParam, $spec->[0]);
+ }
+ }
+ elsif ($spec eq '!') {
+ # required parameter:
+ if (!exists $params->{$param}) {
+ confess("Required param '$param' is missing!");
+ }
+ }
+ elsif ($spec =~ m{^\!class=(.+)$}i) {
+ my $class = $1;
+ # required parameter ...
+ if (!exists $params->{$param}) {
+ confess("Required param '$param' is missing!");
+ }
+ # ... of specific class
+ if (!$params->{$param}->isa($class)) {
+ confess("Param '$param' is not a '$class', but that is required!");
+ }
+ }
+ elsif ($spec eq '?') {
+ # optional parameter - nothing to do
+ }
+ elsif ($spec =~ m{^\?class=(.+)$}i) {
+ my $class = $1;
+ # optional parameter ...
+ if (exists $params->{$param}) {
+ # ... has been given, so it must match specific class
+ if (!$params->{$param}->isa($class)) {
+ confess("Param '$param' is not a '$class', but that is required!");
+ }
+ }
+ }
+ elsif ($spec =~ m{^m{(.+)}$}) {
+ # try to match given regex:
+ my $regex = $1;
+ my $value = $params->{$param};
+ if ($value !~ m{$regex}) {
+ confess("Required param '$param' isn't matching regex '$regex' (given value was '$value')!");
+ }
+ }
+ else {
+ # complain about unknown spec:
+ confess("Unknown param-spec '$spec' encountered!");
+ }
+ }
+
+ return scalar 1;
}
# ------------------------------------------------------------------------------
@@ -490,7 +582,10 @@ sub instantiateClass
my $class = shift;
my $flags = shift || {};
- checkFlags($flags, ['pathToClass', 'version']);
+ checkParams($flags, {
+ 'pathToClass' => '?',
+ 'version' => '?'
+ });
my $pathToClass = $flags->{pathToClass};
my $requestedVersion = $flags->{version};
@@ -499,10 +594,10 @@ sub instantiateClass
$moduleName .= '.pm';
unless (eval { require $moduleName } ) {
if ($! == 2) {
- die _tr("Module <%s> not found!\n", $moduleName);
+ die _tr("Module '%s' not found!\n", $moduleName);
}
else {
- die _tr("Unable to load module <%s> (%s)\n", $moduleName, $@);
+ die _tr("Unable to load module '%s' (%s)\n", $moduleName, $@);
}
}
if (defined $requestedVersion) {
diff --git a/lib/OpenSLX/Utils.pm b/lib/OpenSLX/Utils.pm
index d23eb6e8..fdb1192c 100644
--- a/lib/OpenSLX/Utils.pm
+++ b/lib/OpenSLX/Utils.pm
@@ -23,7 +23,13 @@ $VERSION = 1.01;
@ISA = qw(Exporter);
@EXPORT = qw(
- copyFile fakeFile linkFile slurpFile spitFile followLink unshiftHereDoc
+ copyFile fakeFile linkFile
+ copyBinaryWithRequiredLibs
+ slurpFile spitFile
+ followLink
+ unshiftHereDoc
+ string2Array
+ chrootInto
);
################################################################################
@@ -88,7 +94,7 @@ sub slurpFile
my $fileName = shift || confess 'need to pass in fileName!';
my $flags = shift || {};
- checkFlags($flags, ['failIfMissing']);
+ checkParams($flags, { 'failIfMissing' => '?' });
my $failIfMissing
= exists $flags->{failIfMissing} ? $flags->{failIfMissing} : 1;
@@ -137,6 +143,39 @@ sub followLink
return $path;
}
+sub copyBinaryWithRequiredLibs {
+ my $params = shift;
+
+ checkParams($params, {
+ 'binary' => '!', # file to copy
+ 'targetFolder' => '!', # where file shall be copied to
+ 'libTargetFolder' => '!', # base target folder for libs
+ 'targetName' => '?', # name of binary in target folder
+ });
+ copyFile($params->{binary}, $params->{targetFolder}, $params->{targetName});
+
+ # determine all required libraries and copy those, too:
+ vlog(1, _tr("calling slxldd for $params->{binary}"));
+ my $slxlddCmd = "slxldd $params->{binary}";
+ vlog(2, "executing: $slxlddCmd");
+ my $requiredLibsStr = qx{$slxlddCmd};
+ if ($?) {
+ die _tr(
+ "slxldd couldn't determine the libs required by '%s'! (%s)",
+ $params->{binary}, $?
+ );
+ }
+ chomp $requiredLibsStr;
+ vlog(2, "slxldd results:\n$requiredLibsStr");
+
+ foreach my $lib (split "\n", $requiredLibsStr) {
+ vlog(3, "copying lib '$lib'");
+ my $libDir = dirname($lib);
+ copyFile($lib, "$params->{libTargetFolder}$libDir");
+ }
+ return $requiredLibsStr;
+}
+
sub unshiftHereDoc
{
my $content = shift;
@@ -148,4 +187,34 @@ sub unshiftHereDoc
split m{\n}, $content;
}
+sub string2Array
+{
+ my $string = shift || '';
+
+ my @lines = split m[\n], $string;
+ for my $line (@lines) {
+ # remove leading and trailing whitespace:
+ $line =~ s{^\s*(.*?)\s*$}{$1};
+ }
+
+ # drop empty lines and comments:
+ return grep { length($_) > 0 && $_ !~ m[^\s*#]; } @lines;
+}
+
+sub chrootInto
+{
+ my $osDir = shift;
+
+ vlog(2, "chrooting into $osDir...");
+ chdir $osDir
+ or die _tr("unable to chdir into '%s' (%s)\n", $osDir, $!);
+
+ # ...do chroot
+ chroot "."
+ or die _tr("unable to chroot into '%s' (%s)\n", $osDir, $!);
+
+ $ENV{PATH} = "/bin:/sbin:/usr/bin:/usr/sbin";
+ return;
+}
+
1;