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.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
67
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
#!/bin/bash
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
if [ "x`id -u`" != "x0" ]; then
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     4
    echo "not root."
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
    exit 1
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
fi
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     7
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     8
set -x
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
set -e
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
rm -rf cmake-build
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
mkdir cmake-build
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
cd cmake-build
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    14
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
cmake -DCMAKE_BUILD_TYPE=Release ../..
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
make -j2
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    17
gcc -o iself -s -O3 ../iself.c
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    18
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    19
#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
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    20
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
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    21
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    22
for feh in `cat binaries-32` ; do
68
79f33789900d Corrected merge.sh filename bug.
Ryan C. Gordon <icculus@icculus.org>
parents: 67
diff changeset
    23
    mkdir -p --mode=0755 `dirname "/$feh"`
67
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    24
    if [ -f "/$feh" ]; then
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    25
        ./fatelf-glue tmp-fatelf "/$feh" "/x86/$feh"
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    26
        chmod --reference="/$feh" tmp-fatelf
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    27
        mv tmp-fatelf "/$feh"
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    28
    else
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    29
        cp -a "/x86/$feh" "/$feh"
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    30
    fi
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
done
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    32
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
# end of merge.sh ...
944bb02f0743 First shot at a script to merge two file systems into one FatELF install.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34