|
@ -43,7 +43,7 @@ source modules/testscfg.sh |
|
|
# The mender_convert_config is always used and provides all the defaults |
|
|
# The mender_convert_config is always used and provides all the defaults |
|
|
declare -a configs=("configs/mender_convert_config") |
|
|
declare -a configs=("configs/mender_convert_config") |
|
|
|
|
|
|
|
|
while (( "$#" )); do |
|
|
while (("$#")); do |
|
|
case "$1" in |
|
|
case "$1" in |
|
|
-o | --overlay) |
|
|
-o | --overlay) |
|
|
overlays+=("${2}") |
|
|
overlays+=("${2}") |
|
@ -103,17 +103,17 @@ alignment_sectors=$((${MENDER_PARTITION_ALIGNMENT} / 512)) |
|
|
|
|
|
|
|
|
if [ "${MENDER_GRUB_EFI_INTEGRATION}" == "y" ]; then |
|
|
if [ "${MENDER_GRUB_EFI_INTEGRATION}" == "y" ]; then |
|
|
boot_part_start=${alignment_sectors} |
|
|
boot_part_start=${alignment_sectors} |
|
|
overhead_sectors=$(( ${alignment_sectors} * 4 )) |
|
|
overhead_sectors=$((${alignment_sectors} * 4)) |
|
|
else |
|
|
else |
|
|
# The two first blocks are typically reserved for U-boot environment. |
|
|
# The two first blocks are typically reserved for U-boot environment. |
|
|
boot_part_start=$(( ${alignment_sectors} * 3)) |
|
|
boot_part_start=$((${alignment_sectors} * 3)) |
|
|
overhead_sectors=$(( ${alignment_sectors} * 6 )) |
|
|
overhead_sectors=$((${alignment_sectors} * 6)) |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
# Validate boot-gap.bin size, ensuring it will fit between MBR and boot_part_start |
|
|
# Validate boot-gap.bin size, ensuring it will fit between MBR and boot_part_start |
|
|
if [ "${MENDER_COPY_BOOT_GAP}" == "y" ]; then |
|
|
if [ "${MENDER_COPY_BOOT_GAP}" == "y" ]; then |
|
|
# Add one block for MBR |
|
|
# Add one block for MBR |
|
|
boot_gap_sectors=$(( $(stat --printf="%b" work/boot-gap.bin) + 1)) |
|
|
boot_gap_sectors=$(($(stat --printf="%b" work/boot-gap.bin) + 1)) |
|
|
if [ ${boot_gap_sectors} -ge ${boot_part_start} ]; then |
|
|
if [ ${boot_gap_sectors} -ge ${boot_part_start} ]; then |
|
|
log_warn "The work/boot-gap.bin file will overwrite the boot partition" |
|
|
log_warn "The work/boot-gap.bin file will overwrite the boot partition" |
|
|
log_fatal "Please increase MENDER_PARTITION_ALIGNMENT (2x will typically solve this))" |
|
|
log_fatal "Please increase MENDER_PARTITION_ALIGNMENT (2x will typically solve this))" |
|
@ -134,14 +134,14 @@ fi |
|
|
# MENDER_PARTITION_ALIGNMENT, it is possible that the boot part is extracted |
|
|
# MENDER_PARTITION_ALIGNMENT, it is possible that the boot part is extracted |
|
|
# as-is from the input image, and the input image might not have used the same |
|
|
# as-is from the input image, and the input image might not have used the same |
|
|
# alignment as our configuration |
|
|
# alignment as our configuration |
|
|
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}) |
|
|
|
|
|
|
|
|
device_type=$(cat work/rootfs/data/mender/device_type | sed 's/[^=]*=//') |
|
|
device_type=$(cat work/rootfs/data/mender/device_type | sed 's/[^=]*=//') |
|
|
artifact_name=$(cat work/rootfs/etc/mender/artifact_info | sed 's/[^=]*=//') |
|
|
artifact_name=$(cat work/rootfs/etc/mender/artifact_info | sed 's/[^=]*=//') |
|
@ -151,11 +151,11 @@ temp_img_name=$(basename "$disk_image") |
|
|
|
|
|
|
|
|
# Check if user has chooses custom filename |
|
|
# Check if user has chooses custom filename |
|
|
if [ -z "${DEPLOY_IMAGE_NAME}" ]; then |
|
|
if [ -z "${DEPLOY_IMAGE_NAME}" ]; then |
|
|
# Strip the image suffix from temp_img_name and set the original image name as |
|
|
# Strip the image suffix from temp_img_name and set the original image name as |
|
|
# the output image name |
|
|
# the output image name |
|
|
image_name="${temp_img_name%.*}" |
|
|
image_name="${temp_img_name%.*}" |
|
|
|
|
|
|
|
|
# Add device types to the filename and replaces whitespace with + to seperate device types. |
|
|
# Add device types to the filename and replaces whitespace with + to seperate device types. |
|
|
image_name="${image_name}-$(sed 's| |+|g' <<< $device_type)-mender" |
|
|
image_name="${image_name}-$(sed 's| |+|g' <<< $device_type)-mender" |
|
|
else |
|
|
else |
|
|
# User has choosen custom filename in config file |
|
|
# User has choosen custom filename in config file |
|
@ -228,16 +228,16 @@ run_and_log_cmd \ |
|
|
"dd if=/dev/zero of=${img_path} bs=512 count=0 seek=${disk_image_total_sectors} status=none" |
|
|
"dd if=/dev/zero of=${img_path} bs=512 count=0 seek=${disk_image_total_sectors} status=none" |
|
|
|
|
|
|
|
|
# boot_part_start, is defined at the beginning of this file |
|
|
# boot_part_start, is defined at the beginning of this file |
|
|
boot_part_end=$(( ${boot_part_start} + ${boot_part_sectors} - 1 )) |
|
|
boot_part_end=$((${boot_part_start} + ${boot_part_sectors} - 1)) |
|
|
|
|
|
|
|
|
rootfsa_start=$(disk_align_sectors ${boot_part_end} ${MENDER_PARTITION_ALIGNMENT} ) |
|
|
rootfsa_start=$(disk_align_sectors ${boot_part_end} ${MENDER_PARTITION_ALIGNMENT}) |
|
|
rootfsa_end=$(( ${rootfsa_start} + ${rootfs_part_sectors} - 1 )) |
|
|
rootfsa_end=$((${rootfsa_start} + ${rootfs_part_sectors} - 1)) |
|
|
|
|
|
|
|
|
rootfsb_start=$(disk_align_sectors ${rootfsa_end} ${MENDER_PARTITION_ALIGNMENT} ) |
|
|
rootfsb_start=$(disk_align_sectors ${rootfsa_end} ${MENDER_PARTITION_ALIGNMENT}) |
|
|
rootfsb_end=$(( ${rootfsb_start} + ${rootfs_part_sectors} - 1 )) |
|
|
rootfsb_end=$((${rootfsb_start} + ${rootfs_part_sectors} - 1)) |
|
|
|
|
|
|
|
|
data_start=$(disk_align_sectors ${rootfsb_end} ${MENDER_PARTITION_ALIGNMENT} ) |
|
|
data_start=$(disk_align_sectors ${rootfsb_end} ${MENDER_PARTITION_ALIGNMENT}) |
|
|
data_end=$(( ${data_start} + ${data_part_sectors} - 1 )) |
|
|
data_end=$((${data_start} + ${data_part_sectors} - 1)) |
|
|
|
|
|
|
|
|
if [ -n "${MENDER_PARTITION_SCHEME}" ]; then |
|
|
if [ -n "${MENDER_PARTITION_SCHEME}" ]; then |
|
|
# Force partition scheme to the one from configs |
|
|
# Force partition scheme to the one from configs |
|
@ -368,7 +368,7 @@ testscfg_add "MENDER_BOOT_PART_MOUNT_LOCATION" "${boot_part_mountpoint}" |
|
|
testscfg_add "MENDER_BOOT_PART_SIZE_MB" "$(disk_sectors_to_mb ${boot_part_sectors})" |
|
|
testscfg_add "MENDER_BOOT_PART_SIZE_MB" "$(disk_sectors_to_mb ${boot_part_sectors})" |
|
|
testscfg_add "MENDER_DATA_PART_SIZE_MB" "${MENDER_DATA_PART_SIZE_MB}" |
|
|
testscfg_add "MENDER_DATA_PART_SIZE_MB" "${MENDER_DATA_PART_SIZE_MB}" |
|
|
testscfg_add "MENDER_DEVICE_TYPE" "${device_type}" |
|
|
testscfg_add "MENDER_DEVICE_TYPE" "${device_type}" |
|
|
testscfg_add "MENDER_PARTITIONING_OVERHEAD_KB" "$(( (${overhead_sectors} * 512) / 1024 ))" |
|
|
testscfg_add "MENDER_PARTITIONING_OVERHEAD_KB" "$(((${overhead_sectors} * 512) / 1024))" |
|
|
testscfg_add "MENDER_PARTITION_ALIGNMENT" "${MENDER_PARTITION_ALIGNMENT}" |
|
|
testscfg_add "MENDER_PARTITION_ALIGNMENT" "${MENDER_PARTITION_ALIGNMENT}" |
|
|
testscfg_add "MENDER_STORAGE_TOTAL_SIZE_MB" "${MENDER_STORAGE_TOTAL_SIZE_MB}" |
|
|
testscfg_add "MENDER_STORAGE_TOTAL_SIZE_MB" "${MENDER_STORAGE_TOTAL_SIZE_MB}" |
|
|
testscfg_add "MENDER_UBOOT_ENV_STORAGE_DEVICE_OFFSET" "12582912" |
|
|
testscfg_add "MENDER_UBOOT_ENV_STORAGE_DEVICE_OFFSET" "12582912" |
|
|