Browse Source

Merge pull request #174 from kacf/2.0.x

2.0.x cherry-picks
2.0.x
Kristian Amlie 5 years ago
committed by GitHub
parent
commit
95993b89cb
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .gitlab-ci.yml
  2. 8
      configs/mender_grub_config
  3. 7
      mender-convert-extract
  4. 3
      mender-convert-modify
  5. 50
      modules/probe.sh
  6. 2
      scripts/test/run-tests.sh

2
.gitlab-ci.yml

@ -31,7 +31,7 @@ stages:
build:
stage: build
services:
- docker:dind
- docker:19.03.5-dind
script:
- IMAGE_NAME=$DOCKER_REPOSITORY:pr ./docker-build --build-arg MENDER_ARTIFACT_VERSION=${MENDER_ARTIFACT_VERSION}
- docker save $DOCKER_REPOSITORY:pr > image.tar

8
configs/mender_grub_config

@ -32,4 +32,10 @@ MENDER_GRUB_KERNEL_IMAGETYPE=""
# if was not possible to auto-detect
MENDER_GRUB_INITRD_IMAGETYPE=""
MENDER_GRUB_BINARY_STORAGE_URL="${MENDER_STORAGE_URL}/mender-convert/grub-efi/2.02"
MENDER_GRUB_BINARY_STORAGE_URL="${MENDER_STORAGE_URL}/mender-convert/grub-efi/2.04"
# Ignore broken UEFI support in certain U-Boot versions (see MEN-2404)
MENDER_IGNORE_UBOOT_BROKEN_UEFI="0"
# Ignore missing EFI stub on ARM (see MEN-2404)
MENDER_IGNORE_MISSING_EFI_STUB="0"

7
mender-convert-extract

@ -18,6 +18,7 @@ echo "Running $(basename $0): $@"
source modules/bootstrap.sh
source modules/disk.sh
source modules/probe.sh
# The mender_convert_config is always used and provides all the defaults
declare -a configs=("configs/mender_convert_config")
@ -106,4 +107,10 @@ if [ "${MENDER_COPY_BOOT_GAP}" == "y" ]; then
log_info "Extracting boot gap to work/boot-gap.bin"
disk_extract_part "${disk_image}" \
1 $(( $(disk_get_part_value ${disk_image} 1 START) - 1)) work/boot-gap.bin
if [ "${MENDER_GRUB_EFI_INTEGRATION}" == "y" ]; then
# Check for known U-Boot problems in the boot gap (probable boot loader
# location).
check_for_broken_uboot_uefi_support work/boot-gap.bin
fi
fi

3
mender-convert-modify

@ -103,6 +103,9 @@ if [ "${MENDER_ENABLE_SYSTEMD}" == "y" ]; then
fi
if [ "${MENDER_GRUB_EFI_INTEGRATION}" == "y" ]; then
# Check for known U-Boot problems in all files on the boot partition.
check_for_broken_uboot_uefi_support work/boot
run_and_log_cmd "wget -Nq '${MENDER_GRUBENV_URL}' -P work/"
run_and_log_cmd "tar xvf work/${MENDER_GRUBENV_VERSION}.tar.gz -C work/"

50
modules/probe.sh

@ -191,13 +191,18 @@ probe_kernel_in_boot_and_root() {
fi
done
if [ -n "${kernel_imagetype_path}" ]; then
log_info "Found Linux kernel image: \n\n\t${kernel_imagetype_path}\n"
kernel_imagetype=$(basename ${kernel_imagetype_path})
else
if [ -z "${kernel_imagetype_path}" ]; then
log_warn "Unfortunately we where not able to find the Linux kernel image."
log_fatal "Please specify the image name using MENDER_GRUB_KERNEL_IMAGETYPE"
fi
log_info "Found Linux kernel image: \n\n\t${kernel_imagetype_path}\n"
kernel_imagetype=$(basename ${kernel_imagetype_path})
if [ "${MENDER_GRUB_EFI_INTEGRATION}" == "y" ]; then
check_efi_compatible_kernel ${kernel_imagetype_path}
fi
echo "${kernel_imagetype}"
}
@ -237,3 +242,40 @@ probe_initrd_in_boot_and_root() {
echo "${initrd_imagetype}"
}
check_for_broken_uboot_uefi_support() {
local path="$1"
# Broken UEFI support in range v2018.09 - v2019.07 (see MEN-2404)
local regex='U-Boot 20(18\.(09|1[0-2])|19\.0[1-7])'
if egrep -qr "$regex" "$path"; then
local log_level=log_fatal
if [ "$MENDER_IGNORE_UBOOT_BROKEN_UEFI" = 1 ]; then
log_level=log_warn
fi
$log_level 'Detected a U-Boot version in the range v2018.09 - v2019.07. These U-Boot versions are known to have broken UEFI support, and therefore the MENDER_GRUB_EFI_INTEGRATION feature is unlikely to work. This only affects newly flashed devices using the partition image (extension ending in "img"). The Mender artifact should still work to upgrade an existing, working device. There are two possible workarounds for this issue: 1) Use either an older or a newer image that works, and use a Mender artifact afterwards to up/down-grade it to the version you want. 2) If the device has a non-UEFI U-Boot port in mender-convert, use that (look for a board specific file in `configs`) . If you want to ignore this error and force creation of the image, set the MENDER_IGNORE_UBOOT_BROKEN_UEFI=1 config option.'
fi
}
check_efi_compatible_kernel() {
kernel_path="$1"
case "$(probe_arch)" in
arm|aarch64)
# On ARM, as of version 2.04, GRUB can only boot kernels which have an EFI
# stub in them. See MEN-2404.
if ! file -k $kernel_path | fgrep 'EFI application'; then
local log_level=log_fatal
if [ "$MENDER_IGNORE_MISSING_EFI_STUB" = 1 ]; then
log_level=log_warn
fi
$log_level 'Detected a kernel which does not have an EFI stub. This kernel is not supported when booting with UEFI. Please consider using a U-Boot port if the board has one (look for a board specific file in `configs`), or find a kernel which has the CONFIG_EFI_STUB turned on. To ignore this message and proceed anyway, set the MENDER_IGNORE_MISSING_EFI_STUB=1 config option.'
fi
;;
*)
# Other platforms are fine.
:
;;
esac
}

2
scripts/test/run-tests.sh

@ -15,7 +15,7 @@ fi
WORKSPACE=./tests
BBB_DEBIAN_IMAGE="bone-debian-9.5-iot-armhf-2018-10-07-4gb.img"
BBB_DEBIAN_IMAGE="bone-debian-9.5-iot-armhf-2018-08-30-4gb.img"
BBB_DEBIAN_IMAGE_URL="http://debian.beagleboard.org/images/${BBB_DEBIAN_IMAGE}.xz"
RASPBIAN_IMAGE="2019-09-26-raspbian-buster-lite"

Loading…
Cancel
Save