aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2013-12-11 07:47:18 +0000
committerMatt Fleming <matt.fleming@intel.com>2013-12-11 09:15:22 +0000
commit31e11d3211ace5ea503d6c9c7a7350b382f41b66 (patch)
tree936bf5cfe4b3a232532f4f5521357b85837df401
parent6e8321066866bf41a91e095fa9421d24dbb886c0 (diff)
downloadsyslinux-31e11d3211ace5ea503d6c9c7a7350b382f41b66.tar.gz
syslinux-31e11d3211ace5ea503d6c9c7a7350b382f41b66.tar.xz
syslinux-31e11d3211ace5ea503d6c9c7a7350b382f41b66.zip
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@intel.com>
-rwxr-xr-xefi/build-gnu-efi.sh25
-rwxr-xr-xefi/check-gnu-efi.sh30
-rw-r--r--mk/efi.mk2
3 files changed, 52 insertions, 5 deletions
diff --git a/efi/build-gnu-efi.sh b/efi/build-gnu-efi.sh
index e90b714d..3844e75b 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 719e9452..3fd193de 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 e12e0a66..ca1dc75f 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)