From e97185912be978df38c53caa74b967b34e9fd63b Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Tue, 13 Feb 2007 17:53:25 +0000 Subject: * slightly reworked distribution lookup mechanism git-svn-id: http://svn.openslx.org/svn/openslx/trunk@701 95ad53e4-c205-0410-b2fa-d234c58c8868 --- installer/OpenSLX/OSSetup/Engine.pm | 39 +++++++++++++++++++++++++++++++++---- installer/slxos-setup | 30 ++++------------------------ 2 files changed, 39 insertions(+), 30 deletions(-) diff --git a/installer/OpenSLX/OSSetup/Engine.pm b/installer/OpenSLX/OSSetup/Engine.pm index bd019b11..52093cbd 100644 --- a/installer/OpenSLX/OSSetup/Engine.pm +++ b/installer/OpenSLX/OSSetup/Engine.pm @@ -6,14 +6,39 @@ # package OpenSLX::OSSetup::Engine; -use vars qw($VERSION); +use vars qw(@ISA @EXPORT $VERSION); $VERSION = 1.01; # API-version . implementation-version +use Exporter; +@ISA = qw(Exporter); + +@EXPORT = qw( + %supportedDistros +); + use strict; use Carp; use File::Basename; use OpenSLX::Basics; +use vars qw(%supportedDistros); + +%supportedDistros = ( +# 'debian-3.1' => 'Debian_3_1', +# 'debian-4.0' => 'Debian_4_0', +# 'fedora-6' => 'Fedora_6', +# 'fedora-6-x86_64' => 'Fedora_6_x86_64', +# 'mandriva-2007.0' => 'Mandriva_2007_0', +# 'suse-9.3' => 'SUSE_9_3', +# 'suse-10.0' => 'SUSE_10_0', +# 'suse-10.0-x86_64' => 'SUSE_10_0_x86_64', + 'suse-10.1' => 'SUSE_10_1', +# 'suse-10.1-x86_64' => 'SUSE_10_1_x86_64', + 'suse-10.2' => 'SUSE_10_2', +# 'suse-10.2-x86_64' => 'SUSE_10_2_x86_64', +# 'ubuntu-6.10' => 'Ubuntu_6_10', +); + ################################################################################ ### interface methods ################################################################################ @@ -33,10 +58,16 @@ sub initialize my $distroName = shift; my $protectSystemPath = shift; + 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", keys %supportedDistros)."\n"; + exit 1; + } + # load module for the requested distro: - $distroName = uc($distroName); - $distroName =~ tr[-.][_]; - my $distroModule = "OpenSLX::OSSetup::Distro::$distroName"; + my $distroModule + = "OpenSLX::OSSetup::Distro::".$supportedDistros{lc($distroName)}; unless (eval "require $distroModule") { if ($! == 2) { die _tr("Distro-module <%s> not found!\n", $distroModule); diff --git a/installer/slxos-setup b/installer/slxos-setup index 30aa82dd..55b6f30f 100755 --- a/installer/slxos-setup +++ b/installer/slxos-setup @@ -54,27 +54,11 @@ if ($versionReq) { exit 1; } -my @supportedDistros = ( - 'debian-3.1', - 'debian-4.0', - 'fedora-6', - 'fedora-6-x86_64', - 'mandriva-2007.0', - 'suse-9.3', - 'suse-10.0', - 'suse-10.0-x86_64', - 'suse-10.1', - 'suse-10.1-x86_64', - 'suse-10.2', - 'suse-10.2-x86_64', - 'ubuntu-6.10', -); - openslxInit(); if ($listReq) { print _tr("List of supported distros:\n\t"); - print join("\n\t", @supportedDistros)."\n"; + print join("\n\t", keys %supportedDistros)."\n"; exit 1; } @@ -83,20 +67,14 @@ if (scalar(@ARGV) != 1) { pod2usage(2); } -my $distroName = $ARGV[0]; -if (!grep { /^$distroName$/ } @supportedDistros) { - print _tr("Sorry, distro '%s' is unsupported.\n", $distroName); - print _tr("List of supported distros:\n\t"); - print join("\n\t", @supportedDistros)."\n"; - exit 1; -} - # 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 ossetup-engine and start it: + +# create ossetup-engine for given distro and start it: +my $distroName = $ARGV[0]; my $engine = OpenSLX::OSSetup::Engine->new; if ($setupRepos) { $engine->initialize($distroName, 0); -- cgit v1.2.3-55-g7522