Browse Source

Format: mender-convert* files with shfmt

Changelog: None
Signed-off-by: Ole Petter <ole.orhagen@northern.tech>
2.4.x
Ole Petter 4 years ago
parent
commit
bbd9fb7c9c
No known key found for this signature in database GPG Key ID: 399DBE0F4D4B02EB
  1. 6
      mender-convert-extract
  2. 11
      mender-convert-modify
  3. 36
      mender-convert-package

6
mender-convert-extract

@ -35,7 +35,7 @@ source modules/probe.sh
declare -a configs=("configs/mender_convert_config")
disk_image=""
while (( "$#" )); do
while (("$#")); do
case "$1" in
-o | --overlay)
overlays+=("${2}")
@ -88,7 +88,7 @@ fi
log_info "Disk parsed successfully"
log_info "NUMBER OF PARTS: ${nr_of_parts} TYPE: $(disk_get_part_value ${disk_image} 1 SCHEME)"
for n in ${part_nrs[*]} ; do
for n in ${part_nrs[*]}; do
part_dst_file="work/part-${n}.fs"
if [ "$(disk_get_part_value ${disk_image} ${n} TYPE)" == "0x8e" ]; then
@ -118,7 +118,7 @@ fi
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
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

11
mender-convert-modify

@ -55,7 +55,7 @@ source modules/testscfg.sh
# The mender_convert_config is always used and provides all the defaults
declare -a configs=("configs/mender_convert_config")
while (( "$#" )); do
while (("$#")); do
case "$1" in
-o | --overlay)
overlays+=("${2}")
@ -209,7 +209,10 @@ EOF
sudo rm -rf work/boot/EFI/Linux
sudo rm -rf work/boot/EFI/systemd
sudo rm -rf work/boot/NvVars
for empty_dir in $(cd work/boot; find . -maxdepth 1 -type d -empty); do
for empty_dir in $(
cd work/boot
find . -maxdepth 1 -type d -empty
); do
sudo rmdir work/boot/$empty_dir
done
@ -276,8 +279,8 @@ run_and_log_cmd "echo 'artifact_name=${MENDER_ARTIFACT_NAME}' \
log_info "Creating state scripts version file."
case "${MENDER_CLIENT_VERSION}" in
1* ) VERSION_STRING='2';;
* ) VERSION_STRING='3';;
1*) VERSION_STRING='2' ;;
*) VERSION_STRING='3' ;;
esac
run_and_log_cmd "sudo mkdir -p work/rootfs/etc/mender/scripts/"
run_and_log_cmd "echo -n ${VERSION_STRING} | sudo tee work/rootfs/etc/mender/scripts/version"

36
mender-convert-package

@ -43,7 +43,7 @@ source modules/testscfg.sh
# The mender_convert_config is always used and provides all the defaults
declare -a configs=("configs/mender_convert_config")
while (( "$#" )); do
while (("$#")); do
case "$1" in
-o | --overlay)
overlays+=("${2}")
@ -103,17 +103,17 @@ alignment_sectors=$((${MENDER_PARTITION_ALIGNMENT} / 512))
if [ "${MENDER_GRUB_EFI_INTEGRATION}" == "y" ]; then
boot_part_start=${alignment_sectors}
overhead_sectors=$(( ${alignment_sectors} * 4 ))
overhead_sectors=$((${alignment_sectors} * 4))
else
# The two first blocks are typically reserved for U-boot environment.
boot_part_start=$(( ${alignment_sectors} * 3))
overhead_sectors=$(( ${alignment_sectors} * 6 ))
boot_part_start=$((${alignment_sectors} * 3))
overhead_sectors=$((${alignment_sectors} * 6))
fi
# Validate boot-gap.bin size, ensuring it will fit between MBR and boot_part_start
if [ "${MENDER_COPY_BOOT_GAP}" == "y" ]; then
# 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
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))"
@ -134,14 +134,14 @@ fi
# 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
# 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
rootfs_part_sectors=$(((${disk_image_total_sectors} - ${data_part_sectors} - \
${boot_part_sectors} - ${overhead_sectors}) / 2))
# 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/[^=]*=//')
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
if [ -z "${DEPLOY_IMAGE_NAME}" ]; then
# Strip the image suffix from temp_img_name and set the original image name as
# the output image name
# Strip the image suffix from temp_img_name and set the original image name as
# the output image 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"
else
# 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"
# 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_end=$(( ${rootfsa_start} + ${rootfs_part_sectors} - 1 ))
rootfsa_start=$(disk_align_sectors ${boot_part_end} ${MENDER_PARTITION_ALIGNMENT})
rootfsa_end=$((${rootfsa_start} + ${rootfs_part_sectors} - 1))
rootfsb_start=$(disk_align_sectors ${rootfsa_end} ${MENDER_PARTITION_ALIGNMENT} )
rootfsb_end=$(( ${rootfsb_start} + ${rootfs_part_sectors} - 1 ))
rootfsb_start=$(disk_align_sectors ${rootfsa_end} ${MENDER_PARTITION_ALIGNMENT})
rootfsb_end=$((${rootfsb_start} + ${rootfs_part_sectors} - 1))
data_start=$(disk_align_sectors ${rootfsb_end} ${MENDER_PARTITION_ALIGNMENT} )
data_end=$(( ${data_start} + ${data_part_sectors} - 1 ))
data_start=$(disk_align_sectors ${rootfsb_end} ${MENDER_PARTITION_ALIGNMENT})
data_end=$((${data_start} + ${data_part_sectors} - 1))
if [ -n "${MENDER_PARTITION_SCHEME}" ]; then
# 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_DATA_PART_SIZE_MB" "${MENDER_DATA_PART_SIZE_MB}"
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_STORAGE_TOTAL_SIZE_MB" "${MENDER_STORAGE_TOTAL_SIZE_MB}"
testscfg_add "MENDER_UBOOT_ENV_STORAGE_DEVICE_OFFSET" "12582912"

Loading…
Cancel
Save