Magellan Linux

Contents of /trunk/installer/include/prepare_bootloader.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1070 - (show annotations) (download) (as text)
Mon May 31 22:51:09 2010 UTC (13 years, 10 months ago) by niro
File MIME type: application/x-sh
File size: 3206 byte(s)
-fixed pipelines again
1 #!/bin/bash
2 # $Id$
3
4 source /etc/installer.conf
5 source ${INSTALLER_DIR}/include/hwdetection.sh
6
7 : ${INSTALL_ROOT="/mnt/magellan"}
8
9 create_device_map()
10 {
11 local chroot
12
13 [[ ! -z ${INSTALL_ROOT} ]] && chroot=chrooted
14
15 # create device.map
16 ${chroot} grub --batch --no-floppy --no-config-file --device-map=/boot/grub/device.map </dev/null
17 }
18
19 install_grub()
20 {
21 local chroot
22 local grub_disk
23
24 if [[ -z ${PARTITION_DISK_BOOT} ]]
25 then
26 grub_disk="${PARTITION_DISK_ROOT}"
27 else
28 grub_disk="${PARTITION_DISK_BOOT}"
29 fi
30
31 [[ ! -z ${INSTALL_ROOT} ]] && chroot=chrooted
32
33 # update grub
34 ${chroot} grub --batch --no-floppy << EOF
35 root $(convert_device ${grub_disk})
36 setup $(convert_device ${grub_disk} | sed "s:,[0-9]::")
37 quit
38 EOF
39
40 return 0
41 }
42
43 convert_device()
44 {
45 local device="$1"
46 local root_part=
47
48 # extract device type (block) and major number for root drive
49 local major_minor=$(ls -Ll ${device} | awk '{if ($6 < 64) printf("%c%d0", $1, $5); else printf("%c%d1", $1, $5)}')
50
51 # find the matching BIOS device
52 for bios_drive in $(grep -v '^#' ${INSTALL_ROOT}/boot/grub/device.map | awk '{print $2}')
53 do
54 bios_major_minor=$(ls -Ll ${bios_drive} 2>/dev/null | awk '{if ($6 < 64) printf("%c%d0", $1, $5); else printf("%c%d1", $1, $5)}')
55
56 if [[ ${major_minor} = ${bios_major_minor} ]]
57 then
58 # we found it
59 root_drive=$(grep ${bios_drive} ${INSTALL_ROOT}/boot/grub/device.map | awk '{print $1}')
60 root_part=$(ls -Ll ${device} | awk '{print $6}')
61 root_part=$(( ${root_part} % 16 - 1 ))
62 break
63 fi
64 done
65
66 drive=$(echo ${root_drive} | sed "s:)$:,${root_part}):")
67 echo ${drive}
68 }
69
70 add_grub_conf()
71 {
72 echo "$@" >> ${INSTALL_ROOT}/boot/grub/grub.conf
73 }
74
75 create_grub_conf()
76 {
77 local splashimage
78 local grub_disk
79
80 if [[ -z ${PARTITION_DISK_BOOT} ]]
81 then
82 grub_disk="${PARTITION_DISK_ROOT}"
83 else
84 grub_disk="${PARTITION_DISK_BOOT}"
85 fi
86
87 # create an empty one
88 :> ${INSTALL_ROOT}/boot/grub/grub.conf
89
90 add_grub_conf "default 0"
91 add_grub_conf "timeout 10"
92 add_grub_conf ""
93
94 # our splashimage
95 splashimage="magellan.xpm.gz"
96
97 # forcefully use gfxsplash
98 [[ ! -f ${INSTALL_ROOT}/boot/${splashimage} ]] && cp ${INSTALLER_DIR}/data/magellan-black2.xpm.gz ${INSTALL_ROOT}/boot/${splashimage}
99
100 if [[ -f ${INSTALL_ROOT}/boot/${splashimage} ]]
101 then
102 add_grub_conf "# splash image"
103 add_grub_conf "splashimage $(convert_device ${grub_disk})/boot/${splashimage}"
104 add_grub_conf "foreground FFFFFF"
105 add_grub_conf "background 253861"
106
107 add_grub_conf ""
108 else
109 add_grub_conf "# some pretty colors"
110 add_grub_conf "color cyan/blue white/blue"
111 add_grub_conf ""
112 fi
113
114 add_grub_conf "title Magellan-Linux $(< ${INSTALL_ROOT}/etc/mageversion) ($(readlink ${INSTALL_ROOT}/boot/vmlinuz | sed s:kernel-::))"
115 add_grub_conf "root $(convert_device ${grub_disk})"
116 add_grub_conf "kernel /boot/$(readlink ${INSTALL_ROOT}/boot/vmlinuz) root=UUID=$(get_uuid ${PARTITION_DISK_ROOT})"
117 add_grub_conf "initrd /boot/$(readlink ${INSTALL_ROOT}/boot/initrd)"
118
119 # add an empty line as spacer between other boot entries
120 add_grub_conf ""
121 }
122
123 install_bootloader()
124 {
125 create_device_map >> ${INSTALLER_LOG} 2>&1
126 echo 25
127 create_grub_conf >> ${INSTALLER_LOG} 2>&1
128 echo 50
129 install_grub >> ${INSTALLER_LOG} 2>&1
130 echo 100
131 }

Properties

Name Value
svn:executable *