1 #!/bin/bash
   2 
   3 #
   4 # Complete testing of jpackage platform-specific packaging.
   5 #
   6 # The script does the following:
   7 # 1. Create packages.
   8 # 2. Install created packages.
   9 # 3. Verifies packages are installed.
  10 # 4. Uninstall created packages.
  11 # 5. Verifies packages are uninstalled.
  12 #
  13 # For the list of accepted command line arguments see `run_tests.sh` script.
  14 #
  15 
  16 # Fail fast
  17 set -e; set -o pipefail;
  18 
  19 # Script debug
  20 dry_run=${JPACKAGE_TEST_DRY_RUN}
  21 
  22 # Default directory where jpackage should write bundle files
  23 output_dir=~/jpackage_bundles
  24 
  25 
  26 set_args ()
  27 {
  28   args=()
  29   local arg_is_output_dir=
  30   local arg_is_mode=
  31   local output_dir_set=
  32   local with_append_actions=yes
  33   for arg in "$@"; do
  34     if [ "$arg" == "-o" ]; then
  35       arg_is_output_dir=yes
  36       output_dir_set=yes
  37     elif [ "$arg" == "-m" ]; then
  38       arg_is_mode=yes
  39       continue
  40     elif [ "$arg" == '--' ]; then
  41       append_actions
  42       with_append_actions=
  43       continue
  44     elif ! case "$arg" in -Djpackage.test.action=*) false;; esac; then
  45       continue
  46     elif [ -n "$arg_is_output_dir" ]; then
  47       arg_is_output_dir=
  48       output_dir="$arg"
  49     elif [ -n "$arg_is_mode" ]; then
  50       arg_is_mode=
  51       continue
  52     fi
  53 
  54     args+=( "$arg" )
  55   done
  56   [ -n "$output_dir_set" ] || args=( -o "$output_dir" "${args[@]}" )
  57   [ -z "$with_append_actions" ] || append_actions
  58 }
  59 
  60 
  61 append_actions ()
  62 {
  63   args+=( '--' '-Djpackage.test.action=create,install,verify-install,uninstall,verify-uninstall' )
  64 }
  65 
  66 
  67 exec_command ()
  68 {
  69   if [ -n "$dry_run" ]; then
  70     echo "$@"
  71   else
  72     eval "$@"
  73   fi
  74 }
  75 
  76 set_args "$@"
  77 basedir="$(dirname $0)"
  78 exec_command "$basedir/run_tests.sh" -m create "${args[@]}"