Annotation of /trunk/installer/include/prepare_bootloader.sh
Parent Directory | Revision Log
Revision 1070 -
(hide annotations)
(download)
(as text)
Mon May 31 22:51:09 2010 UTC (14 years, 4 months ago) by niro
File MIME type: application/x-sh
File size: 3206 byte(s)
Mon May 31 22:51:09 2010 UTC (14 years, 4 months ago) by niro
File MIME type: application/x-sh
File size: 3206 byte(s)
-fixed pipelines again
1 | niro | 1025 | #!/bin/bash |
2 | # $Id$ | ||
3 | niro | 773 | |
4 | niro | 1034 | source /etc/installer.conf |
5 | source ${INSTALLER_DIR}/include/hwdetection.sh | ||
6 | niro | 773 | |
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 | niro | 1062 | ${chroot} grub --batch --no-floppy --no-config-file --device-map=/boot/grub/device.map </dev/null |
17 | niro | 773 | } |
18 | |||
19 | install_grub() | ||
20 | { | ||
21 | local chroot | ||
22 | niro | 1051 | local grub_disk |
23 | niro | 773 | |
24 | niro | 1051 | 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 | niro | 773 | [[ ! -z ${INSTALL_ROOT} ]] && chroot=chrooted |
32 | |||
33 | # update grub | ||
34 | niro | 1062 | ${chroot} grub --batch --no-floppy << EOF |
35 | niro | 1051 | root $(convert_device ${grub_disk}) |
36 | setup $(convert_device ${grub_disk} | sed "s:,[0-9]::") | ||
37 | niro | 773 | 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 | niro | 1051 | local grub_disk |
79 | niro | 773 | |
80 | if [[ -z ${PARTITION_DISK_BOOT} ]] | ||
81 | then | ||
82 | niro | 1051 | grub_disk="${PARTITION_DISK_ROOT}" |
83 | else | ||
84 | grub_disk="${PARTITION_DISK_BOOT}" | ||
85 | niro | 773 | 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 | niro | 1034 | [[ ! -f ${INSTALL_ROOT}/boot/${splashimage} ]] && cp ${INSTALLER_DIR}/data/magellan-black2.xpm.gz ${INSTALL_ROOT}/boot/${splashimage} |
99 | niro | 773 | |
100 | if [[ -f ${INSTALL_ROOT}/boot/${splashimage} ]] | ||
101 | then | ||
102 | add_grub_conf "# splash image" | ||
103 | niro | 1051 | add_grub_conf "splashimage $(convert_device ${grub_disk})/boot/${splashimage}" |
104 | niro | 773 | 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 | niro | 1051 | add_grub_conf "root $(convert_device ${grub_disk})" |
116 | niro | 1045 | add_grub_conf "kernel /boot/$(readlink ${INSTALL_ROOT}/boot/vmlinuz) root=UUID=$(get_uuid ${PARTITION_DISK_ROOT})" |
117 | niro | 773 | 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 | niro | 1070 | create_device_map >> ${INSTALLER_LOG} 2>&1 |
126 | niro | 773 | echo 25 |
127 | niro | 1070 | create_grub_conf >> ${INSTALLER_LOG} 2>&1 |
128 | niro | 773 | echo 50 |
129 | niro | 1070 | install_grub >> ${INSTALLER_LOG} 2>&1 |
130 | niro | 773 | echo 100 |
131 | } |
Properties
Name | Value |
---|---|
svn:executable | * |