From 55d4f64e83f92236669670b24615410b46d0a376 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 24 Aug 2010 22:35:52 +0200 Subject: squashfs export updated.. see #435 --- Makefile | 10 +- .../eglibc-packages/mksquashfs/usr/bin/mksquashfs | Bin 97460 -> 0 bytes .../eglibc-packages/mksquashfs/usr/bin/mksquashfs3 | Bin 93192 -> 0 bytes .../mksquashfs/usr/bin/mksquashfs_3_3 | Bin 0 -> 93192 bytes .../mksquashfs/usr/bin/mksquashfs_4 | Bin 0 -> 97460 bytes installer/OpenSLX/OSExport/Distro/Base.pm | 8 ++ installer/OpenSLX/OSExport/Distro/Suse.pm | 19 ++++ installer/OpenSLX/OSExport/Distro/Ubuntu.pm | 20 ++++ installer/OpenSLX/OSExport/FileSystem/SquashFS.pm | 119 +++++++++++++++++++-- 9 files changed, 163 insertions(+), 13 deletions(-) delete mode 100755 initramfs/eglibc-packages/mksquashfs/usr/bin/mksquashfs delete mode 100755 initramfs/eglibc-packages/mksquashfs/usr/bin/mksquashfs3 create mode 100755 initramfs/eglibc-packages/mksquashfs/usr/bin/mksquashfs_3_3 create mode 100755 initramfs/eglibc-packages/mksquashfs/usr/bin/mksquashfs_4 diff --git a/Makefile b/Makefile index 8e92eadd..06f89665 100644 --- a/Makefile +++ b/Makefile @@ -196,11 +196,11 @@ plain-install: tar -xp -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/; \ cp -p boot-env/syslinux/pxemenu-*.example boot-env/syslinux/README.pxe \ $(SLX_BUILD_PATH)$(SLX_CONFIG_PATH)/boot-env/syslinux/; \ - cp -p tools/mksquashfs $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/squashfs/; \ - cp -p initramfs/eglibc-packages/mksquashfs/usr/bin/mksquashfs3 \ - $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/squashfs/mksquashfs3; \ - cp -p initramfs/eglibc-packages/mksquashfs/usr/bin/mksquashfs \ - $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/squashfs/mksquashfs4; \ + cp -p tools/mksquashfs $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/squashfs/mksquashfs_3_2; \ + cp -p initramfs/eglibc-packages/mksquashfs/usr/bin/mksquashfs_3_3 \ + $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/squashfs/; \ + cp -p initramfs/eglibc-packages/mksquashfs/usr/bin/mksquashfs_4 \ + $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/squashfs/; \ tar --exclude=.svn -cp -C initramfs tpm | \ tar -xp -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share; \ diff --git a/initramfs/eglibc-packages/mksquashfs/usr/bin/mksquashfs b/initramfs/eglibc-packages/mksquashfs/usr/bin/mksquashfs deleted file mode 100755 index b40e6e42..00000000 Binary files a/initramfs/eglibc-packages/mksquashfs/usr/bin/mksquashfs and /dev/null differ diff --git a/initramfs/eglibc-packages/mksquashfs/usr/bin/mksquashfs3 b/initramfs/eglibc-packages/mksquashfs/usr/bin/mksquashfs3 deleted file mode 100755 index 0f4efdc8..00000000 Binary files a/initramfs/eglibc-packages/mksquashfs/usr/bin/mksquashfs3 and /dev/null differ diff --git a/initramfs/eglibc-packages/mksquashfs/usr/bin/mksquashfs_3_3 b/initramfs/eglibc-packages/mksquashfs/usr/bin/mksquashfs_3_3 new file mode 100755 index 00000000..0f4efdc8 Binary files /dev/null and b/initramfs/eglibc-packages/mksquashfs/usr/bin/mksquashfs_3_3 differ diff --git a/initramfs/eglibc-packages/mksquashfs/usr/bin/mksquashfs_4 b/initramfs/eglibc-packages/mksquashfs/usr/bin/mksquashfs_4 new file mode 100755 index 00000000..b40e6e42 Binary files /dev/null and b/initramfs/eglibc-packages/mksquashfs/usr/bin/mksquashfs_4 differ diff --git a/installer/OpenSLX/OSExport/Distro/Base.pm b/installer/OpenSLX/OSExport/Distro/Base.pm index aa24f8de..5223ce95 100644 --- a/installer/OpenSLX/OSExport/Distro/Base.pm +++ b/installer/OpenSLX/OSExport/Distro/Base.pm @@ -47,6 +47,14 @@ sub initDistroInfo { } +sub getSquashfsVersion +{ + my $self = shift; + my $distroVersion = shift; + + return "4.0"; +} + 1; ################################################################################ diff --git a/installer/OpenSLX/OSExport/Distro/Suse.pm b/installer/OpenSLX/OSExport/Distro/Suse.pm index 586cf51a..9e62e6e5 100644 --- a/installer/OpenSLX/OSExport/Distro/Suse.pm +++ b/installer/OpenSLX/OSExport/Distro/Suse.pm @@ -123,4 +123,23 @@ sub initDistroInfo return; } + +sub getSquashfsVersion +{ + my $self = shift; + my $distroVersion = shift; + + my %versionMap = ( + '11.0' => '3.2', + '11.1' => '3.2', + '11.2' => '3.3', + '11.3' => '4.0' + ); + + my $distroDefault = '4.0'; + + return $versionMap{$distroVersion} || $distroDefault; +} + + 1; diff --git a/installer/OpenSLX/OSExport/Distro/Ubuntu.pm b/installer/OpenSLX/OSExport/Distro/Ubuntu.pm index a1e477d5..3826f019 100644 --- a/installer/OpenSLX/OSExport/Distro/Ubuntu.pm +++ b/installer/OpenSLX/OSExport/Distro/Ubuntu.pm @@ -85,4 +85,24 @@ sub initDistroInfo return; } + +sub getSquashfsVersion +{ + my $self = shift; + my $distroVersion = shift; + + my %versionMap = ( + '8.04' => '3.3', + '8.10' => '3.3', + '9.04' => '3.3', + '9.10' => '4.0', + '10.04' => '4.0' + ); + + my $distroDefault = '4.0'; + + return $versionMap{$distroVersion} || $distroDefault; +} + + 1; 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 -- cgit v1.2.3-55-g7522