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