forked from OERV-BSP/image-builder
71 lines
2.3 KiB
Bash
71 lines
2.3 KiB
Bash
#!/usr/bin/env false
|
|
|
|
parse_image_layout_impl_output_format_partitioned_disk() {
|
|
logi "Parsing partitioned_disk image"
|
|
if [ -z ${PARTITION_TABLE_TYPE+x} ]; then
|
|
loge "PARTITION_TABLE_TYPE not provided"
|
|
exit 1
|
|
fi
|
|
echo "PARTITION_TABLE_TYPE=${PARTITION_TABLE_TYPE}"
|
|
if ! is_function "parse_image_layout_impl_partitioned_disk_table_${PARTITION_TABLE_TYPE}"; then
|
|
loge "PARTITION_TABLE_TYPE \"${PARTITION_TABLE_TYPE}\" not implemented"
|
|
exit 1
|
|
fi
|
|
"parse_image_layout_impl_partitioned_disk_table_${PARTITION_TABLE_TYPE}"
|
|
}
|
|
|
|
parse_image_layout_impl_sort_mountpoint() {
|
|
mountpoints=""
|
|
for fs_idx in $(seq 0 $(( IMAGE_LAYOUT_FILESYSTEM_COUNT - 1 ))); do
|
|
mountpoints+="$(eval echo \$\{FILESYSTEM_"${fs_idx}"_MOUNTPOINT\}) ${fs_idx}
|
|
"
|
|
done
|
|
mountpoints="$(echo "${mountpoints}" | sort)"
|
|
sorted_mountpoint_idx="$(echo "${mountpoints}" | rev | cut -d ' ' -f 1 | rev | tr '\n' ' ')"
|
|
echo "MOUNTPOINT_SORTED_IDX=\"${sorted_mountpoint_idx}\""
|
|
}
|
|
|
|
parse_image_layout_impl() {
|
|
# shellcheck shell=dash disable=SC1091
|
|
. "${RECEIPE_DIR}/image-layout.conf"
|
|
|
|
if [ -z ${OUTPUT_FORMAT+x} ]; then
|
|
loge "OUTPUT_FORMAT not provided"
|
|
exit 1
|
|
fi
|
|
echo "OUTPUT_FORMAT=${OUTPUT_FORMAT}"
|
|
if ! is_function "parse_image_layout_impl_output_format_${OUTPUT_FORMAT}"; then
|
|
loge "OUTPUT_FORMAT \"${OUTPUT_FORMAT}\" not implemented"
|
|
exit 1
|
|
fi
|
|
|
|
# Collect number of FILESYSTEMs
|
|
IMAGE_LAYOUT_FILESYSTEM_COUNT=0
|
|
|
|
"parse_image_layout_impl_output_format_${OUTPUT_FORMAT}"
|
|
|
|
parse_image_layout_impl_sort_mountpoint
|
|
}
|
|
|
|
# shellcheck shell=dash disable=SC2016
|
|
get_fs_uuid_by_mountpoint_impl='
|
|
get_fs_uuid_by_mountpoint_impl() {
|
|
for part_idx in $(seq 1 99); do
|
|
if eval "[ -z \"\${PARTITION_${part_idx}_USAGE+x}\" ]"; then
|
|
echo "partition not found by mountpoint: ${1} 1>&2";
|
|
exit 1;
|
|
fi;
|
|
fs_idx="PARTITION_${part_idx}_FILESYSTEM_IDX" &&
|
|
fs_idx="${!fs_idx}" &&
|
|
fs_mp="FILESYSTEM_${fs_idx}_MOUNTPOINT" &&
|
|
fs_mp="${!fs_mp}" &&
|
|
if [ "${fs_mp}" = "${1}" ]; then
|
|
fs_uuid="FILESYSTEM_${fs_idx}_UUID" &&
|
|
echo "${!fs_uuid}" &&
|
|
return;
|
|
fi;
|
|
done
|
|
;}; get_fs_uuid_by_mountpoint_impl'
|
|
|
|
get_fs_uuid_by_mountpoint="eval ${get_fs_uuid_by_mountpoint_impl}"
|