From 7926993940c0d4f8b1bab9557cf972364d782402 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Mon, 28 May 2007 21:10:57 +0000 Subject: * added support for 'local:'-URLs, which trigger the automatic start of a busybox-httpd for each repository, through which every request will be routed (thus giving access to files outside of the chroot) * renamed executeInSubprocess() to callInSubprocess() and added a real implementation of executeInSubprocess(), too * updated all settings.local.example files to reflect the new way of accessing local files git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1102 95ad53e4-c205-0410-b2fa-d234c58c8868 --- installer/OpenSLX/OSSetup/Engine.pm | 65 +++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 3 deletions(-) (limited to 'installer/OpenSLX/OSSetup/Engine.pm') diff --git a/installer/OpenSLX/OSSetup/Engine.pm b/installer/OpenSLX/OSSetup/Engine.pm index 82c93648..9d7d31ab 100644 --- a/installer/OpenSLX/OSSetup/Engine.pm +++ b/installer/OpenSLX/OSSetup/Engine.pm @@ -79,6 +79,20 @@ sub new return bless $self, $class; } +sub DESTROY +{ + my $self = shift; + + if ($self->{'local-http-server-master-pid'} == $$) { + # we are the master process, so we clean up all the servers that we + # have started: + while(my ($localURL, $pid) = each %{$self->{'local-http-servers'}}) { + vlog 1, _tr("stopping local HTTP-server for URL '%s'.", $localURL); + kill TERM => $pid; + } + } +} + sub initialize { my $self = shift; @@ -160,13 +174,15 @@ sub installVendorOS } $self->createVendorOSPath(); + $self->startLocalURLServersAsNeeded(); + my $baseSystemFile = "$self->{'vendor-os-path'}/.openslx-base-system"; if (-e $baseSystemFile) { vlog 0, _tr("found existing base system, continuing...\n"); } else { # basic setup, stage1a-c: $self->setupStage1A(); - executeInSubprocess( sub { + callInSubprocess( sub { # some tasks that involve a chrooted environment: $self->changePersonalityIfNeeded(); $self->setupStage1B(); @@ -176,7 +192,7 @@ sub installVendorOS slxsystem("touch $baseSystemFile"); # just touch the file, in order to indicate a basic system } - executeInSubprocess( sub { + callInSubprocess( sub { # another task that involves a chrooted environment: $self->changePersonalityIfNeeded(); $self->setupStage1D(); @@ -268,7 +284,10 @@ sub updateVendorOS die _tr("can't update vendor-OS '%s', since it doesn't exist!\n", $self->{'vendor-os-path'}); } - executeInSubprocess( sub { + + $self->startLocalURLServersAsNeeded(); + + callInSubprocess( sub { $self->changePersonalityIfNeeded(); $self->updateStage1D(); }); @@ -489,6 +508,14 @@ sub sortRepositoryURLs my $self = shift; my $repoInfo = shift; + if ($repoInfo->{'url'} =~ m[^local:]) { + # a local URL blocks all the others, in order to avoid causing + # (external) network traffic: + my $localURL = $repoInfo->{'url'}; + $localURL =~ s[^local:][http:]; + return [ $localURL ]; + } + my %urlInfo; # specified URL always has highest precedence: $urlInfo{$repoInfo->{url}} = 0 if defined $repoInfo->{url}; @@ -546,6 +573,38 @@ try_next_url: return @foundFiles; } +sub startLocalURLServersAsNeeded +{ + my $self = shift; + + $self->{'local-http-server-master-pid'} = $$; + + foreach my $repoInfo (values %{$self->{'distro-info'}->{repository}}) { + + next unless $repoInfo->{'url'} =~ m[^local:]; + my $localURL = $repoInfo->{url}; + if (!exists $self->{'local-http-servers'}->{$localURL}) { + my $busyboxName + = $self->hostIs64Bit() + ? 'busybox.x86_64' + : 'busybox.i586'; + my $busybox = "$openslxConfig{'share-path'}/busybox/$busyboxName"; + my $port = 5080; + if ($localURL =~ m[:(\d+)/]) { + $port = $1; + } + my $pid = executeInSubprocess( + $busybox, "httpd", + '-p', $port, + '-h', '/', + '-f' + ); + vlog 1, _tr("started local HTTP-server for URL '%s'.", $localURL); + $self->{'local-http-servers'}->{$localURL} = $pid; + } + } +} + sub setupStage1A { my $self = shift; -- cgit v1.2.3-55-g7522