summaryrefslogtreecommitdiffstats
path: root/scripts/scrubtree
blob: 54e891521c51e57beb146111e0cd146766c08823 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash

if [ -z "$1" ]; then
    echo "Usage: $0 /path/to/tree"
    exit 1
fi

p=$1

STRIP=strip
ARCH=`uname -m | sed -e 's/i.86/i386/'`

if [ $ARCH = ia64 ]; then
    STRIP="strip --strip-debug"
fi

# Must create ld.so.conf, because ldconfig does not cache
# dirs specified on the command line.
touch $p/etc/ld.so.conf
mkdir $p/proc
mount -t proc proc $p/proc
[ -d $p/usr/X11R6/lib ] && echo /usr/X11R6/lib > $p/etc/ld.so.conf
(cd $p; /usr/sbin/chroot $p usr/sbin/ldconfig )

if [ $ARCH != s390 -a $ARCH != s390x ]; then
    rm -f $p/usr/sbin/ldconfig 
fi
rm $p/etc/ld.so.conf

(cd $p/usr/bin; ./collage | $p/usr/lib/anaconda-runtime/mkcollagelinks ./collage)

mv $p/usr/sbin/busybox.anaconda $p/usr/bin/busybox
(cd $p/usr/bin;
set $(./busybox 2>&1| awk '/^\t([a-z\[]+,)+/' | sed 's/,//g' | sed 's/ +//');
while [ -n "$1" ]; do
    if [ $1 != "busybox" -a $1 != "sh" ]; then
	ln -sf ./busybox $1
    fi
    shift
done
)

umount $p/proc

for l in `find $p -type f -perm +100 | grep -v "usr/X11R6/lib/modules" | xargs file | sed -n 's/^\([^:]*\):.*ELF.*$/\1/p'`; do
    $STRIP $l -R .comment -R .note `objdump -h $l | \
	sed -n 's/^.*\(\.gnu\.warning\.[^ ]*\) .*$/-R \1/p'`
done