diff options
author | Roland McGrath <roland@redhat.com> | 2009-01-04 03:26:58 -0800 |
---|---|---|
committer | Roland McGrath <roland@redhat.com> | 2009-01-04 03:26:58 -0800 |
commit | e5528628bd8a01aa42916314173f65330487fa85 (patch) | |
tree | 876989a14b7f9a164d751d74d312b59bc82402f7 | |
download | debuginfo-test-scripts-e5528628bd8a01aa42916314173f65330487fa85.tar.gz debuginfo-test-scripts-e5528628bd8a01aa42916314173f65330487fa85.tar.xz debuginfo-test-scripts-e5528628bd8a01aa42916314173f65330487fa85.zip |
initial commit of testing scripts
-rw-r--r-- | .gitignore | 6 | ||||
-rwxr-xr-x | extract-distro.sh | 17 | ||||
-rwxr-xr-x | extract-rpm.sh | 30 | ||||
-rwxr-xr-x | find-files.sh | 13 | ||||
-rwxr-xr-x | pack-debuginfo.sh | 89 |
5 files changed, 155 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fb6a0b4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +*.i?86 +*.x86_64 +*.ppc +*.ppc64 +lost+found +*~ diff --git a/extract-distro.sh b/extract-distro.sh new file mode 100755 index 0000000..866b897 --- /dev/null +++ b/extract-distro.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +n=1 +if [ "x$1" = "x-j" ]; then + n=$2 + shift + shift +esac + +here=`pwd` + +for distro; do + for dir in $distro/*/debug/; do + echo "considering ${dir}..." + (cd "$dir" && ls | ./extract-rpm.sh "$here") | ./pack-debuginfo.sh $n + done +done diff --git a/extract-rpm.sh b/extract-rpm.sh new file mode 100755 index 0000000..56bf0d9 --- /dev/null +++ b/extract-rpm.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +v=0 +if [ "x$1" = "x-v" ]; then + v=1 + shift +fi + +dest=$1; shift + +for rpm; do + + name="${rpm%.rpm}" + if [ "$name" = "$rpm" ]; then + [ $v -eq 0 ] || echo >&2 "not .rpm: $rpm" + continue + fi + name="${name##*/}" + if [ -d "$dest/$name" ] && ! rmdir "$dest/$name" 2> /dev/null; then + [ $v -eq 0 ] || echo >&2 "$name already there" + continue + fi + mkdir -p "$dest/$name" || exit + rpm2cpio "$rpm" | + (cd "$dest/$name"; cpio --quiet --extract --no-abs --make-dir || + echo >&2 "FAILED: $name") + + echo "$name" + +done diff --git a/find-files.sh b/find-files.sh new file mode 100755 index 0000000..2094291 --- /dev/null +++ b/find-files.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +while read dir; do + find "$dir" -name '*.debug' -type f -print0 | + xargs -0 file -N -F ' ' -i | + awk ' +NF == 2 && $2 == "application/x-executable" { print $1 >> "exec" ; next } +NF == 2 && $2 == "application/x-sharedlib" { print $1 >> "dyn" ; next } +NF == 2 && $2 == "application/x-object" { print $1 >> "rel" ; next } +NF == 2 && $2 == "application/x-archive" { print $1 >> "archive" ; next } +{ print "unexpected line:", $0; next } +' +done 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 |