Browse Source

Merge pull request #218 from lluiscampos/resubmit-incorrect-part-num

Fix incorrect use of partition number
revert-252-rm-only-tag-2.2.x
Lluis Campos 5 years ago
committed by GitHub
parent
commit
3c384876aa
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      mender-convert-extract
  2. 12
      modules/disk.sh

5
mender-convert-extract

@ -76,7 +76,8 @@ 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 -a part_nrs=($(disk_get_part_nums ${disk_image}))
declare -i nr_of_parts=${#part_nrs[@]}
log_info "Validating disk image" log_info "Validating disk image"
@ -87,7 +88,7 @@ fi
log_info "Disk parsed successfully" log_info "Disk parsed successfully"
log_info "NUMBER OF PARTS: ${nr_of_parts} TYPE: $(disk_get_part_value ${disk_image} 1 SCHEME)" log_info "NUMBER OF PARTS: ${nr_of_parts} TYPE: $(disk_get_part_value ${disk_image} 1 SCHEME)"
for ((n=1;n<=${nr_of_parts};n++)); do for n in ${part_nrs[*]} ; do
part_dst_file="work/part-${n}.fs" part_dst_file="work/part-${n}.fs"
if [ "$(disk_get_part_value ${disk_image} ${n} TYPE)" == "0x8e" ]; then if [ "$(disk_get_part_value ${disk_image} ${n} TYPE)" == "0x8e" ]; then

12
modules/disk.sh

@ -40,15 +40,19 @@ disk_get_part_value() {
echo "$(partx -o ${3} -g -r --nr ${2} ${1})" echo "$(partx -o ${3} -g -r --nr ${2} ${1})"
} }
# Prints number of partitions found in disk image # Prints the partition numbers of all the partitions
# #
# Example usage: # Example usage:
# #
# nr_of_parts=$(disk_get_nr_of_parts ${disk_image_path}) # part_nums=$(disk_get_part_nums ${disk_image_path})
# #
# $1 - path to disk image # $1 - path to disk image
disk_get_nr_of_parts() { disk_get_part_nums() {
echo "$(partx -l ${1} | wc -l)" partx --show $1 | tail -n +2 |
while read line
do
echo $line | awk '{printf "%d\n", $1}'
done
} }
# Extract a file system image from a disk image # Extract a file system image from a disk image

Loading…
Cancel
Save