summaryrefslogtreecommitdiffstats
path: root/installer
diff options
context:
space:
mode:
authorOliver Tappe2007-03-29 16:32:53 +0200
committerOliver Tappe2007-03-29 16:32:53 +0200
commita1ce045c2d6346273ce2ba6692a6dc8f6fe88524 (patch)
treebc38c6f574392cdb4a49c886a8e9b077824e299a /installer
parent* added installation of mksquashfs, adjusted installation of busybox to last ... (diff)
downloadcore-a1ce045c2d6346273ce2ba6692a6dc8f6fe88524.tar.gz
core-a1ce045c2d6346273ce2ba6692a6dc8f6fe88524.tar.xz
core-a1ce045c2d6346273ce2ba6692a6dc8f6fe88524.zip
* now that (thanks to Vito's patch) mksquashfs has more versatile filtering, we no longer take
the detour via rsync, but use mksquashfs directly. git-svn-id: http://svn.openslx.org/svn/openslx/trunk@836 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'installer')
-rw-r--r--installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm63
1 files changed, 57 insertions, 6 deletions
diff --git a/installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm b/installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm
index 41bb9bb9..1a4bafdb 100644
--- a/installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm
+++ b/installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm
@@ -43,11 +43,13 @@ sub exportVendorOS
# TODO: once the include/exclude-patch by Vito has been applied
# to mksquashfs, the extra route via rsync isn't necessary anymore:
- my $mksquashfsCanFilter = 0;
+ my $mksquashfsCanFilter = 1;
if ($mksquashfsCanFilter) {
- # do filtering as part of mksquashfs (needs additional mapping of
- # our internal (rsync-)filter format to regexes):
my $includeExcludeList = $self->determineIncludeExcludeList();
+ # in order to do the filtering as part of mksquashfs, we need to map
+ # our internal (rsync-)filter format to regexes:
+ $includeExcludeList
+ = mapRsyncFilter2Regex($source, $includeExcludeList);
vlog 1, _tr("using include-exclude-filter:\n%s\n", $includeExcludeList);
$self->createSquashFS($source, $target, $includeExcludeList);
} else {
@@ -76,9 +78,24 @@ sub createSquashFS
# mksquasfs isn't significantly faster if fs already exists, but it
# causes the filesystem to grow somewhat, so we remove it in order to
# get the smallest FS-file possible.
- if (system("mksquashfs $source $target -info")) {
- die _tr("unable to create squashfs for source '%s into target '%s', giving up! (%s)",
- $source, $target, $!);
+
+ # dump filter to a file ...
+ my $filterFile = "/tmp/slx-nbdsquash-filter-$$";
+ open(FILTERFILE,"> $filterFile")
+ or die _tr("unable to create tmpfile '%s' (%s)", $filterFile, $!);
+ print FILTERFILE $includeExcludeList;
+ close(FILTERFILE);
+
+ # ... invoke mksquashfs ...
+ vlog 0, _tr("invoking mksquashfs...");
+ my $mksquashfsBinary
+ = "$openslxConfig{'share-path'}/squashfs/mksquashfs";
+ my $res = system("$mksquashfsBinary $source $target -ff $filterFile");
+ unlink($filterFile);
+ # ... remove filter file if done
+ if ($res) {
+ die _tr("unable to create squashfs for source '%s into target '%s', giving up! ($!)",
+ $source, $target);
}
}
@@ -93,4 +110,38 @@ sub showNbdParams
print (('#' x 80)."\n");
}
+sub mapRsyncFilter2Regex
+{
+ my $sourcePath = shift;
+
+ return
+ join "\n",
+ map {
+ if ($_ =~ m[^([-+]\s*)(.+?)\s*$]) {
+ my $action = $1;
+ my $regex = $2;
+ $regex =~ s[\*\*][.+]g;
+ # '**' matches everything
+ $regex =~ s[\*][[^/]+]g;
+ # '*' matches anything except slashes
+ $regex =~ s[\?][[^/]?]g;
+ # '*' matches any single char except slash
+ $regex =~ s[\?][[^/]?]g;
+ # '*' matches any single char except slash
+ $regex =~ s[\.][\\.]g;
+ # escape any dots
+ if (substr($regex, 0, 1) eq '/') {
+ # absolute path given, need to extend by source-path:
+ "$action^$sourcePath$regex\$";
+ } else {
+ # filename pattern given, need to anchor to the end only:
+ "$action$regex\$";
+ }
+ } else {
+ $_;
+ }
+ }
+ split "\n", shift;
+}
+
1;