Commit ee44609e authored by frtabu's avatar frtabu

Fix report problem, improve option flexibility

parent dbca811b
...@@ -35,26 +35,39 @@ function build_usage { ...@@ -35,26 +35,39 @@ function build_usage {
echo "" echo ""
echo "Mandatory Options:" echo "Mandatory Options:"
echo "--------" echo "--------"
echo " --job-name #### OR -jn ####" local -A HELP_BUILD
echo " Specify the name of the Jenkins job." HELP_BUILD["jn"]=" Specify the name of the Jenkins job."
echo "" HELP_BUILD["id"]=" Specify the build ID of the Jenkins job."
echo " --build-id #### OR -id ####" HELP_BUILD["ws"]=" Specify the workspace"
echo " Specify the build ID of the Jenkins job." for (( i=0 ; i<${#SHORT_OPTIONS[@]} ; i++ ))
echo "" do
echo " --workspace #### OR -ws ####" if [ $(( MANDATORY_OPTMASK & $(( 2**$i )) )) -ne 0 ]
echo " Specify the workspace." then
echo "" if [ "${LONG_OPTIONS[$i]}" != "" ]
then
printf " %s #### OR " "--${LONG_OPTIONS[$i]}"
fi
printf "%s #### \n" "-${SHORT_OPTIONS[$i]}"
printf " %s\n\n" "${HELP_BUILD[${SHORT_OPTIONS[$i]}]}"
fi
done
echo "Options:" echo "Options:"
echo "--------" echo "--------"
variant_usage HELP_BUILD["var"]=" Specify the variant to build."
echo " Specify the variant to build." HELP_BUILD["k"]=" Keep the VM alive after the build."
echo "" HELP_BUILD["D"]=" Run as daemon"
echo " --keep-vm-alive OR -k" for (( i=0 ; i<${#SHORT_OPTIONS[@]} ; i++ ))
echo " Keep the VM alive after the build." do
echo "" if [ $(( ALLOWED_OPTMASK & $(( 2**$i )) )) -ne 0 ]
echo " --daemon OR -D" then
echo " Run as daemon" if [ "${LONG_OPTIONS[$i]}" != "" ]
echo "" then
printf " %s #### OR " "--${LONG_OPTIONS[$i]}"
fi
printf "%s #### \n" "-${SHORT_OPTIONS[$i]}"
printf " %s\n\n" "${HELP_BUILD[${SHORT_OPTIONS[$i]}]}"
fi
done
echo " --help OR -h" echo " --help OR -h"
echo " Print this help message." echo " Print this help message."
echo "" echo ""
......
...@@ -186,14 +186,14 @@ function check_command_options { ...@@ -186,14 +186,14 @@ function check_command_options {
if [ $(($GIVEN_OPTIONS & ${MANDATORY_OPTIONS[0]} )) -ne ${MANDATORY_OPTIONS[0]} ] && [ $(($GIVEN_OPTIONS & ${MANDATORY_OPTIONS[1]} )) -ne ${MANDATORY_OPTIONS[1]} ] if [ $(($GIVEN_OPTIONS & ${MANDATORY_OPTIONS[0]} )) -ne ${MANDATORY_OPTIONS[0]} ] && [ $(($GIVEN_OPTIONS & ${MANDATORY_OPTIONS[1]} )) -ne ${MANDATORY_OPTIONS[1]} ]
then then
echo "Syntax Error: missing option(s) for $4 command" echo "Syntax Error: missing option(s) for $4 command"
$4_usage ${4//-/_}_usage
exit 1 exit 1
fi fi
if [ $(($GIVEN_OPTIONS | ${MANDATORY_OPTIONS[0]} | ${MANDATORY_OPTIONS[1]} | $OPTIONAL_OPTIONS )) -ne $(( ${MANDATORY_OPTIONS[0]} | ${MANDATORY_OPTIONS[1]} | $OPTIONAL_OPTIONS )) ] if [ $(( $(($GIVEN_OPTIONS ^ ${MANDATORY_OPTIONS[0]})) | $OPTIONAL_OPTIONS )) -ne $(( $OPTIONAL_OPTIONS )) ] && [ $(( $(($GIVEN_OPTIONS ^ ${MANDATORY_OPTIONS[1]})) | $OPTIONAL_OPTIONS )) -ne $(( $OPTIONAL_OPTIONS )) ]
then then
echo "Syntax Error: unknown option(s) for $4 command" echo "Syntax Error: unknown option(s) for $4 command"
$4_usage ${4//-/_}_usage
exit 1 exit 1
fi fi
} }
...@@ -288,30 +288,67 @@ build_variant_arrays ...@@ -288,30 +288,67 @@ build_variant_arrays
#variables to process options, for each option we define a variable to store #variables to process options, for each option we define a variable to store
# its value and a bit mask, used to check allowed options depending on # its value and a bit mask, used to check allowed options depending on
# the command # the command
SHORT_OPTIONS=( "jn" "id" "ws" "k" "D" "gu" "pu" "mr" "var" "notused" "sb" "sc" "tb" "tc" "br" "co" "epc" )
LONG_OPTIONS=( "job-name" "build-id" "workspace" "keep-vm-alive" "daemon" "git-url" "" "" "variant" "notused" "" "" "" "" "" "" "" )
JOB_NAME=XX JOB_NAME=XX
JOB_NAME_OPTINDEX=0
JOB_NAME_OPTID=1 JOB_NAME_OPTID=1
BUILD_ID=XX BUILD_ID=XX
BUILD_ID_OPTINDEX=1
BUILD_ID_OPTID=2 BUILD_ID_OPTID=2
JENKINS_WKSP_OPTINDEX=2
JENKINS_WKSP_OPTID=4 JENKINS_WKSP_OPTID=4
KEEP_VM_ALIVE=0
KEEP_VM_ALIVE_OPTINDEX=3
KEEP_VM_ALIVE_OPTID=8 KEEP_VM_ALIVE_OPTID=8
RUN_OPTIONS="none" KEEP_VM_ALIVE=0
DAEMON=0
DAEMON_OPTINDEX=4
DAEMON_OPTID=$((2**4)) DAEMON_OPTID=$((2**4))
DAEMON=0
GITURL_OPTINDEX=5
GITURL_OPTID=$((2**5)) GITURL_OPTID=$((2**5))
PU_OPTINDEX=6
PU_OPTID=$((2**6)) PU_OPTID=$((2**6))
PU_TRIG=0
MR_OPTINDEX=7
MR_OPTID=$((2**7)) MR_OPTID=$((2**7))
MR_TRIG=0
VARIANT_OPTINDEX=8
VARIANT_OPTID=$((2**8)) VARIANT_OPTID=$((2**8))
SB_OPTINDEX=10
SB_OPTID=$((2**10)) SB_OPTID=$((2**10))
SC_OPTINDEX=11
SC_OPTID=$((2**11)) SC_OPTID=$((2**11))
TB_OPTINDEX=12
TB_OPTID=$((2**12)) TB_OPTID=$((2**12))
TC_OPTINDEX=13
TC_OPTID=$((2**13)) TC_OPTID=$((2**13))
BR_OPTINDEX=14
BR_OPTID=$((2**14)) BR_OPTID=$((2**14))
CO_OPTINDEX=15
CO_OPTID=$((2**15)) CO_OPTID=$((2**15))
MR_TRIG=0
PU_TRIG=0 EPC_IPADDR_OPTINDEX=16
EPC_IPADDR=""
EPC_IPADDR_OPTID=$((2**16)) EPC_IPADDR_OPTID=$((2**16))
EPC_IPADDR=""
RUN_OPTIONS="none"
# list of variables that can be set via the --setvar option # list of variables that can be set via the --setvar option
AUTHORIZED_VAR=("VM_OSREL RUN_EXPERIMENTAL") AUTHORIZED_VAR=("VM_OSREL RUN_EXPERIMENTAL")
...@@ -430,7 +467,7 @@ case $key in ...@@ -430,7 +467,7 @@ case $key in
MANDATORY_OPTMASK[0]+=$(($GITURL_OPTID + $PU_OPTID + $BR_OPTID + $CO_OPTID)) MANDATORY_OPTMASK[0]+=$(($GITURL_OPTID + $PU_OPTID + $BR_OPTID + $CO_OPTID))
MANDATORY_OPTMASK[1]=$(($JOB_NAME_OPTID + $BUILD_ID_OPTID + $JENKINS_WKSP_OPTID)) MANDATORY_OPTMASK[1]=$(($JOB_NAME_OPTID + $BUILD_ID_OPTID + $JENKINS_WKSP_OPTID))
MANDATORY_OPTMASK[1]+=$(($GITURL_OPTID + $MR_OPTID + $SB_OPTID + $SC_OPTID)) MANDATORY_OPTMASK[1]+=$(($GITURL_OPTID + $MR_OPTID + $SB_OPTID + $SC_OPTID))
MANDATORY_OPTMASK[1]+=$(($GITURL_OPTID + $TB_OPTID + $TC_OPTID)) MANDATORY_OPTMASK[1]+=$(($TB_OPTID + $TC_OPTID))
shift shift
;; ;;
-jn|--job-name) -jn|--job-name)
...@@ -534,7 +571,7 @@ case $key in ...@@ -534,7 +571,7 @@ case $key in
shift shift
shift shift
;; ;;
--epc) -epc)
check_ipv4addr "$2" check_ipv4addr "$2"
check_ipv4addr "$3" check_ipv4addr "$3"
EPC_IPADDR="$2" EPC_IPADDR="$2"
...@@ -553,7 +590,7 @@ case $key in ...@@ -553,7 +590,7 @@ case $key in
check_set_variant ${key//"-"} check_set_variant ${key//"-"}
shift shift
;; ;;
--variant) -var|--variant)
variant="$2" variant="$2"
check_set_variant ${2} check_set_variant ${2}
shift shift
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment