summaryrefslogtreecommitdiffstats
path: root/installer/OpenSLX/OSSetup/Distro/Base.pm
diff options
context:
space:
mode:
authorOliver Tappe2007-07-28 16:11:27 +0200
committerOliver Tappe2007-07-28 16:11:27 +0200
commitcbce11c51c6aa5674b01821a7adc7c31f7999c7e (patch)
tree38fd368f9b9d1a7db30131578d7fb77060d9800d /installer/OpenSLX/OSSetup/Distro/Base.pm
parent* added example settings file for ubuntu-6.10 (diff)
downloadcore-cbce11c51c6aa5674b01821a7adc7c31f7999c7e.tar.gz
core-cbce11c51c6aa5674b01821a7adc7c31f7999c7e.tar.xz
core-cbce11c51c6aa5674b01821a7adc7c31f7999c7e.zip
* changed several class interfaces as a result of trying to integrate support
for Debian & Ubunto installation (which is still not complete, though) * fixed some bugs along the way (especially the meta-packagers trying to invoke a private function of OpenSLX::OSSetup::Engine) git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1281 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'installer/OpenSLX/OSSetup/Distro/Base.pm')
-rw-r--r--installer/OpenSLX/OSSetup/Distro/Base.pm62
1 files changed, 58 insertions, 4 deletions
diff --git a/installer/OpenSLX/OSSetup/Distro/Base.pm b/installer/OpenSLX/OSSetup/Distro/Base.pm
index 9b59a828..020215ea 100644
--- a/installer/OpenSLX/OSSetup/Distro/Base.pm
+++ b/installer/OpenSLX/OSSetup/Distro/Base.pm
@@ -20,6 +20,7 @@ our $VERSION = 1.01; # API-version . implementation-version
use File::Basename;
use OpenSLX::Basics;
+use OpenSLX::Utils;
################################################################################
### interface methods
@@ -121,6 +122,63 @@ sub initDistroInfo
sub startSession
{
+ my $self = shift;
+ my $osDir = shift;
+
+ # ensure that the session will be finished even if the script crashes:
+ addCleanupFunction(
+ "slxos-setup::distro::chroot", sub { $self->finishSession(); }
+ );
+
+ # make sure there's a /dev/zero and /dev/null
+ if (!-e "$osDir/dev" && !mkdir("$osDir/dev")) {
+ die _tr("unable to create folder '%s' (%s)\n", "$osDir/dev", $!);
+ }
+ if (!-e "$osDir/dev/zero" && slxsystem("mknod $osDir/dev/zero c 1 5")) {
+ die _tr("unable to create node '%s' (%s)\n", "$osDir/dev/zero", $!);
+ }
+ if (!-e "$osDir/dev/null" && slxsystem("mknod $osDir/dev/null c 1 3")) {
+ die _tr("unable to create node '%s' (%s)\n", "$osDir/dev/null", $!);
+ }
+
+ # fake proc, depending on what is needed ...
+ if (!-e "$osDir/proc" && !mkdir("$osDir/proc")) {
+ die _tr("unable to create folder '%s' (%s)\n", "$osDir/proc", $!);
+ }
+ if (!-e "$osDir/proc/cpuinfo" && slxsystem("cp /proc/cpuinfo $osDir/proc/")) {
+ die _tr("unable to copy file '%s' (%s)\n", "/proc/cpuinfo", $!);
+ }
+ # TODO: alternatively, we could mount proc, but that causes problems
+ # when we are not able to umount it properly (which may happen
+ # if 'umount' is not available in the chroot!)
+ #
+ # mount /proc
+# if (!-e "$osDir/proc") {
+# slxsystem("mkdir -p $osDir/proc");
+# }
+# if (slxsystem("mount -t proc proc $osDir/proc 2>/dev/null")) {
+# die _tr("unable to mount '%s' (%s)\n", "$osDir/proc", $!);
+# }
+
+ # enter chroot jail
+ chrootInto($osDir);
+ $ENV{PATH} = "/bin:/sbin:/usr/bin:/usr/sbin";
+
+ return;
+}
+
+sub finishSession
+{
+ my $self = shift;
+
+ removeCleanupFunction('slxos-setup::distro::chroot');
+
+ # unmount /proc
+# if (slxsystem('ash', '-c', 'umount /proc 2>/dev/null')) {
+# die _tr("unable to unmount '%s' (%s)\n", "/proc", $!);
+# }
+
+ return;
}
sub updateDistroConfig
@@ -130,10 +188,6 @@ sub updateDistroConfig
}
}
-sub finishSession
-{
-}
-
sub pickKernelFile
{
my $self = shift;