]>
Commit | Line | Data |
---|---|---|
bd688d0c PZ |
1 | #!/bin/bash |
2 | ||
3 | DEBUG="" | |
4 | ||
5 | if [ "$1" == "--debug" ]; then | |
6 | DEBUG="--debug" | |
7 | shift | |
8 | fi | |
9 | ||
10 | if [ -z "$1" ]; then | |
11 | echo "Usage: $0 /path/to/tree" | |
12 | exit 1 | |
13 | fi | |
14 | ||
15 | p=$1 | |
16 | ||
17 | STRIP=strip | |
18 | ARCH=`uname -m | sed -e 's/i.86/i386/'` | |
19 | ||
20 | if [ $ARCH = ia64 ]; then | |
21 | STRIP="strip --strip-debug" | |
22 | fi | |
23 | ||
24 | if [ $ARCH = x86_64 -o $ARCH = s390x ]; then | |
25 | LIBDIR=lib64 | |
26 | else | |
27 | LIBDIR=lib | |
28 | fi | |
29 | ||
30 | # Must create ld.so.conf, because ldconfig does not cache | |
31 | # dirs specified on the command line. | |
32 | touch $p/etc/ld.so.conf | |
33 | mkdir $p/proc | |
34 | mount -t proc proc $p/proc | |
35 | [ -d $p/usr/X11R6/$LIBDIR ] && echo /usr/X11R6/$LIBDIR > $p/etc/ld.so.conf | |
36 | echo /usr/kerberos/$LIBDIR > $p/etc/ld.so.conf | |
37 | (cd $p; /usr/sbin/chroot $p usr/sbin/ldconfig ) | |
38 | ||
39 | if [ $ARCH != s390 -a $ARCH != s390x ]; then | |
40 | rm -f $p/usr/sbin/ldconfig | |
41 | fi | |
42 | rm $p/etc/ld.so.conf | |
43 | ||
44 | # | |
45 | # make sure we have links for programs supplied by busybox | |
46 | # | |
47 | # HOWEVER dont clobber existing programs supplied by other packages if exist | |
48 | # | |
3ef72932 | 49 | mv $p/sbin/busybox.anaconda $p/usr/bin/busybox |
bd688d0c PZ |
50 | (cd $p/usr/bin; |
51 | set $(./busybox 2>&1| awk '/^\t([[:alnum:]_\[]+,)+/' | sed 's/,//g' | sed 's/ +//'); | |
52 | dontclobber=(sh busybox reboot shutdown poweroff) | |
53 | while [ -n "$1" ]; do | |
54 | save= | |
55 | for n in ${dontclobber[@]} ; do | |
56 | if [ "$1" == "$n" ]; then | |
57 | save=$n | |
58 | fi | |
59 | done | |
60 | # if it's not in our list and it doesn't exist, link to busybox | |
61 | if [ -z "$save" -a ! -f "$1" ]; then | |
62 | ln -sf ./busybox $1 | |
63 | else | |
64 | [ -n "$DEBUG" ] && echo "Overriding busybox version of $1" | |
65 | fi | |
66 | shift | |
67 | done | |
68 | ) | |
69 | ||
70 | umount $p/proc | |
71 | ||
72 | for l in `find $p -type f -perm +100 | grep -v "usr/X11R6/$LIBDIR/modules" | xargs file | sed -n 's/^\([^:]*\):.*ELF.*$/\1/p'`; do | |
73 | $STRIP $l -R .comment -R .note `objdump -h $l | \ | |
74 | sed -n 's/^.*\(\.gnu\.warning\.[^ ]*\) .*$/-R \1/p'` | |
75 | done |