Browse Source

Merge pull request #13 from DominikAdamski/MEN-2147-improved-error-handling

Improved hadling of errors
1.0.x
Adam Podogrocki 6 years ago
committed by GitHub
parent
commit
a9df768fb3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      bbb-convert-stage-5.sh
  2. 39
      mender-convert.sh
  3. 20
      rpi3-convert-stage-5.sh

6
bbb-convert-stage-5.sh

@ -96,7 +96,7 @@ build_env_lock_boot_files() {
# #
# $1 - linux kernel version # $1 - linux kernel version
build_grub_efi() { build_grub_efi() {
grub_dir=$output_dir/grub local grub_dir=$output_dir/grub
local grub_build=$grub_dir/build local grub_build=$grub_dir/build
local grub_repo_vc_dir=$grub_dir/.git local grub_repo_vc_dir=$grub_dir/.git
local repo_clean=0 local repo_clean=0
@ -204,7 +204,7 @@ do_install_bootloader() {
if [ -z "${bootloader_toolchain}" ]; then if [ -z "${bootloader_toolchain}" ]; then
echo "ARM GCC toolchain not set. Aborting." echo "ARM GCC toolchain not set. Aborting."
exit 1 exit 1
fi fi
if [ -z "${device_type}" ]; then if [ -z "${device_type}" ]; then
echo "Target device type name not set. Aborting." echo "Target device type name not set. Aborting."
@ -255,7 +255,7 @@ do_install_bootloader() {
rm -rf $output_dir/sdimg rm -rf $output_dir/sdimg
[[ $keep -eq 0 ]] && { rm -rf $grubenv_dir $grubenv_build_dir $grub_dir; } [[ $keep -eq 0 ]] && { rm -rf $grubenv_dir $grubenv_build_dir $grub_dir; }
echo -e "\nAll done." [[ $rc -ne 0 ]] && { echo -e "\nStage failure."; exit 1; } || { echo -e "\nStage done."; }
} }
PARAMS="" PARAMS=""

39
mender-convert.sh

@ -170,6 +170,8 @@ tenant_token=
declare -a rootfs_partition_ids=("rootfs_a" "rootfs_b") declare -a rootfs_partition_ids=("rootfs_a" "rootfs_b")
declare -a mender_disk_mappings declare -a mender_disk_mappings
declare -a raw_disk_mappings declare -a raw_disk_mappings
#Supported devices
declare -a supported_devices=("beaglebone" "raspberrypi3")
do_raw_disk_image_shrink_rootfs() { do_raw_disk_image_shrink_rootfs() {
if [ -z "${raw_disk_image}" ]; then if [ -z "${raw_disk_image}" ]; then
@ -253,6 +255,11 @@ do_raw_disk_image_create_partitions() {
exit 1 exit 1
fi fi
local supported=$(echo ${supported_devices[@]} | grep -o $device_type | wc -w)
[[ $supported -eq 0 ]] && \
{ echo "Error: incorrect device type. Aborting."; exit 1; }
mkdir -p $output_dir && cd $output_dir mkdir -p $output_dir && cd $output_dir
# In case of missing .sdimg name use the default format. # In case of missing .sdimg name use the default format.
@ -383,6 +390,12 @@ do_install_mender_to_mender_disk_image() {
show_help show_help
exit 1 exit 1
fi fi
local supported=$(echo ${supported_devices[@]} | grep -o $device_type | wc -w)
[[ $supported -eq 0 ]] && \
{ echo "Error: incorrect device type. Aborting."; exit 1; }
# mender-image-1.5.0 # mender-image-1.5.0
stage_4_args="-m $mender_disk_image -d $device_type -g ${mender_client} -a ${artifact_name}" stage_4_args="-m $mender_disk_image -d $device_type -g ${mender_client} -a ${artifact_name}"
@ -424,6 +437,11 @@ do_install_bootloader_to_mender_disk_image() {
exit 1 exit 1
fi fi
local supported=$(echo ${supported_devices[@]} | grep -o $device_type | wc -w)
[[ $supported -eq 0 ]] && \
{ echo "Error: incorrect device type. Aborting."; exit 1; }
case "$device_type" in case "$device_type" in
"beaglebone") "beaglebone")
stage_5_args="-m $mender_disk_image -d $device_type -b ${bootloader_toolchain} $keep" stage_5_args="-m $mender_disk_image -d $device_type -b ${bootloader_toolchain} $keep"
@ -471,7 +489,13 @@ do_mender_disk_image_to_artifact() {
rootfs_partition_id="rootfs_a" rootfs_partition_id="rootfs_a"
fi fi
inarray=$(echo ${rootfs_partition_ids[@]} | grep -o $rootfs_partition_id | wc -w) local supported=$(echo ${supported_devices[@]} | grep -o $device_type | wc -w)
[[ $supported -eq 0 ]] && \
{ echo "Error: incorrect device type. Aborting."; exit 1; }
inarray=$(echo ${rootfs_types[@]} | grep -o $rootfs_type | wc -w)
[[ $inarray -eq 0 ]] && \ [[ $inarray -eq 0 ]] && \
{ echo "Error: invalid rootfs type provided. Aborting."; exit 1; } { echo "Error: invalid rootfs type provided. Aborting."; exit 1; }
@ -551,12 +575,18 @@ do_mender_disk_image_to_artifact() {
detach_device_maps ${mender_disk_mappings[@]} detach_device_maps ${mender_disk_mappings[@]}
rm -rf $sdimg_base_dir rm -rf $sdimg_base_dir
[[ $ret -ne 0 ]] && { exit 1; }
} }
do_from_raw_disk_image() { do_from_raw_disk_image() {
do_raw_disk_image_create_partitions do_raw_disk_image_create_partitions || rc=$?
do_install_mender_to_mender_disk_image [[ $rc -ne 0 ]] && { exit 1; }
do_install_bootloader_to_mender_disk_image
do_install_mender_to_mender_disk_image || rc=$?
[[ $rc -ne 0 ]] && { exit 1; }
do_install_bootloader_to_mender_disk_image || rc=$?
[[ $rc -ne 0 ]] && { exit 1; }
} }
#read -s -p "Enter password for sudo: " sudoPW #read -s -p "Enter password for sudo: " sudoPW
@ -671,4 +701,3 @@ case "$1" in
show_help show_help
;; ;;
esac esac

20
rpi3-convert-stage-5.sh

@ -68,11 +68,15 @@ build_uboot_files() {
run mender_try_to_recover run mender_try_to_recover
EOF EOF
$uboot_dir/tools/mkimage -A arm -T script -C none -n "Boot script" -d "boot.cmd" boot.scr if [ ! -e $uboot_dir/tools/mkimage ]; then
echo "Error: cannot build U-Boot. Aborting"
return 1
fi
$uboot_dir/tools/mkimage -A arm -T script -C none -n "Boot script" -d "boot.cmd" boot.scr
cp -t $bin_dir_pi $uboot_dir/boot.scr $uboot_dir/tools/env/fw_printenv $uboot_dir/u-boot.bin cp -t $bin_dir_pi $uboot_dir/boot.scr $uboot_dir/tools/env/fw_printenv $uboot_dir/u-boot.bin
cd $output_dir return 0
} }
# Takes following arguments: # Takes following arguments:
@ -174,18 +178,20 @@ do_install_bootloader() {
mkdir -p $output_dir && cd $output_dir mkdir -p $output_dir && cd $output_dir
# Build patched U-Boot files. # Build patched U-Boot files.
build_uboot_files $bootloader_toolchain build_uboot_files $bootloader_toolchain || rc=$?
cd $output_dir
mount_mender_disk ${mender_disk_mappings[@]}
install_files ${output_dir}/sdimg/boot ${output_dir}/sdimg/primary if [ "$rc" -eq 0 ]; then
mount_mender_disk ${mender_disk_mappings[@]}
install_files ${output_dir}/sdimg/boot ${output_dir}/sdimg/primary
fi
detach_device_maps ${mender_disk_mappings[@]} detach_device_maps ${mender_disk_mappings[@]}
[[ $keep -eq 0 ]] && { rm -f ${output_dir}/config.txt ${output_dir}/cmdline.txt; [[ $keep -eq 0 ]] && { rm -f ${output_dir}/config.txt ${output_dir}/cmdline.txt;
rm -rf $uboot_dir $bin_base_dir $sdimg_base_dir; } rm -rf $uboot_dir $bin_base_dir $sdimg_base_dir; }
echo -e "\nStage done." [[ "$rc" -ne 0 ]] && { echo -e "\nStage failure."; exit 1; } || { echo -e "\nStage done."; }
} }
# Conditional once we support other boards # Conditional once we support other boards

Loading…
Cancel
Save