#!/bin/sh -efu # initrddiff # Perform a diff on the files contained within different initrd # images and show the result. # Usage: initrddiff [diffoptions] # # diffoptions: # Most of the single letter options allowable by GNU diff(1) are acceptable. # By default -NrU0 is used. If providing a value don't forget the -r option. # # License: GPL . shell-error [ -z "${DEBUG-}" ] || set -x decompress() { local cmd='cat' typ= typ="$(file -b "$1")" case "$typ" in 'bzip2 compressed data'*) cmd='bunzip -c' ;; 'gzip compressed data'*) cmd='gunzip -c' ;; 'xz compressed data'*) cmd='unxz -c' ;; esac $cmd "$1" } extract() { decompress "$1" | cpio -t | sed -e "s,lib/modules/[^/]\+,lib/modules/," | sort } diffopts= while [ "$#" -gt 2 ]; do diffopts="$diffopts $1" shift done if [ $# != 2 ]; then printf '%s\n' "Usage: $PROG [diffoptions] " exit fi for f; do [ -f "$f" ] || fatal "No such file or directory" done exec 3<