Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1157 - (hide annotations) (download) (as text)
Tue Sep 14 20:07:38 2010 UTC (13 years, 7 months ago) by niro
File MIME type: application/x-sh
File size: 3448 byte(s)
-use the right grub_prefix properly
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 1157 local grub_prefix
80 niro 773
81     if [[ -z ${PARTITION_DISK_BOOT} ]]
82     then
83 niro 1051 grub_disk="${PARTITION_DISK_ROOT}"
84 niro 1157 # if no extra partition for grub was defined, we need the bootprefix set to /boot
85     grub_prefix="/boot"
86 niro 1051 else
87     grub_disk="${PARTITION_DISK_BOOT}"
88 niro 1157 # got a extra boot partition, no bootprefix needed
89     grub_prefix=""
90 niro 773 fi
91    
92     # create an empty one
93     :> ${INSTALL_ROOT}/boot/grub/grub.conf
94    
95     add_grub_conf "default 0"
96     add_grub_conf "timeout 10"
97     add_grub_conf ""
98    
99     # our splashimage
100     splashimage="magellan.xpm.gz"
101    
102     # forcefully use gfxsplash
103 niro 1034 [[ ! -f ${INSTALL_ROOT}/boot/${splashimage} ]] && cp ${INSTALLER_DIR}/data/magellan-black2.xpm.gz ${INSTALL_ROOT}/boot/${splashimage}
104 niro 773
105     if [[ -f ${INSTALL_ROOT}/boot/${splashimage} ]]
106     then
107     add_grub_conf "# splash image"
108 niro 1157 add_grub_conf "splashimage $(convert_device ${grub_disk})${grub_prefix}/${splashimage}"
109 niro 773 add_grub_conf "foreground FFFFFF"
110     add_grub_conf "background 253861"
111    
112     add_grub_conf ""
113     else
114     add_grub_conf "# some pretty colors"
115     add_grub_conf "color cyan/blue white/blue"
116     add_grub_conf ""
117     fi
118    
119     add_grub_conf "title Magellan-Linux $(< ${INSTALL_ROOT}/etc/mageversion) ($(readlink ${INSTALL_ROOT}/boot/vmlinuz | sed s:kernel-::))"
120 niro 1051 add_grub_conf "root $(convert_device ${grub_disk})"
121 niro 1157 add_grub_conf "kernel ${grub_prefix}/$(readlink ${INSTALL_ROOT}/boot/vmlinuz) root=UUID=$(get_uuid ${PARTITION_DISK_ROOT})"
122     add_grub_conf "initrd ${grub_prefix}/$(readlink ${INSTALL_ROOT}/boot/initrd)"
123 niro 773
124     # add an empty line as spacer between other boot entries
125     add_grub_conf ""
126     }
127    
128     install_bootloader()
129     {
130 niro 1070 create_device_map >> ${INSTALLER_LOG} 2>&1
131 niro 773 echo 25
132 niro 1070 create_grub_conf >> ${INSTALLER_LOG} 2>&1
133 niro 773 echo 50
134 niro 1070 install_grub >> ${INSTALLER_LOG} 2>&1
135 niro 773 echo 100
136     }
137 niro 1073
138     install_bootloader

Properties

Name Value
svn:executable *