expand-on-first-boot: Fix after failing on every error

Message ID f27b7463-3e9a-4022-8c11-9a217753f01b@siemens.com
State Rejected, archived
Headers show
Series expand-on-first-boot: Fix after failing on every error | expand

Commit Message

Jan Kiszka May 30, 2024, 6:49 p.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

As we bail out on every failing command, the test of GPT causes a
premature script end if there is now GPT in the game.

Fixes: 991d2e903930 ("expand-on-first-boot: Preserve MBR on expansion of GPT disks")
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 .../expand-on-first-boot/files/expand-last-partition.sh         | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Uladzimir Bely May 31, 2024, 6:48 a.m. UTC | #1
On Thu, 2024-05-30 at 20:49 +0200, 'Jan Kiszka' via isar-users wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> As we bail out on every failing command, the test of GPT causes a
> premature script end if there is now GPT in the game.
> 
> Fixes: 991d2e903930 ("expand-on-first-boot: Preserve MBR on expansion
> of GPT disks")
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  .../expand-on-first-boot/files/expand-last-partition.sh         | 2
> +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meta/recipes-support/expand-on-first-boot/files/expand-
> last-partition.sh b/meta/recipes-support/expand-on-first-
> boot/files/expand-last-partition.sh
> index 0cb2ee21..7660bf44 100755
> --- a/meta/recipes-support/expand-on-first-boot/files/expand-last-
> partition.sh
> +++ b/meta/recipes-support/expand-on-first-boot/files/expand-last-
> partition.sh
> @@ -41,7 +41,7 @@ if [ "$DISK_SIZE" -lt "$MINIMAL_SIZE" ]; then
>  	exit 0
>  fi
>  
> -IS_GPT="$(sfdisk -d "${BOOT_DEV}" 2>/dev/null | grep -q "label: gpt"
> && echo 1)"
> +IS_GPT="$(sfdisk -d "${BOOT_DEV}" 2>/dev/null | grep -q "label: gpt"
> && echo 1 || true)"
>  if [ "$IS_GPT" = "1" ]; then
>  	dd if="${BOOT_DEV}" of=/dev/shm/__mbr__.bak count=1
>  fi
> -- 
> 2.43.0
> 

Hello.

Sent the same a day ago (faced the issue on NanoPi Neo):
https://groups.google.com/g/isar-users/c/D_sCls1hwj0
Jan Kiszka May 31, 2024, 7:32 a.m. UTC | #2
On 31.05.24 08:48, Uladzimir Bely wrote:
> On Thu, 2024-05-30 at 20:49 +0200, 'Jan Kiszka' via isar-users wrote:
>> From: Jan Kiszka <jan.kiszka@siemens.com>
>>
>> As we bail out on every failing command, the test of GPT causes a
>> premature script end if there is now GPT in the game.
>>
>> Fixes: 991d2e903930 ("expand-on-first-boot: Preserve MBR on expansion
>> of GPT disks")
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>> ---
>>  .../expand-on-first-boot/files/expand-last-partition.sh         | 2
>> +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/meta/recipes-support/expand-on-first-boot/files/expand-
>> last-partition.sh b/meta/recipes-support/expand-on-first-
>> boot/files/expand-last-partition.sh
>> index 0cb2ee21..7660bf44 100755
>> --- a/meta/recipes-support/expand-on-first-boot/files/expand-last-
>> partition.sh
>> +++ b/meta/recipes-support/expand-on-first-boot/files/expand-last-
>> partition.sh
>> @@ -41,7 +41,7 @@ if [ "$DISK_SIZE" -lt "$MINIMAL_SIZE" ]; then
>>  	exit 0
>>  fi
>>  
>> -IS_GPT="$(sfdisk -d "${BOOT_DEV}" 2>/dev/null | grep -q "label: gpt"
>> && echo 1)"
>> +IS_GPT="$(sfdisk -d "${BOOT_DEV}" 2>/dev/null | grep -q "label: gpt"
>> && echo 1 || true)"
>>  if [ "$IS_GPT" = "1" ]; then
>>  	dd if="${BOOT_DEV}" of=/dev/shm/__mbr__.bak count=1
>>  fi
>> -- 
>> 2.43.0
>>
> 
> Hello.
> 
> Sent the same a day ago (faced the issue on NanoPi Neo):
> https://groups.google.com/g/isar-users/c/D_sCls1hwj0
> 

Ah, sorry, didn't arrive in my inbox, also not as "spam". We really need
this list to be properly archived and accessible via alternative
channels, probably lists.linux.dev.

Anyway, your version is even nicer.

Jan

Patch

diff --git a/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh b/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh
index 0cb2ee21..7660bf44 100755
--- a/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh
+++ b/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh
@@ -41,7 +41,7 @@  if [ "$DISK_SIZE" -lt "$MINIMAL_SIZE" ]; then
 	exit 0
 fi
 
-IS_GPT="$(sfdisk -d "${BOOT_DEV}" 2>/dev/null | grep -q "label: gpt" && echo 1)"
+IS_GPT="$(sfdisk -d "${BOOT_DEV}" 2>/dev/null | grep -q "label: gpt" && echo 1 || true)"
 if [ "$IS_GPT" = "1" ]; then
 	dd if="${BOOT_DEV}" of=/dev/shm/__mbr__.bak count=1
 fi