diff --git a/elements/localboot/README.md b/elements/localboot/README.md index ac5ecb3d3..f2a9b340a 100644 --- a/elements/localboot/README.md +++ b/elements/localboot/README.md @@ -1,7 +1,21 @@ Installs grub boot loader from packages. -Set up grub boot loader on the disk using os-refresh-config when system boot -up and enables boot from HDD. This needs at least one PXE boot after deployment -to work properly. +If you want to build an image with localboot for non arm architecture: -In case Grub serial terminal support is needed, use serial-console element. + * Set up grub boot loader on the disk using os-refresh-config when system boot + up and enables boot from HDD. This needs at least one PXE boot after deployment + to work properly. + In case Grub serial terminal support is needed, use serial-console element. + +If you want to build an image with localboot for uboot arm boards: + + * uboot (when set to boot from the disk) looks on the first disk partition + for a file named boot.scr in / or /boot. This is a uboot + script file, packaged in the special uboot format (like uImage and uInitrd) + by the mkimage command, that tells uboot where the kernel and initrd are, and + what the kernel boot arguments. This file is created by mkimage command + using the flash-kernel script, provided by the u-boot-tools package. + + * The user must provide a uboot script file which contains kernel, initrd and console + parameters. This file path is read from an environment variable named + UBOOT\_SCRIPT\_FILE\_PATH. diff --git a/elements/localboot/install.d/99-boot-helpers b/elements/localboot/install.d/99-boot-helpers new file mode 100755 index 000000000..1d8119a9d --- /dev/null +++ b/elements/localboot/install.d/99-boot-helpers @@ -0,0 +1,19 @@ +#!/bin/bash + +set -eux +set -o pipefail + +if [ "$ARCH" == "amd64" -o "$ARCH" == "i386" ]; then + install-packages grub-pc + +elif [ "$ARCH" == "aarch64" -o "$ARCH" == "armhf" ]; then + install-package u-boot-tools + #This copies uboot scripts to boot folder + if [ -f "$UBOOT_SCRIPT_FILE_PATH" ] ; then + cp "$UBOOT_SCRIPT_FILE_PATH" "$TARGET_ROOT/boot/boot.cmd" + fi + +else + echo "ERROR: localboot is not supported for $ARCH architectures." + exit 1 +fi diff --git a/elements/localboot/install.d/99-grub b/elements/localboot/install.d/99-grub deleted file mode 100755 index 244c45564..000000000 --- a/elements/localboot/install.d/99-grub +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -set -eux -set -o pipefail - -if [ "$ARCH" == "amd64" -o "$ARCH" == "i386" ]; then - install-packages grub-pc -else - echo "ERROR: localboot is not supported for $ARCH architectures." - exit 1 -fi diff --git a/elements/localboot/os-refresh-config/configure.d/01-bootable b/elements/localboot/os-refresh-config/configure.d/01-bootable new file mode 100755 index 000000000..1746786f0 --- /dev/null +++ b/elements/localboot/os-refresh-config/configure.d/01-bootable @@ -0,0 +1,71 @@ +#!/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. + +set -eu +set -o pipefail + +echo Installing Boot Loader +if [[ "aarch64 armhf" =~ "$(uname -m)" ]]; then + KERNEL_RELEASE="$(uname -r)" + KERNEL="/boot/vmlinuz-$KERNEL_RELEASE" + RAMDISK="/boot/initrd.img-$KERNEL_RELEASE" + FILE="/boot/boot.cmd" + #this file will contain script with boot parameters like ramdisk and kernel + #address and console parameters. This varies from arm board to board, User + #will provide boot script. + if [ -f "$FILE" ] ; then + #boot.scr file is created by below command which requires u-boot-tools package. + mkimage -C none -A arm -T script -d "$FILE" /boot/boot.scr + else + echo "$FILE file not found to generate boot.scr" + fi + +else + grub_bin=$(which grub) + if [ -n "$grub_bin" ] ; then + grub_ver="$($grub_bin --version | grep 0\.97)" + if [ -n "$grub_ver" ] ; then + echo "Legacy grub 0.97 found" + $grub_bin --batch << EOF +root (hd0,0) +setup (hd0) +EOF + else + echo "unknown legacy grub version" + fi + else + # Some distros have grub2 binaries named as grub2-install, grub2-mkconfig, etc. + # Others have grub-install, grub-mkconfig, etc.. + grub_bin_prefix="grub" + grub_bin="$(which ${grub_bin_prefix}-mkconfig)" + if [ -n "${grub_bin}" ] ; then + grub_bin_prefix="grub2" + grub_bin="$(which ${grub_bin_prefix}-mkconfig)" + fi + if [ -n "$grub_bin" ] ; then + grub_ver="$($grub_bin --version | grep 2\...)" + if [ -n "$grub_ver" ] ; then + echo "GRUB 2.xx found" + ${grub_bin_prefix}-mkconfig -o /boot/${grub_bin_prefix}/grub.cfg + ${grub_bin_prefix}-install --force /dev/sda + else + echo "unknown grub version" + fi + fi + fi + +fi diff --git a/elements/localboot/os-refresh-config/configure.d/01-install-grub b/elements/localboot/os-refresh-config/configure.d/01-install-grub deleted file mode 100755 index d2924dc99..000000000 --- a/elements/localboot/os-refresh-config/configure.d/01-install-grub +++ /dev/null @@ -1,53 +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. - -set -eu -set -o pipefail - -echo Installing Boot Loader -grub_bin=`which grub` -if [ -n "$grub_bin" ] ; then - grub_ver=`$grub_bin --version | grep 0\.97` - if [ -n "$grub_ver" ] ; then - echo Legacy grub 0.97 found - $grub_bin --batch << EOF -root (hd0,0) -setup (hd0) -EOF - else - echo "unknown legacy grub version" - fi -else - # Some distros have grub2 binaries named as grub2-install, grub2-mkconfig, etc. - # Others have grub-install, grub-mkconfig, etc.. - grub_bin_prefix="grub" - grub_bin=`which ${grub_bin_prefix}-mkconfig` - if [ "" == "${grub_bin}" ] ; then - grub_bin_prefix="grub2" - grub_bin=`which ${grub_bin_prefix}-mkconfig` - fi - if [ -n "$grub_bin" ] ; then - grub_ver=`$grub_bin --version | grep 2\...` - if [ -n "$grub_ver" ] ; then - echo GRUB 2.xx found - ${grub_bin_prefix}-mkconfig -o /boot/${grub_bin_prefix}/grub.cfg - ${grub_bin_prefix}-install --force /dev/sda - else - echo "unknown grub version" - fi - fi -fi