aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Baylis <charles.baylis@linaro.org>2016-04-28 16:05:29 +0100
committerMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2016-05-16 10:44:11 +0000
commit297bd05ca3e3282de306b79c4a4d9a7be16ac126 (patch)
tree716202f9a10b7a394043656eea6cd3707b1a3e1b
parentc8cdeb4ced9d6c6eaa496cbcfac37b2db7c23b44 (diff)
Add error handling for component_init.
The component_init function can return errors, but they are not propagated at the call sites. Also move build_failure, build_success and test_success to common.sh so that they are available earlier in abe.sh. Change-Id: Idc9b2e59a2a3bdbffaf53598b1eb0cd36201871b
-rwxr-xr-xabe.sh39
-rw-r--r--lib/checkout.sh12
-rw-r--r--lib/common.sh35
-rw-r--r--lib/component.sh16
-rw-r--r--lib/globals.sh6
5 files changed, 70 insertions, 38 deletions
diff --git a/abe.sh b/abe.sh
index 6bb8ed51..5cef1327 100755
--- a/abe.sh
+++ b/abe.sh
@@ -430,6 +430,10 @@ command_line_arguments=$*
# Initialize an entry in the data array for components
collect_data abe
+if [ $? -ne 0 ]; then
+ error "collect_data failed"
+ build_failure
+fi
#
# These functions actually do something
@@ -565,41 +569,6 @@ set_package()
return 1
}
-build_failure()
-{
- local time="`expr ${SECONDS} / 60`"
- error "Build process failed after ${time} minutes"
-
- if test x"${gerrit}" = xyes; then
- gerrit_build_status ${gcc_version} 1
- fi
- exit 1
-}
-
-build_success()
-{
- local time="`expr ${SECONDS} / 60`"
- notice "Build process succeeded after ${time} minutes"
-
- if test x"${gerrit}" = xyes; then
- gerrit_build_status ${gcc_version} 0
- fi
-
- return 0
-}
-
-test_success()
-{
- local time="`expr ${SECONDS} / 60`"
- notice "Test run completed after ${time} minutes"
-
- if test x"${gerrit}" = xyes; then
- gerrit_build_status ${gcc_version} 6
- fi
-
- return 0
-}
-
# Switches that require a following directive need to make sure they don't
# parse the -- of the following switch.
check_directive()
diff --git a/lib/checkout.sh b/lib/checkout.sh
index 5f65c41e..e8a389aa 100644
--- a/lib/checkout.sh
+++ b/lib/checkout.sh
@@ -41,6 +41,10 @@ checkout_all()
package="gcc"
fi
collect_data ${package}
+ if [ $? -ne 0 ]; then
+ error "collect_data failed"
+ return 1
+ fi
local filespec="`get_component_filespec ${package}`"
if test "`component_is_tar ${package}`" = no; then
@@ -70,6 +74,10 @@ checkout_all()
# GDB now needs expat for XML support.
mkdir -p ${local_builds}/destdir/${host}/bin/
collect_data expat
+ if [ $? -ne 0 ]; then
+ error "collect_data failed"
+ return 1
+ fi
fetch expat
extract expat
rsync -ar ${local_snapshots}/expat-2.1.0-1/include ${local_builds}/destdir/${host}/usr/
@@ -77,6 +85,10 @@ checkout_all()
# GDB now has python support, for mingw we have to download a
# pre-built win2 binary that works with mingw32.
collect_data python
+ if [ $? -ne 0 ]; then
+ error "collect_data failed"
+ return 1
+ fi
fetch python
extract python
# The mingw package of python contains a script used by GDB to
diff --git a/lib/common.sh b/lib/common.sh
index 984fa54d..a4c7277b 100644
--- a/lib/common.sh
+++ b/lib/common.sh
@@ -302,3 +302,38 @@ is_package_in_runtests()
done
return 1
}
+
+build_failure()
+{
+ local time="`expr ${SECONDS} / 60`"
+ error "Build process failed after ${time} minutes"
+
+ if test x"${gerrit}" = xyes; then
+ gerrit_build_status ${gcc_version} 1
+ fi
+ exit 1
+}
+
+build_success()
+{
+ local time="`expr ${SECONDS} / 60`"
+ notice "Build process succeeded after ${time} minutes"
+
+ if test x"${gerrit}" = xyes; then
+ gerrit_build_status ${gcc_version} 0
+ fi
+
+ return 0
+}
+
+test_success()
+{
+ local time="`expr ${SECONDS} / 60`"
+ notice "Test run completed after ${time} minutes"
+
+ if test x"${gerrit}" = xyes; then
+ gerrit_build_status ${gcc_version} 6
+ fi
+
+ return 0
+}
diff --git a/lib/component.sh b/lib/component.sh
index 6c96a368..0fc90c43 100644
--- a/lib/component.sh
+++ b/lib/component.sh
@@ -53,7 +53,9 @@ component_init ()
value="`echo ${index} | cut -d '=' -f2-20 | sed -e 's:^[a-zA-Z]*=::' | tr '%' ' '`"
eval "local ifset=\${${component}[${name}]:-notset}"
if test x"${ifset}" = x"notset"; then
- eval "${component}[${name}]="${value}""
+ # $value is supposed to be safe for bare shell expansion
+ # typically it is surrounded by double quotes
+ eval "${component}[${name}]="${value}
if test $? -gt 0; then
return 1
fi
@@ -500,10 +502,14 @@ collect_data ()
local date="`git log -n 1 --format=%aD | tr ' ' '%'`"
local filespec="abe.git"
local srcdir="${abe_path}"
- local configure="`grep ${srcdir}/configure ${abe_top}/config.log | tr -s ' ' | cut -d ' ' -f 4-10| tr ' ' '%'`"
+ local configure=\""`grep ${srcdir}/configure ${abe_top}/config.log | tr -s ' ' | cut -d ' ' -f 4-10| tr ' ' '%'`"\"
popd
component_init ${component} TOOL=${component} ${branch:+BRANCH=${branch}} ${revision:+REVISION=${revision}} ${url:+URL=${url}} ${filespec:+FILESPEC=${filespec}} ${data:+DATE=${date}} ${srcdir:+SRCDIR=${srcdir}} ${configure:+CONFIGURE=${configure}}
- return 0
+ if [ $? -ne 0 ]; then
+ error "component_init failed"
+ return 1
+ fi
+ return 0
fi
if test -d ${local_builds}/${host}/${target}; then
@@ -598,6 +604,10 @@ collect_data ()
fi
confvars="${confvars} ${runtest_flags:+RUNTESTFLAGS=\"`echo ${runtest_flags} | tr ' ' '%'`\"}"
component_init ${component} TOOL=${component} ${branch:+BRANCH=${branch}} ${revision:+REVISION=${revision}} ${srcdir:+SRCDIR=${srcdir}} ${builddir:+BUILDDIR=${builddir}} ${filespec:+FILESPEC=${filespec}} ${url:+URL=${url}} ${confvars}
+ if [ $? -ne 0 ]; then
+ error "component_init failed"
+ return 1
+ fi
default_makeflags=
default_configure_flags=
diff --git a/lib/globals.sh b/lib/globals.sh
index 2d4eaace..53bd9a42 100644
--- a/lib/globals.sh
+++ b/lib/globals.sh
@@ -216,6 +216,12 @@ import_manifest()
esac
component_init $i ${branch:+BRANCH=${branch}} ${revision:+REVISION=${revision}} ${url:+URL=${url}} ${filespec:+FILESPEC=${filespec}} ${srcdir:+SRCDIR=${srcdir}} ${builddir:+BUILDDIR=${builddir}} ${stage1_flags:+STAGE1=\"${stage1_flags}\"} ${stage2_flags:+STAGE2=\"${stage2_flags}\"} ${configure:+CONFIGURE=\"${configure}\"} ${makeflags:+MAKEFLAGS=\"${makeflags}\"} ${static:+STATICLINK=${static}}
+ if [ $? -ne 0 ]; then
+ error "component_init failed while parsing manifest"
+ build_failure
+ return 1
+ fi
+
unset stage1_flags
unset stage2_flags
unset url