From 270f8904948e9cfa6db63148c806876fffecea20 Mon Sep 17 00:00:00 2001 From: Jose Diaz de Grenu Date: Mon, 28 Aug 2017 17:21:08 +0200 Subject: [PATCH] recovery-initramfs-init: remove parted dependency Turns out that the busybox' fdisk applet is also able to parse the GPT partition tables. This saves around 0.5 MiB of space. https://jira.digi.com/browse/DEL-4565 Signed-off-by: Jose Diaz de Grenu --- .../recipes-core/images/dey-image-recovery-initramfs.bb | 1 - .../recovery/recovery-initramfs/automount_block.sh | 4 ++-- .../recovery/recovery-initramfs/recovery-initramfs-init | 4 ++-- .../recipes-digi/swu-images/files/ccimx6/preinstall_swu.sh | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/meta-digi-dey/recipes-core/images/dey-image-recovery-initramfs.bb b/meta-digi-dey/recipes-core/images/dey-image-recovery-initramfs.bb index bd484673d..1d5ad31a2 100644 --- a/meta-digi-dey/recipes-core/images/dey-image-recovery-initramfs.bb +++ b/meta-digi-dey/recipes-core/images/dey-image-recovery-initramfs.bb @@ -5,7 +5,6 @@ LICENSE = "MIT" PACKAGE_INSTALL = " \ busybox \ - parted \ psplash \ recovery-initramfs \ swupdate \ diff --git a/meta-digi-dey/recipes-core/recovery/recovery-initramfs/automount_block.sh b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/automount_block.sh index 1d3466b4b..e437f0b6d 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-initramfs/automount_block.sh +++ b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/automount_block.sh @@ -23,12 +23,12 @@ PARTITION="$(echo "${MDEV}" | sed -n -e '/^mmc/{s,^[^p]\+p\([0-9]\+\)$,\1,g;T;p} # This will detect if the block device has a update partition is_update_device() { - parted -s "/dev/${DEVICE}" print | grep -qs update + fdisk -l "/dev/${DEVICE}" | grep -qs update } # This will verify that the requested partition is the update partition is_update_partition() { - parted -s "/dev/${DEVICE}" print | sed -ne "s,^[^0-9]*\([0-9]\+\).*\.*,\1,g;T;p" | grep -qs "${PARTITION}" + fdisk -l "/dev/${DEVICE}" | sed -ne "s,^[^0-9]*\([0-9]\+\).*\.*,\1,g;T;p" | grep -qs "${PARTITION}" } if is_update_device; then diff --git a/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init index 5f70a0e3d..7e7e2dd8b 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init +++ b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init @@ -230,7 +230,7 @@ format_ubi_volume() { #------------------------------------------------------------------------------ format_emmc_block() { # Find partition block number. - local partition_block="/dev/mmcblk0p$(parted -s /dev/mmcblk0 print | sed -ne "s,^[^0-9]*\([0-9]\+\).*\<${1}\>.*,\1,g;T;p")" + local partition_block="/dev/mmcblk0p$(fdisk -l /dev/mmcblk0 | sed -ne "s,^[^0-9]*\([0-9]\+\).*\<${1}\>.*,\1,g;T;p")" if [ -b "${partition_block}" ]; then # Umount in case partition is mounted, ignore errors. if grep -qs "${partition_block}" /proc/mounts; then @@ -458,7 +458,7 @@ if [ -n "${encryption_key_bool}" ]; then # Format partition. if [ "$(is_nand)" = "no" ]; then psplash_message "Formatting rootfs partition..." - rootfs_block="/dev/mmcblk0p$(parted -s /dev/mmcblk0 print | sed -ne "s,^[^0-9]*\([0-9]\+\).*\.*,\1,g;T;p")" + rootfs_block="/dev/mmcblk0p$(fdisk -l /dev/mmcblk0 | sed -ne "s,^[^0-9]*\([0-9]\+\).*\.*,\1,g;T;p")" trustfence-tool --format ${rootfs_block} cryptroot fi psplash_progress "100" diff --git a/meta-digi-dey/recipes-digi/swu-images/files/ccimx6/preinstall_swu.sh b/meta-digi-dey/recipes-digi/swu-images/files/ccimx6/preinstall_swu.sh index 07bca0909..8723cfc11 100644 --- a/meta-digi-dey/recipes-digi/swu-images/files/ccimx6/preinstall_swu.sh +++ b/meta-digi-dey/recipes-digi/swu-images/files/ccimx6/preinstall_swu.sh @@ -72,7 +72,7 @@ if [ -b /dev/mapper/cryptroot ]; then exit 0 fi -rootfs_block="/dev/mmcblk0p$(parted -s /dev/mmcblk0 print | sed -ne "s,^[^0-9]*\([0-9]\+\).*\.*,\1,g;T;p")" +rootfs_block="/dev/mmcblk0p$(fdisk -l /dev/mmcblk0 | sed -ne "s,^[^0-9]*\([0-9]\+\).*\.*,\1,g;T;p")" # Open LUKS encrypted device trustfence-tool ${rootfs_block} cryptroot