misc/merge.sh
author Ryan C. Gordon <icculus@icculus.org>
Sun, 04 Oct 2009 16:15:45 -0400
changeset 68 79f33789900d
parent 67 944bb02f0743
child 69 eac4c3810ee4
permissions -rwxr-xr-x
Corrected merge.sh filename bug.

#!/bin/bash

if [ "x`id -u`" != "x0" ]; then
    echo "not root."
    exit 1
fi

set -x
set -e

rm -rf cmake-build
mkdir cmake-build
cd cmake-build

cmake -DCMAKE_BUILD_TYPE=Release ../..
make -j2
gcc -o iself -s -O3 ../iself.c

#time for feh in bin boot etc lib opt sbin usr var ; do find /$feh -type f -exec ./iself {} \; ; done |perl -w -pi -e 's/\A\///;' |grep -v "usr/lib32/" |sort |uniq > ./binaries-64
time for feh in bin boot etc lib opt sbin usr var ; do find /x86/$feh -type f -exec ./iself {} \; ; done |perl -w -pi -e 's/\A\/x86\///;' |grep -v "usr/lib64" |sort |uniq > ./binaries-32

for feh in `cat binaries-32` ; do
    mkdir -p --mode=0755 `dirname "/$feh"`
    if [ -f "/$feh" ]; then
        ./fatelf-glue tmp-fatelf "/$feh" "/x86/$feh"
        chmod --reference="/$feh" tmp-fatelf
        mv tmp-fatelf "/$feh"
    else
        cp -a "/x86/$feh" "/$feh"
    fi
done

# end of merge.sh ...