git: cefe58791b0f - main - release: Support GNU stat in mkisoimages.sh

From: Jessica Clarke <jrtc27_at_FreeBSD.org>
Date: Fri, 15 Jul 2022 22:18:06 UTC
The branch main has been updated by jrtc27:

URL: https://cgit.FreeBSD.org/src/commit/?id=cefe58791b0fc5243250b2449107540b03d64689

commit cefe58791b0fc5243250b2449107540b03d64689
Author:     Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2022-07-15 22:04:48 +0000
Commit:     Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2022-07-15 22:04:48 +0000

    release: Support GNU stat in mkisoimages.sh
    
    BSD stat and GNU stat differ significantly when it comes to using a
    custom format string, both in the option name and in the format string
    itself. Handle both here (assuming Linux means GNU stat rather than BSD
    stat).
    
    Reviewed by:    brooks, gjb
    Obtained from:  CheriBSD
    Differential Revision:  https://reviews.freebsd.org/D35814
---
 release/amd64/mkisoimages.sh | 6 +++++-
 release/arm64/mkisoimages.sh | 6 +++++-
 release/riscv/mkisoimages.sh | 6 +++++-
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/release/amd64/mkisoimages.sh b/release/amd64/mkisoimages.sh
index a90578c02ebd..a8bf186247f0 100644
--- a/release/amd64/mkisoimages.sh
+++ b/release/amd64/mkisoimages.sh
@@ -112,7 +112,11 @@ if [ "$bootable" != "" ]; then
 
 	# Create a GPT image containing the partitions we need for hybrid boot.
 	hybridfilename=$(mktemp /tmp/hybrid.img.XXXXXX)
-	imgsize=`stat -f %z "$NAME"`
+	if [ "$(uname -s)" = "Linux" ]; then
+		imgsize=`stat -c %s "$NAME"`
+	else
+		imgsize=`stat -f %z "$NAME"`
+	fi
 	$MKIMG -s gpt \
 	    --capacity $imgsize \
 	    -b "$BASEBITSDIR/boot/pmbr" \
diff --git a/release/arm64/mkisoimages.sh b/release/arm64/mkisoimages.sh
index e7e56eef1cb6..2a30c8e3e975 100644
--- a/release/arm64/mkisoimages.sh
+++ b/release/arm64/mkisoimages.sh
@@ -107,7 +107,11 @@ if [ "$bootable" != "" ]; then
 
 	# Create a GPT image containing the EFI partition.
 	efifilename=$(mktemp /tmp/efi.img.XXXXXX)
-	imgsize=`stat -f %z "$NAME"`
+	if [ "$(uname -s)" = "Linux" ]; then
+		imgsize=`stat -c %s "$NAME"`
+	else
+		imgsize=`stat -f %z "$NAME"`
+	fi
 	$MKIMG -s gpt \
 	    --capacity $imgsize \
 	    $espparam \
diff --git a/release/riscv/mkisoimages.sh b/release/riscv/mkisoimages.sh
index e7e56eef1cb6..2a30c8e3e975 100644
--- a/release/riscv/mkisoimages.sh
+++ b/release/riscv/mkisoimages.sh
@@ -107,7 +107,11 @@ if [ "$bootable" != "" ]; then
 
 	# Create a GPT image containing the EFI partition.
 	efifilename=$(mktemp /tmp/efi.img.XXXXXX)
-	imgsize=`stat -f %z "$NAME"`
+	if [ "$(uname -s)" = "Linux" ]; then
+		imgsize=`stat -c %s "$NAME"`
+	else
+		imgsize=`stat -f %z "$NAME"`
+	fi
 	$MKIMG -s gpt \
 	    --capacity $imgsize \
 	    $espparam \