summaryrefslogtreecommitdiffstats
path: root/scripts/pythondeps
blob: e82719768c5b9cc6698ae5b4851a4bed68b2a9e9 (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
#!/bin/bash

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

# remove all non unused python files
DIR=$1

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

if [ "$ARCH" = "x86_64" -o $ARCH = s390x ]; then
    LIBDIR=lib64
else
    LIBDIR=lib
fi

mkdir -p $DIR/proc
mount -t proc /proc $DIR/proc
if [ $ARCH = "sparc" -o $ARCH = "sparc64" ]; then
    mkdir $DIR/dev
    mknod $DIR/dev/openprom c 10 139
    <$DIR/dev/openprom
fi
(/usr/sbin/chroot $DIR /usr/bin/anaconda -m dir://mnt/source --test --text --traceonly; \
cd $DIR; find usr/$LIBDIR/python* usr/lib/anaconda usr/lib/booty -type f | sed 's,^,/,' ) | \
sort | uniq -u | sed s,^,./, | while read fn; do
    [ ! -d "$DIR/$fn" ] && rm "$DIR/$fn"
done
umount $DIR/proc
rmdir $DIR/proc
rm -rf $DIR/dev