Skip to content
Browse files

lsinitramfs: read kernel version and compression type

  • Loading branch information...
1 parent 22a09ea commit 6cf8c1518821ecd534cd84b5fb73914a63c0bd69 @falconindy committed May 15, 2011
Showing with 17 additions and 1 deletion.
  1. +17 −1 lsinitramfs
View
18 lsinitramfs
@@ -75,10 +75,23 @@ declare image=$1
if (( analyze )); then
declare -a binaries explicitmod modules foundhooks hooks
+ declare kernver compress
+
+ # read compression type
+ case "$(file -b "$image")" in
+ data|lzma*) compress=LZMA ;;
+ ASCII*) compress=none ;;
+ gzip*) compress=gzip ;;
+ bzip2*) compress=bzip2 ;;
+ XZ*) compress=XZ ;;
+ esac
# read contents of image
while read -r line; do
if [[ $line = *.ko?(.gz) ]]; then # module
+ if [[ -z $kernver ]]; then
+ [[ $line =~ /lib/modules/([^/]+)/ ]] && kernver=${BASH_REMATCH[1]}
+ fi
line=${line##*/}
modules+=("${line%.ko?(.gz)}")
continue
@@ -102,6 +115,10 @@ if (( analyze )); then
done < <(bsdtar Oxf "$image" config)
# print results
+ printf '==> Kernel: %s\n' "${kernver:-unknown}"
+ printf '==> Compressed with: %s\n' "${compress:-unknown}"
+ printf '\n'
+
printf '==> Included modules:\n'
printf ' %s\n' "${modules[@]}"
printf '\n'
@@ -125,4 +142,3 @@ else
bsdcpio -i --quiet $verbose $list <"$image"
fi
-

0 comments on commit 6cf8c15

Please sign in to comment.
Something went wrong with that request. Please try again.