[syslinux:firmware] efi: Make gnu-efi build scripts more robust

syslinux-bot for Matt Fleming matt.fleming at intel.com
Wed Dec 11 02:09:06 PST 2013


Commit-ID:  31e11d3211ace5ea503d6c9c7a7350b382f41b66
Gitweb:     http://www.syslinux.org/commit/31e11d3211ace5ea503d6c9c7a7350b382f41b66
Author:     Matt Fleming <matt.fleming at intel.com>
AuthorDate: Wed, 11 Dec 2013 07:47:18 +0000
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Wed, 11 Dec 2013 09:15:22 +0000

efi: Make gnu-efi build scripts more robust

Modify the scripts to check that they're called with the correct number
of arguments and error out otherwise after printing some helpful info.

This change also stops relying on passing arguments through environment
variables and instead passes them explicitly to the scripts, which is
definitely more robust, and handles the case where the scripts are
invoked directly.

Of course, now that the scripts can be invoked directly we need to
regard any input as hostile and exit immediately on error.

Signed-off-by: Matt Fleming <matt.fleming at intel.com>

---
 efi/build-gnu-efi.sh | 25 ++++++++++++++++++++++---
 efi/check-gnu-efi.sh | 30 +++++++++++++++++++++++++++++-
 mk/efi.mk            |  2 +-
 3 files changed, 52 insertions(+), 5 deletions(-)

diff --git a/efi/build-gnu-efi.sh b/efi/build-gnu-efi.sh
index e90b714..3844e75 100755
--- a/efi/build-gnu-efi.sh
+++ b/efi/build-gnu-efi.sh
@@ -1,10 +1,29 @@
 #!/bin/sh
 
+set -e
+
+# Initialise the gnu-efi submodule and ensure the source is up-to-date.
+# Then build and install it for the given architecture.
+
+if [ $# -lt 3 ]; then
+cat <<EOF
+Usage: $0: <arch> <srcdir> <objdir>
+
+Build the <arch> gnu-efi libs and header files and install in <objdir>.
+
+  <arch>   - A gnu-efi \$ARCH argument, i.e. ia32, x86_64
+  <srcdir> - The top-level directory of the Syslinux source
+  <objdir> - The Syslinux object directory
+
+EOF
+    exit 1
+fi
+
 ARCH=$1
-objdir=$2
-topdir=$3
+srcdir=`realpath $2`
+objdir=`realpath $3`
 
-pushd $topdir
+pushd $srcdir
 git submodule init
 git submodule update
 
diff --git a/efi/check-gnu-efi.sh b/efi/check-gnu-efi.sh
index 719e945..3fd193d 100755
--- a/efi/check-gnu-efi.sh
+++ b/efi/check-gnu-efi.sh
@@ -1,11 +1,39 @@
 #!/bin/sh
 
+# Verify that gnu-efi is installed in the object directory for our
+# firmware. If it isn't, build it.
+
+if [ $# -lt 3 ]; then
+cat <<EOF
+Usage: $0: <arch> <srcdir> <objdir>
+
+Check for gnu-efi libraries and header files in <objdir> and, if none
+exist, build and install them.
+
+  <arch>   - A gnu-efi \$ARCH argument, i.e. ia32, x86_64
+  <srcdir> - The top-level directory of the Syslinux source
+  <objdir> - The Syslinux object directory
+
+EOF
+    exit 1
+fi
+
 ARCH=$1
+srcdir=`realpath $2`
+objdir=`realpath $3`
 
 if [ ! -f $objdir/include/$ARCH/efibind.h ]; then
     # Build the external project with a clean make environment, as
     # Syslinux disables built-in implicit rules.
     export MAKEFLAGS=
 
-    $topdir/efi/build-gnu-efi.sh $ARCH $objdir $topdir &> /dev/null
+    build=$srcdir/efi/build-gnu-efi.sh
+    $build $ARCH $srcdir $objdir &> /dev/null
+    if [ $? -ne 0 ]; then
+	printf "Failed to build gnu-efi. "
+	printf "Execute the following command for full details: \n\n"
+	printf "$build $ARCH $srcdir $objdir\n\n"
+
+	exit 1
+    fi
 fi
diff --git a/mk/efi.mk b/mk/efi.mk
index e12e0a6..ca1dc75 100644
--- a/mk/efi.mk
+++ b/mk/efi.mk
@@ -21,7 +21,7 @@ ifeq ($(ARCH),x86_64)
 	EFI_SUBARCH = $(ARCH)
 endif
 
-$(shell $(topdir)/efi/check-gnu-efi.sh $(EFI_SUBARCH))
+$(shell $(topdir)/efi/check-gnu-efi.sh $(EFI_SUBARCH) $(topdir) $(objdir))
 
 #LIBDIR=/usr/lib
 FORMAT=efi-app-$(EFI_SUBARCH)


More information about the Syslinux-commits mailing list