From 71ecbe8e688b11dd3baf8dc1c41d3b355eac01c6 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Fri, 23 Oct 2009 17:26:38 +0000 Subject: default directories introduced. please test and say what you think. examples see plugins vmware and vmchooser. can be simplyfied further (VIRTDIR, ETC...). /opt/openslx can bu user for plugins, ect as well (maybe PLUGINDIR?). git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@3177 95ad53e4-c205-0410-b2fa-d234c58c8868 --- installer/OpenSLX/OSSetup/Engine.pm | 114 ++++++++++++++++++++++++++++-------- 1 file changed, 90 insertions(+), 24 deletions(-) (limited to 'installer/OpenSLX/OSSetup/Engine.pm') diff --git a/installer/OpenSLX/OSSetup/Engine.pm b/installer/OpenSLX/OSSetup/Engine.pm index ba901d23..f5a27ee7 100644 --- a/installer/OpenSLX/OSSetup/Engine.pm +++ b/installer/OpenSLX/OSSetup/Engine.pm @@ -28,6 +28,7 @@ use Exporter; use Config::General; use File::Basename; +use File::Path; use URI; use OpenSLX::Basics; @@ -93,7 +94,8 @@ sub initialize } if ($vendorOSName !~ m[^([^\-]+\-[^\-]+)(?:\-(.+))?]) { die _tr( - "Given vendor-OS has unknown format, expected '-[-]'\n" + "Given vendor-OS has unknown format, " . + "expected '-[-]'\n" ); } my $distroName = lc($1); @@ -119,14 +121,16 @@ sub initialize } elsif ($actionType eq 'update' && $support !~ m[(update)]i) { print _tr( - "Sorry, update support for vendor-OS '%s' has not been implemented!\n", + "Sorry, update support for vendor-OS '%s' has not been " . + "implemented!\n", $distroName ); exit 1; } elsif ($actionType eq 'shell' && $support !~ m[(shell)]i) { print _tr( - "Sorry, vendor-OS '%s' has no support for chrooted shells available!\n", + "Sorry, vendor-OS '%s' has no support for chrooted shells " . + "available!\n", $distroName ); exit 1; @@ -154,7 +158,8 @@ sub initialize if ($actionType =~ m{^(install|update|shell|plugin)}) { # setup path to distribution-specific info: my $sharedDistroInfoDir - = "$openslxConfig{'base-path'}/share/distro-info/$self->{'distro-name'}"; + = "$openslxConfig{'base-path'}/share/distro-info/" . + "$self->{'distro-name'}"; if (!-d $sharedDistroInfoDir) { die _tr( "unable to find shared distro-info in '%s'\n", @@ -266,6 +271,9 @@ sub installVendorOS ) ); + # generate default openslx directories for the client + $self->_generateDefaultDirs(); + # add the uclibs and tools to the stage1 and add them to library search # path $self->_copyUclibcRootfs(); @@ -305,7 +313,9 @@ sub cloneVendorOS # 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", + "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'} ) ); @@ -321,7 +331,9 @@ sub cloneVendorOS 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)? ", + "Last time this vendor-OS was cloned, it has been cloned " . + "from '%s', now you specified a different source: '%s'\n" . + "Would you still like to proceed (%s/%s)?", $lastCloneSource, $source, $yes, $no ); my $answer = ; @@ -361,6 +373,10 @@ sub cloneVendorOS ) ); } + + # generate default openslx directories for the client + $self->_generateDefaultDirs(); + # add the uclibs and tools to the stage1 and add them to library search # path $self->_copyUclibcRootfs(); @@ -401,6 +417,7 @@ sub updateVendorOS } ); + $self->_generateDefaultDirs(); $self->_copyUclibcRootfs(); $self->_touchVendorOS(); vlog( @@ -419,7 +436,8 @@ sub startChrootedShellForVendorOS if (!-e $self->{'vendor-os-path'}) { die _tr( - "can't start chrooted shell for vendor-OS '%s', since it doesn't exist!\n", + "can't start chrooted shell for vendor-OS '%s', since it doesn't " . + "exist!\n", $self->{'vendor-os-path'} ); } @@ -457,7 +475,8 @@ sub callChrootedFunctionForVendorOS if (!-e $self->{'vendor-os-path'}) { die _tr( - "can't call chrooted function for vendor-OS '%s', since it doesn't exist!\n", + "can't call chrooted function for vendor-OS '%s', since it " . + "doesn't exist!\n", $self->{'vendor-os-path'} ); } @@ -626,7 +645,8 @@ sub removeVendorOSFromConfigDB vlog( 0, _tr( - "purging export '%s', since it belongs to the vendor-OS being deleted...", + "purging export '%s', since it belongs to the vendor-OS " . + "being deleted...", $export->{name} ) ); @@ -839,7 +859,8 @@ sub _configureBestMirrorsForRepository my $mirrorsToUseCount = $openslxConfig{'mirrors-to-use-count'} || 5; vlog(1, _tr( - "selecting the '%s' best mirrors (from a set of '%s') for repo '%s' ...", + "selecting the '%s' best mirrors (from a set of '%s') for repo " . + "'%s' ...", $mirrorsToUseCount, $mirrorsToTryCount, $repoInfo->{key} ) ); @@ -1071,6 +1092,38 @@ sub _touchVendorOS return; } +sub _generateDefaultDirs +{ + my $self = shift; + my $targetRoot = shift || $self->{'vendor-os-path'}; + + vlog(0, _tr("Creating default directories ...\n")); + + my $OPENSLX_DEFAULT_DIR = "/opt/openslx"; + my $OPENSLX_DEFAULT_CONFDIR = "/etc/opt/openslx"; + my $OPENSLX_DEFAULT_LOGDIR = "/var/log/openslx"; + my $OPENSLX_DEFAULT_BINDIR = "/var/opt/openslx/bin"; + my $OPENSLX_DEFAULT_LIBDIR = "/var/opt/openslx/lib"; + my $OPENSLX_DEFAULT_VIRTDIR = "/var/lib/virt"; + mkpath("$targetRoot/$OPENSLX_DEFAULT_DIR", + "$targetRoot/$OPENSLX_DEFAULT_CONFDIR", + "$targetRoot/$OPENSLX_DEFAULT_LOGDIR", + "$targetRoot/$OPENSLX_DEFAULT_BINDIR", + "$targetRoot/$OPENSLX_DEFAULT_LIBDIR", + "$targetRoot/$OPENSLX_DEFAULT_VIRTDIR"); + slxsystem("chmod 1777 $targetRoot/$OPENSLX_DEFAULT_LOGDIR"); + + my $openslxConfig = "OPENSLX_DEFAULT_DIR=$OPENSLX_DEFAULT_DIR\n"; + $openslxConfig .= "OPENSLX_DEFAULT_CONFDIR=$OPENSLX_DEFAULT_CONFDIR\n"; + $openslxConfig .= "OPENSLX_DEFAULT_LOGDIR=$OPENSLX_DEFAULT_LOGDIR\n"; + $openslxConfig .= "OPENSLX_DEFAULT_BINDIR=$OPENSLX_DEFAULT_BINDIR\n"; + $openslxConfig .= "OPENSLX_DEFAULT_LIBDIR=$OPENSLX_DEFAULT_LIBDIR\n"; + $openslxConfig .= "OPENSLX_DEFAULT_VIRTDIR=$OPENSLX_DEFAULT_VIRTDIR\n"; + + spitFile("$targetRoot/$OPENSLX_DEFAULT_CONFDIR/openslx.conf", + "$openslxConfig"); +} + sub _copyUclibcRootfs { my $self = shift; @@ -1170,7 +1223,8 @@ sub _sortRepositoryURLs if (!@URLs) { die( _tr( - "repository '%s' has no URLs defined, unable to fetch anything!", + "repository '%s' has no URLs defined, " . + "unable to fetch anything!", $repoInfo->{name}, ) ); @@ -1210,10 +1264,12 @@ try_next_url: } elsif ($basefile =~ /.*\.rpm/) { vlog(5,"Trying suggested name because of .rpm-ending."); } else { - die _tr("file <$basefile> not found in list received from mirror"); + die _tr("file <$basefile> not found in list received from" . + "mirror"); } vlog(2, "fetching <$basefile>..."); - if (slxsystem("wget", "-c", "-O", "$basefile", "$url/$basedir$basefile") == 0) { + if (slxsystem("wget", "-c", "-O", "$basefile", + "$url/$basedir$basefile") == 0) { $foundFile = $basefile; last; } @@ -1253,11 +1309,12 @@ sub _startLocalURLServersAsNeeded 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 + next if $localURL =~ m[^\w+:]; # anything /w a protcol-spec is non-local if (!exists $localHttpServers{$localURL}) { my $pid = executeInSubprocess( - $self->busyboxBinary(), "httpd", '-p', $port, '-h', '/', '-f' + $self->busyboxBinary(), "httpd", '-p', $port, '-h', '/', + '-f' ); vlog(1, _tr( @@ -1300,7 +1357,8 @@ sub _setupStage1A # we create *all* of the above folders by creating stage1cDir: my $stage1cDir - = "$self->{'stage1aDir'}/$self->{'stage1bSubdir'}/$self->{'stage1cSubdir'}"; + = "$self->{'stage1aDir'}/$self->{'stage1bSubdir'}/". + "$self->{'stage1cSubdir'}"; if (slxsystem("mkdir -p $stage1cDir")) { die _tr("unable to create directory '%s', giving up! (%s)\n", $stage1cDir, $!); @@ -1346,7 +1404,8 @@ sub _stage1A_setupResolver #copyFile("$libcFolder/libnss_files*", "$self->{stage1aDir}$libcFolder"); my $stage1cDir - = "$self->{'stage1aDir'}/$self->{'stage1bSubdir'}/$self->{'stage1cSubdir'}"; + = "$self->{'stage1aDir'}/$self->{'stage1bSubdir'}/" . + "$self->{'stage1cSubdir'}"; copyFile('/etc/resolv.conf', "$stage1cDir/etc"); return; } @@ -1359,14 +1418,16 @@ sub _stage1A_copyPrerequiredFiles vlog(2, "copying folder with pre-required files..."); my $stage1cDir - = "$self->{'stage1aDir'}/$self->{'stage1bSubdir'}/$self->{'stage1cSubdir'}"; + = "$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", + "unable to copy folder with pre-required files to folder '%s'" . + "(%s)\n", $stage1cDir, $! ); } @@ -1391,7 +1452,8 @@ sub _stage1A_copyTrustedPackageKeys ]; if (slxsystem($cmd)) { die _tr( - "unable to copy folder with trusted package keys to folder '%s' (%s)\n", + "unable to copy folder with trusted package keys to folder " . + "'%s' (%s)\n", "$stage1bDir/trusted-package-keys", $! ); } @@ -1467,7 +1529,8 @@ sub _stage1B_chrootAndBootstrap $self->{'distro-info'}->{repository}->{base} ); $self->{'baseURL-index'} = 0; - my @pkgs = string2Array($self->{'distro-info'}->{'prereq-packages'}); + my @pkgs = + string2Array($self->{'distro-info'}->{'prereq-packages'}); vlog( 2, "downloading these prereq packages:\n\t" . join("\n\t", @pkgs) @@ -1476,7 +1539,8 @@ sub _stage1B_chrootAndBootstrap $self->{'prereq-packages'} = \@prereqPkgs; $self->{packager}->bootstrap(\@prereqPkgs); - @pkgs = string2Array($self->{'distro-info'}->{'bootstrap-packages'}); + @pkgs = + string2Array($self->{'distro-info'}->{'bootstrap-packages'}); push( @pkgs, string2Array( @@ -1537,7 +1601,8 @@ sub _stage1C_cleanupBasicVendorOS my $self = shift; my $stage1cDir - = "$self->{'stage1aDir'}/$self->{'stage1bSubdir'}/$self->{'stage1cSubdir'}"; + = "$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", @@ -1791,7 +1856,8 @@ sub _installPlugins ); for my $pluginInfo ( sort { - $self->_sortPluginsByDependency($a->{plugin_name}, $b->{plugin_name}); + $self->_sortPluginsByDependency($a->{plugin_name}, + $b->{plugin_name}); } @$plugins ) { my $pluginName = $pluginInfo->{plugin_name}; -- cgit v1.2.3-55-g7522