From 416ab8a37f1b07dc9f6c0fb3ff1a8ff2036510b5 Mon Sep 17 00:00:00 2001 From: Sebastian Schmelzer Date: Thu, 2 Sep 2010 17:50:49 +0200 Subject: change dir structure --- src/installer/OpenSLX/OSSetup/Distro/Any_Clone.pm | 31 ++ src/installer/OpenSLX/OSSetup/Distro/Base.pm | 371 +++++++++++++++++++++ src/installer/OpenSLX/OSSetup/Distro/Debian.pm | 135 ++++++++ src/installer/OpenSLX/OSSetup/Distro/Debian_3_1.pm | 74 ++++ src/installer/OpenSLX/OSSetup/Distro/Fedora.pm | 48 +++ src/installer/OpenSLX/OSSetup/Distro/Gentoo.pm | 33 ++ src/installer/OpenSLX/OSSetup/Distro/Scilin.pm | 48 +++ src/installer/OpenSLX/OSSetup/Distro/Suse.pm | 98 ++++++ src/installer/OpenSLX/OSSetup/Distro/Ubuntu.pm | 119 +++++++ 9 files changed, 957 insertions(+) create mode 100644 src/installer/OpenSLX/OSSetup/Distro/Any_Clone.pm create mode 100644 src/installer/OpenSLX/OSSetup/Distro/Base.pm create mode 100644 src/installer/OpenSLX/OSSetup/Distro/Debian.pm create mode 100644 src/installer/OpenSLX/OSSetup/Distro/Debian_3_1.pm create mode 100644 src/installer/OpenSLX/OSSetup/Distro/Fedora.pm create mode 100644 src/installer/OpenSLX/OSSetup/Distro/Gentoo.pm create mode 100644 src/installer/OpenSLX/OSSetup/Distro/Scilin.pm create mode 100644 src/installer/OpenSLX/OSSetup/Distro/Suse.pm create mode 100644 src/installer/OpenSLX/OSSetup/Distro/Ubuntu.pm (limited to 'src/installer/OpenSLX/OSSetup/Distro') diff --git a/src/installer/OpenSLX/OSSetup/Distro/Any_Clone.pm b/src/installer/OpenSLX/OSSetup/Distro/Any_Clone.pm new file mode 100644 index 00000000..43385a29 --- /dev/null +++ b/src/installer/OpenSLX/OSSetup/Distro/Any_Clone.pm @@ -0,0 +1,31 @@ +# Copyright (c) 2006, 2007 - OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# OSSetup/Distro/Any_Clone.pm +# - provides generic clone-only overrides of the OSSetup Distro API. +# ----------------------------------------------------------------------------- +package OpenSLX::OSSetup::Distro::Any_Clone; + +use strict; +use warnings; + +use base qw(OpenSLX::OSSetup::Distro::Base); + +################################################################################ +### interface methods +################################################################################ +sub new +{ + my $class = shift; + my $self = {}; + return bless $self, $class; +} + +1; \ No newline at end of file diff --git a/src/installer/OpenSLX/OSSetup/Distro/Base.pm b/src/installer/OpenSLX/OSSetup/Distro/Base.pm new file mode 100644 index 00000000..c356e6d9 --- /dev/null +++ b/src/installer/OpenSLX/OSSetup/Distro/Base.pm @@ -0,0 +1,371 @@ +# Copyright (c) 2006..2010 - OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# OSSetup/Distro/Base.pm +# - provides base implementation of the OSSetup Distro API. +# ----------------------------------------------------------------------------- +package OpenSLX::OSSetup::Distro::Base; + +use strict; +use warnings; + +our $VERSION = 1.01; # API-version . implementation-version + +use Fcntl qw(:DEFAULT :flock); +use File::Basename; +use File::Path; +use Scalar::Util qw( weaken ); + +use OpenSLX::Basics; +use OpenSLX::Utils; + +################################################################################ +### interface methods +################################################################################ +sub new +{ + confess "Creating OpenSLX::OSSetup::System::Base-objects directly makes no sense!"; +} + +sub initialize +{ + my $self = shift; + my $engine = shift; + + $self->{'engine'} = $engine; + weaken($self->{'engine'}); + # avoid circular reference between distro and its engine + + if ($engine->{'distro-name'} =~ m[x86_64]) { + # be careful to only try installing 64-bit systems if actually + # running on a 64-bit host, as otherwise we are going to fail later, + # anyway: + my $arch = `uname -m`; + if ($?) { + die _tr("unable to determine architecture of host system (%s)\n", $!); + } + if ($arch !~ m[x86_64]) { + die _tr("you can't install a 64-bit system on a 32-bit host, sorry!\n"); + } + } + + $self->{'stage1a-binaries'} = { + "$openslxConfig{'base-path'}/share/busybox/busybox" => 'bin', + }; + + $self->{'stage1b-faked-files'} = [ + '/etc/mtab', + ]; + + $self->{'stage1c-faked-files'} = [ + ]; + + $self->{'clone-filter'} = " + + /var + - /var/tmp/* + - /var/spool/* + - /var/cache/apt/archives/*.deb + - /var/cache/apt/archives/lock + - /var/cache/apt/archives/partial/* + + /var/cache/apt/archives/partial + - /var/tmp/* + + /var/tmp/apt + - /var/opt/openslx + - /var/lib/vmware + - /var/lib/ntp/* + - /var/run/* + + /var/run/screen + - /var/log/* + + /var/log/apt + - /usr/lib/vmware/modules/* + + /usr + - /tmp/* + + /tmp + - /sys/* + + /sys + + /sbin + - /root/* + + /root + - /proc/* + + /proc + - /opt/openslx + + /opt + - /media/* + + /media + - /mnt/* + + /mnt + + /lib64 + - /lib/ld-uClibc* + + /lib + - /home/* + + /home + - /etc/vmware/* + + /etc/vmware + - /etc/vmware-installer + - /etc/grub* + - /etc/shadow* + - /etc/samba/secrets.tdb + - /etc/resolv.conf.* + - /etc/opt/openslx + + /etc/opt/openslx + - /etc/exports* + - /etc/X11/xorg.* + - /etc/X11/XF86* + + /etc + - /dev/* + + /dev + + /boot + + /bin + - /* + - .svn + - .git + - .*.cmd + - *~ + - *lost+found* + - *.old + - *.bak + "; + + return; +} + +sub fixPrerequiredFiles +{ +} + +sub startSession +{ + my $self = shift; + my $osDir = shift; + + # setup a fixed locale environment to avoid warnings about unset locales + # (like for instance shown by apt-get) + $ENV{LC_ALL} = 'POSIX'; + + # ensure that a couple of important devices exist + my %devInfo = ( + mem => { type => 'c', major => '1', minor => '1' }, + null => { type => 'c', major => '1', minor => '3' }, + zero => { type => 'c', major => '1', minor => '5' }, + random => { type => 'c', major => '1', minor => '8' }, + urandom => { type => 'c', major => '1', minor => '9' }, + kmsg => { type => 'c', major => '1', minor => '11' }, + tty => { type => 'c', major => '5', minor => '0' }, + console => { type => 'c', major => '5', minor => '1' }, + ptmx => { type => 'c', major => '5', minor => '2' }, + ); + if (!-e "$osDir/dev" && !mkpath("$osDir/dev")) { + die _tr("unable to create folder '%s' (%s)\n", "$osDir/dev", $!); + } + foreach my $dev (keys %devInfo) { + my $info = $devInfo{$dev}; + if (!-e "$osDir//dev/$dev") { + if (slxsystem( + "mknod $osDir//dev/$dev $info->{type} $info->{major} $info->{minor}" + )) { + croak(_tr("unable to create dev-node '%s'! (%s)", $dev, $!)); + } + } + } + + # enter chroot jail + chrootInto($osDir); + $ENV{PATH} = join(':', @{$self->getDefaultPathList()}); + + # mount /proc (if we have 'mount' available) + if (qx{which mount 2>/dev/null}) { + if (!-e '/proc' && !mkpath('/proc')) { + die _tr("unable to create folder '%s' (%s)\n", "$osDir/proc", $!); + } + if (slxsystem("mount -t proc proc '/proc'")) { + warn _tr("unable to mount '%s' (%s)\n", "$osDir/proc", $!); + } + if (!-e '/dev/pts' && !mkpath('/dev/pts')) { + die _tr("unable to create folder '%s' (%s)\n", "$osDir/dev/pts", $!); + } + if (slxsystem("mount -t devpts devpts '/dev/pts'")) { + warn _tr("unable to mount '%s' (%s)\n", "$osDir/dev/pts", $!); + } + } + + return 1; +} + +sub finishSession +{ + my $self = shift; + + # umount /proc, /dev/pts (if we have 'umount' available) + if (qx{which umount 2>/dev/null}) { + if (slxsystem("umount /proc")) { + warn _tr("unable to umount '%s' (%s)\n", "/proc", $!); + } + if (slxsystem("umount /dev/pts")) { + warn _tr("unable to umount '%s' (%s)\n", "/dev/pts", $!); + } + } + + return 1; +} + +sub getDefaultPathList +{ + my $self = shift; + + return [ qw( + /sbin + /usr/sbin + /usr/local/sbin + /usr/local/bin + /usr/bin + /bin + /usr/bin/X11 + /usr/X11R6/bin + /opt/kde3/bin + /opt/gnome/bin + ) ]; +} + +sub updateDistroConfig +{ + if (slxsystem("ldconfig")) { + die _tr("unable to run ldconfig (%s)", $!); + } +} + +sub pickKernelFile +{ + my $self = shift; + my $kernelPath = shift; + + my $newestKernelFile; + my $newestKernelFileSortKey = ''; + my $kernelPattern = '{vmlinuz,kernel-genkernel-x86}-*'; + foreach my $kernelFile (glob("$kernelPath/$kernelPattern")) { + next unless $kernelFile =~ m{ + (?:vmlinuz|x86)-(\d+)\.(\d+)\.(\d+)(?:\.(\d+))?-(\d+(?:\.\d+)?) + }x; + my $sortKey + = sprintf("%02d.%02d.%02d.%02d-%2.1f", $1, $2, $3, $4||0, $5); + if ($newestKernelFileSortKey lt $sortKey) { + $newestKernelFile = $kernelFile; + $newestKernelFileSortKey = $sortKey; + } + } + + if (!defined $newestKernelFile) { + die _tr("unable to pick a kernel-file from path '%s'!", $kernelPath); + } + return $newestKernelFile; +} + +sub preSystemInstallationHook +{ +} + +sub postSystemInstallationHook +{ +} + +sub setPasswordForUser +{ + my $self = shift; + my $username = shift; + my $password = shift; + + my $hashedPassword = $self->hashPassword($password); + + my $writePasswordFunction = sub { + # now read, change and write shadow-file in atomic manner: + my $shadowFile = '/etc/shadow'; + if (!-e $shadowFile) { + spitFile( $shadowFile, ''); + } + slxsystem("cp -r $shadowFile $shadowFile~"); + my $shadowFH; + open($shadowFH, '+<', $shadowFile) + or croak _tr("could not open file '%s'! (%s)", $shadowFile, $!); + flock($shadowFH, LOCK_EX) + or croak _tr("could not lock file '%s'! (%s)", $shadowFile, $!); + my $lastChanged = int(time()/24/60/60); + my $newEntry + = "$username:$hashedPassword:$lastChanged:0:99999:7:::"; + my $content = do { local $/; <$shadowFH> }; + if ($content =~ m{^$username:}ims) { + $content =~ s{^$username:.+?$}{$newEntry}ms; + } else { + $content .= "$newEntry\n"; + } + seek($shadowFH, 0, 0) + or croak _tr("could not seek file '%s'! (%s)", $shadowFile, $!); + print $shadowFH $content + or croak _tr("could not write to file '%s'! (%s)", $shadowFile, $!); + close($shadowFH) + or croak _tr("could not close file '%s'! (%s)", $shadowFile, $!); + unlink "$shadowFile~"; + }; + $self->{engine}->callChrootedFunctionForVendorOS($writePasswordFunction); +} + +sub hashPassword +{ + my $self = shift; + my $password = shift; + + my $busyboxBin = $self->{engine}->busyboxBinary(); + my $hashedPassword = qx{$busyboxBin cryptpw -a md5 $password}; + chomp $hashedPassword; + + return $hashedPassword; +} + +1; +################################################################################ + +=pod + +=head1 NAME + +OpenSLX::OSSetup::System::Base - the base class for all OSSetup backends + +=head1 SYNOPSIS + + package OpenSLX::OSSetup::coolnewOS; + + use vars qw(@ISA $VERSION); + @ISA = ('OpenSLX::OSSetup::Base'); + $VERSION = 1.01; + + use coolnewOS; + + sub new + { + my $class = shift; + my $self = {}; + return bless $self, $class; + } + + # override all methods of OpenSLX::OSSetup::Base in order to implement + # a full OS-setup backend + ... + +I> + +=head1 DESCRIPTION + +This class defines the OSSetup interface for the OpenSLX. + +Aim of the OSSetup abstraction is to make it possible to install a large set +of different operating systems transparently. + +... + +=cut diff --git a/src/installer/OpenSLX/OSSetup/Distro/Debian.pm b/src/installer/OpenSLX/OSSetup/Distro/Debian.pm new file mode 100644 index 00000000..bdb9dcc1 --- /dev/null +++ b/src/installer/OpenSLX/OSSetup/Distro/Debian.pm @@ -0,0 +1,135 @@ +# Copyright (c) 2006, 2007 - OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# OSSetup/Distro/Debian.pm +# - provides Debian-specific overrides of the OSSetup Distro API. +# ----------------------------------------------------------------------------- +package OpenSLX::OSSetup::Distro::Debian; + +use strict; +use warnings; + +use base qw(OpenSLX::OSSetup::Distro::Base); + +use OpenSLX::Basics; +use OpenSLX::Utils; + +################################################################################ +### interface methods +################################################################################ +sub new +{ + my $class = shift; + my $self = {}; + return bless $self, $class; +} + +sub initialize +{ + my $self = shift; + my $engine = shift; + + $self->SUPER::initialize($engine); + $self->{'packager-type'} = 'dpkg'; + $self->{'meta-packager-type'} = $ENV{SLX_META_PACKAGER} || 'apt'; + $self->{'stage1c-faked-files'} = []; + return; +} + +sub preSystemInstallationHook +{ + my $self = shift; + + $self->SUPER::preSystemInstallationHook(); + + # create required /dev-entries + my %devInfo = ( + mem => { type => 'c', major => '1', minor => '1' }, + null => { type => 'c', major => '1', minor => '3' }, + zero => { type => 'c', major => '1', minor => '5' }, + random => { type => 'c', major => '1', minor => '8' }, + urandom => { type => 'c', major => '1', minor => '9' }, + kmsg => { type => 'c', major => '1', minor => '11' }, + console => { type => 'c', major => '5', minor => '1' }, + ptmx => { type => 'c', major => '5', minor => '2' }, + ); + foreach my $dev (keys %devInfo) { + my $info = $devInfo{$dev}; + if (!-e "/dev/$dev") { + if (slxsystem( + "mknod /dev/$dev $info->{type} $info->{major} $info->{minor}" + )) { + croak(_tr("unable to create dev-node '%s'! (%s)", $dev, $!)); + } + } + } + foreach my $devDir ('pts', 'shm', '.udevdb', '.udev') { + if (!-e "/dev/$devDir") { + if (slxsystem("mkdir -p /dev/$devDir")) { + croak(_tr("unable to create dev-dir '%s'! (%s)", $devDir, $!)); + } + } + } + + # replace /usr/sbin/invoke-rc.d by a dummy, in order to avoid a whole lot + # of initscripts being started. Wishful thinking: there should be another + # way to stop Debian from doing this, as this is not really very supportive + # of folder-based installations (then again: I may simply be too stupid + # to find out how it is supposed to work ...) + rename('/usr/sbin/invoke-rc.d', '/usr/sbin/_invoke-rc.d'); + spitFile('/usr/sbin/invoke-rc.d', "#! /bin/sh\nexit 0\n"); + chmod 0755, '/usr/sbin/invoke-rc.d'; +} + +sub startSession +{ + my $self = shift; + my $osDir = shift; + + $self->SUPER::startSession($osDir); + + # As in preSystemInstallationHook, we replace /usr/sbin/invoke-rc.d by a + # dummy. + # + # During installation, this might not exist yet, so we better check + if (-e '/usr/sbin/invoke-rc.d') { + rename('/usr/sbin/invoke-rc.d', '/usr/sbin/_invoke-rc.d'); + spitFile('/usr/sbin/invoke-rc.d', "#! /bin/sh\nexit 0\n"); + chmod 0755, '/usr/sbin/invoke-rc.d'; + } +} + +sub finishSession +{ + my $self = shift; + + # restore /usr/sbin/invoke-rc.d + rename('/usr/sbin/_invoke-rc.d', '/usr/sbin/invoke-rc.d'); + + $self->SUPER::finishSession(); +} + +sub setPasswordForUser +{ + my $self = shift; + my $username = shift; + my $password = shift; + + # activate shadow passwords + my $activateShadowFunction = sub { + slxsystem('/sbin/shadowconfig', 'on'); + }; + $self->{engine}->callChrootedFunctionForVendorOS($activateShadowFunction); + + # invoke default behaviour + $self->SUPER::setPasswordForUser($username, $password); +} + +1; \ No newline at end of file diff --git a/src/installer/OpenSLX/OSSetup/Distro/Debian_3_1.pm b/src/installer/OpenSLX/OSSetup/Distro/Debian_3_1.pm new file mode 100644 index 00000000..03c6fdf9 --- /dev/null +++ b/src/installer/OpenSLX/OSSetup/Distro/Debian_3_1.pm @@ -0,0 +1,74 @@ +# Copyright (c) 2006, 2007 - OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# OSSetup/Distro/Debian_3_1.pm +# - provides Debian-3.1-specific overrides of the OSSetup Distro API. +# ----------------------------------------------------------------------------- +package OpenSLX::OSSetup::Distro::Debian_3_1; + +use strict; +use warnings; + +use base qw(OpenSLX::OSSetup::Distro::Debian); + +use OpenSLX::Basics; +use OpenSLX::Utils; + +################################################################################ +### implementation +################################################################################ +sub preSystemInstallationHook +{ + my $self = shift; + + $self->SUPER::preSystemInstallationHook(); + + # when the kernel package is being configured, it insists on trying to + # create an initrd, which neither works nor makes sense in our environment. + # + # in order to circumvent this problem, we manually install initrd-tools + # (which contains mkinitrd) ... + $self->{engine}->{'meta-packager'}->installPackages('initrd-tools'); + # ... and replace /usr/sbin/mkinitrd with a dummy, in order to skip the + # initrd-creation. + rename('/usr/sbin/mkinitrd', '/usr/sbin/_mkinitrd'); + spitFile('/usr/sbin/mkinitrd', "#! /bin/sh\ntouch \$2\n"); + chmod 0755, '/usr/sbin/mkinitrd'; +} + +sub startSession +{ + my $self = shift; + my $osDir = shift; + + $self->SUPER::startSession($osDir); + + # As in preSystemInstallationHook, we replace /usr/sbin/mkinitrd with a + # dummy, in order to skip the initrd-creation. + # + # During installation, this might not exist yet, so we better check + if (-e '/usr/sbin/mkinitrd') { + rename('/usr/sbin/mkinitrd', '/usr/sbin/_mkinitrd'); + spitFile('/usr/sbin/mkinitrd', "#! /bin/sh\ntouch \$2\n"); + chmod 0755, '/usr/sbin/mkinitrd'; + } +} + +sub finishSession +{ + my $self = shift; + + # restore /usr/sbin/mkinitrd + rename('/usr/sbin/_mkinitrd', '/usr/sbin/mkinitrd'); + + $self->SUPER::finishSession(); +} + +1; \ No newline at end of file diff --git a/src/installer/OpenSLX/OSSetup/Distro/Fedora.pm b/src/installer/OpenSLX/OSSetup/Distro/Fedora.pm new file mode 100644 index 00000000..80480340 --- /dev/null +++ b/src/installer/OpenSLX/OSSetup/Distro/Fedora.pm @@ -0,0 +1,48 @@ +# Copyright (c) 2006, 2007 - OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# OSSetup/Distro/Fedora.pm +# - provides Fedora-specific overrides of the OSSetup Distro API. +# ----------------------------------------------------------------------------- +package OpenSLX::OSSetup::Distro::Fedora; + +use strict; +use warnings; + +use base qw(OpenSLX::OSSetup::Distro::Base); + +use OpenSLX::Basics; + +################################################################################ +### interface methods +################################################################################ +sub new +{ + my $class = shift; + my $self = {}; + return bless $self, $class; +} + +sub initialize +{ + my $self = shift; + my $engine = shift; + + $self->SUPER::initialize($engine); + $self->{'packager-type'} = 'rpm'; + $self->{'meta-packager-type'} = $ENV{SLX_META_PACKAGER} || 'yum'; + $self->{'stage1c-faked-files'} = [ + '/etc/fstab', + '/etc/mtab', + ]; + return; +} + +1; \ No newline at end of file diff --git a/src/installer/OpenSLX/OSSetup/Distro/Gentoo.pm b/src/installer/OpenSLX/OSSetup/Distro/Gentoo.pm new file mode 100644 index 00000000..79fd0e29 --- /dev/null +++ b/src/installer/OpenSLX/OSSetup/Distro/Gentoo.pm @@ -0,0 +1,33 @@ +# Copyright (c) 2006, 2007 - OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# OSSetup/Distro/Gentoo.pm +# - provides Gentoo-specific overrides of the OSSetup Distro API. +# ----------------------------------------------------------------------------- +package OpenSLX::OSSetup::Distro::Gentoo; + +use strict; +use warnings; + +use base qw(OpenSLX::OSSetup::Distro::Base); + +use OpenSLX::Basics; + +################################################################################ +### interface methods +################################################################################ +sub new +{ + my $class = shift; + my $self = {}; + return bless $self, $class; +} + +1; diff --git a/src/installer/OpenSLX/OSSetup/Distro/Scilin.pm b/src/installer/OpenSLX/OSSetup/Distro/Scilin.pm new file mode 100644 index 00000000..e1ce5fc3 --- /dev/null +++ b/src/installer/OpenSLX/OSSetup/Distro/Scilin.pm @@ -0,0 +1,48 @@ +# Copyright (c) 2009 - OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# OSSetup/Distro/Scilin.pm +# - provides Scientific Linux specific overrides of the OSSetup Distro API. +# ----------------------------------------------------------------------------- +package OpenSLX::OSSetup::Distro::Scilin; + +use strict; +use warnings; + +use base qw(OpenSLX::OSSetup::Distro::Base); + +use OpenSLX::Basics; + +################################################################################ +### interface methods +################################################################################ +sub new +{ + my $class = shift; + my $self = {}; + return bless $self, $class; +} + +sub initialize +{ + my $self = shift; + my $engine = shift; + + $self->SUPER::initialize($engine); + $self->{'packager-type'} = 'rpm'; + $self->{'meta-packager-type'} = $ENV{SLX_META_PACKAGER} || 'yum'; + $self->{'stage1c-faked-files'} = [ + '/etc/fstab', + '/etc/mtab', + ]; + return; +} + +1; diff --git a/src/installer/OpenSLX/OSSetup/Distro/Suse.pm b/src/installer/OpenSLX/OSSetup/Distro/Suse.pm new file mode 100644 index 00000000..8e85e46a --- /dev/null +++ b/src/installer/OpenSLX/OSSetup/Distro/Suse.pm @@ -0,0 +1,98 @@ +# Copyright (c) 2006, 2007 - OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# OSSetup/Distro/Suse.pm +# - provides SUSE-specific overrides of the OSSetup Distro API. +# ----------------------------------------------------------------------------- +package OpenSLX::OSSetup::Distro::Suse; + +use strict; +use warnings; + +use base qw(OpenSLX::OSSetup::Distro::Base); + +use OpenSLX::Basics; + +################################################################################ +### interface methods +################################################################################ +sub new +{ + my $class = shift; + my $self = {}; + return bless $self, $class; +} + +sub initialize +{ + my $self = shift; + my $engine = shift; + + $self->SUPER::initialize($engine); + $self->{'packager-type'} = 'rpm'; + + # use 'zypper' as meta-packager from 10.2 onwards and use 'smart' for + # older releases + my $defaultMetaPackager = 'zypper'; + if ($self->{'engine'}->{'distro-name'} =~ m{-([^-]+)$}) { + my $distroVersion = 0.0 + $1; + if ($distroVersion <= 10.2) { + $defaultMetaPackager = 'smart'; + } + } + $self->{'meta-packager-type'} + = $ENV{SLX_META_PACKAGER} || $defaultMetaPackager; + + if ($engine->{'action-type'} eq 'install') { + # Inform SUSE RPMs that we're performing an installation - this is + # only important for installations taking place in stage 1c: + $ENV{YAST_IS_RUNNING} = "instsys"; + } + + return; +} + +sub fixPrerequiredFiles +{ + my $self = shift; + my $stage1cDir = shift; + + chown( + 0, 0, "$stage1cDir/etc/group", "$stage1cDir/etc/passwd", + "$stage1cDir/etc/shadow" + ); + return; +} + +sub updateDistroConfig +{ + my $self = shift; + + # invoke SuSEconfig in order to allow it to update the configuration: + if (slxsystem('SuSEconfig')) { + die _tr("unable to run SuSEconfig (%s)", $!); + } + $self->SUPER::updateDistroConfig(); + return; +} + +sub hashPassword +{ + my $self = shift; + my $password = shift; + + my $busyboxBin = $self->{engine}->busyboxBinary(); + my $hashedPassword = qx{$busyboxBin cryptpw -a blowfish '$password'}; + chomp $hashedPassword; + + return $hashedPassword; +} + +1; diff --git a/src/installer/OpenSLX/OSSetup/Distro/Ubuntu.pm b/src/installer/OpenSLX/OSSetup/Distro/Ubuntu.pm new file mode 100644 index 00000000..f0f42487 --- /dev/null +++ b/src/installer/OpenSLX/OSSetup/Distro/Ubuntu.pm @@ -0,0 +1,119 @@ +# Copyright (c) 2006, 2007 - OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# OSSetup/Distro/Ubuntu.pm +# - provides Ubuntu-specific overrides of the OSSetup Distro API. +# ----------------------------------------------------------------------------- +package OpenSLX::OSSetup::Distro::Ubuntu; + +use strict; +use warnings; + +use base qw(OpenSLX::OSSetup::Distro::Base); + +use OpenSLX::Basics; +use OpenSLX::Utils; + +################################################################################ +### interface methods +################################################################################ +sub new +{ + my $class = shift; + my $self = {}; + return bless $self, $class; +} + +sub initialize +{ + my $self = shift; + my $engine = shift; + + $self->SUPER::initialize($engine); + $self->{'packager-type'} = 'dpkg'; + $self->{'meta-packager-type'} = $ENV{SLX_META_PACKAGER} || 'apt'; + $self->{'stage1c-faked-files'} = []; + return; +} + +sub preSystemInstallationHook +{ + my $self = shift; + + $self->SUPER::preSystemInstallationHook(); + + # fake required /dev-entries + my %devInfo = ( + mem => { type => 'c', major => '1', minor => '1' }, + null => { type => 'c', major => '1', minor => '3' }, + zero => { type => 'c', major => '1', minor => '5' }, + random => { type => 'c', major => '1', minor => '8' }, + urandom => { type => 'c', major => '1', minor => '9' }, + kmsg => { type => 'c', major => '1', minor => '11' }, + console => { type => 'c', major => '5', minor => '1' }, + ptmx => { type => 'c', major => '5', minor => '2' }, + ); + foreach my $dev (keys %devInfo) { + my $info = $devInfo{$dev}; + if (!-e "/dev/$dev") { + if (slxsystem( + "mknod /dev/$dev $info->{type} $info->{major} $info->{minor}" + )) { + croak(_tr("unable to create dev-node '%s'! (%s)", $dev, $!)); + } + } + } + foreach my $devDir ('pts', 'shm', '.udevdb', '.udev') { + if (!-e "/dev/$devDir") { + if (slxsystem("mkdir -p /dev/$devDir")) { + croak(_tr("unable to create dev-dir '%s'! (%s)", $devDir, $!)); + } + } + } + + # replace /usr/sbin/invoke-rc.d by a dummy, in order to avoid a whole lot + # of initscripts being started. Wishful thinking: there should be another + # way to stop Ubuntu from doing this, as this is not really very supportive + # of folder-based installations (then again: I may simply be too stupid + # to find out how it is supposed to work ...) + rename('/usr/sbin/invoke-rc.d', '/usr/sbin/_invoke-rc.d'); + spitFile('/usr/sbin/invoke-rc.d', "#! /bin/sh\nexit 0\n"); + chmod 0755, '/usr/sbin/invoke-rc.d'; +} + +sub startSession +{ + my $self = shift; + my $osDir = shift; + + $self->SUPER::startSession($osDir); + + # As in preSystemInstallationHook, we replace /usr/sbin/invoke-rc.d by a + # dummy. + # + # During installation, this might not exist yet, so we better check + if (-e '/usr/sbin/invoke-rc.d') { + rename('/usr/sbin/invoke-rc.d', '/usr/sbin/_invoke-rc.d'); + spitFile('/usr/sbin/invoke-rc.d', "#! /bin/sh\nexit 0\n"); + chmod 0755, '/usr/sbin/invoke-rc.d'; + } +} + +sub finishSession +{ + my $self = shift; + + # restore /usr/sbin/invoke-rc.d + rename('/usr/sbin/_invoke-rc.d', '/usr/sbin/invoke-rc.d'); + + $self->SUPER::finishSession(); +} + +1; -- cgit v1.2.3-55-g7522