diff options
Diffstat (limited to 'installer/OpenSLX/OSExport/FileSystem')
-rw-r--r-- | installer/OpenSLX/OSExport/FileSystem/SquashFS.pm | 119 |
1 files changed, 111 insertions, 8 deletions
diff --git a/installer/OpenSLX/OSExport/FileSystem/SquashFS.pm b/installer/OpenSLX/OSExport/FileSystem/SquashFS.pm index a092ddf0..77034c9c 100644 --- a/installer/OpenSLX/OSExport/FileSystem/SquashFS.pm +++ b/installer/OpenSLX/OSExport/FileSystem/SquashFS.pm @@ -184,6 +184,10 @@ sub showExportConfigInfo ### implementation methods ################################################################################ +################################################################################# +# Branch to choose the appropriate squashfs version according to target system # +################################################################################ + sub _createSquashFS { my $self = shift; @@ -191,6 +195,34 @@ sub _createSquashFS my $target = shift; my $includeExcludeList = shift; + + my @versionString = split(/-/, $self->{engine}->{'vendor-os-name'}); + my $mksquashfsVersion = $self->{engine}->{distro}->getSquashfsVersion($versionString[1]); + + vlog(0, "found version string $versionString[1] out of $self->{engine}->{'vendor-os-name'}"); + vlog(0, "use squashfs version: $mksquashfsVersion"); + + $self->_createSquashFS_prepare($target); + + my $mksquashfsParams; + + $mksquashfsVersion == '3.2' && do + {$mksquashfsParams = $self->_createSquashFS_setup_3_2($includeExcludeList)}; + $mksquashfsVersion == '3.3' && do + {$mksquashfsParams = $self->_createSquashFS_setup_3_3($includeExcludeList)}; + $mksquashfsVersion == '4.0' && do + {$mksquashfsParams = $self->_createSquashFS_setup_4($includeExcludeList)}; + + $self->_createSquashFS_run($source, $target, $mksquashfsParams); + + return; +} + +sub _createSquashFS_prepare +{ + my $self = shift; + my $target = shift; + system("rm -f $target"); # mksquasfs isn't significantly faster if fs already exists, but it # causes the filesystem to grow somewhat, so we remove it in order to @@ -199,27 +231,98 @@ sub _createSquashFS my $baseDir = dirname($target); if (!-e $baseDir) { if (system("mkdir -p $baseDir")) { - die _tr("unable to create directory '%s', giving up! (%s)\n", + die _tr("unable to create directory '%s', giving up! (%s)\n", $baseDir, $!); } } + return; +} - # dump filter to a file ... - my $filterFile = "/tmp/slx-nbdsquash-filter-$$"; - spitFile($filterFile, $includeExcludeList); +sub _createSquashFS_run { + my $self = shift; + my $source = shift; + my $target = shift; + my $params = shift; + # ... invoke mksquashfs ... vlog(0, _tr("invoking mksquashfs...")); - my $mksquashfsBinary = - "$openslxConfig{'base-path'}/share/squashfs/mksquashfs"; - my $res = system("$mksquashfsBinary $source $target -ff $filterFile"); - unlink($filterFile); + my $mksquashfsBinary = + "$openslxConfig{'base-path'}/share/squashfs/$params->{binary}"; + my $res = + system("$mksquashfsBinary $source $target $params->{cmdlineOptions}"); + unlink($params->{tmpfile}); # ... remove filter file if done if ($res) { die _tr( "unable to create squashfs for source '%s' as target '%s', giving up! (%s)", $source, $target, $!); } + return; +} + +sub _createSquashFS_setup_4 +{ + my $self = shift; + my $includeExcludeList = shift; + + # dump filter to a file ... + my $filterFile = "/tmp/slx-nbdsquash-filter-$$"; + my $includeFile = "/tmp/slx-nbdsquash-includes-$$"; + spitFile($filterFile, $includeExcludeList); + + slxsystem("sed $filterFile -e '/^-/d' -e 's/^+[ \t]*//' > $includeFile"); + slxsystem("sed -i $filterFile -e '/^+/d' -e 's/^-[ \t]*//'"); + + my $result = { + binary => "mksquashfs_4", + cmdlineOptions => "-wildcards -ef $filterFile", + tmpfile => "$filterFile" + }; + + return $result; +} + + +sub _createSquashFS_setup_3_3 +{ + my $self = shift; + my $includeExcludeList = shift; + + # dump filter to a file ... + my $filterFile = "/tmp/slx-nbdsquash-filter-$$"; + my $includeFile = "/tmp/slx-nbdsquash-includes-$$"; + spitFile($filterFile, $includeExcludeList); + + slxsystem("sed $filterFile -e '/^-/d' -e 's/^+[ \t]*//' > $includeFile"); + slxsystem("sed -i $filterFile -e '/^+/d' -e 's/^-[ \t]*//'"); + + my $result = { + binary => "mksquashfs_3_3", + cmdlineOptions => "-wildcards -ef $filterFile", + tmpfile => "$filterFile" + }; + + return $result; +} + + +sub _createSquashFS_setup_3_2 +{ + my $self = shift; + my $includeExcludeList = shift; + + # dump filter to a file ... + my $filterFile = "/tmp/slx-nbdsquash-filter-$$"; + spitFile($filterFile, $includeExcludeList); + + my $result = { + binary => "mksquashfs_3_2", + cmdlineOptions => "-ff $filterFile", + tmpfile => "$filterFile" + }; + + return $result; } sub _determineIncludeExcludeList |