lorax/rewrite/scratch/scrubtree
David Cantrell 2aef98cb23 Giant directory of the old scripts.
Placed here for reference as to what remains to be done.

The orig/ subdir is the unmodified tools from anaconda.  The scratch/
subdir is a merge of orig in to a working area.  I delete blocks of
code from there as I rewrite them.
2008-10-04 18:52:23 -10:00

71 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
DEBUG=""
if [ "$1" == "--debug" ]; then
DEBUG="--debug"
shift
fi
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
if [ $ARCH = x86_64 -o $ARCH = s390x ]; then
LIBDIR=lib64
else
LIBDIR=lib
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/$LIBDIR ] && echo /usr/X11R6/$LIBDIR > $p/etc/ld.so.conf
echo /usr/kerberos/$LIBDIR > $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
#
# make sure we have links for programs supplied by busybox
#
# HOWEVER dont clobber existing programs supplied by other packages if exist
#
mv $p/usr/sbin/busybox.anaconda $p/usr/bin/busybox
(cd $p/usr/bin;
set $(./busybox 2>&1| awk '/^\t([[:alnum:]_\[]+,)+/' | sed 's/,//g' | sed 's/ +//');
while [ -n "$1" ]; do
if [ $1 != "busybox" -a $1 != "sh" -a $1 != "shutdown" -a $1 != "poweroff" -a $1 != "reboot" ]; then
# if file doesnt already exist, link to busybox
if [ ! -f "$1" ]; then
ln -sf ./busybox $1
else
[ -n "$DEBUG" ] && echo "Overriding busybox version of $1"
fi
fi
shift
done
)
umount $p/proc
for l in `find $p -type f -perm +100 | grep -v "usr/X11R6/$LIBDIR/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