summaryrefslogtreecommitdiffstats
path: root/pack-debuginfo.sh
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2009-01-04 03:26:58 -0800
committerRoland McGrath <roland@redhat.com>2009-01-04 03:26:58 -0800
commite5528628bd8a01aa42916314173f65330487fa85 (patch)
tree876989a14b7f9a164d751d74d312b59bc82402f7 /pack-debuginfo.sh
downloaddebuginfo-test-scripts-e5528628bd8a01aa42916314173f65330487fa85.tar.gz
debuginfo-test-scripts-e5528628bd8a01aa42916314173f65330487fa85.tar.xz
debuginfo-test-scripts-e5528628bd8a01aa42916314173f65330487fa85.zip
initial commit of testing scripts
Diffstat (limited to 'pack-debuginfo.sh')
-rwxr-xr-xpack-debuginfo.sh89
1 files changed, 89 insertions, 0 deletions
diff --git a/pack-debuginfo.sh b/pack-debuginfo.sh
new file mode 100755
index 0000000..fae5cb7
--- /dev/null
+++ b/pack-debuginfo.sh
@@ -0,0 +1,89 @@
+#!/bin/sh
+
+get_size()
+{
+ size="$1->$3"
+}
+
+do_src()
+{
+ if was=`du -sh usr/src`; then
+ tar cf - usr/src | bzip2 -9 > src.tar.bz2
+ is=`du -sh src.tar.bz2`
+ rm -rf usr/src &
+ get_size $was $is
+ else
+ size="missing"
+ fi
+ printf "src %s" "$size" > summary
+}
+
+do_collect()
+{
+ > exec
+ > dyn
+ > rel
+ > archive
+ find usr/lib* -type f -print0 | xargs -0 file -N -F ' ' -i |
+ awk -v dir="$dir" -v src="$size" '
+BEGIN { e = d = r = u = a = 0 }
+NF == 2 && $2 == "application/x-executable" { print $1 > "exec" ; ++e; next }
+NF == 2 && $2 == "application/x-sharedlib" { print $1 > "dyn" ; ++d; next }
+NF == 2 && $2 == "application/x-object" { print $1 > "rel" ; ++r; next }
+NF == 2 && $2 == "application/x-archive" { print $1 > "archive" ; ++a; next }
+{ print "unexpected line from", dir ": " $0 > "/dev/stderr";
+ ++u; print $0 > "bogon"; next }
+END {
+ printf "exec %d dyn %d rel %d archive %d", e, d, r, a;
+ if (u) printf " bogons %d", u;
+ print ""
+}'
+}
+
+do_dir()
+{
+ cd "$dir"
+
+ do_src &
+
+ find usr/lib/* -type f ! -links 1 -exec rm -f {} \;
+
+ summary=`do_collect`
+
+ was=`du -sh usr/lib/debug`
+ (echo 'all: \'
+ sed 's,$,.bz2,;$!s,$,\\,' exec dyn rel
+ echo '%.bz2: %; bzip2 -9 $<'
+ ) | make -s -r -f - -j`getconf _NPROCESSORS_ONLN`
+ is=`du -sh usr/lib/debug`
+ get_size $was $is
+
+ wait
+
+ echo " $summary bz2 $size" >> summary
+
+ cd ..
+}
+
+n=${1:-1}
+run=$n
+while read dir; do
+
+ if [ -r "$dir/summary" ]; then
+ echo >&2 "$dir looks packed"
+ continue
+ fi
+
+
+ if [ $run -gt 1 ]; then
+ do_dir &
+ run=$[$run - 1]
+ else
+ do_dir
+ wait
+ run=$n
+ fi
+
+done
+
+wait