Logically, the final branch of the if should be qualified with a check
for the emptiness of FreeBSDDist. This is awkward in the current
structure, since we really want to do the distpath lookup only if
needed. (This is not very important right now, but we are about to
add another case which will do a more-likely-to-bomb-out and
more-likely-to-block-on-the-db lookup.) So refactor into `return'
style. This lets us introduce local variables in each branch.
Now gate the final branch appropriately. The overall result is that
if no useful FreeBSD build is found, we simply do not set the
freebsd_* runvars, rather than setting them to wrong values (eg,
`freebsd_distpath=/i386'.
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
local envvar="FREEBSD_${arch^^}_BUILDJOB"
if [ -n "${!envvar}" ]; then
freebsd_runvars="freebsdbuildjob=${!envvar}"
- elif [ -n "$FREEBSD_DIST" ] && [ -n "$FREEBSD_VERSION" ]; then
+ return
+ fi
+ if [ -n "$FREEBSD_DIST" ] && [ -n "$FREEBSD_VERSION" ]; then
freebsd_runvars="freebsd_distpath=$FREEBSD_DIST/$arch \
freebsd_version=$FREEBSD_VERSION"
- else
- local distpath=`getconfig "FreeBSDDist"`
+ return
+ fi
+ local distpath=`getconfig "FreeBSDDist"`
+ if [ -n "$distpath" ]; then
local version=`getconfig "FreeBSDVersion"`
freebsd_runvars="freebsd_distpath=$distpath/$arch \
freebsd_version=$version"
+ return
fi
}