summaryrefslogtreecommitdiffstats
path: root/lib/MDV/Draklive
diff options
context:
space:
mode:
Diffstat (limited to 'lib/MDV/Draklive')
-rw-r--r--lib/MDV/Draklive/Loopback.pm24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/MDV/Draklive/Loopback.pm b/lib/MDV/Draklive/Loopback.pm
index 55e7c93..0032e6e 100644
--- a/lib/MDV/Draklive/Loopback.pm
+++ b/lib/MDV/Draklive/Loopback.pm
@@ -15,7 +15,7 @@ our %loop_types;
squashfs => {
read_only => 1,
is_loopback => 1,
- modules => sub { "loop", has_squashfs4_with_lzma($_[0]) ? "squashfs" : "squashfs_lzma" },
+ modules => sub { "loop", best_squashfs4_compression($_[0]) ? "squashfs" : "squashfs_lzma" },
extension => '-lzma.sqfs',
build => sub {
my ($live, $dir) = @_;
@@ -29,15 +29,15 @@ our %loop_types;
my $exclude_file = tmpnam();
output_p($exclude_file, map { $root . "$_\n" } grep { -e $root . $_ } @{$dir->{exclude} || []});
my $sort = $live->{settings}{config_root} . '/' . $dir->{sort};
- my $squashfs4 = has_squashfs4_with_lzma($live);
+ my $squashfs4_comp = best_squashfs4_compression($live);
run_foreach(sub {
if (/^mksquashfs: file .*, uncompressed size (\d+) bytes\s*(?:DUPLICATE|LINK)?$/) {
$progress->{current} += $1;
$progress->show(time());
}
},
- $squashfs4 ? 'mksquashfs' : 'mksquashfs3', $src, $dest,
- $squashfs4 ? ('-comp', 'lzma') : '-lzma',
+ $squashfs4_comp ? 'mksquashfs' : 'mksquashfs3', $src, $dest,
+ $squashfs4_comp ? ('-comp', $squashfs4_comp) : '-lzma',
'-noappend', '-no-progress', '-info', '-b', '1048576',
#'-processors', 1,
'-ef', $exclude_file,
@@ -133,10 +133,20 @@ sub get_loop_modules {
();
}
-sub has_squashfs4_with_lzma {
- my ($live) = @_;
+sub has_squashfs4_with {
+ my ($live, $comp) = @_;
my $kernel = $live->find_kernel;
- cat_($live->get_system_root . "/boot/config-" . $live->find_kernel->{version}) =~ /^CONFIG_DECOMPRESS_LZMA_NEEDED=y$/m;
+ my $ucomp = uc($comp);
+ cat_($live->get_system_root . "/boot/config-" . $live->find_kernel->{version}) =~ /^CONFIG_SQUASHFS_$ucomp=y$/m;
+}
+
+sub mksquashfs4_compressors() {
+ map { /^Compressors available/ .. /^$/ ? if_(/^\t(\w+)/, chomp_($1)) : () } `mksquashfs 2>&1`;
+}
+
+sub best_squashfs4_compression {
+ my ($live) = @_;
+ find { has_squashfs4_with($live, $_) } intersection([ mksquashfs4_compressors() ], [ qw(xz lzma) ]);
}
1;