Add a helper routine is_valid_addon() that simplifies later

code.

Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
pull/8/head
Robert Nelson 13 years ago
parent 541498305f
commit 8db83b65b9

@ -35,6 +35,7 @@ unset SMSC95XX_MOREMEM
unset DD_UBOOT
unset KERNEL_DEB
unset USE_UENV
unset ADDON
GIT_VERSION=$(git rev-parse --short HEAD)
IN_VALID_UBOOT=1
@ -98,6 +99,22 @@ function is_element_of {
return 1
}
#########################################################################
#
# Define valid "--addon" values.
#
#########################################################################
VALID_ADDONS="pico ulcd"
function is_valid_addon {
if is_element_of $1 "${VALID_ADDONS}" ] ; then
return 0
else
return 1
fi
}
function check_root {
if [[ $UID -ne 0 ]]; then
echo "$0 must be run as sudo user or root"
@ -1659,29 +1676,6 @@ case "$UBOOT_TYPE" in
esac
}
function check_addon_type {
IN_VALID_ADDON=1
case "$ADDON_TYPE" in
pico)
ADDON=pico
unset IN_VALID_ADDON
;;
ulcd)
ADDON=ulcd
unset IN_VALID_ADDON
;;
esac
if [ "$IN_VALID_ADDON" ] ; then
usage
fi
}
function check_distro {
IN_VALID_DISTRO=1
@ -1772,7 +1766,7 @@ Optional:
precise-armel (12.04)
precise-armhf (12.04)
--addon <device>
--addon <additional peripheral device>
pico
ulcd <beagle xm>
@ -1852,8 +1846,7 @@ while [ ! -z "$1" ]; do
;;
--addon)
checkparm $2
ADDON_TYPE="$2"
check_addon_type
ADDON=$2
;;
--svideo-ntsc)
SVIDEO_NTSC=1
@ -1892,6 +1885,13 @@ if [ "$IN_VALID_UBOOT" ] ; then
usage
fi
if [ -n ${ADDON} ] ; then
if ! is_valid_addon ${ADDON} ; then
echo "ERROR: ${ADDON} is not a valid addon type"
usage
fi
fi
echo ""
echo "Script Version git: ${GIT_VERSION}"
echo "-----------------------------"

Loading…
Cancel
Save