From 887511601787db60b5692802fc2ccdfd47c0d698 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Thu, 27 Sep 2012 09:58:30 -0400 Subject: lsinitcpio: add -c, --config option to dump config Now that mkinitcpio stores the build time config file in the image, we should have a way of easily getting it back out. Signed-off-by: Dave Reisner --- bash-completion | 2 +- lsinitcpio | 12 +++++++++--- lsinitcpio.1.txt | 3 +++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/bash-completion b/bash-completion index e56cd6c..4e548af 100644 --- a/bash-completion +++ b/bash-completion @@ -3,7 +3,7 @@ _lsinitcpio() { local cur opts - opts=(-a --analyze -h --help -n --nocolor -v --verbose -x --extract) + opts=(-a --analyze -c --config -h --help -n --nocolor -v --verbose -x --extract) _get_comp_words_by_ref cur diff --git a/lsinitcpio b/lsinitcpio index 46ea9f0..1d4a343 100755 --- a/lsinitcpio +++ b/lsinitcpio @@ -17,7 +17,8 @@ lsinitcpio %VERSION% usage: ${0##*/} [options] Options: - -a, --analyze analyze contents + -a, --analyze analyze contents of image + -c, --config show configuration file image was built with -h, --help display this help -n, --nocolor disable colorized output -v, --verbose more verbose output @@ -162,8 +163,8 @@ analyze_image() { fi } -OPT_SHORT='ahnvx' -OPT_LONG=('analyze' 'help' 'nocolor' 'verbose' 'extract') +OPT_SHORT='achnvx' +OPT_LONG=('analyze' 'help' 'nocolor' 'showconfig' 'verbose' 'extract') if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then exit 1 @@ -175,6 +176,8 @@ while :; do case $1 in -a|--analyze) analyze=1 ;; + -c|--config) + showconfig=1 ;; -h|--help) usage exit 0 ;; @@ -227,6 +230,9 @@ esac if (( analyze )); then analyze_image "$image" +elif (( showconfig )); then + decomp "$1" | bsdtar xOf - buildconfig 2>/dev/null || + die 'Failed to extract config from image (mkinitcpio too old?)' else decomp "$image" | bsdcpio -i --quiet $verbose $list fi diff --git a/lsinitcpio.1.txt b/lsinitcpio.1.txt index 7a152ab..63b5566 100644 --- a/lsinitcpio.1.txt +++ b/lsinitcpio.1.txt @@ -23,6 +23,9 @@ Options Analyze the contents of the specified image and print output in human readable form. +*-c, \--config*:: + Show the configuration file the given image was built with. + *-h, \--help*:: Output a short overview of available command-line switches. -- cgit v1.2.3-24-g4f1b