summaryrefslogtreecommitdiffstats
path: root/initramfs
diff options
context:
space:
mode:
authorOliver Tappe2008-03-20 01:04:16 +0100
committerOliver Tappe2008-03-20 01:04:16 +0100
commita0ce0340d0f95514008cfac751fe58748bbadd88 (patch)
tree844bb9e015f2fbcd83de54c3a63dd027b1218211 /initramfs
parent* fixed several bugs with respect to the listing of plugins (as part of a system (diff)
downloadcore-a0ce0340d0f95514008cfac751fe58748bbadd88.tar.gz
core-a0ce0340d0f95514008cfac751fe58748bbadd88.tar.xz
core-a0ce0340d0f95514008cfac751fe58748bbadd88.zip
* Switched indent used in Perl-code and settings files from tabs to 4 spaces.
May need some manual corrections here and there, but should basically be ok. git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1658 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'initramfs')
-rw-r--r--initramfs/OpenSLX/LibScanner.pm388
-rw-r--r--initramfs/OpenSLX/MakeInitRamFS/Distro/Base.pm16
-rw-r--r--initramfs/OpenSLX/MakeInitRamFS/Distro/Debian.pm22
-rw-r--r--initramfs/OpenSLX/MakeInitRamFS/Distro/SUSE.pm20
-rw-r--r--initramfs/OpenSLX/MakeInitRamFS/Distro/Ubuntu.pm22
-rw-r--r--initramfs/OpenSLX/MakeInitRamFS/Engine.pm1170
6 files changed, 819 insertions, 819 deletions
diff --git a/initramfs/OpenSLX/LibScanner.pm b/initramfs/OpenSLX/LibScanner.pm
index c5cef34a..b1c96d7c 100644
--- a/initramfs/OpenSLX/LibScanner.pm
+++ b/initramfs/OpenSLX/LibScanner.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# LibScanner.pm
-# - module that recursively scans a given binary for library dependencies
+# - module that recursively scans a given binary for library dependencies
# -----------------------------------------------------------------------------
package OpenSLX::LibScanner;
@@ -27,236 +27,236 @@ use OpenSLX::Utils;
################################################################################
sub new
{
- my $class = shift;
- my $params = shift || {};
+ my $class = shift;
+ my $params = shift || {};
- checkParams($params, {
- 'root-path' => '!',
- 'verbose' => '?',
- } );
+ checkParams($params, {
+ 'root-path' => '!',
+ 'verbose' => '?',
+ } );
- my $self = {
- rootPath => $params->{'root-path'},
- verbose => $params->{'verbose'} || 0,
- };
+ my $self = {
+ rootPath => $params->{'root-path'},
+ verbose => $params->{'verbose'} || 0,
+ };
- return bless $self, $class;
+ return bless $self, $class;
}
sub determineRequiredLibs
{
- my $self = shift;
- my @binaries = @_;
+ my $self = shift;
+ my @binaries = @_;
- $self->{filesToDo} = [];
- $self->{libs} = [];
- $self->{libInfo} = {};
+ $self->{filesToDo} = [];
+ $self->{libs} = [];
+ $self->{libInfo} = {};
- $self->_fetchLoaderConfig();
-
- foreach my $binary (@binaries) {
- if (substr($binary, 0, 1) ne '/') {
- # force relative paths relative to $rootPath:
- $binary = "$self->{rootPath}/$binary";
- }
- if (!-e $binary) {
- warn _tr("$0: unable to find file '%s', skipping it\n", $binary);
- next;
- }
- push @{$self->{filesToDo}}, $binary;
- }
-
- foreach my $file (@{$self->{filesToDo}}) {
- $self->_addLibsForBinary($file);
- }
+ $self->_fetchLoaderConfig();
+
+ foreach my $binary (@binaries) {
+ if (substr($binary, 0, 1) ne '/') {
+ # force relative paths relative to $rootPath:
+ $binary = "$self->{rootPath}/$binary";
+ }
+ if (!-e $binary) {
+ warn _tr("$0: unable to find file '%s', skipping it\n", $binary);
+ next;
+ }
+ push @{$self->{filesToDo}}, $binary;
+ }
+
+ foreach my $file (@{$self->{filesToDo}}) {
+ $self->_addLibsForBinary($file);
+ }
- return @{$self->{libs}};
+ return @{$self->{libs}};
}
sub _fetchLoaderConfig
{
- my $self = shift;
+ my $self = shift;
- my @libFolders;
+ my @libFolders;
- if (!-e "$self->{rootPath}/etc") {
- die _tr("'%s'-folder not found, maybe wrong root-path?\n",
- "$self->{rootPath}/etc");
- }
- $self->_fetchLoaderConfigFile("$self->{rootPath}/etc/ld.so.conf");
+ if (!-e "$self->{rootPath}/etc") {
+ die _tr("'%s'-folder not found, maybe wrong root-path?\n",
+ "$self->{rootPath}/etc");
+ }
+ $self->_fetchLoaderConfigFile("$self->{rootPath}/etc/ld.so.conf");
- # add "trusted" folders /lib and /usr/lib if not already in place:
- if (!grep { m[^$self->{rootPath}/lib$] } @libFolders) {
- push @libFolders, "$self->{rootPath}/lib";
- }
- if (!grep { m[^$self->{rootPath}/usr/lib$] } @libFolders) {
- push @libFolders, "$self->{rootPath}/usr/lib";
- }
+ # add "trusted" folders /lib and /usr/lib if not already in place:
+ if (!grep { m[^$self->{rootPath}/lib$] } @libFolders) {
+ push @libFolders, "$self->{rootPath}/lib";
+ }
+ if (!grep { m[^$self->{rootPath}/usr/lib$] } @libFolders) {
+ push @libFolders, "$self->{rootPath}/usr/lib";
+ }
- # add lib32-folders for 64-bit Debians, as they do not
- # refer those in ld.so.conf (which I find strange...)
- if (-e '/lib32' && !grep { m[^$self->{rootPath}/lib32$] } @libFolders) {
- push @libFolders, "$self->{rootPath}/lib32";
- }
- if (-e '/usr/lib32'
- && !grep { m[^$self->{rootPath}/usr/lib32$] } @libFolders)
- {
- push @libFolders, "$self->{rootPath}/usr/lib32";
- }
+ # add lib32-folders for 64-bit Debians, as they do not
+ # refer those in ld.so.conf (which I find strange...)
+ if (-e '/lib32' && !grep { m[^$self->{rootPath}/lib32$] } @libFolders) {
+ push @libFolders, "$self->{rootPath}/lib32";
+ }
+ if (-e '/usr/lib32'
+ && !grep { m[^$self->{rootPath}/usr/lib32$] } @libFolders)
+ {
+ push @libFolders, "$self->{rootPath}/usr/lib32";
+ }
- $self->{libFolders} = \@libFolders;
+ $self->{libFolders} = \@libFolders;
- return;
+ return;
}
sub _fetchLoaderConfigFile
{
- my $self = shift;
- my $ldConfFile = shift;
+ my $self = shift;
+ my $ldConfFile = shift;
- return unless -e $ldConfFile;
- my $ldconfFH;
- if (!open($ldconfFH, '<', $ldConfFile)) {
- warn(_tr("unable to open file '%s' (%s)", $ldConfFile, $!));
- return;
- }
- while (<$ldconfFH>) {
- chomp;
- if (m{^\s*include\s+(.+?)\s*$}i) {
- my @incFiles = glob("$self->{rootPath}$1");
- foreach my $incFile (@incFiles) {
- if ($incFile) {
- $self->_fetchLoaderConfigFile($incFile);
- }
- }
- next;
- }
- if (m{\S+}i) {
- s[=.+][];
- # remove any lib-type specifications (e.g. '=libc5')
- push @{$self->{libFolders}}, "$self->{rootPath}$_";
- }
- }
- close $ldconfFH
- or die(_tr("unable to close file '%s' (%s)", $ldConfFile, $!));
- return;
+ return unless -e $ldConfFile;
+ my $ldconfFH;
+ if (!open($ldconfFH, '<', $ldConfFile)) {
+ warn(_tr("unable to open file '%s' (%s)", $ldConfFile, $!));
+ return;
+ }
+ while (<$ldconfFH>) {
+ chomp;
+ if (m{^\s*include\s+(.+?)\s*$}i) {
+ my @incFiles = glob("$self->{rootPath}$1");
+ foreach my $incFile (@incFiles) {
+ if ($incFile) {
+ $self->_fetchLoaderConfigFile($incFile);
+ }
+ }
+ next;
+ }
+ if (m{\S+}i) {
+ s[=.+][];
+ # remove any lib-type specifications (e.g. '=libc5')
+ push @{$self->{libFolders}}, "$self->{rootPath}$_";
+ }
+ }
+ close $ldconfFH
+ or die(_tr("unable to close file '%s' (%s)", $ldConfFile, $!));
+ return;
}
sub _addLibsForBinary
{
- my $self = shift;
- my $binary = shift;
+ my $self = shift;
+ my $binary = shift;
- # first do some checks:
- warn _tr("analyzing '%s'...\n", $binary) if $self->{verbose};
- my $fileInfo = `file --dereference --brief --mime $binary 2>/dev/null`;
- if ($?) {
- die _tr("unable to fetch file info for '%s', giving up!\n", $binary);
- }
- chomp $fileInfo;
- warn _tr("\tinfo is: '%s'...\n", $fileInfo) if $self->{verbose};
- if ($fileInfo !~ m[^application/(x-executable|x-shared)]i) {
- # ignore anything that's not an executable or a shared library
- warn _tr(
- "%s: ignored, as it isn't an executable or a shared library\n",
- $binary
- );
- next;
- }
+ # first do some checks:
+ warn _tr("analyzing '%s'...\n", $binary) if $self->{verbose};
+ my $fileInfo = `file --dereference --brief --mime $binary 2>/dev/null`;
+ if ($?) {
+ die _tr("unable to fetch file info for '%s', giving up!\n", $binary);
+ }
+ chomp $fileInfo;
+ warn _tr("\tinfo is: '%s'...\n", $fileInfo) if $self->{verbose};
+ if ($fileInfo !~ m[^application/(x-executable|x-shared)]i) {
+ # ignore anything that's not an executable or a shared library
+ warn _tr(
+ "%s: ignored, as it isn't an executable or a shared library\n",
+ $binary
+ );
+ next;
+ }
- # fetch file info again, this time without '--mime' in order to get the architecture
- # bitwidth:
- $fileInfo = `file --dereference --brief $binary 2>/dev/null`;
- if ($?) {
- die _tr("unable to fetch file info for '%s', giving up!\n", $binary);
- }
- chomp $fileInfo;
- warn _tr("\tinfo is: '%s'...\n", $fileInfo) if $self->{verbose};
- my $bitwidth = ($fileInfo =~ m[64-bit]i) ? 64 : 32;
- # determine whether binary is 32- or 64-bit platform
+ # fetch file info again, this time without '--mime' in order to get the architecture
+ # bitwidth:
+ $fileInfo = `file --dereference --brief $binary 2>/dev/null`;
+ if ($?) {
+ die _tr("unable to fetch file info for '%s', giving up!\n", $binary);
+ }
+ chomp $fileInfo;
+ warn _tr("\tinfo is: '%s'...\n", $fileInfo) if $self->{verbose};
+ my $bitwidth = ($fileInfo =~ m[64-bit]i) ? 64 : 32;
+ # determine whether binary is 32- or 64-bit platform
- # now find out about needed libs, we first try objdump...
- warn _tr("\ttrying objdump...\n") if $self->{verbose};
- my $res = `objdump -p $binary 2>/dev/null`;
- if (!$?) {
- # find out if rpath is set for binary:
- my $rpath;
- if ($res =~ m[^\s*RPATH\s*(\S+)]im) {
- $rpath = $1;
- warn _tr("\trpath='%s'\n", $rpath) if $self->{verbose};
- }
- while ($res =~ m[^\s*NEEDED\s*(.+?)\s*$]gm) {
- $self->_addLib($1, $bitwidth, $rpath);
- }
- } else {
- # ...objdump failed, so we try readelf instead:
- warn _tr("\ttrying readelf...\n") if $self->{verbose};
- $res = `readelf -d $binary 2>/dev/null`;
- if ($?) {
- die _tr(
- "neither objdump nor readelf seems to be installed, giving up!\n"
- );
- }
- # find out if rpath is set for binary:
- my $rpath;
- if ($res =~ m{Library\s*rpath:\s*\[([^\]]+)}im) {
- $rpath = $1;
- warn _tr("\trpath='%s'\n", $rpath) if $self->{verbose};
- }
- while ($res =~ m{\(NEEDED\)[^\[]+\[(.+?)\]\s*$}gm) {
- $self->_addLib($1, $bitwidth, $rpath);
- }
- }
- return;
+ # now find out about needed libs, we first try objdump...
+ warn _tr("\ttrying objdump...\n") if $self->{verbose};
+ my $res = `objdump -p $binary 2>/dev/null`;
+ if (!$?) {
+ # find out if rpath is set for binary:
+ my $rpath;
+ if ($res =~ m[^\s*RPATH\s*(\S+)]im) {
+ $rpath = $1;
+ warn _tr("\trpath='%s'\n", $rpath) if $self->{verbose};
+ }
+ while ($res =~ m[^\s*NEEDED\s*(.+?)\s*$]gm) {
+ $self->_addLib($1, $bitwidth, $rpath);
+ }
+ } else {
+ # ...objdump failed, so we try readelf instead:
+ warn _tr("\ttrying readelf...\n") if $self->{verbose};
+ $res = `readelf -d $binary 2>/dev/null`;
+ if ($?) {
+ die _tr(
+ "neither objdump nor readelf seems to be installed, giving up!\n"
+ );
+ }
+ # find out if rpath is set for binary:
+ my $rpath;
+ if ($res =~ m{Library\s*rpath:\s*\[([^\]]+)}im) {
+ $rpath = $1;
+ warn _tr("\trpath='%s'\n", $rpath) if $self->{verbose};
+ }
+ while ($res =~ m{\(NEEDED\)[^\[]+\[(.+?)\]\s*$}gm) {
+ $self->_addLib($1, $bitwidth, $rpath);
+ }
+ }
+ return;
}
sub _addLib
{
- my $self = shift;
- my $lib = shift;
- my $bitwidth = shift;
- my $rpath = shift;
+ my $self = shift;
+ my $lib = shift;
+ my $bitwidth = shift;
+ my $rpath = shift;
- if (!exists $self->{libInfo}->{$lib}) {
- my $libPath;
- my @folders = @{$self->{libFolders}};
- if (defined $rpath) {
- # add rpath if given (explicit paths set during link stage)
- push @folders, split ':', $rpath;
- }
- foreach my $folder (@folders) {
- if (-e "$folder/$lib") {
- # have library matching name, now check if the platform is ok, too:
- my $libFileInfo =
- `file --dereference --brief $folder/$lib 2>/dev/null`;
- if ($?) {
- die _tr("unable to fetch file info for '%s', giving up!\n",
- $folder / $lib);
- }
- my $libBitwidth = ($libFileInfo =~ m[64-bit]i) ? 64 : 32;
- if ($bitwidth != $libBitwidth) {
- vlog(
- 0,
- _tr(
- '%s has wrong bitwidth (%s instead of %s)',
- "$folder/$lib", $libBitwidth, $bitwidth
- )
- ) if $self->{verbose};
- next;
- }
- $libPath = "$folder/$lib";
- last;
- }
- }
- if (!defined $libPath) {
- die _tr("unable to find lib %s!\n", $lib);
- }
- print "found $libPath\n" if $self->{verbose};
- push @{$self->{libs}}, $libPath;
- $self->{libInfo}->{$lib} = 1;
- push @{$self->{filesToDo}}, $libPath;
- }
- return;
+ if (!exists $self->{libInfo}->{$lib}) {
+ my $libPath;
+ my @folders = @{$self->{libFolders}};
+ if (defined $rpath) {
+ # add rpath if given (explicit paths set during link stage)
+ push @folders, split ':', $rpath;
+ }
+ foreach my $folder (@folders) {
+ if (-e "$folder/$lib") {
+ # have library matching name, now check if the platform is ok, too:
+ my $libFileInfo =
+ `file --dereference --brief $folder/$lib 2>/dev/null`;
+ if ($?) {
+ die _tr("unable to fetch file info for '%s', giving up!\n",
+ $folder / $lib);
+ }
+ my $libBitwidth = ($libFileInfo =~ m[64-bit]i) ? 64 : 32;
+ if ($bitwidth != $libBitwidth) {
+ vlog(
+ 0,
+ _tr(
+ '%s has wrong bitwidth (%s instead of %s)',
+ "$folder/$lib", $libBitwidth, $bitwidth
+ )
+ ) if $self->{verbose};
+ next;
+ }
+ $libPath = "$folder/$lib";
+ last;
+ }
+ }
+ if (!defined $libPath) {
+ die _tr("unable to find lib %s!\n", $lib);
+ }
+ print "found $libPath\n" if $self->{verbose};
+ push @{$self->{libs}}, $libPath;
+ $self->{libInfo}->{$lib} = 1;
+ push @{$self->{filesToDo}}, $libPath;
+ }
+ return;
}
1;
diff --git a/initramfs/OpenSLX/MakeInitRamFS/Distro/Base.pm b/initramfs/OpenSLX/MakeInitRamFS/Distro/Base.pm
index 53765657..30b9d385 100644
--- a/initramfs/OpenSLX/MakeInitRamFS/Distro/Base.pm
+++ b/initramfs/OpenSLX/MakeInitRamFS/Distro/Base.pm
@@ -9,15 +9,15 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# MakeInitRamFS::Base.pm
-# - provides empty base of the distro-specific part of the OpenSLX
-# MakeInitRamFS API.
+# - provides empty base of the distro-specific part of the OpenSLX
+# MakeInitRamFS API.
# -----------------------------------------------------------------------------
package OpenSLX::MakeInitRamFS::Distro::Base;
use strict;
use warnings;
-our $VERSION = 1.01; # API-version . implementation-version
+our $VERSION = 1.01; # API-version . implementation-version
use OpenSLX::Basics;
@@ -26,11 +26,11 @@ use OpenSLX::Basics;
################################################################################
sub new
{
- my $class = shift;
- my $self = {
- 'base-name' => 'base',
- };
- return bless $self, $class;
+ my $class = shift;
+ my $self = {
+ 'base-name' => 'base',
+ };
+ return bless $self, $class;
}
sub applyChanges
diff --git a/initramfs/OpenSLX/MakeInitRamFS/Distro/Debian.pm b/initramfs/OpenSLX/MakeInitRamFS/Distro/Debian.pm
index 0337b0b3..14d6b12b 100644
--- a/initramfs/OpenSLX/MakeInitRamFS/Distro/Debian.pm
+++ b/initramfs/OpenSLX/MakeInitRamFS/Distro/Debian.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# MakeInitRamFS::Distro::Debian.pm
-# - provides Debian-specific overrides of the MakeInitRamFS::Distro API.
+# - provides Debian-specific overrides of the MakeInitRamFS::Distro API.
# -----------------------------------------------------------------------------
package OpenSLX::MakeInitRamFS::Distro::Debian;
@@ -25,23 +25,23 @@ use OpenSLX::Basics;
################################################################################
sub new
{
- my $class = shift;
- my $self = {
- 'base-name' => 'debian',
- };
- return bless $self, $class;
+ my $class = shift;
+ my $self = {
+ 'base-name' => 'debian',
+ };
+ return bless $self, $class;
}
sub applyChanges
{
- my $self = shift;
- my $engine = shift;
+ my $self = shift;
+ my $engine = shift;
- $engine->_addFilteredKernelModules( qw( af_packet hid unix ));
+ $engine->_addFilteredKernelModules( qw( af_packet hid unix ));
- $engine->_addRequiredLib('/lib/libnss_compat.so.2');
+ $engine->_addRequiredLib('/lib/libnss_compat.so.2');
- return;
+ return;
}
1; \ No newline at end of file
diff --git a/initramfs/OpenSLX/MakeInitRamFS/Distro/SUSE.pm b/initramfs/OpenSLX/MakeInitRamFS/Distro/SUSE.pm
index 4e5963a9..991a2fd1 100644
--- a/initramfs/OpenSLX/MakeInitRamFS/Distro/SUSE.pm
+++ b/initramfs/OpenSLX/MakeInitRamFS/Distro/SUSE.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# MakeInitRamFS::Distro::SUSE.pm
-# - provides SUSE-specific overrides of the MakeInitRamFS::Distro API.
+# - provides SUSE-specific overrides of the MakeInitRamFS::Distro API.
# -----------------------------------------------------------------------------
package OpenSLX::MakeInitRamFS::Distro::SUSE;
@@ -25,21 +25,21 @@ use OpenSLX::Basics;
################################################################################
sub new
{
- my $class = shift;
- my $self = {
- 'base-name' => 'suse',
- };
- return bless $self, $class;
+ my $class = shift;
+ my $self = {
+ 'base-name' => 'suse',
+ };
+ return bless $self, $class;
}
sub applyChanges
{
- my $self = shift;
- my $engine = shift;
+ my $self = shift;
+ my $engine = shift;
- $engine->_addFilteredKernelModules( qw( hid unix ));
+ $engine->_addFilteredKernelModules( qw( hid unix ));
- return;
+ return;
}
1; \ No newline at end of file
diff --git a/initramfs/OpenSLX/MakeInitRamFS/Distro/Ubuntu.pm b/initramfs/OpenSLX/MakeInitRamFS/Distro/Ubuntu.pm
index 121ad030..2ccfe227 100644
--- a/initramfs/OpenSLX/MakeInitRamFS/Distro/Ubuntu.pm
+++ b/initramfs/OpenSLX/MakeInitRamFS/Distro/Ubuntu.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# MakeInitRamFS::Distro::Ubuntu.pm
-# - provides Ubuntu-specific overrides of the MakeInitRamFS::Distro API.
+# - provides Ubuntu-specific overrides of the MakeInitRamFS::Distro API.
# -----------------------------------------------------------------------------
package OpenSLX::MakeInitRamFS::Distro::Ubuntu;
@@ -25,23 +25,23 @@ use OpenSLX::Basics;
################################################################################
sub new
{
- my $class = shift;
- my $self = {
- 'base-name' => 'ubuntu',
- };
- return bless $self, $class;
+ my $class = shift;
+ my $self = {
+ 'base-name' => 'ubuntu',
+ };
+ return bless $self, $class;
}
sub applyChanges
{
- my $self = shift;
- my $engine = shift;
+ my $self = shift;
+ my $engine = shift;
- $engine->_addFilteredKernelModules( qw( unix ));
+ $engine->_addFilteredKernelModules( qw( unix ));
- $engine->_addRequiredLib('/lib/libnss_compat.so.2');
+ $engine->_addRequiredLib('/lib/libnss_compat.so.2');
- return;
+ return;
}
1; \ No newline at end of file
diff --git a/initramfs/OpenSLX/MakeInitRamFS/Engine.pm b/initramfs/OpenSLX/MakeInitRamFS/Engine.pm
index 6ce692d6..482af6b2 100644
--- a/initramfs/OpenSLX/MakeInitRamFS/Engine.pm
+++ b/initramfs/OpenSLX/MakeInitRamFS/Engine.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# MakeInitialRamFS::Engine.pm
-# - provides driver engine for MakeInitialRamFS API.
+# - provides driver engine for MakeInitialRamFS API.
# -----------------------------------------------------------------------------
package OpenSLX::MakeInitRamFS::Engine;
@@ -27,105 +27,105 @@ use OpenSLX::OSPlugin::Roster;
use OpenSLX::Utils;
# TODO: implement support for the following (either here or as plugin):
-# wlan
-# tpm
-# cdboot (must be implemented here!)
+# wlan
+# tpm
+# cdboot (must be implemented here!)
################################################################################
### interface methods
################################################################################
sub new
{
- my $class = shift;
- my $params = shift || {};
-
- checkParams($params, {
- 'attrs' => '!',
- 'debug-level' => '?',
- 'export-name' => '!',
- 'export-uri' => '!',
- 'initramfs' => '!',
- 'kernel-params' => '!',
- 'kernel-version' => '!',
- 'plugins' => '!',
- 'root-path' => '!',
- 'slx-version' => '!',
- 'system-name' => '!',
- } );
-
- my $self = $params;
-
- $self->{'system-name'} =~ m{^([^\-]+)-([^:\-]+)}
- or die "unable to extract distro-info from $self->{'system-name'}!";
-
- $self->{'distro-name'} = $1;
- $self->{'distro-ver'} = $2;
-
- my %distroMap = (
- 'debian' => 'Debian',
- 'suse' => 'SUSE',
- 'ubuntu' => 'Ubuntu',
- );
- my $distroModule = $distroMap{$self->{'distro-name'}} || 'Base';
- $self->{distro} = instantiateClass(
- "OpenSLX::MakeInitRamFS::Distro::$distroModule"
- );
-
- $self->{'lib-scanner'}
- = OpenSLX::LibScanner->new({ 'root-path' => $self->{'root-path'} });
-
- $self->{'required-libs'} = {};
- $self->{'suggested-kernel-modules'} = [];
- $self->{'filtered-kernel-modules'} = [];
-
- return bless $self, $class;
+ my $class = shift;
+ my $params = shift || {};
+
+ checkParams($params, {
+ 'attrs' => '!',
+ 'debug-level' => '?',
+ 'export-name' => '!',
+ 'export-uri' => '!',
+ 'initramfs' => '!',
+ 'kernel-params' => '!',
+ 'kernel-version' => '!',
+ 'plugins' => '!',
+ 'root-path' => '!',
+ 'slx-version' => '!',
+ 'system-name' => '!',
+ } );
+
+ my $self = $params;
+
+ $self->{'system-name'} =~ m{^([^\-]+)-([^:\-]+)}
+ or die "unable to extract distro-info from $self->{'system-name'}!";
+
+ $self->{'distro-name'} = $1;
+ $self->{'distro-ver'} = $2;
+
+ my %distroMap = (
+ 'debian' => 'Debian',
+ 'suse' => 'SUSE',
+ 'ubuntu' => 'Ubuntu',
+ );
+ my $distroModule = $distroMap{$self->{'distro-name'}} || 'Base';
+ $self->{distro} = instantiateClass(
+ "OpenSLX::MakeInitRamFS::Distro::$distroModule"
+ );
+
+ $self->{'lib-scanner'}
+ = OpenSLX::LibScanner->new({ 'root-path' => $self->{'root-path'} });
+
+ $self->{'required-libs'} = {};
+ $self->{'suggested-kernel-modules'} = [];
+ $self->{'filtered-kernel-modules'} = [];
+
+ return bless $self, $class;
}
sub execute
{
- my $self = shift;
- my $dryRun = shift;
+ my $self = shift;
+ my $dryRun = shift;
- $self->_collectCMDs();
+ $self->_collectCMDs();
- $self->_executeCMDs() unless $dryRun;
+ $self->_executeCMDs() unless $dryRun;
- return;
+ return;
}
sub haveKernelParam
{
- my $self = shift;
- my $param = shift;
-
- return ref $param eq 'Regexp'
- ? grep { $_ =~ $param } @{ $self->{'kernel-params'} }
- : grep { $_ eq $param } @{ $self->{'kernel-params'} };
+ my $self = shift;
+ my $param = shift;
+
+ return ref $param eq 'Regexp'
+ ? grep { $_ =~ $param } @{ $self->{'kernel-params'} }
+ : grep { $_ eq $param } @{ $self->{'kernel-params'} };
}
sub addKernelParams
{
- my $self = shift;
-
- push @{ $self->{'kernel-params'} }, @_;
-
- return;
+ my $self = shift;
+
+ push @{ $self->{'kernel-params'} }, @_;
+
+ return;
}
sub kernelParams
{
- my $self = shift;
-
- return @{ $self->{'kernel-params'} };
+ my $self = shift;
+
+ return @{ $self->{'kernel-params'} };
}
sub addKernelModules
{
- my $self = shift;
-
- push @{ $self->{'suggested-kernel-modules'} }, @_;
-
- return;
+ my $self = shift;
+
+ push @{ $self->{'suggested-kernel-modules'} }, @_;
+
+ return;
}
################################################################################
@@ -133,641 +133,641 @@ sub addKernelModules
################################################################################
sub _collectCMDs
{
- my $self = shift;
-
- $self->{CMDs} = [];
+ my $self = shift;
+
+ $self->{CMDs} = [];
- $self->_setupBuildPath();
+ $self->_setupBuildPath();
- $self->_addRequiredFSModsAndTools();
-
- $self->_writeInitramfsSetup();
- $self->_writeSlxSystemConf();
+ $self->_addRequiredFSModsAndTools();
+
+ $self->_writeInitramfsSetup();
+ $self->_writeSlxSystemConf();
- $self->_copyDistroSpecificFiles();
- $self->_copyInitramfsFiles();
-
- $self->_copyBusybox();
-
- $self->_copyDhcpClient();
+ $self->_copyDistroSpecificFiles();
+ $self->_copyInitramfsFiles();
+
+ $self->_copyBusybox();
+
+ $self->_copyDhcpClient();
- $self->_copyRamfsTools();
-
- $self->_copyRequiredFSTools();
+ $self->_copyRamfsTools();
+
+ $self->_copyRequiredFSTools();
- $self->_copyRequiredLayeredFSTools();
+ $self->_copyRequiredLayeredFSTools();
- $self->_copyPreAndPostinitFiles();
+ $self->_copyPreAndPostinitFiles();
- if ($self->{'debug-level'}) {
- $self->_copyDebugTools();
- }
+ if ($self->{'debug-level'}) {
+ $self->_copyDebugTools();
+ }
- $self->_calloutToPlugins();
+ $self->_calloutToPlugins();
- $self->{distro}->applyChanges($self);
+ $self->{distro}->applyChanges($self);
- $self->_copyKernelModules();
-
- $self->_copyRequiredLibs();
-
- $self->_createInitRamFS();
+ $self->_copyKernelModules();
+
+ $self->_copyRequiredLibs();
+
+ $self->_createInitRamFS();
- return;
+ return;
}
sub _executeCMDs
{
- my $self = shift;
-
- foreach my $cmd (@{$self->{CMDs}}) {
- if (ref($cmd) eq 'HASH') {
- vlog(3, "writing $cmd->{file}");
- my $flags = defined $cmd->{mode} ? { mode => $cmd->{mode} } : undef;
- spitFile($cmd->{file}, $cmd->{content}, $flags);
- }
- else {
- vlog(3, "executing: $cmd");
- if (slxsystem($cmd)) {
- die _tr(
- "unable to execute shell-cmd\n\t%s", $cmd
- );
- }
- }
- }
-
- return;
+ my $self = shift;
+
+ foreach my $cmd (@{$self->{CMDs}}) {
+ if (ref($cmd) eq 'HASH') {
+ vlog(3, "writing $cmd->{file}");
+ my $flags = defined $cmd->{mode} ? { mode => $cmd->{mode} } : undef;
+ spitFile($cmd->{file}, $cmd->{content}, $flags);
+ }
+ else {
+ vlog(3, "executing: $cmd");
+ if (slxsystem($cmd)) {
+ die _tr(
+ "unable to execute shell-cmd\n\t%s", $cmd
+ );
+ }
+ }
+ }
+
+ return;
}
sub addCMD
{
- my $self = shift;
- my $cmd = shift;
-
- push @{$self->{CMDs}}, $cmd;
+ my $self = shift;
+ my $cmd = shift;
+
+ push @{$self->{CMDs}}, $cmd;
- return;
+ return;
}
-
+
sub _setupBuildPath
{
- my $self = shift;
-
- my $buildPath = "$openslxConfig{'temp-path'}/slx-initramfs";
- $self->addCMD("rm -rf $buildPath");
-
- my @stdFolders = qw(
- bin
- dev
- etc
- etc/init-hooks
- etc/sysconfig
- lib
- mnt
- proc
- root
- sys
- tmp
- usr/share
- var/lib
- var/lib/nfs/state
- var/run
- );
- $self->addCMD(
- 'mkdir -p ' . join(' ', map { "$buildPath/$_"; } @stdFolders)
- );
- $self->addCMD("ln -sfn /bin $buildPath/sbin");
-
- $self->{'build-path'} = $buildPath;
-
- return;
-}
-
+ my $self = shift;
+
+ my $buildPath = "$openslxConfig{'temp-path'}/slx-initramfs";
+ $self->addCMD("rm -rf $buildPath");
+
+ my @stdFolders = qw(
+ bin
+ dev
+ etc
+ etc/init-hooks
+ etc/sysconfig
+ lib
+ mnt
+ proc
+ root
+ sys
+ tmp
+ usr/share
+ var/lib
+ var/lib/nfs/state
+ var/run
+ );
+ $self->addCMD(
+ 'mkdir -p ' . join(' ', map { "$buildPath/$_"; } @stdFolders)
+ );
+ $self->addCMD("ln -sfn /bin $buildPath/sbin");
+
+ $self->{'build-path'} = $buildPath;
+
+ return;
+}
+
sub _copyDistroSpecificFiles
{
- my $self = shift;
-
- my $distroSpecsPath = "$openslxConfig{'base-path'}/share/distro-specs";
-
- my $distroName = $self->{'distro-name'};
- my $distroVer = $self->{'distro-ver'};
-
- # concatenate default- and distro-specific configuration into one file
- my $config = slurpFile("$distroSpecsPath/$distroName/config-default");
- $config .= "\n";
- $config .= slurpFile("$distroSpecsPath/$distroName/config-$distroVer");
- $self->addCMD( {
- file => "$self->{'build-path'}/etc/sysconfig/config",
- content => $config,
- } );
-
- # concatenate default- and distro-specific functions into one file
- my $functions = slurpFile("$distroSpecsPath/$distroName/functions-default");
- $functions .= "\n";
- $functions
- .= slurpFile("$distroSpecsPath/$distroName/functions-$distroVer");
- $self->addCMD( {
- file => "$self->{'build-path'}/etc/distro-functions",
- content => $functions,
- } );
-
- my $defaultsPath = "$distroSpecsPath/$distroName/files-default";
- if (-e $defaultsPath) {
- $self->addCMD(
- "cp -a $defaultsPath $self->{'build-path'}/etc/sysconfig/files"
- );
- }
-
- return 1;
+ my $self = shift;
+
+ my $distroSpecsPath = "$openslxConfig{'base-path'}/share/distro-specs";
+
+ my $distroName = $self->{'distro-name'};
+ my $distroVer = $self->{'distro-ver'};
+
+ # concatenate default- and distro-specific configuration into one file
+ my $config = slurpFile("$distroSpecsPath/$distroName/config-default");
+ $config .= "\n";
+ $config .= slurpFile("$distroSpecsPath/$distroName/config-$distroVer");
+ $self->addCMD( {
+ file => "$self->{'build-path'}/etc/sysconfig/config",
+ content => $config,
+ } );
+
+ # concatenate default- and distro-specific functions into one file
+ my $functions = slurpFile("$distroSpecsPath/$distroName/functions-default");
+ $functions .= "\n";
+ $functions
+ .= slurpFile("$distroSpecsPath/$distroName/functions-$distroVer");
+ $self->addCMD( {
+ file => "$self->{'build-path'}/etc/distro-functions",
+ content => $functions,
+ } );
+
+ my $defaultsPath = "$distroSpecsPath/$distroName/files-default";
+ if (-e $defaultsPath) {
+ $self->addCMD(
+ "cp -a $defaultsPath $self->{'build-path'}/etc/sysconfig/files"
+ );
+ }
+
+ return 1;
}
sub _copyInitramfsFiles
{
- my $self = shift;
-
- my $initramfsPath = "$openslxConfig{'base-path'}/share/initramfs";
-
- find(
- {
- wanted => sub {
- my $len = length($initramfsPath);
- my $file = $File::Find::name;
- my $relName = length($file) > $len ? substr($file, $len+1) : '';
- if (-d) {
- $self->addCMD("mkdir -p $self->{'build-path'}/$relName");
- } elsif (-l $file) {
- my $target = readlink $file;
- $self->addCMD(
- "ln -sf $target $self->{'build-path'}/$relName"
- );
- } elsif (qx{file $file} =~ m{ELF}) {
- $self->addCMD(
- "cp -p $file $self->{'build-path'}/$relName"
- );
- } else {
- my $text = slurpFile($file, { 'io-layer' => 'bytes' } );
-
- # replace macros
- # TODO: find out what these mean and maybe find a
- # different, better solution
- my %macro = (
- 'COMDIRINDXS' => '/tmp/scratch /var/lib/nobody',
- 'COMETCEXCL' => "XF86Config*\nissue*\nmtab*\nfstab*\n",
- 'KERNVER' => $self->{'kernel-version'},
- # keep serverip as it is (it is handled by init itself)
- 'serverip' => '@@@serverip@@@',
- );
- $text =~ s{\@\@\@([^\@]+)\@\@\@}{
- if (!exists $macro{$1}) {
- warn _tr(
- 'unknown macro @@@%s@@@ found in %s',
- $1, $File::Find::name
- );
- '';
- } else {
- $macro{$1};
- }
- }eogms;
-
- # force shebang with ash
- $text =~ s{\A#!\s*/bin/.+?$}{#!/bin/ash}ms;
-
- $self->addCMD( {
- file => "$self->{'build-path'}/$relName",
- content => $text,
- mode => (-x $file ? 0755 : undef),
- } );
- }
- },
- no_chdir => 1,
- },
- $initramfsPath
- );
-
- return;
+ my $self = shift;
+
+ my $initramfsPath = "$openslxConfig{'base-path'}/share/initramfs";
+
+ find(
+ {
+ wanted => sub {
+ my $len = length($initramfsPath);
+ my $file = $File::Find::name;
+ my $relName = length($file) > $len ? substr($file, $len+1) : '';
+ if (-d) {
+ $self->addCMD("mkdir -p $self->{'build-path'}/$relName");
+ } elsif (-l $file) {
+ my $target = readlink $file;
+ $self->addCMD(
+ "ln -sf $target $self->{'build-path'}/$relName"
+ );
+ } elsif (qx{file $file} =~ m{ELF}) {
+ $self->addCMD(
+ "cp -p $file $self->{'build-path'}/$relName"
+ );
+ } else {
+ my $text = slurpFile($file, { 'io-layer' => 'bytes' } );
+
+ # replace macros
+ # TODO: find out what these mean and maybe find a
+ # different, better solution
+ my %macro = (
+ 'COMDIRINDXS' => '/tmp/scratch /var/lib/nobody',
+ 'COMETCEXCL' => "XF86Config*\nissue*\nmtab*\nfstab*\n",
+ 'KERNVER' => $self->{'kernel-version'},
+ # keep serverip as it is (it is handled by init itself)
+ 'serverip' => '@@@serverip@@@',
+ );
+ $text =~ s{\@\@\@([^\@]+)\@\@\@}{
+ if (!exists $macro{$1}) {
+ warn _tr(
+ 'unknown macro @@@%s@@@ found in %s',
+ $1, $File::Find::name
+ );
+ '';
+ } else {
+ $macro{$1};
+ }
+ }eogms;
+
+ # force shebang with ash
+ $text =~ s{\A#!\s*/bin/.+?$}{#!/bin/ash}ms;
+
+ $self->addCMD( {
+ file => "$self->{'build-path'}/$relName",
+ content => $text,
+ mode => (-x $file ? 0755 : undef),
+ } );
+ }
+ },
+ no_chdir => 1,
+ },
+ $initramfsPath
+ );
+
+ return;
}
sub _copyBusybox
{
- my $self = shift;
-
- $self->_copyPlatformSpecificBinary(
- "$openslxConfig{'base-path'}/share/busybox/busybox", '/bin/busybox'
- );
-
- my $busyboxForHost
- = "$openslxConfig{'base-path'}/share/busybox/busybox"
- . ( hostIs64Bit() ? '.x86_64' : '.i586' );
-
- my $busyboxHelp = qx{$busyboxForHost --help};
- if ($busyboxHelp !~ m{defined functions:(.+)\z}ims) {
- die "unable to parse busybox --help output:\n$busyboxHelp";
- }
- my $rawAppletList = $1;
- my @busyboxApplets
- = map {
- $_ =~ s{\s+}{}igms;
- $_;
- }
- split m{,}, $rawAppletList;
- foreach my $applet (@busyboxApplets) {
- $self->addCMD("ln -sf /bin/busybox $self->{'build-path'}/bin/$applet");
- }
-
- # fake the sh link in busybox environment
- my $shFake = "#!/bin/ash\n/bin/ash \$\@";
- $self->addCMD( {
- file => "$self->{'build-path'}/bin/sh",
- content => $shFake,
- mode => 0755
- } );
-
- return;
+ my $self = shift;
+
+ $self->_copyPlatformSpecificBinary(
+ "$openslxConfig{'base-path'}/share/busybox/busybox", '/bin/busybox'
+ );
+
+ my $busyboxForHost
+ = "$openslxConfig{'base-path'}/share/busybox/busybox"
+ . ( hostIs64Bit() ? '.x86_64' : '.i586' );
+
+ my $busyboxHelp = qx{$busyboxForHost --help};
+ if ($busyboxHelp !~ m{defined functions:(.+)\z}ims) {
+ die "unable to parse busybox --help output:\n$busyboxHelp";
+ }
+ my $rawAppletList = $1;
+ my @busyboxApplets
+ = map {
+ $_ =~ s{\s+}{}igms;
+ $_;
+ }
+ split m{,}, $rawAppletList;
+ foreach my $applet (@busyboxApplets) {
+ $self->addCMD("ln -sf /bin/busybox $self->{'build-path'}/bin/$applet");
+ }
+
+ # fake the sh link in busybox environment
+ my $shFake = "#!/bin/ash\n/bin/ash \$\@";
+ $self->addCMD( {
+ file => "$self->{'build-path'}/bin/sh",
+ content => $shFake,
+ mode => 0755
+ } );
+
+ return;
}
sub _copyRamfsTools
{
- my $self = shift;
-
- my @ramfsTools = qw(ddcprobe 915resolution);
- foreach my $tool (@ramfsTools) {
- $self->_copyPlatformSpecificBinary(
- "$openslxConfig{'base-path'}/share/ramfstools/$tool",
- "/bin/$tool"
- );
- }
-
- return;
-}
-
+ my $self = shift;
+
+ my @ramfsTools = qw(ddcprobe 915resolution);
+ foreach my $tool (@ramfsTools) {
+ $self->_copyPlatformSpecificBinary(
+ "$openslxConfig{'base-path'}/share/ramfstools/$tool",
+ "/bin/$tool"
+ );
+ }
+
+ return;
+}
+
sub _copyDebugTools
{
- my $self = shift;
-
- my @debugTools = qw(strace);
- foreach my $tool (@debugTools) {
- my $toolPath = $self->_findBinary($tool);
- if (!$toolPath) {
- warn _tr('debug-tool "%s" is not available', $tool);
- next;
- }
- $self->addCMD("cp -p $toolPath $self->{'build-path'}/bin");
- $self->_addRequiredLibsFor($toolPath);
- }
-
- return;
-}
-
+ my $self = shift;
+
+ my @debugTools = qw(strace);
+ foreach my $tool (@debugTools) {
+ my $toolPath = $self->_findBinary($tool);
+ if (!$toolPath) {
+ warn _tr('debug-tool "%s" is not available', $tool);
+ next;
+ }
+ $self->addCMD("cp -p $toolPath $self->{'build-path'}/bin");
+ $self->_addRequiredLibsFor($toolPath);
+ }
+
+ return;
+}
+
sub _copyDhcpClient
{
- my $self = shift;
-
- # TODO: instead of using dhclient, we should check if the client
- # provided by busybox still does not support fetching NIS stuff
- # (and implement that if it doesn't)
-
- my $toolPath = $self->_findBinary('dhclient');
- if (!$toolPath) {
- warn _tr('tool "dhclient" is not available, using "udhcpc" instead');
- return;
- }
- $self->addCMD("cp -p $toolPath $self->{'build-path'}/bin");
- $self->_addRequiredLibsFor($toolPath);
-
- return;
-}
-
+ my $self = shift;
+
+ # TODO: instead of using dhclient, we should check if the client
+ # provided by busybox still does not support fetching NIS stuff
+ # (and implement that if it doesn't)
+
+ my $toolPath = $self->_findBinary('dhclient');
+ if (!$toolPath) {
+ warn _tr('tool "dhclient" is not available, using "udhcpc" instead');
+ return;
+ }
+ $self->addCMD("cp -p $toolPath $self->{'build-path'}/bin");
+ $self->_addRequiredLibsFor($toolPath);
+
+ return;
+}
+
sub _findBinary
{
- my $self = shift;
- my $binary = shift;
-
- my @binDirs = qw(
- bin sbin usr/bin usr/sbin usr/local/bin usr/local/sbin usr/bin/X11
- );
- foreach my $binDir (@binDirs) {
- my $binPath = "$self->{'root-path'}/$binDir/$binary";
- return $binPath if -f $binPath && -x $binPath;
- }
-
- return;
-}
-
+ my $self = shift;
+ my $binary = shift;
+
+ my @binDirs = qw(
+ bin sbin usr/bin usr/sbin usr/local/bin usr/local/sbin usr/bin/X11
+ );
+ foreach my $binDir (@binDirs) {
+ my $binPath = "$self->{'root-path'}/$binDir/$binary";
+ return $binPath if -f $binPath && -x $binPath;
+ }
+
+ return;
+}
+
sub _copyPlatformSpecificBinary
{
- my $self = shift;
- my $binaryPath = shift;
- my $targetPath = shift;
+ my $self = shift;
+ my $binaryPath = shift;
+ my $targetPath = shift;
- my $binary = $self->_platformSpecificFileFor($binaryPath);
-
- $self->addCMD("cp -p $binary $self->{'build-path'}$targetPath");
- $self->_addRequiredLibsFor($binary);
+ my $binary = $self->_platformSpecificFileFor($binaryPath);
+
+ $self->addCMD("cp -p $binary $self->{'build-path'}$targetPath");
+ $self->_addRequiredLibsFor($binary);
- return;
+ return;
}
sub _copyRequiredFSTools
{
- my $self = shift;
+ my $self = shift;
- foreach my $tool (@{$self->{'fs-tools'}}) {
- my $toolPath = $self->_findBinary($tool);
- if (!$toolPath) {
- die _tr('filesystem-tool "%s" is not available, giving up!', $tool);
- }
- $self->addCMD("cp -p $toolPath $self->{'build-path'}/bin");
- $self->_addRequiredLibsFor($toolPath);
- }
+ foreach my $tool (@{$self->{'fs-tools'}}) {
+ my $toolPath = $self->_findBinary($tool);
+ if (!$toolPath) {
+ die _tr('filesystem-tool "%s" is not available, giving up!', $tool);
+ }
+ $self->addCMD("cp -p $toolPath $self->{'build-path'}/bin");
+ $self->_addRequiredLibsFor($toolPath);
+ }
- return;
+ return;
}
sub _copyRequiredLayeredFSTools
{
- my $self = shift;
-
- my @tools;
- if ($self->haveKernelParam('unionfs')) {
- push @tools, 'unionctl';
- }
- if ($self->haveKernelParam('cowloop')) {
- push @tools, 'cowdev';
- }
- foreach my $tool (@tools) {
- my $toolPath = $self->_findBinary($tool);
- if (!$toolPath) {
- die _tr(
- 'layered-fs-tool "%s" is not available, giving up!', $tool
- );
- }
- $self->addCMD("cp -p $toolPath $self->{'build-path'}/bin");
- $self->_addRequiredLibsFor($toolPath);
- }
-
- return;
+ my $self = shift;
+
+ my @tools;
+ if ($self->haveKernelParam('unionfs')) {
+ push @tools, 'unionctl';
+ }
+ if ($self->haveKernelParam('cowloop')) {
+ push @tools, 'cowdev';
+ }
+ foreach my $tool (@tools) {
+ my $toolPath = $self->_findBinary($tool);
+ if (!$toolPath) {
+ die _tr(
+ 'layered-fs-tool "%s" is not available, giving up!', $tool
+ );
+ }
+ $self->addCMD("cp -p $toolPath $self->{'build-path'}/bin");
+ $self->_addRequiredLibsFor($toolPath);
+ }
+
+ return;
}
sub _copyRequiredLibs
{
- my $self = shift;
+ my $self = shift;
- # separate 64-bit libs from 32-bit libs and copy them into different
- # destination folders
- my @libs64 = grep { $_ =~ m{/lib64/} } keys %{$self->{'required-libs'}};
- my @libs32 = grep { $_ !~ m{/lib64/} } keys %{$self->{'required-libs'}};
- if (@libs64) {
- $self->addCMD("mkdir -p $self->{'build-path'}/lib64");
- foreach my $lib (@libs64) {
- $self->addCMD("cp -p $lib $self->{'build-path'}/lib64/");
- }
- }
- foreach my $lib (@libs32) {
- $self->addCMD("cp -p $lib $self->{'build-path'}/lib/");
- }
+ # separate 64-bit libs from 32-bit libs and copy them into different
+ # destination folders
+ my @libs64 = grep { $_ =~ m{/lib64/} } keys %{$self->{'required-libs'}};
+ my @libs32 = grep { $_ !~ m{/lib64/} } keys %{$self->{'required-libs'}};
+ if (@libs64) {
+ $self->addCMD("mkdir -p $self->{'build-path'}/lib64");
+ foreach my $lib (@libs64) {
+ $self->addCMD("cp -p $lib $self->{'build-path'}/lib64/");
+ }
+ }
+ foreach my $lib (@libs32) {
+ $self->addCMD("cp -p $lib $self->{'build-path'}/lib/");
+ }
- return;
+ return;
}
sub _addRequiredLibsFor
{
- my $self = shift;
- my $binary = shift;
+ my $self = shift;
+ my $binary = shift;
- my @libs = $self->{'lib-scanner'}->determineRequiredLibs($binary);
- foreach my $lib (@libs) {
- $self->_addRequiredLib($lib);
- }
+ my @libs = $self->{'lib-scanner'}->determineRequiredLibs($binary);
+ foreach my $lib (@libs) {
+ $self->_addRequiredLib($lib);
+ }
- return;
+ return;
}
sub _addRequiredLib
{
- my $self = shift;
- my $lib = shift;
+ my $self = shift;
+ my $lib = shift;
- $self->{'required-libs'}->{$lib} = 1;
+ $self->{'required-libs'}->{$lib} = 1;
- return;
+ return;
}
sub _addFilteredKernelModules
{
- my $self = shift;
+ my $self = shift;
- push @{ $self->{'filtered-kernel-modules'} }, @_;
+ push @{ $self->{'filtered-kernel-modules'} }, @_;
- return;
+ return;
}
sub _copyKernelModules
{
- my $self = shift;
-
- # read modules.dep and use it to determine module dependencies
- my $sourcePath = "$self->{'root-path'}/lib/modules/$self->{'kernel-version'}";
- my @modulesDep = slurpFile("$sourcePath/modules.dep")
- or die _tr('unable to open %s!', "$sourcePath/modules.dep");
- my (%dependentModules, %modulePath, %modulesToBeCopied);
- foreach my $modulesDep (@modulesDep) {
- next if $modulesDep !~ m{^(.+?)/([^/]+)\.ko:\s*(.*?)\s*$};
- my $path = $1;
- my $module = $2;
- my $dependentsList = $3;
- my $fullModulePath = "$path/$module.ko";
- $modulePath{$module} = [] if !exists $modulePath{$module};
- push @{$modulePath{$module}}, $fullModulePath;
- $dependentModules{$fullModulePath} = [ split ' ', $dependentsList ];
- }
-
- my $targetPath
- = "$self->{'build-path'}/lib/modules/$self->{'kernel-version'}";
- $self->addCMD("mkdir -p $targetPath");
- $self->addCMD("cp -p $sourcePath/modules.* $targetPath/");
-
- # TODO: find out what's the story behing the supposedly required
- # modules 'af_packet', 'unix' and 'hid' (which seem to be
- # missing at least on some systems
- my @kernelModules = qw(
- af_packet unix hid usbhid uhci-hcd ohci-hcd
- );
- push @kernelModules, @{ $self->{'suggested-kernel-modules'} };
-
- push @kernelModules, split ' ', $self->{attrs}->{ramfs_fsmods};
- push @kernelModules, split ' ', $self->{attrs}->{ramfs_miscmods};
- push @kernelModules, split ' ', $self->{attrs}->{ramfs_nicmods};
-
- # a function that determines dependent modules recursively
- my $addDependentsSub;
- $addDependentsSub = sub {
- my $modulePath = shift;
- foreach my $dependentModule (@{$dependentModules{$modulePath}}) {
- next if $modulesToBeCopied{$dependentModule};
- $modulesToBeCopied{$dependentModule} = 1;
- $addDependentsSub->($dependentModule);
- }
- };
-
- # start with the given kernel modules (names) and build a list of all
- # required modules
- foreach my $kernelModule (@kernelModules) {
- if (!$modulePath{$kernelModule}) {
- if (! grep { $_ eq $kernelModule }
- @{ $self->{'filtered-kernel-modules'} }
- ) {
- warn _tr(
- 'kernel module "%s" not found (in modules.dep)',
- $kernelModule
- );
- }
- }
- foreach my $modulePath (@{$modulePath{$kernelModule}}) {
- next if $modulesToBeCopied{$modulePath};
- $modulesToBeCopied{$modulePath} = 1;
- $addDependentsSub->($modulePath);
- }
- }
-
- # copy all the modules that we think are required
- foreach my $moduleToBeCopied (sort keys %modulesToBeCopied) {
- my $targetDir = "$self->{'build-path'}" . dirname($moduleToBeCopied);
- $self->addCMD("mkdir -p $targetDir");
- my $source = followLink(
- "$self->{'root-path'}$moduleToBeCopied", $self->{'root-path'}
- );
- my $target = "$self->{'build-path'}$moduleToBeCopied";
- $self->addCMD("cp -p --dereference $source $target");
- }
-
- return;
+ my $self = shift;
+
+ # read modules.dep and use it to determine module dependencies
+ my $sourcePath = "$self->{'root-path'}/lib/modules/$self->{'kernel-version'}";
+ my @modulesDep = slurpFile("$sourcePath/modules.dep")
+ or die _tr('unable to open %s!', "$sourcePath/modules.dep");
+ my (%dependentModules, %modulePath, %modulesToBeCopied);
+ foreach my $modulesDep (@modulesDep) {
+ next if $modulesDep !~ m{^(.+?)/([^/]+)\.ko:\s*(.*?)\s*$};
+ my $path = $1;
+ my $module = $2;
+ my $dependentsList = $3;
+ my $fullModulePath = "$path/$module.ko";
+ $modulePath{$module} = [] if !exists $modulePath{$module};
+ push @{$modulePath{$module}}, $fullModulePath;
+ $dependentModules{$fullModulePath} = [ split ' ', $dependentsList ];
+ }
+
+ my $targetPath
+ = "$self->{'build-path'}/lib/modules/$self->{'kernel-version'}";
+ $self->addCMD("mkdir -p $targetPath");
+ $self->addCMD("cp -p $sourcePath/modules.* $targetPath/");
+
+ # TODO: find out what's the story behing the supposedly required
+ # modules 'af_packet', 'unix' and 'hid' (which seem to be
+ # missing at least on some systems
+ my @kernelModules = qw(
+ af_packet unix hid usbhid uhci-hcd ohci-hcd
+ );
+ push @kernelModules, @{ $self->{'suggested-kernel-modules'} };
+
+ push @kernelModules, split ' ', $self->{attrs}->{ramfs_fsmods};
+ push @kernelModules, split ' ', $self->{attrs}->{ramfs_miscmods};
+ push @kernelModules, split ' ', $self->{attrs}->{ramfs_nicmods};
+
+ # a function that determines dependent modules recursively
+ my $addDependentsSub;
+ $addDependentsSub = sub {
+ my $modulePath = shift;
+ foreach my $dependentModule (@{$dependentModules{$modulePath}}) {
+ next if $modulesToBeCopied{$dependentModule};
+ $modulesToBeCopied{$dependentModule} = 1;
+ $addDependentsSub->($dependentModule);
+ }
+ };
+
+ # start with the given kernel modules (names) and build a list of all
+ # required modules
+ foreach my $kernelModule (@kernelModules) {
+ if (!$modulePath{$kernelModule}) {
+ if (! grep { $_ eq $kernelModule }
+ @{ $self->{'filtered-kernel-modules'} }
+ ) {
+ warn _tr(
+ 'kernel module "%s" not found (in modules.dep)',
+ $kernelModule
+ );
+ }
+ }
+ foreach my $modulePath (@{$modulePath{$kernelModule}}) {
+ next if $modulesToBeCopied{$modulePath};
+ $modulesToBeCopied{$modulePath} = 1;
+ $addDependentsSub->($modulePath);
+ }
+ }
+
+ # copy all the modules that we think are required
+ foreach my $moduleToBeCopied (sort keys %modulesToBeCopied) {
+ my $targetDir = "$self->{'build-path'}" . dirname($moduleToBeCopied);
+ $self->addCMD("mkdir -p $targetDir");
+ my $source = followLink(
+ "$self->{'root-path'}$moduleToBeCopied", $self->{'root-path'}
+ );
+ my $target = "$self->{'build-path'}$moduleToBeCopied";
+ $self->addCMD("cp -p --dereference $source $target");
+ }
+
+ return;
}
sub _copyPreAndPostinitFiles
{
- my $self = shift;
+ my $self = shift;
- foreach my $cfg (
- 'default/initramfs/preinit.local',
- "$self->{'system-name'}/initramfs/preinit.local",
- 'default/initramfs/postinit.local',
+ foreach my $cfg (
+ 'default/initramfs/preinit.local',
+ "$self->{'system-name'}/initramfs/preinit.local",
+ 'default/initramfs/postinit.local',
"$self->{'system-name'}/initramfs/postinit.local"
- ) {
- my $cfgPath = "$openslxConfig{'private-path'}/config/$cfg";
- next if !-f $cfgPath;
- $self->addCMD("cp -p $cfgPath $self->{'build-path'}/bin/");
- }
- return;
+ ) {
+ my $cfgPath = "$openslxConfig{'private-path'}/config/$cfg";
+ next if !-f $cfgPath;
+ $self->addCMD("cp -p $cfgPath $self->{'build-path'}/bin/");
+ }
+ return;
}
sub _platformSpecificFileFor
{
- my $self = shift;
- my $binary = shift;
+ my $self = shift;
+ my $binary = shift;
- if ($self->{'system-name'} =~ m{64}) {
- return $binary . '.x86_64';
- }
- return $binary . '.i586';
+ if ($self->{'system-name'} =~ m{64}) {
+ return $binary . '.x86_64';
+ }
+ return $binary . '.i586';
}
sub _addRequiredFSModsAndTools
{
- my $self = shift;
-
- my $osExportEngine = instantiateClass("OpenSLX::OSExport::Engine");
- $osExportEngine->initializeFromExisting($self->{'export-name'});
- my $fsMods = $self->{attrs}->{ramfs_fsmods} || '';
- foreach my $fsMod ($osExportEngine->requiredFSMods()) {
- $fsMods .= " $fsMod" if $fsMods !~ m{$fsMod};
- }
- $self->{attrs}->{ramfs_fsmods} = $fsMods;
-
- my @fsTools = $osExportEngine->requiredFSTools();
- $self->{'fs-tools'} = \@fsTools;
+ my $self = shift;
+
+ my $osExportEngine = instantiateClass("OpenSLX::OSExport::Engine");
+ $osExportEngine->initializeFromExisting($self->{'export-name'});
+ my $fsMods = $self->{attrs}->{ramfs_fsmods} || '';
+ foreach my $fsMod ($osExportEngine->requiredFSMods()) {
+ $fsMods .= " $fsMod" if $fsMods !~ m{$fsMod};
+ }
+ $self->{attrs}->{ramfs_fsmods} = $fsMods;
+
+ my @fsTools = $osExportEngine->requiredFSTools();
+ $self->{'fs-tools'} = \@fsTools;
- return;
+ return;
}
sub _writeInitramfsSetup
{
- my $self = shift;
-
- # generate initramfs-setup file containing attributes that are
- # relevant for the initramfs only (before there's a root-FS):
- my $initramfsAttrs = {
- 'host_name' => 'slx-client', # just to have something at all
- 'ramfs_fsmods' => $self->{attrs}->{ramfs_fsmods} || '',
- 'ramfs_miscmods' => $self->{attrs}->{ramfs_miscmods} || '',
- 'ramfs_nicmods' => $self->{attrs}->{ramfs_nicmods} || '',
- 'rootfs' => $self->{'export-uri'} || '',
- };
- my $content = "# attributes set by slxconfig-demuxer:\n";
- foreach my $attr (keys %$initramfsAttrs) {
- $content .= qq[$attr="$initramfsAttrs->{$attr}"\n];
- }
- $self->addCMD( {
- file => "$self->{'build-path'}/etc/initramfs-setup",
- content => $content
- } );
-
- return;
+ my $self = shift;
+
+ # generate initramfs-setup file containing attributes that are
+ # relevant for the initramfs only (before there's a root-FS):
+ my $initramfsAttrs = {
+ 'host_name' => 'slx-client', # just to have something at all
+ 'ramfs_fsmods' => $self->{attrs}->{ramfs_fsmods} || '',
+ 'ramfs_miscmods' => $self->{attrs}->{ramfs_miscmods} || '',
+ 'ramfs_nicmods' => $self->{attrs}->{ramfs_nicmods} || '',
+ 'rootfs' => $self->{'export-uri'} || '',
+ };
+ my $content = "# attributes set by slxconfig-demuxer:\n";
+ foreach my $attr (keys %$initramfsAttrs) {
+ $content .= qq[$attr="$initramfsAttrs->{$attr}"\n];
+ }
+ $self->addCMD( {
+ file => "$self->{'build-path'}/etc/initramfs-setup",
+ content => $content
+ } );
+
+ return;
}
sub _writeSlxSystemConf
{
- my $self = shift;
-
- # generate slxsystem.conf file with variables that are needed
- # in stage3 init.
- # TODO: either put this stuff into initramfs-setup or find another solution
- my $date = strftime("%d.%m.%Y", localtime);
- my $slxConf = unshiftHereDoc(<<" End-of-Here");
- slxconf_date=$date
- slxconf_kernver=$self->{'kernel-version'}
- slxconf_listnwmod="$self->{attrs}->{ramfs_nicmods}"
- slxconf_distro_name=$self->{'distro-name'}
- slxconf_distro_ver=$self->{'distro-ver'}
- slxconf_system_name=$self->{'system-name'}
- slxconf_slxver="$self->{'slx-version'}"
- End-of-Here
- $self->addCMD( {
- file => "$self->{'build-path'}/etc/sysconfig/slxsystem.conf",
- content => $slxConf
- } );
-
- return;
+ my $self = shift;
+
+ # generate slxsystem.conf file with variables that are needed
+ # in stage3 init.
+ # TODO: either put this stuff into initramfs-setup or find another solution
+ my $date = strftime("%d.%m.%Y", localtime);
+ my $slxConf = unshiftHereDoc(<<" End-of-Here");
+ slxconf_date=$date
+ slxconf_kernver=$self->{'kernel-version'}
+ slxconf_listnwmod="$self->{attrs}->{ramfs_nicmods}"
+ slxconf_distro_name=$self->{'distro-name'}
+ slxconf_distro_ver=$self->{'distro-ver'}
+ slxconf_system_name=$self->{'system-name'}
+ slxconf_slxver="$self->{'slx-version'}"
+ End-of-Here
+ $self->addCMD( {
+ file => "$self->{'build-path'}/etc/sysconfig/slxsystem.conf",
+ content => $slxConf
+ } );
+
+ return;
}
sub _calloutToPlugins
{
- my $self = shift;
+ my $self = shift;
- my $pluginInitdPath = "$self->{'build-path'}/etc/plugin-init.d";
- my $initHooksPath = "$self->{'build-path'}/etc/init-hooks";
- $self->addCMD("mkdir -p $pluginInitdPath $initHooksPath");
+ my $pluginInitdPath = "$self->{'build-path'}/etc/plugin-init.d";
+ my $initHooksPath = "$self->{'build-path'}/etc/init-hooks";
+ $self->addCMD("mkdir -p $pluginInitdPath $initHooksPath");
- foreach my $pluginName (@{$self->{'plugins'}}) {
- my $plugin = OpenSLX::OSPlugin::Roster->getPlugin($pluginName);
- next if !$plugin;
- $plugin->setupPluginInInitramfs($self->{attrs}, $self);
- }
- return;
+ foreach my $pluginName (@{$self->{'plugins'}}) {
+ my $plugin = OpenSLX::OSPlugin::Roster->getPlugin($pluginName);
+ next if !$plugin;
+ $plugin->setupPluginInInitramfs($self->{attrs}, $self);
+ }
+ return;
}
sub _createInitRamFS
{
- my $self = shift;
+ my $self = shift;
- my $buildPath = $self->{'build-path'};
- $self->addCMD(
- "cd $buildPath "
- . "&& find . "
- . "| cpio -H newc --quiet --create "
- . "| gzip -9 >$self->{initramfs}"
- );
+ my $buildPath = $self->{'build-path'};
+ $self->addCMD(
+ "cd $buildPath "
+ . "&& find . "
+ . "| cpio -H newc --quiet --create "
+ . "| gzip -9 >$self->{initramfs}"
+ );
- return;
+ return;
}
1;