Browse Source

Merge pull request #141 from oleorhagen/shellcheck

Shellcheck
2.0.x
oleorhagen 5 years ago
committed by GitHub
parent
commit
222d52d834
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      docker-mender-convert
  2. 36
      mender-convert
  3. 10
      mender-convert-extract
  4. 6
      mender-convert-modify
  5. 16
      mender-convert-package
  6. 4
      modules/config.sh
  7. 18
      modules/disk.sh
  8. 56
      modules/probe.sh
  9. 12
      scripts/bootstrap-rootfs-overlay-demo-server.sh
  10. 12
      scripts/bootstrap-rootfs-overlay-hosted-server.sh
  11. 18
      scripts/bootstrap-rootfs-overlay-production-server.sh
  12. 210
      scripts/run-tests.sh

14
docker-mender-convert

@ -21,10 +21,10 @@ IMAGE_NAME=${IMAGE_NAME:-mender-convert}
MENDER_CONVERT_DIR="$(pwd)" MENDER_CONVERT_DIR="$(pwd)"
docker run \ docker run \
-v $MENDER_CONVERT_DIR:/mender-convert \ -v $MENDER_CONVERT_DIR:/mender-convert \
--privileged=true \ --privileged=true \
--cap-add=SYS_MODULE \ --cap-add=SYS_MODULE \
-v /dev:/dev \ -v /dev:/dev \
-v /lib/modules:/lib/modules:ro \ -v /lib/modules:/lib/modules:ro \
--env MENDER_ARTIFACT_NAME=${MENDER_ARTIFACT_NAME} \ --env MENDER_ARTIFACT_NAME=${MENDER_ARTIFACT_NAME} \
$IMAGE_NAME "$@" $IMAGE_NAME "$@"

36
mender-convert

@ -1,4 +1,4 @@
#!/usr/bin/env bash #! /usr/bin/env bash
# #
# Copyright 2019 Northern.tech AS # Copyright 2019 Northern.tech AS
# #
@ -56,33 +56,33 @@ trap trap_exit EXIT
# We only handle a selection of the arguments here, the rest are passed on # We only handle a selection of the arguments here, the rest are passed on
# to the sub-scripts. # to the sub-scripts.
while (( "$#" )); do while (("$#")); do
case "$1" in case "$1" in
-h | --help) -h | --help)
show_help show_help
exit 0 exit 0
;; ;;
-v | --version) -v | --version)
show_version show_version
exit 0 exit 0
;; ;;
*) *)
break; break
;; ;;
esac esac
done done
mender_convert_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) mender_convert_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
if [ "${mender_convert_dir}" != "${PWD}" ]; then if [ "${mender_convert_dir}" != "${PWD}" ]; then
echo "You must execute mender-convert from the root directory: ${mender_convert_dir}" echo "You must execute mender-convert from the root directory: ${mender_convert_dir}"
exit 1 exit 1
fi fi
if [ -z "${MENDER_ARTIFACT_NAME}" ]; then if [ -z "${MENDER_ARTIFACT_NAME}" ]; then
echo "Sorry, it seems that you have not defined MENDER_ARTIFACT_NAME" echo "Sorry, it seems that you have not defined MENDER_ARTIFACT_NAME"
echo "You can do this with the following command:" echo "You can do this with the following command:"
echo "" echo ""
echo -e "\tMENDER_ARTIFACT_NAME="release-1" ./mender-convert" echo -e "\tMENDER_ARTIFACT_NAME=\"release-1\" ./mender-convert"
exit 1 exit 1
fi fi

10
mender-convert-extract

@ -1,4 +1,4 @@
#!/bin/bash #! /usr/bin/env bash
# #
# Copyright 2019 Northern.tech AS # Copyright 2019 Northern.tech AS
# #
@ -61,7 +61,7 @@ source modules/config.sh $(printf "%q " "${configs[@]}")
MKFS_VFAT="/usr/bin/mkfs.vfat" MKFS_VFAT="/usr/bin/mkfs.vfat"
if [ ! -f ${MKFS_VFAT} ]; then if [ ! -f ${MKFS_VFAT} ]; then
MKFS_VFAT="/sbin/mkfs.vfat" MKFS_VFAT="/sbin/mkfs.vfat"
fi fi
declare -i nr_of_parts=$(disk_get_nr_of_parts ${disk_image}) declare -i nr_of_parts=$(disk_get_nr_of_parts ${disk_image})
@ -93,9 +93,9 @@ done
# but we do require it be present and hence we might need to generate # but we do require it be present and hence we might need to generate
# a filesystem image here. # a filesystem image here.
if [ ${nr_of_parts} -eq 1 ]; then if [ ${nr_of_parts} -eq 1 ]; then
log_info "Generating boot partition (required, does not exist in original image)" log_info "Generating boot partition (required, does not exist in original image)"
run_and_log_cmd "dd if=/dev/zero of=work/boot-generated.vfat count=${MENDER_BOOT_PART_SIZE_MB} bs=1M status=none" run_and_log_cmd "dd if=/dev/zero of=work/boot-generated.vfat count=${MENDER_BOOT_PART_SIZE_MB} bs=1M status=none"
run_and_log_cmd "${MKFS_VFAT} work/boot-generated.vfat" run_and_log_cmd "${MKFS_VFAT} work/boot-generated.vfat"
fi fi
# Extract boot gap, that is the area from sector 1 until first part, and # Extract boot gap, that is the area from sector 1 until first part, and

6
mender-convert-modify

@ -1,4 +1,4 @@
#!/bin/bash #! /usr/bin/env bash
# #
# Copyright 2019 Northern.tech AS # Copyright 2019 Northern.tech AS
# #
@ -17,11 +17,11 @@
# Default that can be overridden by providing this method in a # Default that can be overridden by providing this method in a
# configuration file passed with '--config' # configuration file passed with '--config'
function platform_modify() { function platform_modify() {
true true
} }
function user_local_modify() { function user_local_modify() {
true true
} }
function trap_exit() { function trap_exit() {

16
mender-convert-package

@ -1,4 +1,4 @@
#!/bin/bash #! /usr/bin/env bash
# #
# Copyright 2019 Northern.tech AS # Copyright 2019 Northern.tech AS
# #
@ -17,7 +17,7 @@
# Default that can be overridden by providing this method in a # Default that can be overridden by providing this method in a
# configuration file passed with '--config' # configuration file passed with '--config'
function platform_package() { function platform_package() {
true true
} }
function trap_exit() { function trap_exit() {
@ -69,7 +69,7 @@ source modules/config.sh $(printf "%q " "${configs[@]}")
PARTED="/usr/bin/parted" PARTED="/usr/bin/parted"
if [ ! -f ${PARTED} ]; then if [ ! -f ${PARTED} ]; then
PARTED="/sbin/parted" PARTED="/sbin/parted"
fi fi
output_dir=work output_dir=work
@ -129,8 +129,8 @@ fi
boot_part_sectors=$(disk_align_sectors ${boot_part_sectors} ${MENDER_PARTITION_ALIGNMENT} ) boot_part_sectors=$(disk_align_sectors ${boot_part_sectors} ${MENDER_PARTITION_ALIGNMENT} )
# Calculate rootfs size # Calculate rootfs size
rootfs_part_sectors=$(( (${disk_image_total_sectors} - ${data_part_sectors} \ rootfs_part_sectors=$(((${disk_image_total_sectors} - ${data_part_sectors} - \
- ${boot_part_sectors} - ${overhead_sectors}) / 2 )) ${boot_part_sectors} - ${overhead_sectors}) / 2))
# Make sure rootfs size is aligned to MENDER_PARTITION_ALIGNMENT # Make sure rootfs size is aligned to MENDER_PARTITION_ALIGNMENT
rootfs_part_sectors=$(disk_align_sectors ${rootfs_part_sectors} ${MENDER_PARTITION_ALIGNMENT} ) rootfs_part_sectors=$(disk_align_sectors ${rootfs_part_sectors} ${MENDER_PARTITION_ALIGNMENT} )
@ -146,9 +146,9 @@ actual_rootfs_size=$(sudo du --apparent-size -s --block-size=512 work/rootfs | c
rootfs_image_sectors=$(awk -v r1="$actual_rootfs_size" 'BEGIN{printf "%.0f", r1 * 1.50}') rootfs_image_sectors=$(awk -v r1="$actual_rootfs_size" 'BEGIN{printf "%.0f", r1 * 1.50}')
if [ ${rootfs_image_sectors} -gt ${rootfs_part_sectors} ]; then if [ ${rootfs_image_sectors} -gt ${rootfs_part_sectors} ]; then
log_warn "The calculated rootfs partition size $(disk_sectors_to_mb ${rootfs_part_sectors}) MiB is too small." log_warn "The calculated rootfs partition size $(disk_sectors_to_mb ${rootfs_part_sectors}) MiB is too small."
log_warn "The actual rootfs image size is $(disk_sectors_to_mb ${rootfs_image_sectors}) MiB" log_warn "The actual rootfs image size is $(disk_sectors_to_mb ${rootfs_image_sectors}) MiB"
log_fatal "You can try adjusting the MENDER_STORAGE_TOTAL_SIZE_MB variable to increase available space" log_fatal "You can try adjusting the MENDER_STORAGE_TOTAL_SIZE_MB variable to increase available space"
fi fi
# Extract file-system type from rootfs # Extract file-system type from rootfs

4
modules/config.sh

@ -17,6 +17,6 @@
# Read in the array of config files to process # Read in the array of config files to process
read -a configs <<< "${@}" read -a configs <<< "${@}"
for config in "${configs[@]}"; do for config in "${configs[@]}"; do
log_info "Using configuration file: ${config}" log_info "Using configuration file: ${config}"
source "${config}" source "${config}"
done done

18
modules/disk.sh

@ -65,17 +65,16 @@ disk_extract_part() {
# #
# $1 - MiB value # $1 - MiB value
disk_mb_to_sectors() { disk_mb_to_sectors() {
echo "$(( (${1} * 1024 * 1024) / 512 ))" echo "$(( (${1} * 1024 * 1024) / 512 ))"
} }
# Convert 512 sectors to MiB # Convert 512 sectors to MiB
# #
# $1 - number of 512 sectors # $1 - number of 512 sectors
disk_sectors_to_mb() { disk_sectors_to_mb() {
echo "$(( (${1} * 512) / 1024 / 1024 ))" echo "$(( (${1} * 512) / 1024 / 1024 ))"
} }
# Align value (result is number of 512 sectors) # Align value (result is number of 512 sectors)
# #
# $1 - value to align (number of 512 sectors) # $1 - value to align (number of 512 sectors)
@ -115,7 +114,7 @@ disk_create_file_system_from_folder() {
"ext4") "ext4")
MKFS_EXT4="/usr/bin/mkfs.ext4" MKFS_EXT4="/usr/bin/mkfs.ext4"
if [ ! -f ${MKFS_EXT4} ]; then if [ ! -f ${MKFS_EXT4} ]; then
MKFS_EXT4="/sbin/mkfs.ext4" MKFS_EXT4="/sbin/mkfs.ext4"
fi fi
run_and_log_cmd "${MKFS_EXT4} -q -F ${2}" run_and_log_cmd "${MKFS_EXT4} -q -F ${2}"
;; ;;
@ -123,12 +122,13 @@ disk_create_file_system_from_folder() {
"xfs") "xfs")
MKFS_XFS="/usr/bin/mkfs.xfs" MKFS_XFS="/usr/bin/mkfs.xfs"
if [ ! -f ${MKFS_XFS} ]; then if [ ! -f ${MKFS_XFS} ]; then
MKFS_XFS="/sbin/mkfs.xfs" MKFS_XFS="/sbin/mkfs.xfs"
fi fi
run_and_log_cmd "${MKFS_XFS} -q -f ${2}" run_and_log_cmd "${MKFS_XFS} -q -f ${2}"
;; ;;
*) *)
log_fatal "Unknown file system type specified: ${4}" log_fatal "Unknown file system type specified: ${4}"
;;
esac esac
run_and_log_cmd "mkdir -p work/output" run_and_log_cmd "mkdir -p work/output"
@ -158,7 +158,7 @@ disk_boot_part() {
# boot part was extracted or generated. # boot part was extracted or generated.
boot_part="work/boot-generated.vfat" boot_part="work/boot-generated.vfat"
if [ ! -f ${boot_part} ]; then if [ ! -f ${boot_part} ]; then
boot_part="work/part-1.fs" boot_part="work/part-1.fs"
fi fi
echo "${boot_part}" echo "${boot_part}"
} }
@ -168,9 +168,9 @@ disk_boot_part() {
disk_root_part() { disk_root_part() {
boot_part="work/boot-generated.vfat" boot_part="work/boot-generated.vfat"
if [ ! -f ${boot_part} ]; then if [ ! -f ${boot_part} ]; then
root_part="work/part-2.fs" root_part="work/part-2.fs"
else else
root_part="work/part-1.fs" root_part="work/part-1.fs"
fi fi
echo "${root_part}" echo "${root_part}"
} }

56
modules/probe.sh

@ -19,31 +19,31 @@
# No input parameters and these work on the assumption that boot and root parts # No input parameters and these work on the assumption that boot and root parts
# are mounted at work/boot and work/rootfs # are mounted at work/boot and work/rootfs
probe_arch() { probe_arch() {
# --dereference, means to follow symlinks because 'ls' could be a symlink # --dereference, means to follow symlinks because 'ls' could be a symlink
# to busybox # to busybox
file_info="" file_info=""
for location in bin/ls usr/bin/ls; do for location in bin/ls usr/bin/ls; do
if [ -e work/rootfs/${location} ]; then if [ -e work/rootfs/${location} ]; then
file_info=$(file -b --dereference work/rootfs/${location}) file_info=$(file -b --dereference work/rootfs/${location})
break break
fi
done
if [ -z "${file_info}" ]; then
log_fatal "Sorry, where not able to determinate target architecture"
fi fi
done
target_arch="unknown" if [ -z "${file_info}" ]; then
if grep -q x86-64 <<< "${file_info}"; then log_fatal "Sorry, where not able to determinate target architecture"
target_arch="x86-64" fi
elif grep -Eq "ELF 32-bit.*ARM" <<< "${file_info}"; then
target_arch="arm" target_arch="unknown"
elif grep -Eq "ELF 64-bit.*aarch64" <<< "${file_info}"; then if grep -q x86-64 <<< "${file_info}"; then
target_arch="aarch64" target_arch="x86-64"
else elif grep -Eq "ELF 32-bit.*ARM" <<< "${file_info}"; then
log_fatal "Unsupported architecture: ${file_info}" target_arch="arm"
fi elif grep -Eq "ELF 64-bit.*aarch64" <<< "${file_info}"; then
echo "${target_arch}" target_arch="aarch64"
else
log_fatal "Unsupported architecture: ${file_info}"
fi
echo "${target_arch}"
} }
# Prints GRUB EFI name depending on target architecture # Prints GRUB EFI name depending on target architecture
@ -64,7 +64,8 @@ probe_grub_efi_name() {
efi_name="grub-efi-bootaa64.efi" efi_name="grub-efi-bootaa64.efi"
;; ;;
*) *)
log_fatal "Unknown arch: ${arch}" log_fatal "Unknown arch: ${arch}"
;;
esac esac
echo "$efi_name" echo "$efi_name"
} }
@ -87,7 +88,8 @@ probe_debian_arch_name() {
deb_arch="arm64" deb_arch="arm64"
;; ;;
*) *)
log_fatal "Unknown arch: ${arch}" log_fatal "Unknown arch: ${arch}"
;;
esac esac
echo "${deb_arch}" echo "${deb_arch}"
} }
@ -112,7 +114,8 @@ probe_grub_efi_target_name() {
efi_target_name="bootaa64.efi" efi_target_name="bootaa64.efi"
;; ;;
*) *)
log_fatal "Unknown arch: ${arch}" log_fatal "Unknown arch: ${arch}"
;;
esac esac
echo "$efi_target_name" echo "$efi_target_name"
} }
@ -163,7 +166,6 @@ probe_initrd_image() {
echo "${initrd_image_path}" echo "${initrd_image_path}"
} }
# Prints Linux kernel image name # Prints Linux kernel image name
# #
# It will look for it in both boot and rootfs parts. If image is only present # It will look for it in both boot and rootfs parts. If image is only present

12
scripts/bootstrap-rootfs-overlay-demo-server.sh

@ -19,8 +19,8 @@ set -o errexit
root_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd ) root_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )
if [ "${root_dir}" != "${PWD}" ]; then if [ "${root_dir}" != "${PWD}" ]; then
echo "You must execute $(basename $0) from the root directory: ${root_dir}" echo "You must execute $(basename $0) from the root directory: ${root_dir}"
exit 1 exit 1
fi fi
server_ip="" server_ip=""
@ -44,12 +44,12 @@ while (( "$#" )); do
done done
if [ -z "${output_dir}" ]; then if [ -z "${output_dir}" ]; then
echo "Sorry, but you need to provide an output directory using the '-o/--output-dir' option" echo "Sorry, but you need to provide an output directory using the '-o/--output-dir' option"
exit 1 exit 1
fi fi
if [ -z "${server_ip}" ]; then if [ -z "${server_ip}" ]; then
echo "Sorry, but you need to provide a server IP address using the '-s/--server-ip' option" echo "Sorry, but you need to provide a server IP address using the '-s/--server-ip' option"
exit 1 exit 1
fi fi
mkdir -p ${output_dir}/etc/mender mkdir -p ${output_dir}/etc/mender

12
scripts/bootstrap-rootfs-overlay-hosted-server.sh

@ -19,8 +19,8 @@ set -o errexit
root_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd ) root_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )
if [ "${root_dir}" != "${PWD}" ]; then if [ "${root_dir}" != "${PWD}" ]; then
echo "You must execute $(basename $0) from the root directory: ${root_dir}" echo "You must execute $(basename $0) from the root directory: ${root_dir}"
exit 1 exit 1
fi fi
tenant_token="" tenant_token=""
@ -44,13 +44,13 @@ while (( "$#" )); do
done done
if [ -z "${output_dir}" ]; then if [ -z "${output_dir}" ]; then
echo "Sorry, but you need to provide an output directory using the '-o/--output-dir' option" echo "Sorry, but you need to provide an output directory using the '-o/--output-dir' option"
exit 1 exit 1
fi fi
if [ -z "${tenant_token}" ]; then if [ -z "${tenant_token}" ]; then
echo "Sorry, but you need to provide a tenant token using the '-t/--tenant-token' option" echo "Sorry, but you need to provide a tenant token using the '-t/--tenant-token' option"
exit 1 exit 1
fi fi
mkdir -p ${output_dir}/etc/mender mkdir -p ${output_dir}/etc/mender

18
scripts/bootstrap-rootfs-overlay-production-server.sh

@ -19,8 +19,8 @@ set -o errexit
root_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd ) root_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )
if [ "${root_dir}" != "${PWD}" ]; then if [ "${root_dir}" != "${PWD}" ]; then
echo "You must execute $(basename $0) from the root directory: ${root_dir}" echo "You must execute $(basename $0) from the root directory: ${root_dir}"
exit 1 exit 1
fi fi
server_url="" server_url=""
@ -48,13 +48,13 @@ while (( "$#" )); do
done done
if [ -z "${output_dir}" ]; then if [ -z "${output_dir}" ]; then
echo "Sorry, but you need to provide an output directory using the '-o/--output-dir' option" echo "Sorry, but you need to provide an output directory using the '-o/--output-dir' option"
exit 1 exit 1
fi fi
if [ -z "${server_url}" ]; then if [ -z "${server_url}" ]; then
echo "Sorry, but you need to provide a server URL using the '-s/--server-url' option" echo "Sorry, but you need to provide a server URL using the '-s/--server-url' option"
exit 1 exit 1
fi fi
mkdir -p ${output_dir}/etc/mender mkdir -p ${output_dir}/etc/mender
@ -65,11 +65,11 @@ cat <<- EOF > ${output_dir}/etc/mender/mender.conf
"ServerURL": "${server_url}", "ServerURL": "${server_url}",
EOF EOF
if [ -n "${server_cert}" ] ; then if [ -n "${server_cert}" ]; then
cat <<- EOF >> ${output_dir}/etc/mender/mender.conf cat <<- EOF >> ${output_dir}/etc/mender/mender.conf
"ServerCertificate": "/etc/mender/server.crt", "ServerCertificate": "/etc/mender/server.crt",
EOF EOF
cp -f "${server_cert}" ${output_dir}/etc/mender/server.crt cp -f "${server_cert}" ${output_dir}/etc/mender/server.crt
fi fi
cat <<- EOF >> ${output_dir}/etc/mender/mender.conf cat <<- EOF >> ${output_dir}/etc/mender/mender.conf

210
scripts/run-tests.sh

@ -4,8 +4,8 @@ set -e
root_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd ) root_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )
if [ "${root_dir}" != "${PWD}" ]; then if [ "${root_dir}" != "${PWD}" ]; then
echo "You must execute $(basename $0) from the root directory: ${root_dir}" echo "You must execute $(basename $0) from the root directory: ${root_dir}"
exit 1 exit 1
fi fi
WORKSPACE=./tests WORKSPACE=./tests
@ -34,104 +34,104 @@ MENDER_ACCEPTANCE_URL="https://raw.githubusercontent.com/mendersoftware/meta-men
export PATH="${PATH}:/sbin" export PATH="${PATH}:/sbin"
convert_and_test() { convert_and_test() {
device_type=$1 device_type=$1
artifact_name=$2 artifact_name=$2
image_url=$3 image_url=$3
image_name=$4 image_name=$4
image_name_compressed=$5 image_name_compressed=$5
config=$6 # Optional config=$6 # Optional
wget --progress=dot:giga -N ${image_url} -P input/ wget --progress=dot:giga -N ${image_url} -P input/
echo "Extracting: ${image_name_compressed}" echo "Extracting: ${image_name_compressed}"
case "${image_name_compressed}" in case "${image_name_compressed}" in
*.gz) *.gz)
gunzip -f input/${image_name_compressed} gunzip -f input/${image_name_compressed}
;; ;;
*.zip) *.zip)
cd input cd input
unzip -o ${image_name_compressed} unzip -o ${image_name_compressed}
cd - cd -
;; ;;
*.xz) *.xz)
xz -d -f input/${image_name_compressed} xz -d -f input/${image_name_compressed}
;; ;;
*) *)
echo "Unknown image type: ${image_name_compressed}" echo "Unknown image type: ${image_name_compressed}"
exit 1 exit 1
esac ;;
esac
rm -f ${WORKSPACE}/test_config
rm -f ${WORKSPACE}/test_config
# Two motives for the following statement # Two motives for the following statement
# #
# - speed up tests by avoiding decompression on all images (majority of images # - speed up tests by avoiding decompression on all images (majority of images
# we test have a platform specific configuration) # we test have a platform specific configuration)
# #
# - test providing multiple '--config' options # - test providing multiple '--config' options
# #
# - (when no platform configuration is provided) test conversion without # - (when no platform configuration is provided) test conversion without
# '--config' and with MENDER_COMPRESS_DISK_IMAGE=y. Compressed disk # '--config' and with MENDER_COMPRESS_DISK_IMAGE=y. Compressed disk
# images is the default user facing option and we need to ensure that we # images is the default user facing option and we need to ensure that we
# cover this in the tests. # cover this in the tests.
if [ -n "${config}" ]; then if [ -n "${config}" ]; then
echo "Will disable MENDER_COMPRESS_DISK_IMAGE for this image" echo "Will disable MENDER_COMPRESS_DISK_IMAGE for this image"
echo "MENDER_COMPRESS_DISK_IMAGE=n" > ${WORKSPACE}/test_config echo "MENDER_COMPRESS_DISK_IMAGE=n" > ${WORKSPACE}/test_config
local MENDER_CONVERT_EXTRA_ARGS="--config ${config} --config ${WORKSPACE}/test_config" local MENDER_CONVERT_EXTRA_ARGS="--config ${config} --config ${WORKSPACE}/test_config"
fi fi
MENDER_ARTIFACT_NAME=${artifact_name} ./docker-mender-convert \ MENDER_ARTIFACT_NAME=${artifact_name} ./docker-mender-convert \
--disk-image input/${image_name} \ --disk-image input/${image_name} \
${MENDER_CONVERT_EXTRA_ARGS} ${MENDER_CONVERT_EXTRA_ARGS}
if pip3 list | grep -q -e pytest-html; then if pip3 list | grep -q -e pytest-html; then
html_report_args="--html=${MENDER_CONVERT_DIR}/report_${device_type}.html --self-contained-html" html_report_args="--html=${MENDER_CONVERT_DIR}/report_${device_type}.html --self-contained-html"
fi fi
# Need to decompress images built with MENDER_COMPRESS_DISK_IMAGE=y before # Need to decompress images built with MENDER_COMPRESS_DISK_IMAGE=y before
# running tests. # running tests.
if [ -f deploy/${device_type}-${artifact_name}.sdimg.gz ]; then if [ -f deploy/${device_type}-${artifact_name}.sdimg.gz ]; then
# sudo is needed because the image is created using docker-mender-convert # sudo is needed because the image is created using docker-mender-convert
# which sets root permissions on the image # which sets root permissions on the image
sudo gunzip --force deploy/${device_type}-${artifact_name}.sdimg.gz sudo gunzip --force deploy/${device_type}-${artifact_name}.sdimg.gz
fi fi
cd ${WORKSPACE}/mender-image-tests cd ${WORKSPACE}/mender-image-tests
# This is a trick to make pytest generate different junit reports # This is a trick to make pytest generate different junit reports
# for different runs: renaming the tests folder to tests_<testsuite> # for different runs: renaming the tests folder to tests_<testsuite>
cp -r tests tests_${device_type} cp -r tests tests_${device_type}
python3 -m pytest --verbose \ python3 -m pytest --verbose \
--junit-xml="${MENDER_CONVERT_DIR}/results_${device_type}.xml" \ --junit-xml="${MENDER_CONVERT_DIR}/results_${device_type}.xml" \
${html_report_args} \ ${html_report_args} \
--test-conversion \ --test-conversion \
--test-variables="${MENDER_CONVERT_DIR}/deploy/${device_type}-${artifact_name}.cfg" \ --test-variables="${MENDER_CONVERT_DIR}/deploy/${device_type}-${artifact_name}.cfg" \
--board-type="${device_type}" \ --board-type="${device_type}" \
--mender-image=${device_type}-${artifact_name}.sdimg \ --mender-image=${device_type}-${artifact_name}.sdimg \
--sdimg-location="${MENDER_CONVERT_DIR}/deploy" \ --sdimg-location="${MENDER_CONVERT_DIR}/deploy" \
tests_${device_type} tests_${device_type}
exitcode=$? exitcode=$?
cd - cd -
return $exitcode return $exitcode
} }
get_pytest_files() { get_pytest_files() {
wget -N ${MENDER_ACCEPTANCE_URL}/pytest.ini -P $WORKSPACE/mender-image-tests wget -N ${MENDER_ACCEPTANCE_URL}/pytest.ini -P $WORKSPACE/mender-image-tests
wget -N ${MENDER_ACCEPTANCE_URL}/common.py -P $WORKSPACE/mender-image-tests wget -N ${MENDER_ACCEPTANCE_URL}/common.py -P $WORKSPACE/mender-image-tests
wget -N ${MENDER_ACCEPTANCE_URL}/conftest.py -P $WORKSPACE/mender-image-tests wget -N ${MENDER_ACCEPTANCE_URL}/conftest.py -P $WORKSPACE/mender-image-tests
wget -N ${MENDER_ACCEPTANCE_URL}/fixtures.py -P $WORKSPACE/mender-image-tests wget -N ${MENDER_ACCEPTANCE_URL}/fixtures.py -P $WORKSPACE/mender-image-tests
} }
if [ ! -d ${WORKSPACE}/mender-image-tests ]; then if [ ! -d ${WORKSPACE}/mender-image-tests ]; then
git clone https://github.com/mendersoftware/mender-image-tests ${WORKSPACE}/mender-image-tests git clone https://github.com/mendersoftware/mender-image-tests ${WORKSPACE}/mender-image-tests
else else
cd ${WORKSPACE}/mender-image-tests cd ${WORKSPACE}/mender-image-tests
git pull git pull
cd - cd -
fi fi
mkdir -p ${WORKSPACE} mkdir -p ${WORKSPACE}
@ -141,18 +141,18 @@ get_pytest_files
test_result=0 test_result=0
convert_and_test "qemux86_64" \ convert_and_test "qemux86_64" \
"release-1" \ "release-1" \
"${UBUNTU_IMAGE_URL}" \ "${UBUNTU_IMAGE_URL}" \
"${UBUNTU_IMAGE}" \ "${UBUNTU_IMAGE}" \
"${UBUNTU_IMAGE}.gz" \ "${UBUNTU_IMAGE}.gz" \
"configs/qemux86-64_config" || test_result=$? "configs/qemux86-64_config" || test_result=$?
convert_and_test "raspberrypi" \ convert_and_test "raspberrypi" \
"release-1" \ "release-1" \
"${RASPBIAN_IMAGE_URL}" \ "${RASPBIAN_IMAGE_URL}" \
"${RASPBIAN_IMAGE}.img" \ "${RASPBIAN_IMAGE}.img" \
"${RASPBIAN_IMAGE}.zip" \ "${RASPBIAN_IMAGE}.zip" \
"configs/raspberrypi3_config" || test_result=$? "configs/raspberrypi3_config" || test_result=$?
# MEN-2809: Disabled due broken download link # MEN-2809: Disabled due broken download link
#convert_and_test "linaro-alip" \ #convert_and_test "linaro-alip" \
@ -162,16 +162,16 @@ convert_and_test "raspberrypi" \
# "${TINKER_IMAGE}.zip" || test_result=$? # "${TINKER_IMAGE}.zip" || test_result=$?
convert_and_test "beaglebone" \ convert_and_test "beaglebone" \
"release-1" \ "release-1" \
"${BBB_DEBIAN_IMAGE_URL}" \ "${BBB_DEBIAN_IMAGE_URL}" \
"${BBB_DEBIAN_IMAGE}" \ "${BBB_DEBIAN_IMAGE}" \
"${BBB_DEBIAN_IMAGE}.xz" || test_result=$? "${BBB_DEBIAN_IMAGE}.xz" || test_result=$?
convert_and_test "ubuntu" \ convert_and_test "ubuntu" \
"release-1" \ "release-1" \
"${UBUNTU_SERVER_RPI_IMAGE_URL}" \ "${UBUNTU_SERVER_RPI_IMAGE_URL}" \
"${UBUNTU_SERVER_RPI_IMAGE}" \ "${UBUNTU_SERVER_RPI_IMAGE}" \
"${UBUNTU_SERVER_RPI_IMAGE}.xz" \ "${UBUNTU_SERVER_RPI_IMAGE}.xz" \
"configs/raspberrypi3_config" || test_result=$? "configs/raspberrypi3_config" || test_result=$?
exit $test_result exit $test_result

Loading…
Cancel
Save