diff options
author | Olivier Blin <blino@mageia.org> | 2011-03-15 21:15:40 +0000 |
---|---|---|
committer | Olivier Blin <blino@mageia.org> | 2011-03-15 21:15:40 +0000 |
commit | 100326c4fe516a5d5242a56fee49d2a049e27344 (patch) | |
tree | 041015749da30ce08a764ecd42ac5ac7fa86a898 /lib | |
parent | 7c8fb7918011bf814335338f6788ad52709adad1 (diff) | |
download | draklive-100326c4fe516a5d5242a56fee49d2a049e27344.tar draklive-100326c4fe516a5d5242a56fee49d2a049e27344.tar.gz draklive-100326c4fe516a5d5242a56fee49d2a049e27344.tar.bz2 draklive-100326c4fe516a5d5242a56fee49d2a049e27344.tar.xz draklive-100326c4fe516a5d5242a56fee49d2a049e27344.zip |
add xz compression support for squashfs
Diffstat (limited to 'lib')
-rw-r--r-- | lib/MDV/Draklive/Loopback.pm | 24 |
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; |