Permalink
Browse files

Add support for LZO compression via lzop

  • Loading branch information...
1 parent fd17500 commit 1a5e61c3eb72df02ee9f71acdd85f3296a283189 @falconindy committed May 16, 2011
Showing with 25 additions and 20 deletions.
  1. +4 −4 README.pod
  2. +1 −1 geninit
  3. +1 −1 geninit.conf
  4. +19 −14 lsinitramfs
View
@@ -74,10 +74,10 @@ needs to be a writeable directory with a minimum of 20mb free.
=item B<-z> I<compression>
Override the compression method specified by the config file. geninit supports
-compression via B<gzip>, B<bzip2>, B<lzma>, and B<xz>. You can also use B<none>
-to disable compression. Please note that your kernel I<must> support your
-method and choice and your kernel will not be checked for this support! If in
-doubt, gzip is a safe choice.
+compression via B<gzip>, B<bzip2>, B<lzma>, and B<xz> (with optional support for
+B<lzop>). You can also use B<none> to disable compression. Please note that your
+kernel I<must> support your method and choice and your kernel will not be
+checked for this support! If in doubt, gzip is a safe choice.
=back
View
@@ -508,7 +508,7 @@ compress=${ocompress:-$compress}
if [[ -z $compress || $compress == none ]]; then
compress=cat # NOOP compressor
else
- [[ "$compress" == @(gzip|bzip2|lzma|xz) ]] || die "unknown compression method: $compress"
+ [[ "$compress" == @(gzip|bzip2|lzop|lzma|xz) ]] || die "unknown compression method: $compress"
type -P "$compress" >/dev/null || die "failed to find \`$compress' binary in PATH"
fi
View
@@ -65,7 +65,7 @@ files=()
# This setting is optional: leaving blank or setting to 'none' will cause no
# compression to be applied to the resulting image.
#
-# possible values: none, gzip, bzip2, lzma, xz
+# possible values: none, gzip, bzip2, lzma, xz, lzop
compress=gzip
# vim:set ft=sh sw=2 et:
View
@@ -54,6 +54,10 @@ in_array() {
return 1 # Not Found
}
+decomp() {
+ ${compress:-cat} ${compress:+-cd} "$@"
+}
+
declare verbose=
declare list='--list'
@@ -73,17 +77,18 @@ declare image=$1
[[ $image ]] || usage
[[ -f $image ]] || die "$image: No such file"
+# read compression type
+case "$(file -b "$image")" in
+ data|LZMA*) compress=lzma ;;
+ gzip*) compress=gzip ;;
+ bzip2*) compress=bzip2 ;;
+ lzop*) compress=lzop ;;
+ XZ*) compress=xz ;;
+esac
+
if (( analyze )); then
declare -a binaries explicitmod modules foundhooks hooks
- declare kernver compress ratio
-
- # read compression type
- case "$(file -b "$image")" in
- data|LZMA*) compress=LZMA ;;
- gzip*) compress=gzip ;;
- bzip2*) compress=bzip2 ;;
- XZ*) compress=XZ ;;
- esac
+ declare kernver ratio
# calculate compression ratio
if [[ $compress ]]; then
@@ -94,8 +99,8 @@ if (( analyze )); then
printf '%s.%s%%\n' "${ratio:0:2}" "${ratio:2}"
}
- TIMEFORMAT=%R decomptime=$({ time bsdtar Oxf "$image" >/dev/null; } 2>&1 )
- ratio=$(divide "$(stat -c %s "$image")" "$(bsdtar Oxf "$image" | wc -c)")
+ TIMEFORMAT=%R decomptime=$({ time decomp "$image" >/dev/null; } 2>&1 )
+ ratio=$(divide "$(stat -c %s "$image")" "$(decomp "$image" | bsdtar xOf - | wc -c)")
fi
# read contents of image
@@ -112,7 +117,7 @@ if (( analyze )); then
elif [[ $line = *@(/bin/|/sbin/)* ]]; then
binaries+=("${line#.}")
fi
- done < <(bsdcpio -i --quiet --list <"$image")
+ done < <(decomp "$image" | bsdtar tf -)
# extract and read config
while read -r -a line; do
@@ -124,7 +129,7 @@ if (( analyze )); then
;;
"%MODULES%") explicitmod=("${line[@]:2}") ;;
esac
- done < <(bsdtar Oxf "$image" config)
+ done < <(decomp "$image" | bsdtar xOf - config)
# print results
printf '==> Image: %s\n' "$(readlink -e "$image")"
@@ -157,6 +162,6 @@ if (( analyze )); then
printf '\n'
fi
else
- bsdcpio -i --quiet $verbose $list <"$image"
+ decomp "$image" | bsdcpio -i --quiet $verbose $list
fi

0 comments on commit 1a5e61c

Please sign in to comment.