Magellan Linux

Annotation of /tags/installer-0_1_2/include/prepare_bootloader.sh

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *