mkinitrd unification across distributions
 help / color / mirror / Atom feed
* [PATCH] lsinitrd: add '-s' option to sort the initrd output by file size
@ 2012-01-10 14:45 xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w
       [not found] ` <1326206745-20801-1-git-send-email-xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w @ 2012-01-10 14:45 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA; +Cc: harald-H+wXaHxf7aLQT0dZR+AlfA, Cong Wang

From: Cong Wang <xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

This is useful to analyse which files consume the space of initrd.

Signed-off-by: Cong Wang <xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 lsinitrd |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/lsinitrd b/lsinitrd
index 7da9f61..ad7ece9 100755
--- a/lsinitrd
+++ b/lsinitrd
@@ -19,7 +19,17 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-[[ $# -le 2 ]] || { echo "Usage: $(basename $0) [<initramfs file> [<filename>]]" ; exit 1 ; }
+[[ $# -le 2 ]] || { echo "Usage: $(basename $0) [-s] [<initramfs file> [<filename>]]" ; exit 1 ; }
+
+sorted=0
+while getopts "s" opt; do
+    case $opt in
+        s)  sorted=1;;
+        \?) exit 1;;
+    esac
+done
+shift $((OPTIND-1))
+
 image="${1:-/boot/initramfs-$(uname -r).img}"
 [[ -f "$image" ]]    || { echo "$image does not exist" ; exit 1 ; }
 
@@ -45,5 +55,9 @@ echo "$image: $(du -h $image | awk '{print $1}')"
 echo "========================================================================"
 $CAT "$image" | cpio --extract --verbose --quiet --to-stdout 'lib/dracut/dracut-*' 2>/dev/null
 echo "========================================================================"
-$CAT "$image" | cpio --extract --verbose --quiet --list
+if [ "$sorted" -eq 1 ]; then
+    $CAT "$image" | cpio --extract --verbose --quiet --list | sort -n -k5
+else
+    $CAT "$image" | cpio --extract --verbose --quiet --list
+fi
 echo "========================================================================"
-- 
1.7.7.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-01-23 11:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-10 14:45 [PATCH] lsinitrd: add '-s' option to sort the initrd output by file size xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w
     [not found] ` <1326206745-20801-1-git-send-email-xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-01-23 11:05   ` Harald Hoyer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox