From fa6736a110950b5b4ede661dc3c721d76f2970be Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Fri, 23 Feb 2007 20:26:11 +0000 Subject: * added support for importing the installed vendor-OS into the config-db * slxos-setup now supports three actions: install does a fresh install of a vendor-OS update updates an already installed vendor-OS import-into-db imports an already installed vendor-OS into the config-db * for all actions, you can now specify a specific (vendor-OS provided) selection, which will create a vendor-OS specific to that selection (this is where you can say --selection=kde to have SUSE install a KDE-desktop). git-svn-id: http://svn.openslx.org/svn/openslx/trunk@718 95ad53e4-c205-0410-b2fa-d234c58c8868 --- installer/OpenSLX/OSSetup/Engine.pm | 170 +++++++++++++++++++++++++----------- installer/slxos-setup | 54 +++++++++--- 2 files changed, 159 insertions(+), 65 deletions(-) (limited to 'installer') diff --git a/installer/OpenSLX/OSSetup/Engine.pm b/installer/OpenSLX/OSSetup/Engine.pm index f07689f9..ba8d826a 100644 --- a/installer/OpenSLX/OSSetup/Engine.pm +++ b/installer/OpenSLX/OSSetup/Engine.pm @@ -56,6 +56,7 @@ sub initialize { my $self = shift; my $distroName = shift; + my $selectionName = shift; my $protectSystemPath = shift; if (!exists $supportedDistros{lc($distroName)}) { @@ -85,61 +86,46 @@ sub initialize $distro->initialize($self); $self->{distro} = $distro; + $self->{'selection-name'} = $selectionName; + my $vendorOSName = $self->{distro}->{'base-name'}; + if (length($selectionName) && $selectionName ne 'default') { + $vendorOSName .= "-$selectionName"; + } + $self->{'vendor-os-name'} = $vendorOSName; + # setup path to distribution-specific info: my $distroInfoDir = "../lib/distro-info/$distro->{'base-name'}"; if (!-d $distroInfoDir) { - die _tr("unable to find distro-info for system '%s'", $distro->{'base-name'})."\n"; + die _tr("unable to find distro-info for system '%s'\n", $distro->{'base-name'}); } $self->{'distro-info-dir'} = $distroInfoDir; $self->readDistroInfo(); - $self->setupSystemPaths($protectSystemPath); + if (!exists $self->{'distro-info'}->{'selection'}->{$selectionName}) { + die _tr("selection '%s' is unknown to system '%s'\n", + $selectionName, $distro->{'base-name'}) + ."These selections are available:\n\t" + .join("\n\t", keys %{$self->{'distro-info'}->{'selection'}}) + ."\n"; + } + + $self->{'system-path'} + = "$openslxConfig{'stage1-path'}/$self->{'vendor-os-name'}"; + vlog 1, "system will be installed to '$self->{'system-path'}'"; + if ($protectSystemPath && -e $self->{'system-path'}) { + die _tr("'%s' already exists, giving up!", $self->{'system-path'}); + } $self->createPackager(); $self->createMetaPackager(); -} - -sub setupStage1A -{ - my $self = shift; - vlog 1, "setting up stage1a for $self->{distro}->{'base-name'}..."; - $self->stage1A_createBusyboxEnvironment(); - $self->stage1A_setupResolver(); - $self->stage1A_copyPrerequiredFiles(); - $self->stage1A_copyTrustedPackageKeys(); - $self->stage1A_createRequiredFiles(); } -sub setupStage1B +sub installVendorOS { my $self = shift; - vlog 1, "setting up stage1b for $self->{distro}->{'base-name'}..."; - $self->stage1B_chrootAndBootstrap(); -} - -sub setupStage1C -{ - my $self = shift; - - vlog 1, "setting up stage1c for $self->{distro}->{'base-name'}..."; - $self->stage1C_chrootAndInstallBasicSystem(); -} - -sub setupStage1D -{ - my $self = shift; - - vlog 1, "setting up stage1d for $self->{distro}->{'base-name'}..."; - $self->stage1D_setupPackageSources(); - $self->stage1D_updateBasicSystem(); - $self->stage1D_installPackageSelection(); -} - -sub setupStage1 -{ - my $self = shift; + $self->createSystemPaths(); $self->setupStage1A(); my $pid = fork(); @@ -157,17 +143,57 @@ sub setupStage1 } $self->stage1C_cleanupBasicSystem(); $self->setupStage1D(); + + $self->addInstalledVendorOSToConfigDB(); } -sub setupRepositories +sub updateVendorOS { my $self = shift; - $self->setupStage1D(); + $self->updateStage1D(); } -sub fixPrerequiredFiles +sub addInstalledVendorOSToConfigDB { + my $self = shift; + + my $configDBModule = "OpenSLX::ConfigDB"; + unless (eval "require $configDBModule") { + if ($! == 2) { + vlog 1, _tr("ConfigDB-module not found, unable to access OpenSLX-database.\n"); + } else { + die _tr("Unable to load ConfigDB-module <%s> (%s)\n", $configDBModule, $@); + } + } else { + my $modVersion = $configDBModule->VERSION; + if ($modVersion < 1.01) { + die _tr('Could not load module <%s> (Version <%s> required, but <%s> found)', + $configDBModule, 1.01, $modVersion); + } + $configDBModule->import(qw(:access :manipulation)); + my $openslxDB = connectConfigDB(); + # insert new system if it doesn't already exist in DB: + my $vendorOSName = $self->{'vendor-os-name'}; + my $vendorOS + = fetchVendorOSesByFilter($openslxDB, + { 'name' => $vendorOSName }, + 'id'); + if (defined $vendorOS) { + print STDERR _tr("Vendor-OS <%s> already exists in OpenSLX-database!\n", + $vendorOSName); + } else { + my $id = addVendorOS($openslxDB, { + 'name' => $vendorOSName, + 'path' => $self->{'vendor-os-name'}, + }); + + print STDERR _tr("Vendor-OS <%s> has been added to DB (ID=%s)\n", + $vendorOSName, $id); + } + + disconnectConfigDB($openslxDB); + } } ################################################################################ @@ -177,7 +203,7 @@ sub readDistroInfo { my $self = shift; - vlog 1, "reading configuration info for $self->{distro}->{'base-name'}..."; + vlog 1, "reading configuration info for $self->{'vendor-os-name'}..."; # merge user-provided configuration distro defaults... my %repository = %{$self->{distro}->{config}->{repository}}; my %selection = %{$self->{distro}->{config}->{selection}}; @@ -222,17 +248,9 @@ sub readDistroInfo } } -sub setupSystemPaths +sub createSystemPaths { my $self = shift; - my $protectSystemPath = shift; - - $self->{'system-path'} - = "$openslxConfig{'stage1-path'}/$self->{distro}->{'base-name'}"; - vlog 1, "system will be installed to '$self->{'system-path'}'"; - if ($protectSystemPath && -e $self->{'system-path'}) { - die _tr("'%s' already exists, giving up!", $self->{'system-path'}); - } # specify individual paths for the respective substages: $self->{stage1aDir} = "$self->{'system-path'}/stage1a"; @@ -310,6 +328,18 @@ sub selectBaseURL return $baseURL; } +sub setupStage1A +{ + my $self = shift; + + vlog 1, "setting up stage1a for $self->{'vendor-os-name'}..."; + $self->stage1A_createBusyboxEnvironment(); + $self->stage1A_setupResolver(); + $self->stage1A_copyPrerequiredFiles(); + $self->stage1A_copyTrustedPackageKeys(); + $self->stage1A_createRequiredFiles(); +} + sub stage1A_createBusyboxEnvironment { my $self = shift; @@ -424,6 +454,14 @@ sub stage1A_createRequiredFiles } } +sub setupStage1B +{ + my $self = shift; + + vlog 1, "setting up stage1b for $self->{'vendor-os-name'}..."; + $self->stage1B_chrootAndBootstrap(); +} + sub stage1B_chrootAndBootstrap { my $self = shift; @@ -463,6 +501,14 @@ sub stage1B_chrootAndBootstrap $self->{'local-bootstrap-packages'} = \@allPkgs; } +sub setupStage1C +{ + my $self = shift; + + vlog 1, "setting up stage1c for $self->{'vendor-os-name'}..."; + $self->stage1C_chrootAndInstallBasicSystem(); +} + sub stage1C_chrootAndInstallBasicSystem { my $self = shift; @@ -517,6 +563,24 @@ sub stage1C_cleanupBasicSystem } } +sub setupStage1D +{ + my $self = shift; + + vlog 1, "setting up stage1d for $self->{'vendor-os-name'}..."; + $self->stage1D_setupPackageSources(); + $self->stage1D_updateBasicSystem(); + $self->stage1D_installPackageSelection(); +} + +sub updateStage1D +{ + my $self = shift; + + vlog 1, "updating $self->{'vendor-os-name'}..."; + $self->stage1D_updateBasicSystem(); +} + sub stage1D_setupPackageSources() { my $self = shift; @@ -550,7 +614,7 @@ sub stage1D_installPackageSelection { my $self = shift; - my $selectionName = 'default'; + my $selectionName = $self->{'selection-name'}; vlog 1, "installing package selection <$selectionName>..."; my $pkgSelection = $self->{'distro-info'}->{selection}->{$selectionName}; diff --git a/installer/slxos-setup b/installer/slxos-setup index 55b6f30f..6e829894 100755 --- a/installer/slxos-setup +++ b/installer/slxos-setup @@ -23,6 +23,9 @@ use FindBin; use lib "$FindBin::RealBin"; use lib "$FindBin::RealBin/../lib"; +use lib "$FindBin::RealBin/../config-db"; + # development path to config-db + use OpenSLX::Basics; use OpenSLX::OSSetup::Engine; @@ -34,16 +37,17 @@ my ( $helpReq, $manReq, $listReq, - $setupRepos, $verbose, $versionReq, ); +my $selection = 'default'; + GetOptions( 'help|?' => \$helpReq, 'list' => \$listReq, 'man' => \$manReq, - 'setup-repos' => \$setupRepos, + 'selection=s' => \$selection, 'verbose' => \$verbose, 'version' => \$versionReq, ) or pod2usage(2); @@ -62,8 +66,14 @@ if ($listReq) { exit 1; } -if (scalar(@ARGV) != 1) { - print STDERR _tr("You need to specify exactly one distro name!\n"); +if (scalar(@ARGV) != 2) { + print STDERR _tr("You need to specify exactly one action and one distro name!\n"); + pod2usage(2); +} +my $action = $ARGV[0]; +my $distroName = $ARGV[1]; +if ($action !~ m[^import-into-db|install|update$]i) { + print STDERR _tr("You need to specify exactly one action:\n\tinstall, update or import-into-db\n"); pod2usage(2); } @@ -74,14 +84,19 @@ chdir($FindBin::RealBin) # 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); - $engine->setupRepositories(); -} else { - $engine->initialize($distroName, 1); - $engine->setupStage1(); +if ($action =~ m[import]i) { + $engine->initialize($distroName, $selection, 0); + if (!-e $engine->{'system-path'}) { + die _tr("'%s' doesn't exist, giving up!\n", $engine->{'system-path'}); + } + $engine->addInstalledVendorOSToConfigDB(); +} elsif ($action =~ m[update]i) { + $engine->initialize($distroName, $selection, 0); + $engine->updateVendorOS(); +} elsif ($action =~ m[install]i) { + $engine->initialize($distroName, $selection, 1); + $engine->installVendorOS(); } __END__ @@ -93,13 +108,19 @@ will be used as a stage1 system for OpenSLX. =head1 SYNOPSIS -slxos-setup [options] +slxos-setup [options] Options: --help brief help message --man show full documentation + --selection= specific selection for vendor-OS --version show version + Actions: + import-into-db imports a vendor-OS into the openslx-db + install installs a vendor-OS into a folder + update updates an installed vendor-OS + =head1 OPTIONS =over 8 @@ -112,6 +133,15 @@ Prints a brief help message and exits. Prints the manual page and exits. +=item B<--selection=> + +Many distributions offer several different package selections for +installation. With this option you can specify which of these you +would like to use. + +If you pass an unknown selection, you will see a list of the selections +that are available. + =item B<--version> Prints the version and exits. -- cgit v1.2.3-55-g7522