installer: support for EFI grub bootloader installation (currently only target x86_64-efi)

This commit is contained in:
Silvan Calarco 2013-06-12 01:05:37 +02:00
parent b2a7214e0b
commit 07bfd24444
2 changed files with 147 additions and 178 deletions

View File

@ -2106,57 +2106,6 @@ dcop @dcopid KommanderIf setText installhint "$insthint"
</hbox>
</widget>
</widget>
<widget class="ScriptObject">
<property name="name">
<cstring>setlabel</cstring>
</property>
<property name="geometry">
<rect>
<x>540</x>
<y>40</y>
<width>32</width>
<height>32</height>
</rect>
</property>
<property name="populationText">
<string></string>
</property>
<property name="associations" stdset="0">
<stringlist>
<string>@execBegin
function get_udisks_key() {
LANG=C udisks --show-info $1 | grep " $2:" | head -n1 | sed "s|[[:space:]]*$2:[[:space:]]*\(.*\)|\1|"
}
@if (@devicesbox.currentItem &gt;= 0)
currdev=@String.section(@devicesbox.item(@devicesbox.currentItem)," ",0)
@showdevice.setText(@devicesbox.item(@devicesbox.currentItem))
@dcop(@dcopid, KommanderIf, enableWidget(QString,bool), next, true)
@BackBox.setChecked(true)
#
# set MBR combo box
#
dcop @dcopid KommanderIf "clear(QString)" mbrbox
devices=`udisks --enumerate-device-files | grep -v /dev/disk`
dcop @dcopid KommanderIf "addListItem(QString,QString,int)" mbrbox "$currdev (@i18n("System partition"))" 0
for device in $devices; do
native_path=`get_udisks_key $device native-path`
[ -e $native_path/partition ] &amp;&amp; continue
is_system_internal=`get_udisks_key $device "system internal"`
partscheme=`get_udisks_key $device scheme`
if [ "$is_system_internal" == "1" -o "@removablebox.checked" == "1" ]; then
[ "$partscheme" == "mbr" ] &amp;&amp; \
dcop @dcopid KommanderIf "addListItem(QString,QString,int)" mbrbox "${device:5:5} (master boot record)" 0
fi
done
dcop @dcopid KommanderIf "setCurrentItem(int)" 0
@endif
@execEnd
@setBootableCheckbox.execute()</string>
</stringlist>
</property>
</widget>
<widget class="ScriptObject">
<property name="name">
<cstring>scanDevices</cstring>
@ -2243,6 +2192,66 @@ done
</stringlist>
</property>
</widget>
<widget class="ScriptObject">
<property name="name">
<cstring>setlabel</cstring>
</property>
<property name="geometry">
<rect>
<x>540</x>
<y>40</y>
<width>32</width>
<height>32</height>
</rect>
</property>
<property name="populationText">
<string></string>
</property>
<property name="associations" stdset="0">
<stringlist>
<string>@execBegin
function get_udisks_key() {
LANG=C udisks --show-info $1 | grep " $2:" | head -n1 | sed "s|[[:space:]]*$2:[[:space:]]*\(.*\)|\1|"
}
function get_udisks_key_last() {
LANG=C udisks --show-info $1 | grep " $2:" | tail -n1 | sed "s|[[:space:]]*$2:[[:space:]]*\(.*\)|\1|"
}
@if (@devicesbox.currentItem &gt;= 0)
currdev=@String.section(@devicesbox.item(@devicesbox.currentItem)," ",0)
@showdevice.setText(@devicesbox.item(@devicesbox.currentItem))
@dcop(@dcopid, KommanderIf, enableWidget(QString,bool), next, true)
@BackBox.setChecked(true)
#
# set MBR combo box
#
dcop @dcopid KommanderIf "clear(QString)" mbrbox
devices=`udisks --enumerate-device-files | grep -v /dev/disk`
dcop @dcopid KommanderIf "addListItem(QString,QString,int)" mbrbox "$currdev (@i18n("System partition"))" 0
for device in $devices; do
native_path=`get_udisks_key $device native-path`
if [ -e $native_path/partition ]; then
partition_label=`get_udisks_key_last $device label`
if [ "${partition_label:0:3}" = "EFI" ]; then
dcop @dcopid KommanderIf "addListItem(QString,QString,int)" mbrbox "${device:5:5} (@i18n("EFI system partition"))" 0
fi
else
is_system_internal=`get_udisks_key $device "system internal"`
partscheme=`get_udisks_key $device scheme`
if [ "$is_system_internal" == "1" -o "@removablebox.checked" == "1" ]; then
[ "$partscheme" == "mbr" ] &amp;&amp; \
dcop @dcopid KommanderIf "addListItem(QString,QString,int)" mbrbox "${device:5:5} (master boot record)" 0
fi
fi
done
dcop @dcopid KommanderIf "setCurrentItem(int)" 0
@endif
@execEnd
@setBootableCheckbox.execute()</string>
</stringlist>
</property>
</widget>
</widget>
<widget class="QWidget">
<property name="name">
@ -2644,45 +2653,6 @@ done
<set>AlignCenter</set>
</property>
</widget>
<widget class="ScriptObject">
<property name="name">
<cstring>setlabel_2</cstring>
</property>
<property name="geometry">
<rect>
<x>550</x>
<y>50</y>
<width>32</width>
<height>32</height>
</rect>
</property>
<property name="populationText">
<string></string>
</property>
<property name="associations" stdset="0">
<stringlist>
<string>@execBegin
@format_home_box.setEnabled(false)
@if (@devicesbox_2.currentItem &gt;= 0)
currdev=@String.section(@devicesbox_2.item(@devicesbox_2.currentItem)," ",0)
if [ "$currdev" != "none" -a "$currdev" != "nessuna" ]; then
dcop @dcopid KommanderIf "setText(QString,QString)" showdevice_2 "@devicesbox_2.item(@devicesbox_2.currentItem)"
dcop @dcopid KommanderIf "setEnabled(QString,bool)" format_home_box true
dcop @dcopid KommanderIf "setEnabled(QString,bool)" formathome_group @format_home_box.checked()
else
dcop @dcopid KommanderIf "setText(QString,QString)" showdevice_2 ""
dcop @dcopid KommanderIf "setEnabled(QString,bool)" format_home_box false
dcop @dcopid KommanderIf "setEnabled(QString,bool)" formathome_group false
fi
@dcop(@dcopid, KommanderIf, enableWidget(QString,bool), next, true)
@BackBox.setChecked(true)
dcop @dcopid KommanderIf "setCurrentItem(int)" 0
@endif
@execEnd
@setBootableCheckbox.execute()</string>
</stringlist>
</property>
</widget>
<widget class="ScriptObject">
<property name="name">
<cstring>scanDevices_2</cstring>
@ -2750,6 +2720,45 @@ done
</stringlist>
</property>
</widget>
<widget class="ScriptObject">
<property name="name">
<cstring>setlabel_2</cstring>
</property>
<property name="geometry">
<rect>
<x>550</x>
<y>50</y>
<width>32</width>
<height>32</height>
</rect>
</property>
<property name="populationText">
<string></string>
</property>
<property name="associations" stdset="0">
<stringlist>
<string>@execBegin
@format_home_box.setEnabled(false)
@if (@devicesbox_2.currentItem &gt;= 0)
currdev=@String.section(@devicesbox_2.item(@devicesbox_2.currentItem)," ",0)
if [ "$currdev" != "none" -a "$currdev" != "nessuna" ]; then
dcop @dcopid KommanderIf "setText(QString,QString)" showdevice_2 "@devicesbox_2.item(@devicesbox_2.currentItem)"
dcop @dcopid KommanderIf "setEnabled(QString,bool)" format_home_box true
dcop @dcopid KommanderIf "setEnabled(QString,bool)" formathome_group @format_home_box.checked()
else
dcop @dcopid KommanderIf "setText(QString,QString)" showdevice_2 ""
dcop @dcopid KommanderIf "setEnabled(QString,bool)" format_home_box false
dcop @dcopid KommanderIf "setEnabled(QString,bool)" formathome_group false
fi
@dcop(@dcopid, KommanderIf, enableWidget(QString,bool), next, true)
@BackBox.setChecked(true)
dcop @dcopid KommanderIf "setCurrentItem(int)" 0
@endif
@execEnd
@setBootableCheckbox.execute()</string>
</stringlist>
</property>
</widget>
</widget>
<widget class="QWidget">
<property name="name">
@ -2942,9 +2951,10 @@ done
<property name="associations" stdset="0">
<stringlist>
<string>@execBegin
mbrstring=@String.section(@mbrbox.item(@mbrbox.currentItem)," ",1)
mbrdevice=@String.section(@mbrbox.item(@mbrbox.currentItem)," ",0)
mbrpart=${mbrdevice:3:2}
if [ "$mbrpart" ]; then
if [ "$mbrpart" -a "${mbrstring/EFI}" = "${mbrstring}" ]; then
if [ $mbrpart -le 4 ]; then
dcop @dcopid KommanderIf setEnabled bootableBox true
else
@ -3192,22 +3202,20 @@ _EOF
@dcop(@dcopid, KommanderIf, enableWidget(QString,bool), back,false)
installdevice=@String.section(@devicesbox.item(@devicesbox.currentItem)," ",0)
mbrdevice=@String.section(@mbrbox.item(@mbrbox.currentItem)," ",0)
mbrstring="@mbrbox.item(@mbrbox.currentItem)"
if [ "${mbrstring/EFI}" != "${mbrstring}" ]; then
efidevice=/dev/@String.section(@mbrbox.item(@mbrbox.currentItem)," ",0)
else
mbrdevice=/dev/@String.section(@mbrbox.item(@mbrbox.currentItem)," ",0)
fi
installhomedevice=@String.section(@devicesbox_2.item(@devicesbox_2.currentItem)," ",0)
[ "$installhomedevice" = "none" ] &amp;&amp; installhomedevice=
IFS=$'\n'
CHAINLOAD_SELECTED=(`dcop @dcopid KommanderIf selection chainloadbox`)
for i in ${CHAINLOAD_SELECTED[*]}; do
chainloaddevices="/dev/${i:0:4} $chainloaddevices"
done
IFS=$' \t\n'
cat &gt;&gt;$conffile &lt;&lt; _EOF
INSTALL_DEVICE='/dev/$installdevice'
INSTALL_DRIVER='@driverlabel.text'
INSTALL_BOOTLOADER_DEVICE='/dev/$mbrdevice'
INSTALL_BOOTLOADER_DEVICE='$mbrdevice'
INSTALL_BOOTLOADER_DEVICE_EFI='$efidevice'
INSTALL_BOOTLOADER_DEVICE_SETBOOTABLE=@bootableBox.checked
INSTALL_BOOTLOADER_CHAINLOAD=($chainloaddevices)
INSTALL_FSTYPE='@fstypebox.item(@fstypebox.currentItem)'

View File

@ -1,5 +1,5 @@
# openmamba installation script
# Copyright (c) 2007-2011 by Silvan Calarco <silvan.calarco@mambasoft.it>
# Copyright (c) 2007-2013 by Silvan Calarco <silvan.calarco@mambasoft.it>
#
# For the devfs2gdev() function:
# Copyright (c) 2006 by Davide Madrisan <davide.madrisan@gmail.com>
@ -430,16 +430,7 @@ chroot $MOUNTPOINT \
}
# --fstab=/etc/fstab ||
if [ "$INSTALL_BOOTLOADER_DEVICE" ]; then
dcop_write $"Installing bootloader on $INSTALL_BOOTLOADER_DEVICE..." 85
INSTALL_BOOTLOADER_DEVICE_BYID=$INSTALL_BOOTLOADER_DEVICE
for f in `ls /dev/disk/by-id/*`; do
if [ "$INSTALL_BOOTLOADER_DEVICE" = "`readlink -f $f`" ]; then
INSTALL_BOOTLOADER_DEVICE_BYID=$f
break
fi
done
if [ "$INSTALL_BOOTLOADER_DEVICE" -o "$INSTALL_BOOTLOADER_DEVICE_EFI" ]; then
CMDLINE=`cat /proc/cmdline`
echo $"Current kernel command line is '$CMDLINE'"
NOMODESET_ADD=`echo $CMDLINE | grep "nomodeset" | sed "s|.*\(nomodeset\).*|\1|"`
@ -450,6 +441,20 @@ if [ "$INSTALL_BOOTLOADER_DEVICE" ]; then
if [ "$GRUB_CMDLINE_ADD" ]; then
sed -i "s|GRUB_CMDLINE_LINUX=\"\(.*\)\"|GRUB_CMDLINE_LINUX=\"\1 $GRUB_CMDLINE_ADD\"|" $MOUNTPOINT/etc/default/grub
fi
fi
if [ "$INSTALL_BOOTLOADER_DEVICE" ]; then
#
# MBR/BOOT SECTOR
#
dcop_write $"Installing bootloader on $INSTALL_BOOTLOADER_DEVICE..." 85
INSTALL_BOOTLOADER_DEVICE_BYID=$INSTALL_BOOTLOADER_DEVICE
for f in `ls /dev/disk/by-id/*`; do
if [ "$INSTALL_BOOTLOADER_DEVICE" = "`readlink -f $f`" ]; then
INSTALL_BOOTLOADER_DEVICE_BYID=$f
break
fi
done
echo "GRUB_INSTALL_DEVICE=$INSTALL_BOOTLOADER_DEVICE_BYID" >> $MOUNTPOINT/etc/sysconfig/grub
if [ "$INSTALL_BOOTLOADER_DEVICE_INTERNAL" != "1" ]; then
@ -465,25 +470,6 @@ if [ "$INSTALL_BOOTLOADER_DEVICE" ]; then
grub-install $INSTALL_BOOTLOADER_DEVICE --root-directory=$MOUNTPOINT --target=i386-pc --recheck --no-floppy --force
fi
# DEV_NAME_ORIG=(${DEV_NAME_ORIG[*]} $GRUB_DEV)
# DEV_NAME_DEST=(${DEV_NAME_DEST[*]} $NEW_GRUB_DEV)
# # create a couple of conversion vectors to convert/dev/sd* devices names
# # into how they will appear on the installed system
# unset CURR_DRIVER LOAD_DRIVER_LIST
# CURR_SD_LETTER=0
# while read line; do
# GRUB_DEV=`echo ${line/*[[:space:]]/}`
# if [ "${GRUB_DEV:0:7}" = "/dev/sd" ]; then
# NEW_GRUB_DEV=/dev/sd${LETTERS[CURR_SD_LETTER]}
# let CURR_SD_LETTER+=1
# else
# NEW_GRUB_DEV=$GRUB_DEV
# fi
# DEV_NAME_ORIG=(${DEV_NAME_ORIG[*]} $GRUB_DEV)
# DEV_NAME_DEST=(${DEV_NAME_DEST[*]} $NEW_GRUB_DEV)
# done < /boot/grub/device.map
if [ "${INSTALL_BOOTLOADER_DEVICE:8:2}" = "" ]; then
# MBR install: set /boot partition as bootable as required by grub2
# CHECK: this does not work when install device is an extended partition, but in this case
@ -499,54 +485,29 @@ if [ "$INSTALL_BOOTLOADER_DEVICE" ]; then
echo $"Warning: there was an error setting bootloader partition as bootable." >&2
fi
[ "$INSTALL_BOOTLOADER_CHAINLOAD" ] && {
# configure boot chainloader for e.g. windows
GRUB_OTHER_TITLES=()
GRUB_OTHER_DEVICES=()
for i in ${INSTALL_BOOTLOADER_CHAINLOAD[*]}; do
# FIXME: missing conversion from device to grub (hdx,y) form
unset ID_FS_UUID ID_FS_TYPE ID_FS_LABEL
eval `blkid $i -o udev`
if [ "$ID_FS_UUID" ]; then
if [ "$ID_FS_TYPE" = "ntfs" ]; then
[ "$ID_FS_LABEL" ] &&
ID_FS_LABEL="Windows ($ID_FS_LABEL)" || ID_FS_LABEL="Windows"
elif [ "${ID_FS_TYPE:0:3}" = "fat" ]; then
[ "$ID_FS_LABEL" ] &&
ID_FS_LABEL="Win/DOS ($ID_FS_LABEL)" || ID_FS_LABEL="Windows/DOS"
else
[ "$ID_FS_LABEL" ] &&
ID_FS_LABEL="Other OS ($ID_FS_LABEL)" || ID_FS_LABEL="Other OS"
fi
[ "$ID_FS_LABEL" ] || ID_FS_LABEL="Unknown"
GRUB_OTHER_DEVICES=(${GRUB_OTHER_DEVICES[*]} /dev/disk/by-uuid/$ID_FS_UUID)
GRUB_OTHER_TITLES=(${GRUB_OTHER_TITLES[*]} "\"$ID_FS_LABEL\"")
else
GRUB_OTHER_DEV=$i
for o in `seq 1 ${#DEV_NAME_ORIG[*]}`; do
[ "${DEV_NAME_ORIG[o-1]}" = "${i:5:3}" ] && {
GRUB_OTHER_DEV=${DEV_NAME_DEST[o-1]}${i:8:2}
break
}
done
# echo $"Renaming device "${DEV_NAME_ORIG[o-1]}$" to "${DEV_NAME_DEST[o-1]}
# sed -i "s|/dev/${DEV_NAME_ORIG[o-1]:5:3}|/dev/${DEV_NAME_DEST[o-1]:5:3}|" \
# $MOUNTPOINT/boot/grub/devices.map \
# $MOUNTPOINT/etc/sysconfig/grub
# CURR_ROOT_LETTER=0
# sed -i "s|root=/dev/${INSTALL_DEVICE:5:5}|root=/dev/${DEV_NAME_DEST[o-1]:5:3}|" \
# $MOUNTPOINT/boot/grub/grub.cfg
# done
GRUB_OTHER_DEVICES=(${GRUB_OTHER_DEVICES[*]} $GRUB_OTHER_DEV)
GRUB_OTHER_TITLES=(${GRUB_OTHER_TITLES[*]} "\"Windows on $GRUB_OTHER_DEV\"")
fi
done
cat >> $MOUNTPOINT/etc/sysconfig/grub << _EOF
GRUB_OTHER_DEVICES=(${GRUB_OTHER_DEVICES[*]})
GRUB_OTHER_TITLES=(${GRUB_OTHER_TITLES[*]})
_EOF
}
elif [ "$INSTALL_BOOTLOADER_DEVICE_EFI" ]; then
#
# EFI
#
dcop_write $"Installing bootloader on ""$INSTALL_BOOTLOADER_DEVICE_EFI (EFI)..." 85
INSTALL_BOOTLOADER_DEVICE_EFI_BYID=$INSTALL_BOOTLOADER_DEVICE_EFI
for f in `ls /dev/disk/by-id/*`; do
if [ "$INSTALL_BOOTLOADER_DEVICE_EFI" = "`readlink -f $f`" ]; then
INSTALL_BOOTLOADER_DEVICE_EFI_BYID=$f
break
fi
done
echo "GRUB_INSTALL_DEVICE_EFI=$INSTALL_BOOTLOADER_DEVICE_EFI_BYID" >> $MOUNTPOINT/etc/sysconfig/grub
echo $"Installing grub bootloader on ""$INSTALL_BOOTLOADER_DEVICE_EFI (EFI)"
[ -e $MOUNTPOINT/boot/efi ] || mkdir -p $MOUNTPOINT/boot/efi
mount $INSTALL_BOOTLOADER_DEVICE_EFI $MOUNTPOINT/boot/efi
grub-install --root-directory=$MOUNTPOINT --efi-directory=$MOUNTPOINT/boot/efi --target=x86_64-efi \
--bootloader-id="openmamba Boot Manager" --recheck --no-floppy
umount $MOUNTPOINT/boot/efi
fi
if [ "$INSTALL_BOOTLOADER_DEVICE" -o "$INSTALL_BOOTLOADER_DEVICE_EFI" ]; then
# mount all disks and dbus for Grub other linuxes detection to work (30_other_linux)
mount -o bind /mnt $MOUNTPOINT/mnt
mount -o bind /var/run/dbus $MOUNTPOINT/var/run/dbus