@ -182,10 +182,10 @@ declare -a raw_disk_mappings
declare -a supported_devices=("beaglebone" "raspberrypi3")
declare -a supported_devices=("beaglebone" "raspberrypi3")
do_raw_disk_image_shrink_rootfs() {
do_raw_disk_image_shrink_rootfs() {
echo -e "$step/$total Shrinking raw disk image root filesystem..."
log "$step/$total Shrinking raw disk image root filesystem..."
((step++))
((step++))
if [ -z "${raw_disk_image}" ]; then
if [ -z "${raw_disk_image}" ]; then
echo "Raw disk image not set. Aborting."
log "Raw disk image not set. Aborting."
return 1
return 1
fi
fi
@ -202,7 +202,7 @@ do_raw_disk_image_shrink_rootfs() {
# Find first available loopback device.
# Find first available loopback device.
loopdevice=($(losetup -f))
loopdevice=($(losetup -f))
[ $? -ne 0 ] && { echo "Error: inaccesible loopback device"; return 1; }
[ $? -ne 0 ] && { log "Error: inaccesible loopback device"; return 1; }
# Mount appropriate partition.
# Mount appropriate partition.
if [[ $count -eq 1 ]]; then
if [[ $count -eq 1 ]]; then
@ -210,7 +210,7 @@ do_raw_disk_image_shrink_rootfs() {
elif [[ $count -eq 2 ]]; then
elif [[ $count -eq 2 ]]; then
sudo losetup $loopdevice $raw_disk_image -o $(($rootfsstart * $sector_size))
sudo losetup $loopdevice $raw_disk_image -o $(($rootfsstart * $sector_size))
else
else
echo "Error: invalid/unsupported embedded raw disk image. Aborting."
log "Error: invalid/unsupported embedded raw disk image. Aborting."
return 1
return 1
fi
fi
@ -220,14 +220,14 @@ do_raw_disk_image_shrink_rootfs() {
new_size_sectors=$(( $min_size_blocks * $block_size / $sector_size ))
new_size_sectors=$(( $min_size_blocks * $block_size / $sector_size ))
align_partition_size new_size_sectors $sector_size
align_partition_size new_size_sectors $sector_size
echo -e "\tRoot filesystem size:\
log "\tRoot filesystem size:\
\n\tminimal: $(( $min_size_blocks * $block_size )) \
\n\tminimal: $(( $min_size_blocks * $block_size )) \
\n\taligned: $(( $new_size_sectors * $sector_size ))\
\n\taligned: $(( $new_size_sectors * $sector_size ))\
\n\tsectors: $new_size_sectors"
\n\tsectors: $new_size_sectors"
sudo e2fsck -y -f $loopdevice
sudo e2fsck -y -f $loopdevice >> "$build_log" 2>&1
sudo resize2fs -p $loopdevice ${new_size_sectors}s
sudo resize2fs -p $loopdevice ${new_size_sectors}s >> "$build_log" 2>&1
sudo e2fsck -y -f $loopdevice
sudo e2fsck -y -f $loopdevice >> "$build_log" 2>&1
sudo losetup -d $loopdevice
sudo losetup -d $loopdevice
sudo losetup $loopdevice $raw_disk_image
sudo losetup $loopdevice $raw_disk_image
@ -242,15 +242,15 @@ do_raw_disk_image_shrink_rootfs() {
endsector=($(sudo parted $loopdevice -ms unit s print | grep "^$count" | cut -f3 -d: | sed 's/[^0-9]*//g'))
endsector=($(sudo parted $loopdevice -ms unit s print | grep "^$count" | cut -f3 -d: | sed 's/[^0-9]*//g'))
sudo losetup -d $loopdevice
sudo losetup -d $loopdevice
echo -e "\tRaw disk image new endsector: $endsector"
log "\tRaw disk image new endsector: $endsector"
truncate -s $((($endsector+1) * $sector_size)) $raw_disk_image
truncate -s $((($endsector+1) * $sector_size)) $raw_disk_image
echo -e "\tNew root filesystem size (sectors): $new_size_sectors"
log "\tNew root filesystem size (sectors): $new_size_sectors"
return 0
return 0
}
}
do_raw_disk_image_create_partitions() {
do_raw_disk_image_create_partitions() {
echo -e "$step/$total Repartitioning raw disk image..."
log "$step/$total Repartitioning raw disk image..."
((step++))
((step++))
if [ -z "$raw_disk_image" ] || [ -z "$device_type" ] || \
if [ -z "$raw_disk_image" ] || [ -z "$device_type" ] || \
@ -260,14 +260,14 @@ do_raw_disk_image_create_partitions() {
fi
fi
if [[ ! -f ${raw_disk_image} ]]; then
if [[ ! -f ${raw_disk_image} ]]; then
echo "Raw disk image not found. Aborting."
log "Raw disk image not found. Aborting."
return 1
return 1
fi
fi
local supported=$(echo ${supported_devices[@]} | grep -o $device_type | wc -w)
local supported=$(echo ${supported_devices[@]} | grep -o $device_type | wc -w)
[[ $supported -eq 0 ]] && \
[[ $supported -eq 0 ]] && \
{ echo "Error: incorrect device type. Aborting."; return 1; }
{ log "Error: incorrect device type. Aborting."; return 1; }
mkdir -p $output_dir && cd $output_dir
mkdir -p $output_dir && cd $output_dir
@ -290,16 +290,16 @@ do_raw_disk_image_create_partitions() {
sector_size raw_disk_counts
sector_size raw_disk_counts
[ -z "${prootfs_size}" ] && \
[ -z "${prootfs_size}" ] && \
{ echo -e "root filesystem size not set. Aborting."; return 1; }
{ log "root filesystem size not set. Aborting."; return 1; }
echo -e "\tDetected raw disk image with $raw_disk_counts partition(s)."
log "\tDetected raw disk image with $raw_disk_counts partition(s)."
local mender_disk_image_size=
local mender_disk_image_size=
calculate_mender_disk_size $pboot_start $pboot_size \
calculate_mender_disk_size $pboot_start $pboot_size \
$prootfs_size $data_part_size_mb \
$prootfs_size $data_part_size_mb \
$sector_size pdata_size mender_disk_image_size
$sector_size pdata_size mender_disk_image_size
echo -e "\tCreating Mender disk image:\
log "\tCreating Mender disk image:\
\n\t\timage size: ${mender_disk_image_size} bytes\
\n\t\timage size: ${mender_disk_image_size} bytes\
\n\t\troot filesystem size: $((${prootfs_size} * $sector_size)) bytes\
\n\t\troot filesystem size: $((${prootfs_size} * $sector_size)) bytes\
\n\t\tdata partition size: $(($pdata_size * $sector_size)) bytes"
\n\t\tdata partition size: $(($pdata_size * $sector_size)) bytes"
@ -315,7 +315,7 @@ do_raw_disk_image_create_partitions() {
create_device_maps $mender_disk_image mender_disk_mappings
create_device_maps $mender_disk_image mender_disk_mappings
echo -e "$step/$total Formatting repartitioned raw disk image..."
log "$step/$total Formatting repartitioned raw disk image..."
((step++))
((step++))
make_mender_disk_filesystem ${mender_disk_mappings[@]}
make_mender_disk_filesystem ${mender_disk_mappings[@]}
@ -330,7 +330,7 @@ do_raw_disk_image_create_partitions() {
rc=$?
rc=$?
echo -e "$step/$total Cleaning intermediate files..."
log "$step/$total Cleaning intermediate files..."
((step++))
((step++))
# Clean and detach.
# Clean and detach.
detach_device_maps ${mender_disk_mappings[@]}
detach_device_maps ${mender_disk_mappings[@]}
@ -339,7 +339,7 @@ do_raw_disk_image_create_partitions() {
rm -rf $embedded_base_dir
rm -rf $embedded_base_dir
rm -rf $sdimg_base_dir
rm -rf $sdimg_base_dir
[ $rc -eq 0 ] || { echo -e "\nRepartitioning of $raw_disk_image image failed."; }
[ $rc -eq 0 ] || { log "\nRepartitioning of $raw_disk_image image failed."; }
return $rc
return $rc
}
}
@ -352,19 +352,19 @@ do_make_sdimg_beaglebone() {
mount_mender_disk ${mender_disk_mappings[@]}
mount_mender_disk ${mender_disk_mappings[@]}
mount_raw_disk ${raw_disk_mappings[@]}
mount_raw_disk ${raw_disk_mappings[@]}
echo -e "$step/$total Setting boot partition..."
log "$step/$total Setting boot partition..."
((step++))
((step++))
stage_2_args="$sdimg_boot_dir $embedded_rootfs_dir"
stage_2_args="$sdimg_boot_dir $embedded_rootfs_dir"
${tool_dir}/bbb-convert-stage-2.sh ${stage_2_args} || ret=$?
${tool_dir}/bbb-convert-stage-2.sh ${stage_2_args} || ret=$?
[[ $ret -ne 0 ]] && { echo "Aborting."; return $ret; }
[[ $ret -ne 0 ]] && { log "Aborting."; return $ret; }
echo -e "$step/$total Setting root filesystem partition..."
log "$step/$total Setting root filesystem partition..."
((step++))
((step++))
stage_3_args="$sdimg_primary_dir $embedded_rootfs_dir"
stage_3_args="$sdimg_primary_dir $embedded_rootfs_dir"
${tool_dir}/bbb-convert-stage-3.sh ${stage_3_args} || ret=$?
${tool_dir}/bbb-convert-stage-3.sh ${stage_3_args} || ret=$?
[[ $ret -ne 0 ]] && { echo "Aborting."; return $ret; }
[[ $ret -ne 0 ]] && { log "Aborting."; return $ret; }
echo -e "$step/$total Setting file system table..."
log "$step/$total Setting file system table..."
((step++))
((step++))
set_fstab $device_type
set_fstab $device_type
@ -372,7 +372,7 @@ do_make_sdimg_beaglebone() {
}
}
do_make_sdimg_raspberrypi3() {
do_make_sdimg_raspberrypi3() {
echo -e "$step/$total Setting boot partition..."
log "$step/$total Setting boot partition..."
((step++))
((step++))
image_boot_part=$(fdisk -l ${raw_disk_image} | grep FAT32)
image_boot_part=$(fdisk -l ${raw_disk_image} | grep FAT32)
@ -380,7 +380,7 @@ do_make_sdimg_raspberrypi3() {
boot_part_end=$(echo ${image_boot_part} | awk '{print $3}')
boot_part_end=$(echo ${image_boot_part} | awk '{print $3}')
boot_part_size=$(echo ${image_boot_part} | awk '{print $4}')
boot_part_size=$(echo ${image_boot_part} | awk '{print $4}')
echo -e "\tExtracting boot partition from raw disk image."
log "\tExtracting boot partition from raw disk image."
extract_file_from_image ${raw_disk_image} ${boot_part_start} \
extract_file_from_image ${raw_disk_image} ${boot_part_start} \
${boot_part_size} "boot.vfat"
${boot_part_size} "boot.vfat"
@ -388,7 +388,7 @@ do_make_sdimg_raspberrypi3() {
${tool_dir}/rpi3-convert-stage-2.sh ${stage_2_args} || ret=$?
${tool_dir}/rpi3-convert-stage-2.sh ${stage_2_args} || ret=$?
[[ $ret -ne 0 ]] && { return $ret; }
[[ $ret -ne 0 ]] && { return $ret; }
echo -e "$step/$total Setting root filesystem partition..."
log "$step/$total Setting root filesystem partition..."
((step++))
((step++))
image_rootfs_part=$(fdisk -l ${raw_disk_image} | grep Linux)
image_rootfs_part=$(fdisk -l ${raw_disk_image} | grep Linux)
@ -396,7 +396,7 @@ do_make_sdimg_raspberrypi3() {
rootfs_part_end=$(echo ${image_rootfs_part} | awk '{print $3}')
rootfs_part_end=$(echo ${image_rootfs_part} | awk '{print $3}')
rootfs_part_size=$(echo ${image_rootfs_part} | awk '{print $4}')
rootfs_part_size=$(echo ${image_rootfs_part} | awk '{print $4}')
echo -e "\tExtracting root filesystem partition from raw disk image."
log "\tExtracting root filesystem partition from raw disk image."
extract_file_from_image ${raw_disk_image} ${rootfs_part_start} \
extract_file_from_image ${raw_disk_image} ${rootfs_part_start} \
${rootfs_part_size} "rootfs.img"
${rootfs_part_size} "rootfs.img"
@ -410,7 +410,7 @@ do_make_sdimg_raspberrypi3() {
sudo install -d -m 755 ${sdimg_primary_dir}/uboot
sudo install -d -m 755 ${sdimg_primary_dir}/uboot
sudo install -d -m 755 ${sdimg_primary_dir}/data
sudo install -d -m 755 ${sdimg_primary_dir}/data
echo -e "$step/$total Setting file system table..."
log "$step/$total Setting file system table..."
((step++))
((step++))
set_fstab $device_type
set_fstab $device_type
@ -422,7 +422,7 @@ do_make_sdimg_raspberrypi3() {
}
}
do_install_mender_to_mender_disk_image() {
do_install_mender_to_mender_disk_image() {
echo -e "$step/$total Installing Mender to Mender disk image..."
log "$step/$total Installing Mender to Mender disk image..."
((step++))
((step++))
if [ -z "$mender_disk_image" ] || [ -z "$device_type" ] || \
if [ -z "$mender_disk_image" ] || [ -z "$device_type" ] || \
@ -434,7 +434,7 @@ do_install_mender_to_mender_disk_image() {
local supported=$(echo ${supported_devices[@]} | grep -o $device_type | wc -w)
local supported=$(echo ${supported_devices[@]} | grep -o $device_type | wc -w)
[[ $supported -eq 0 ]] && \
[[ $supported -eq 0 ]] && \
{ echo "Error: incorrect device type. Aborting."; return 1; }
{ log "Error: incorrect device type. Aborting."; return 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}"
@ -462,7 +462,7 @@ do_install_mender_to_mender_disk_image() {
eval set -- " ${stage_4_args}"
eval set -- " ${stage_4_args}"
${tool_dir}/convert-stage-4.sh ${stage_4_args} || ret=$?
${tool_dir}/convert-stage-4.sh ${stage_4_args} || ret=$?
[[ $ret -ne 0 ]] && { echo -e "\nInstalling Mender to Mender disk image failed."; return $ret; }
[[ $ret -ne 0 ]] && { log "\nInstalling Mender to Mender disk image failed."; return $ret; }
# Update test configuration file
# Update test configuration file
update_test_config_file $device_type artifact-name $artifact_name
update_test_config_file $device_type artifact-name $artifact_name
@ -471,7 +471,7 @@ do_install_mender_to_mender_disk_image() {
}
}
do_install_bootloader_to_mender_disk_image() {
do_install_bootloader_to_mender_disk_image() {
echo -e "$step/$total Installing Bootloader to Mender disk image..."
log "$step/$total Installing Bootloader to Mender disk image..."
((step++))
((step++))
if [ -z "$mender_disk_image" ] || [ -z "$device_type" ] || \
if [ -z "$mender_disk_image" ] || [ -z "$device_type" ] || \
@ -483,14 +483,14 @@ do_install_bootloader_to_mender_disk_image() {
local supported=$(echo ${supported_devices[@]} | grep -o $device_type | wc -w)
local supported=$(echo ${supported_devices[@]} | grep -o $device_type | wc -w)
[[ $supported -eq 0 ]] && \
[[ $supported -eq 0 ]] && \
{ echo "Error: incorrect device type. Aborting."; return 1; }
{ log "Error: incorrect device type. Aborting."; return 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"
eval set -- " ${stage_5_args}"
eval set -- " ${stage_5_args}"
${tool_dir}/bbb-convert-stage-5.sh ${stage_5_args}|| ret=$?
${tool_dir}/bbb-convert-stage-5.sh ${stage_5_args}|| ret=$?
[[ $ret -ne 0 ]] && { echo -e "\nInstalling Bootloader failed."; return $ret; }
[[ $ret -ne 0 ]] && { log "\nInstalling Bootloader failed."; return $ret; }
# Update test configuration file
# Update test configuration file
update_test_config_file $device_type distro-feature "mender-grub" \
update_test_config_file $device_type distro-feature "mender-grub" \
@ -500,7 +500,7 @@ do_install_bootloader_to_mender_disk_image() {
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"
eval set -- " ${stage_5_args}"
eval set -- " ${stage_5_args}"
${tool_dir}/rpi3-convert-stage-5.sh ${stage_5_args}|| ret=$?
${tool_dir}/rpi3-convert-stage-5.sh ${stage_5_args}|| ret=$?
[[ $ret -ne 0 ]] && { echo -e "\nInstalling Bootloader failed."; return $ret; }
[[ $ret -ne 0 ]] && { log "\nInstalling Bootloader failed."; return $ret; }
# Update test configuration file
# Update test configuration file
update_test_config_file $device_type mount-location "\/uboot"
update_test_config_file $device_type mount-location "\/uboot"
@ -511,38 +511,38 @@ do_install_bootloader_to_mender_disk_image() {
}
}
do_mender_disk_image_to_artifact() {
do_mender_disk_image_to_artifact() {
echo -e "$step/$total Creating Mender Artifact..."
log "$step/$total Creating Mender Artifact..."
((step++))
((step++))
if [ -z "${mender_disk_image}" ]; then
if [ -z "${mender_disk_image}" ]; then
echo "Mender disk image not set. Aborting."
log "Mender disk image not set. Aborting."
return 1
return 1
fi
fi
if [ -z "${device_type}" ]; then
if [ -z "${device_type}" ]; then
echo "Target device_type name not set. Aborting."
log "Target device_type name not set. Aborting."
return 1
return 1
fi
fi
if [ -z "${artifact_name}" ]; then
if [ -z "${artifact_name}" ]; then
echo "Artifact name not set. Aborting."
log "Artifact name not set. Aborting."
return 1
return 1
fi
fi
if [ -z "${rootfs_partition_id}" ]; then
if [ -z "${rootfs_partition_id}" ]; then
echo -e "\tRootfs partition id not set - 'primary' will be used by default."
log "\tRootfs partition id not set - 'primary' will be used by default."
rootfs_partition_id="primary"
rootfs_partition_id="primary"
fi
fi
local supported=$(echo ${supported_devices[@]} | grep -o $device_type | wc -w)
local supported=$(echo ${supported_devices[@]} | grep -o $device_type | wc -w)
[[ $supported -eq 0 ]] && \
[[ $supported -eq 0 ]] && \
{ echo "Error: incorrect device type. Aborting."; return 1; }
{ log "Error: incorrect device type. Aborting."; return 1; }
inarray=$(echo ${rootfs_partition_ids[@]} | grep -o $rootfs_partition_id | wc -w)
inarray=$(echo ${rootfs_partition_ids[@]} | grep -o $rootfs_partition_id | wc -w)
[[ $inarray -eq 0 ]] && \
[[ $inarray -eq 0 ]] && \
{ echo "Error: invalid rootfs partition id provided. Aborting."; return 1; }
{ log "Error: invalid rootfs partition id provided. Aborting."; return 1; }
local count=
local count=
local bootstart=
local bootstart=
@ -557,7 +557,7 @@ do_mender_disk_image_to_artifact() {
rootfs_a_size rootfs_b_start rootfs_b_size
rootfs_a_size rootfs_b_start rootfs_b_size
ret=$?
ret=$?
[[ $ret -ne 0 ]] && \
[[ $ret -ne 0 ]] && \
{ echo "Error: cannot validate Mender disk image. Aborting."; return 1; }
{ log "Error: cannot validate Mender disk image. Aborting."; return 1; }
# Check if device type matches.
# Check if device type matches.
create_device_maps $mender_disk_image mender_disk_mappings
create_device_maps $mender_disk_image mender_disk_mappings
@ -567,12 +567,12 @@ do_mender_disk_image_to_artifact() {
mender_device_type=$( cat $sdimg_data_dir/mender/device_type | sed 's/[^=].*=//' )
mender_device_type=$( cat $sdimg_data_dir/mender/device_type | sed 's/[^=].*=//' )
if [ "$mender_device_type" != "$device_type" ]; then
if [ "$mender_device_type" != "$device_type" ]; then
echo "Error: device types of Mender artifact & Mender not matching. Aborting."
log "Error: device types of Mender artifact & Mender not matching. Aborting."
ret=1
ret=1
fi
fi
if ! [ -x "$(command -v mender-artifact)" ]; then
if ! [ -x "$(command -v mender-artifact)" ]; then
echo "Error: mender-artifact not found in PATH. Aborting."
log "Error: mender-artifact not found in PATH. Aborting."
ret=1
ret=1
fi
fi
@ -599,12 +599,12 @@ do_mender_disk_image_to_artifact() {
fsck.ext4 -fp $mender_rootfs_image &> /dev/null || ret=$?
fsck.ext4 -fp $mender_rootfs_image &> /dev/null || ret=$?
[[ $ret -ne 0 ]] && \
[[ $ret -ne 0 ]] && \
{ echo -e "Error: checking $mender_rootfs_basename file system failed. Aborting."; }
{ log "Error: checking $mender_rootfs_basename file system failed. Aborting."; }
# Find first available loopback device.
# Find first available loopback device.
loopdevice=($(sudo losetup -f || ret=$?))
loopdevice=($(sudo losetup -f || ret=$?))
[[ $ret -ne 0 ]] && \
[[ $ret -ne 0 ]] && \
{ echo -e "Error: cannot find an unused loop device. Aborting."; }
{ log "Error: cannot find an unused loop device. Aborting."; }
if [ $ret -eq 0 ]; then
if [ $ret -eq 0 ]; then
#Mount extracted ext4 partition to verify 'artifact_info' file content.
#Mount extracted ext4 partition to verify 'artifact_info' file content.
@ -623,7 +623,7 @@ do_mender_disk_image_to_artifact() {
# Note: expected Mender Artifact name follows the scheme:
# Note: expected Mender Artifact name follows the scheme:
# mender-<device_name>-<artifact_name>.mender.
# mender-<device_name>-<artifact_name>.mender.
mender_artifact=${output_dir}/${mender_disk_filename}.mender
mender_artifact=${output_dir}/${mender_disk_filename}.mender
echo -e "\tWriting Mender artifact to: ${mender_artifact}"
log "\tWriting Mender artifact to: ${mender_artifact}"
#Create Mender artifact
#Create Mender artifact
mender-artifact write rootfs-image \
mender-artifact write rootfs-image \
@ -634,8 +634,8 @@ do_mender_disk_image_to_artifact() {
ret=$?
ret=$?
[[ $ret -eq 0 ]] && \
[[ $ret -eq 0 ]] && \
{ echo -e "\tCreating Mender Artifact succeeded."; } || \
{ log "\tCreating Mender Artifact succeeded."; } || \
{ echo -e "\tCreating Mender Artifact failed."; }
{ log "\tCreating Mender Artifact failed."; }
fi
fi
fi
fi
@ -680,6 +680,10 @@ source ${tool_dir}/mender-convert-functions.sh
export -f create_device_maps
export -f create_device_maps
export -f detach_device_maps
export -f detach_device_maps
export -f mount_mender_disk
export -f mount_mender_disk
export -f log
export -f logsetup
logsetup
while (( "$#" )); do
while (( "$#" )); do
case "$1" in
case "$1" in
@ -744,7 +748,7 @@ while (( "$#" )); do
break
break
;;
;;
-*)
-*)
echo "Error: unsupported option $1" >&2
log "Error: unsupported option $1"
exit 1
exit 1
;;
;;
*)
*)
@ -755,7 +759,7 @@ while (( "$#" )); do
done
done
[ -z "${data_part_size_mb}" ] && \
[ -z "${data_part_size_mb}" ] && \
{ echo "Default 'data' partition size set to 128MB"; data_part_size_mb=128; }
{ log "Default 'data' partition size set to 128MB"; data_part_size_mb=128; }
eval set -- "$PARAMS"
eval set -- "$PARAMS"
@ -766,48 +770,48 @@ case "$1" in
raw-disk-image-shrink-rootfs)
raw-disk-image-shrink-rootfs)
total=1
total=1
do_raw_disk_image_shrink_rootfs || rc=$?
do_raw_disk_image_shrink_rootfs || rc=$?
[[ $rc -ne 0 ]] && { echo -e "Check $build_log for details."; exit 1; }
[[ $rc -ne 0 ]] && { log "Check $build_log for details."; exit 1; }
echo -e "The rootfs partition in the raw disk image has been shrinked successfully!"
log "The rootfs partition in the raw disk image has been shrinked successfully!"
echo -e "You can now convert the output raw disk image\n\t$raw_disk_image\
log "You can now convert the output raw disk image\n\t$raw_disk_image\
\nto a Mender disk image."
\nto a Mender disk image."
;;
;;
raw-disk-image-create-partitions)
raw-disk-image-create-partitions)
total=6
total=6
do_raw_disk_image_create_partitions || rc=$?
do_raw_disk_image_create_partitions || rc=$?
[[ $rc -ne 0 ]] && { echo -e "Check $build_log for details."; exit 1; }
[[ $rc -ne 0 ]] && { log "Check $build_log for details."; exit 1; }
echo -e "A new Mender disk image with partition layout to support Mender has been successfully created!"
log "A new Mender disk image with partition layout to support Mender has been successfully created!"
echo -e "You can find the output Mender disk image at:\n\t${mender_disk_image}."
log "You can find the output Mender disk image at:\n\t${mender_disk_image}."
;;
;;
install-mender-to-mender-disk-image)
install-mender-to-mender-disk-image)
total=1
total=1
do_install_mender_to_mender_disk_image || rc=$?
do_install_mender_to_mender_disk_image || rc=$?
[[ $rc -ne 0 ]] && { echo -e "Check $build_log for details."; exit 1; }
[[ $rc -ne 0 ]] && { log "Check $build_log for details."; exit 1; }
echo -e "The Mender client has been successfully installed to the Mender disk image."
log "The Mender client has been successfully installed to the Mender disk image."
echo -e "You can find the output Mender disk image at:\n\t${mender_disk_image}."
log "You can find the output Mender disk image at:\n\t${mender_disk_image}."
;;
;;
install-bootloader-to-mender-disk-image)
install-bootloader-to-mender-disk-image)
total=1
total=1
do_install_bootloader_to_mender_disk_image || rc=$?
do_install_bootloader_to_mender_disk_image || rc=$?
[[ $rc -ne 0 ]] && { echo -e "Check $build_log for details."; exit 1; }
[[ $rc -ne 0 ]] && { log "Check $build_log for details."; exit 1; }
echo -e "A bootloader configuration supporting dual A/B rootfs updates has been installed to the Mender disk image!"
log "A bootloader configuration supporting dual A/B rootfs updates has been installed to the Mender disk image!"
echo -e "You can find the output Mender disk image at:\n\t${mender_disk_image}."
log "You can find the output Mender disk image at:\n\t${mender_disk_image}."
;;
;;
mender-disk-image-to-artifact)
mender-disk-image-to-artifact)
total=1
total=1
do_mender_disk_image_to_artifact || rc=$?
do_mender_disk_image_to_artifact || rc=$?
[[ $rc -ne 0 ]] && { echo -e "Check $build_log for details."; exit 1; }
[[ $rc -ne 0 ]] && { log "Check $build_log for details."; exit 1; }
echo -e "A Mender Artifact has been successfully extracted from your Mender disk image!"
log "A Mender Artifact has been successfully extracted from your Mender disk image!"
echo -e "You can find the Mender Artifact at:\n\t$mender_artifact\nand use it to deploy updates."
log "You can find the Mender Artifact at:\n\t$mender_artifact\nand use it to deploy updates."
;;
;;
from-raw-disk-image)
from-raw-disk-image)
total=9
total=9
do_from_raw_disk_image || rc=$?
do_from_raw_disk_image || rc=$?
[[ $rc -ne 0 ]] && { echo -e "Check $build_log for details."; exit 1; }
[[ $rc -ne 0 ]] && { log "Check $build_log for details."; exit 1; }
echo -e "Conversion complete!"
log "Conversion complete!"
echo -e "The Mender disk image you can provision your device storage with is at:\
log "The Mender disk image you can provision your device storage with is at:\
\n\t${mender_disk_image}."
\n\t${mender_disk_image}."
echo -e "The Mender root file system partition is at:\n\t${mender_rootfs_image}."
log "The Mender root file system partition is at:\n\t${mender_rootfs_image}."
echo -e "The Mender Artifact you can upload to your Mender server to deploy to your devices is at:\
log "The Mender Artifact you can upload to your Mender server to deploy to your devices is at:\
\n\t${mender_artifact}."
\n\t${mender_artifact}."
;;
;;
*)
*)