Merge "bootloader: remove extlinux/syslinux path"
This commit is contained in:
commit
75ee18b01b
@ -2,10 +2,7 @@
|
|||||||
bootloader
|
bootloader
|
||||||
==========
|
==========
|
||||||
|
|
||||||
Installs ``grub[2]`` on boot partition on the system. In case GRUB2 is
|
Installs ``grub[2]`` on boot partition on the system.
|
||||||
not available in the system, a fallback to Extlinux will happen. It's
|
|
||||||
also possible to enforce the use of Extlinux by exporting a
|
|
||||||
``DIB_EXTLINUX`` variable to the environment.
|
|
||||||
|
|
||||||
Arguments
|
Arguments
|
||||||
=========
|
=========
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Copyright 2014 Hewlett-Packard Development Company, L.P.
|
|
||||||
# All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
# dib-lint: disable=safe_sudo
|
|
||||||
|
|
||||||
if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then
|
|
||||||
set -x
|
|
||||||
fi
|
|
||||||
set -eu
|
|
||||||
set -o pipefail
|
|
||||||
|
|
||||||
[ -n "$TARGET_ROOT" ]
|
|
||||||
|
|
||||||
source $_LIB/img-functions
|
|
||||||
|
|
||||||
if [ -d $TARGET_ROOT/boot/extlinux ] ; then
|
|
||||||
CONF=$TARGET_ROOT/boot/extlinux/extlinux.conf
|
|
||||||
elif [ -d $TARGET_ROOT/boot/syslinux ] ; then
|
|
||||||
CONF=$TARGET_ROOT/boot/syslinux/syslinux.cfg
|
|
||||||
else
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Dig up the initrd and kernel to use.
|
|
||||||
select_boot_kernel_initrd $TARGET_ROOT
|
|
||||||
|
|
||||||
# Serial console on Power is hvc0
|
|
||||||
if [[ "powerpc ppc64 ppc64le" =~ "$ARCH" ]] ; then
|
|
||||||
SERIAL_CONSOLE="hvc0"
|
|
||||||
else
|
|
||||||
SERIAL_CONSOLE="ttyS0,115200"
|
|
||||||
fi
|
|
||||||
|
|
||||||
sudo sh -c "cat > $CONF <<_EOF_
|
|
||||||
DEFAULT linux
|
|
||||||
|
|
||||||
LABEL linux
|
|
||||||
KERNEL /boot/$KERNEL
|
|
||||||
APPEND ro root=LABEL=${DIB_ROOT_LABEL} console=tty0 console=${SERIAL_CONSOLE} nofb nomodeset gfxpayload=text
|
|
||||||
INITRD /boot/$RAMDISK
|
|
||||||
_EOF_"
|
|
@ -9,57 +9,26 @@ fi
|
|||||||
set -eu
|
set -eu
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
BOOT_DEV=$IMAGE_BLOCK_DEVICE
|
if [ ${DIB_EXTLINUX:-0} != "0" ]; then
|
||||||
|
echo "DIB_EXTLINUX no longer supported"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Some distros have pre-installed grub in some other way, and want to
|
||||||
|
# skip this.
|
||||||
|
if [[ -f "/tmp/grub/install" ]]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
BOOT_DEV=$IMAGE_BLOCK_DEVICE
|
||||||
# All available devices, handy for some bootloaders...
|
# All available devices, handy for some bootloaders...
|
||||||
declare -A DEVICES
|
declare -A DEVICES
|
||||||
eval DEVICES=( $IMAGE_BLOCK_DEVICES )
|
eval DEVICES=( $IMAGE_BLOCK_DEVICES )
|
||||||
|
|
||||||
function install_extlinux {
|
|
||||||
install-packages -m bootloader extlinux
|
|
||||||
|
|
||||||
echo "Installing Extlinux..."
|
|
||||||
|
|
||||||
# Find and install mbr.bin
|
|
||||||
for MBR in /usr/share/syslinux/mbr.bin /usr/lib/syslinux/mbr.bin \
|
|
||||||
/usr/lib/extlinux/mbr.bin /usr/lib/EXTLINUX/mbr.bin ; do
|
|
||||||
if [ -f $MBR ]; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [ ! -f $MBR ]; then
|
|
||||||
echo "mbr.bin (from EXT/SYSLINUX) not found."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
dd if=$MBR of=$BOOT_DEV
|
|
||||||
|
|
||||||
# Find any pre-created extlinux install directory
|
|
||||||
for EXTDIR in /boot/extlinux /boot/syslinux ; do
|
|
||||||
if [ -d $EXTDIR ] ; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [ ! -d $EXTDIR ] ; then
|
|
||||||
# No install directory found so default to /boot/syslinux
|
|
||||||
EXTDIR=/boot/syslinux
|
|
||||||
mkdir -p $EXTDIR
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Finally install extlinux
|
|
||||||
extlinux --install $EXTDIR
|
|
||||||
}
|
|
||||||
|
|
||||||
function install_grub2 {
|
|
||||||
|
|
||||||
# Check for offline installation of grub
|
|
||||||
if [ -f "/tmp/grub/install" ] ; then
|
|
||||||
source /tmp/grub/install
|
|
||||||
|
|
||||||
# Right now we can't use pkg-map to branch by arch, so tag an
|
# Right now we can't use pkg-map to branch by arch, so tag an
|
||||||
# architecture specific virtual package so we can install the
|
# architecture specific virtual package so we can install the
|
||||||
# rigth thing based on distribution.
|
# rigth thing based on distribution.
|
||||||
elif [[ "$ARCH" =~ "ppc" ]]; then
|
if [[ "$ARCH" =~ "ppc" ]]; then
|
||||||
install-packages -m bootloader grub-ppc64
|
install-packages -m bootloader grub-ppc64
|
||||||
elif [[ "${DIB_BLOCK_DEVICE}" == "mbr" ||
|
elif [[ "${DIB_BLOCK_DEVICE}" == "mbr" ||
|
||||||
"${DIB_BLOCK_DEVICE}" == "gpt" ]]; then
|
"${DIB_BLOCK_DEVICE}" == "gpt" ]]; then
|
||||||
@ -73,8 +42,6 @@ function install_grub2 {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# XXX: grub-probe on the nbd0/loop0 device returns nothing - workaround, manually
|
|
||||||
# specify modules. https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1073731
|
|
||||||
GRUBNAME=$(type -p grub-install) || echo "trying grub2-install"
|
GRUBNAME=$(type -p grub-install) || echo "trying grub2-install"
|
||||||
if [ -z "$GRUBNAME" ]; then
|
if [ -z "$GRUBNAME" ]; then
|
||||||
GRUBNAME=$(type -p grub2-install)
|
GRUBNAME=$(type -p grub2-install)
|
||||||
@ -86,13 +53,6 @@ function install_grub2 {
|
|||||||
GRUB_MKCONFIG="grub-mkconfig"
|
GRUB_MKCONFIG="grub-mkconfig"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If no GRUB2 is found, fallback to extlinux
|
|
||||||
if [ -z "$GRUBNAME" ] || [ $($GRUBNAME --version | grep "0.97" | wc -l) -ne 0 ]; then
|
|
||||||
echo "No GRUB2 found. Fallback to Extlinux..."
|
|
||||||
install_extlinux
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Installing GRUB2..."
|
echo "Installing GRUB2..."
|
||||||
|
|
||||||
# When using EFI image-based builds, particularly rhel element
|
# When using EFI image-based builds, particularly rhel element
|
||||||
@ -266,14 +226,6 @@ function install_grub2 {
|
|||||||
sed -i '$d' /etc/default/grub
|
sed -i '$d' /etc/default/grub
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# grub-mkconfig generates a config with the device in it,
|
|
||||||
# This shouldn't be needed, but old code has bugs
|
|
||||||
DIB_RELEASE=${DIB_RELEASE:-}
|
|
||||||
if [ "$DIB_RELEASE" = 'wheezy' ]; then
|
|
||||||
sed -i "s%search --no.*%%" $GRUB_CFG
|
|
||||||
sed -i "s%set root=.*%set root=(hd0,1)%" $GRUB_CFG
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Fix efi specific instructions in grub config file
|
# Fix efi specific instructions in grub config file
|
||||||
if [ -d /sys/firmware/efi ]; then
|
if [ -d /sys/firmware/efi ]; then
|
||||||
sed -i 's%\(initrd\|linux\)efi /boot%\1 /boot%g' $GRUB_CFG
|
sed -i 's%\(initrd\|linux\)efi /boot%\1 /boot%g' $GRUB_CFG
|
||||||
@ -294,11 +246,4 @@ function install_grub2 {
|
|||||||
cp $GRUB_CFG /boot/efi/$EFI_BOOT_DIR/grub.cfg
|
cp $GRUB_CFG /boot/efi/$EFI_BOOT_DIR/grub.cfg
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
DIB_EXTLINUX=${DIB_EXTLINUX:-0}
|
|
||||||
if [ "$DIB_EXTLINUX" != "0" ]; then
|
|
||||||
install_extlinux
|
|
||||||
else
|
|
||||||
install_grub2
|
|
||||||
fi
|
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
deprecations:
|
||||||
|
- |
|
||||||
|
Removed support for ``extlinux`` and ``grub`` (as opposed to
|
||||||
|
``grub2``) support from the bootloader element.
|
Loading…
Reference in New Issue
Block a user