summaryrefslogtreecommitdiffstats
path: root/installer
diff options
context:
space:
mode:
authorOliver Tappe2008-02-27 23:56:28 +0100
committerOliver Tappe2008-02-27 23:56:28 +0100
commitd4fd61af70387019f788f736869a51308b3d7d72 (patch)
tree8ceb197c19ba9825515bc3fff5dbeddebfc16437 /installer
parentWorking on CD preboot ... (diff)
downloadcore-d4fd61af70387019f788f736869a51308b3d7d72.tar.gz
core-d4fd61af70387019f788f736869a51308b3d7d72.tar.xz
core-d4fd61af70387019f788f736869a51308b3d7d72.zip
* OSPlugin::Engine now provides a real support interface for plugins, which
can be used to get info about the vendor-OS and distro, install/uninstall packages, download files (and more stuff to come). * Adjusted OSSetup::Engine and OSSetup::MetaPackager to the demands of the new support interface. git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1580 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'installer')
-rw-r--r--installer/OpenSLX/OSSetup/Engine.pm49
-rw-r--r--installer/OpenSLX/OSSetup/MetaPackager/Base.pm4
-rw-r--r--installer/OpenSLX/OSSetup/MetaPackager/apt.pm26
-rw-r--r--installer/OpenSLX/OSSetup/MetaPackager/smart.pm24
-rw-r--r--installer/OpenSLX/OSSetup/MetaPackager/yum.pm26
-rw-r--r--installer/OpenSLX/OSSetup/MetaPackager/zypper.pm28
6 files changed, 124 insertions, 33 deletions
diff --git a/installer/OpenSLX/OSSetup/Engine.pm b/installer/OpenSLX/OSSetup/Engine.pm
index 3dc7d7c2..d3956629 100644
--- a/installer/OpenSLX/OSSetup/Engine.pm
+++ b/installer/OpenSLX/OSSetup/Engine.pm
@@ -212,7 +212,7 @@ sub initialize
$distro->initialize($self);
$self->{distro} = $distro;
- if ($actionType =~ m{^(install|update|shell)}) {
+ if ($actionType =~ m{^(install|update|shell|plugin)}) {
# setup path to distribution-specific info:
my $sharedDistroInfoDir
= "$openslxConfig{'base-path'}/share/distro-info/$self->{'distro-name'}";
@@ -261,7 +261,7 @@ sub initialize
= "$openslxConfig{'private-path'}/stage1/$self->{'vendor-os-name'}";
vlog(1, "vendor-OS path is '$self->{'vendor-os-path'}'");
- if ($actionType =~ m{^(install|update|shell)}) {
+ if ($actionType =~ m{^(install|update|shell|plugin)}) {
$self->_createPackager();
$self->_createMetaPackager();
}
@@ -664,6 +664,27 @@ sub pickKernelFile
return $self->{distro}->pickKernelFile(@_);
}
+sub distroName
+{
+ my $self = shift;
+
+ return $self->{'distro-name'};
+}
+
+sub metaPackager
+{
+ my $self = shift;
+
+ return $self->{'meta-packager'};
+}
+
+sub busyboxBinary
+{
+ my $self = shift;
+
+ return $self->{'busybox-binary'};
+}
+
################################################################################
### implementation methods
################################################################################
@@ -789,7 +810,7 @@ sub _configureBestMirrorsForRepository
my $allMirrorsFile
= "$self->{'shared-distro-info-dir'}/mirrors/$repoInfo->{key}";
- my @allMirrors = string2Array(slurpFile($allMirrorsFile));
+ my @allMirrors = string2Array(scalar slurpFile($allMirrorsFile));
my $mirrorsToTryCount = $openslxConfig{'mirrors-to-try-count'} || 20;
my $mirrorsToUseCount = $openslxConfig{'mirrors-to-use-count'} || 5;
@@ -851,16 +872,25 @@ sub _configureBestMirrorsForRepository
!grep { $mirror eq $_ } @tryMirrors;
} @allMirrors;
- # ... now pick randomly until we have reached the limit or there are
+ # ... 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 $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,
@@ -938,17 +968,14 @@ sub _speedTestMirror
}
# now measure the time it takes to download the file
- my $tempFile = "$openslxConfig{'temp-path'}/slx-mirror-testfile";
- unlink $tempFile if -e $tempFile;
my $wgetCmd
- = "$self->{'busybox-binary'} wget -q -O $tempFile $mirror/$file";
+ = "$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;
- unlink $tempFile;
vlog(0, "\tfetched '$file' in $time seconds\n");
return $time;
}
@@ -1092,7 +1119,7 @@ try_next_url:
foreach my $file (split '\s+', $fileVariantStr) {
my $basefile = basename($file);
vlog(2, "fetching <$file>...");
- if (slxsystem("wget", "$url/$file") == 0) {
+ if (slxsystem("wget", "-c", "-O", "$basefile", "$url/$file") == 0) {
$foundFile = $basefile;
last;
}
@@ -1589,7 +1616,7 @@ sub _stage1D_installPackageSelection
}
else {
vlog(1, "installing these packages:\n" . join("\n\t", @pkgs));
- $self->{'meta-packager'}->installSelection(join " ", @pkgs);
+ $self->{'meta-packager'}->installSelection(join " ", @pkgs, 1);
}
return;
}
diff --git a/installer/OpenSLX/OSSetup/MetaPackager/Base.pm b/installer/OpenSLX/OSSetup/MetaPackager/Base.pm
index dd552071..91b2d087 100644
--- a/installer/OpenSLX/OSSetup/MetaPackager/Base.pm
+++ b/installer/OpenSLX/OSSetup/MetaPackager/Base.pm
@@ -53,6 +53,10 @@ sub installSelection
{
}
+sub removeSelection
+{
+}
+
1;
################################################################################
diff --git a/installer/OpenSLX/OSSetup/MetaPackager/apt.pm b/installer/OpenSLX/OSSetup/MetaPackager/apt.pm
index 5cfd2655..137bab5e 100644
--- a/installer/OpenSLX/OSSetup/MetaPackager/apt.pm
+++ b/installer/OpenSLX/OSSetup/MetaPackager/apt.pm
@@ -61,7 +61,8 @@ sub initPackageSources
END-OF-HERE
spitFile('/etc/kernel-img.conf', $kernelConfig);
}
- return;
+
+ return 1;
}
sub setupPackageSource
@@ -89,10 +90,11 @@ sub setupPackageSource
sub installSelection
{
- my $self = shift;
+ my $self = shift;
my $pkgSelection = shift;
+ my $doRefresh = shift || 0;
- if (slxsystem("apt-get -y update")) {
+ if ($doRefresh && slxsystem("apt-get -y update")) {
die _tr("unable to update repository info (%s)\n", $!);
}
if ('/var/cache/debconf/slx-defaults.dat') {
@@ -105,7 +107,20 @@ sub installSelection
}
delete $ENV{DEBCONF_DB_FALLBACK};
delete $ENV{DEBIAN_FRONTEND};
- return;
+
+ return 1;
+}
+
+sub removeSelection
+{
+ my $self = shift;
+ my $pkgSelection = shift;
+
+ if (slxsystem("apt-get -y remove $pkgSelection")) {
+ die _tr("unable to remove selection (%s)\n", $!);
+ }
+
+ return 1;
}
sub updateBasicVendorOS
@@ -118,7 +133,8 @@ sub updateBasicVendorOS
if (slxsystem("apt-get -y upgrade")) {
die _tr("unable to update this vendor-os (%s)\n", $!);
}
- return;
+
+ 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 71d9875c..cbe96009 100644
--- a/installer/OpenSLX/OSSetup/MetaPackager/smart.pm
+++ b/installer/OpenSLX/OSSetup/MetaPackager/smart.pm
@@ -44,7 +44,7 @@ sub initPackageSources
if (slxsystem("smart channel -y --remove-all")) {
die _tr("unable to remove existing channels (%s)\n", $!);
}
- return;
+ return 1;
}
sub setupPackageSource
@@ -79,21 +79,33 @@ sub setupPackageSource
);
}
}
- return;
+ return 1;
}
sub installSelection
{
- my $self = shift;
+ my $self = shift;
my $pkgSelection = shift;
+ my $doRefresh = shift || 0;
- if (slxsystem("smart update")) {
+ if ($doRefresh && slxsystem("smart update")) {
die _tr("unable to update channel info (%s)\n", $!);
}
if (slxsystem("smart install -y $pkgSelection")) {
die _tr("unable to install selection (%s)\n", $!);
}
- return;
+ return 1;
+}
+
+sub removeSelection
+{
+ my $self = shift;
+ my $pkgSelection = shift;
+
+ if (slxsystem("smart remove -y $pkgSelection")) {
+ die _tr("unable to remove selection (%s)\n", $!);
+ }
+ return 1;
}
sub updateBasicVendorOS
@@ -107,7 +119,7 @@ sub updateBasicVendorOS
}
die _tr("unable to update this vendor-os (%s)\n", $!);
}
- return;
+ 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 337227ed..7d2bc630 100644
--- a/installer/OpenSLX/OSSetup/MetaPackager/yum.pm
+++ b/installer/OpenSLX/OSSetup/MetaPackager/yum.pm
@@ -41,7 +41,8 @@ sub initPackageSources
slxsystem("rm -f /etc/yum.repos.d/*");
slxsystem("mkdir -p /etc/yum.repos.d");
- return;
+
+ return 1;
}
sub setupPackageSource
@@ -66,18 +67,32 @@ sub setupPackageSource
}
my $repoFile = "/etc/yum.repos.d/$repoName.repo";
spitFile($repoFile, "$repoDescr\nexclude=$excludeList\n");
- return;
+
+ return 1;
}
sub installSelection
{
- my $self = shift;
+ my $self = shift;
my $pkgSelection = shift;
if (slxsystem("yum -y install $pkgSelection")) {
die _tr("unable to install selection (%s)\n", $!);
}
- return;
+
+ return 1;
+}
+
+sub removeSelection
+{
+ my $self = shift;
+ my $pkgSelection = shift;
+
+ if (slxsystem("yum -y remove $pkgSelection")) {
+ die _tr("unable to remove selection (%s)\n", $!);
+ }
+
+ return 1;
}
sub updateBasicVendorOS
@@ -91,7 +106,8 @@ sub updateBasicVendorOS
}
die _tr("unable to update this vendor-os (%s)\n", $!);
}
- return;
+
+ 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 bb50ad4c..04554e70 100644
--- a/installer/OpenSLX/OSSetup/MetaPackager/zypper.pm
+++ b/installer/OpenSLX/OSSetup/MetaPackager/zypper.pm
@@ -41,7 +41,8 @@ sub initPackageSources
# remove any existing channels
slxsystem("rm -f /etc/zypp/repos.d/*");
- return;
+
+ return 1;
}
sub setupPackageSource
@@ -61,21 +62,35 @@ sub setupPackageSource
die _tr("unable to add repo '%s' (%s)\n", $repoName, $!);
}
- return;
+ return 1;
}
sub installSelection
{
- my $self = shift;
+ my $self = shift;
my $pkgSelection = shift;
+ my $doRefresh = shift || 0;
- if (slxsystem("zypper --non-interactive refresh")) {
+ if ($doRefresh && slxsystem("zypper --non-interactive refresh")) {
die _tr("unable to update repo info (%s)\n", $!);
}
if (slxsystem("zypper --non-interactive install $pkgSelection")) {
die _tr("unable to install selection (%s)\n", $!);
}
- return;
+
+ return 1;
+}
+
+sub removeSelection
+{
+ my $self = shift;
+ my $pkgSelection = shift;
+
+ if (slxsystem("zypper --non-interactive remove $pkgSelection")) {
+ die _tr("unable to remove selection (%s)\n", $!);
+ }
+
+ return 1;
}
sub updateBasicVendorOS
@@ -89,7 +104,8 @@ sub updateBasicVendorOS
}
die _tr("unable to update this vendor-os (%s)\n", $!);
}
- return;
+
+ return 1;
}
1; \ No newline at end of file