Skip to content

Latest commit

 

History

History
executable file
·
108 lines (87 loc) · 3.22 KB

merge.sh

File metadata and controls

executable file
·
108 lines (87 loc) · 3.22 KB
 
1
2
3
4
5
6
7
8
9
10
11
#!/bin/bash
if [ "x`id -u`" != "x0" ]; then
echo "not root."
exit 1
fi
set -x
set -e
rm -rf cmake-build
Oct 14, 2009
Oct 14, 2009
12
mkdir -p cmake-build
Oct 16, 2009
Oct 16, 2009
15
16
17
18
19
20
21
22
23
mkdir -p /x86_64
mkdir -p /x86
umount /x86_64 || echo "ignore any umount errors"
umount /x86 || echo "ignore any umount errors"
mount -t ext3 /dev/sda1 /x86_64
mount -t ext3 /dev/sdb1 /x86
Oct 14, 2009
Oct 14, 2009
24
25
26
27
# Special case: it's a symlink to /lib32, so it causes an endless loop.
rm -f /x86_64/lib/ld-linux.so.2
ln -s ld-2.9.so /x86_64/lib/ld-linux.so.2
Oct 16, 2009
Oct 16, 2009
28
# other issues.
Oct 17, 2009
Oct 17, 2009
29
30
31
32
33
34
35
if [ -d /x86/lib/udev/devices ] ; then
mv /x86/lib/udev/devices /x86/tmp_devices
fi
if [ -d /x86/usr/bin/X11 ]; then
mv /x86/usr/bin/X11 /x86/tmp_X11
fi
Oct 16, 2009
Oct 16, 2009
36
Oct 16, 2009
Oct 16, 2009
37
38
39
# Make sure the home directory is gone.
rm -rf /x86_64/home/fatelf
cp -av /x86_64/etc/skel /x86_64/home/fatelf
Oct 16, 2009
Oct 16, 2009
40
chown -R 1000 /x86_64/home/fatelf
Oct 16, 2009
Oct 16, 2009
41
Oct 16, 2009
Oct 16, 2009
42
43
44
gcc -o fatelf-validate -O3 -s -I../../include -I../../utils ../../utils/fatelf-validate.c ../../utils/fatelf-utils.c
gcc -o fatelf-replace -O3 -s -I../../include -I../../utils ../../utils/fatelf-replace.c ../../utils/fatelf-utils.c
gcc -o fatelf-glue -O3 -s -I../../include -I../../utils ../../utils/fatelf-glue.c ../../utils/fatelf-utils.c
45
gcc -o iself -s -O3 ../iself.c
Oct 14, 2009
Oct 14, 2009
46
gcc -o is32bitelf -s -O3 ../is32bitelf.c
Oct 14, 2009
Oct 14, 2009
48
if [ ! -f ./binaries-32 ]; then
Oct 16, 2009
Oct 16, 2009
49
time for feh in bin boot etc lib opt sbin usr/bin usr/games usr/sbin usr/X11R6 usr/lib usr/local var/lib ; do find /x86/$feh -follow -type f -exec ./iself {} \; ; done |perl -w -pi -e 's/\A\/x86\///;' |sort |uniq > ./binaries-32
Oct 14, 2009
Oct 14, 2009
50
fi
51
52
for feh in `cat binaries-32` ; do
Oct 4, 2009
Oct 4, 2009
53
mkdir -p --mode=0755 `dirname "/x86_64/$feh"`
Oct 14, 2009
Oct 14, 2009
54
55
56
57
if [ ! -f "/x86_64/$feh" ]; then
cp -a "/x86/$feh" "/x86_64/$feh"
else
ISFATELF=0
Oct 4, 2009
Oct 4, 2009
58
./fatelf-validate "/x86_64/$feh" && ISFATELF=1
Oct 4, 2009
Oct 4, 2009
59
if [ "x$ISFATELF" = "x1" ]; then
Oct 4, 2009
Oct 4, 2009
60
./fatelf-replace tmp-fatelf "/x86_64/$feh" "/x86/$feh"
Oct 14, 2009
Oct 14, 2009
61
62
chmod --reference="/x86_64/$feh" tmp-fatelf
mv tmp-fatelf "/x86_64/$feh"
Oct 4, 2009
Oct 4, 2009
63
else
Oct 14, 2009
Oct 14, 2009
64
65
66
67
68
69
70
71
72
SRCIS32BIT=0
DSTIS32BIT=0
./is32bitelf "/x86/$feh" && SRCIS32BIT=1
./is32bitelf "/x86_64/$feh" && DSTIS32BIT=1
if [ "x$SRCIS32BIT" != "x$DSTIS32BIT" ]; then
./fatelf-glue tmp-fatelf "/x86_64/$feh" "/x86/$feh"
chmod --reference="/x86_64/$feh" tmp-fatelf
mv tmp-fatelf "/x86_64/$feh"
fi
Oct 4, 2009
Oct 4, 2009
73
fi
Oct 16, 2009
Oct 16, 2009
77
# We don't need /lib32 and /lib64, but symlink them to /lib just in case.
Oct 4, 2009
Oct 4, 2009
78
79
80
81
82
rm -rf /x86_64/lib32
rm -rf /x86_64/lib64
ln -s /lib /x86_64/lib32
ln -s /lib /x86_64/lib64
Oct 17, 2009
Oct 17, 2009
83
# Set up the boot bits.
Oct 16, 2009
Oct 16, 2009
84
85
86
mkdir -p /x86_64/boot/x86_64
mkdir -p /x86_64/boot/x86
mv /x86_64/boot/*-generic /x86_64/boot/x86_64/
Oct 17, 2009
Oct 17, 2009
87
cp -av /x86/boot/*-generic /x86_64/boot/x86/
Oct 16, 2009
Oct 16, 2009
88
89
cp ../grubmenu.txt /x86_64/boot/grub/menu.lst
Oct 17, 2009
Oct 17, 2009
90
91
92
93
# Hack: force hald to regenerate cache on each run, since it writes a size_t
# in there that causes crashes when you switch between 64 and 32 bit mode.
echo "rm -f /var/cache/hald/fdi-cache" >> /x86_64/etc/default/hal
Oct 17, 2009
Oct 17, 2009
94
95
96
97
# Put some things back.
mv /x86/tmp_devices /x86/lib/udev/devices
mv /x86/tmp_X11 /x86/usr/bin/X11
Oct 16, 2009
Oct 16, 2009
98
99
100
101
umount /x86
umount /x86_64
# We disable fsck intervals...this is a demo, after all!
Oct 17, 2009
Oct 17, 2009
102
set +e
Oct 16, 2009
Oct 16, 2009
103
time fsck.ext3 -D -C 0 -f /dev/sda1
Oct 16, 2009
Oct 16, 2009
104
105
106
tune2fs -c 0 /dev/sda1
tune2fs -i 0 /dev/sda1