Debian Codegraph @

Bootdisks/rhmkroot

raw
1 #!/bin/sh
2
3 set -e
4
5 # Make local mount points
6 mkdir -p mnt1 mnt2
7 # Mount bootdisk image read-only
8 mount boot.img mnt1 -o loop,ro -t msdos
9 # Get the initial ramdisk it contains
10 cp mnt1/initrd.img .
11 # Finished with boot image for now.
12 umount mnt1
13 # Unzip and mount it
14 mv initrd.img initrd.gz
15 gunzip initrd.gz
16 # Prevent warning about having to check the filesystem
17 tune2fs -c 0 -i 0 initrd >/dev/null
18 mount initrd mnt2 -o loop
19
20 # Work in initial ramdisk
21 # Rename it's init
22 mv mnt2/sbin/init mnt2/sbin/init_real
23 # Put BRLTTY on it
24 cp brltty mnt2/sbin
25 # New init is a link to BRLTTY
26 ln -s brltty mnt2/sbin/init
27 # Help files and tables (if the person isn't familiar...)
28 if [ -d etcbrltty ]; then
29 mkdir -p mnt2/etc/brltty
30 install etcbrltty/* mnt2/etc/brltty
31 fi
32 # Make sure some needed device files are present
33 # ttyS0 ttyS1 tty0
34 for i in ttyS0 ttyS1 tty0; do
35 if [ ! -e mnt2/dev/$i ]; then
36 cp -a /dev/$i mnt2/dev/$i
37 chown root:root mnt2/dev/$i
38 fi
39 done
40 # vcsa or vcsa0
41 # NB this doesn't handle devfs...
42 if [ ! -e mnt2/dev/vcsa -a ! -e mnt2/dev/vcsa0 ]; then
43 for i in vcsa vcsa0; do
44 if [ -c /dev/$i ]; then
45 if [ -h /dev/$i ]; then
46 tgt="`readlink /dev/$i`"
47 # This assumes the link is relative...
48 if [ -c /dev/$tgt ]; then
49 cp -a /dev/$tgt mnt2/dev
50 else
51 echo "Failed to get link target of /dev/$i"
52 echo "Failed!!"
53 exit 1
54 fi
55 fi
56 cp -a /dev/$i mnt2/dev
57 fi
58 done
59 fi
60 if [ ! -e mnt2/dev/vcsa -a ! -e mnt2/dev/vcsa0 ]; then
61 echo "Failed to create mnt2/dev/vcsa"
62 echo "Failed!"
63 exit 1
64 fi
65
66 # Done with initial ramdisk. wrap it up.
67 umount mnt2
68 gzip -9 initrd
69 mv initrd.gz myroot.img