| 1 | #!/bin/bash |
| 2 | |
| 3 | # Created by argbash-init v2.5.0 |
| 4 | # ARGBASH_SET_DELIM([ ]) |
| 5 | # ARGBASH_SET_INDENT([ ]) |
| 6 | # ARG_OPTION_STACKING([none]) |
| 7 | # ARG_RESTRICT_VALUES([none]) |
| 8 | # ARG_OPTIONAL_BOOLEAN([clean],[c],[Clean the repository before proceeding. Use with care, as you will lose all uncommitted local modifications and all untracked files.],[off]) |
| 9 | # ARG_HELP([Compile OpenSCAP, perform tests and execute ABI check.]) |
| 10 | # DEFINE_SCRIPT_DIR([]) |
| 11 | # ARGBASH_GO() |
| 12 | # needed because of Argbash --> m4_ignore([ |
| 13 | ### START OF CODE GENERATED BY Argbash v2.5.0 one line above ### |
| 14 | # Argbash is a bash code generator used to get arguments parsing right. |
| 15 | # Argbash is FREE SOFTWARE, see https://argbash.io for more info |
| 16 | |
| 17 | die() |
| 18 | { |
| 19 | local _ret=$2 |
| 20 | test -n "$_ret" || _ret=1 |
| 21 | test "$_PRINT_HELP" = yes && print_help >&2 |
| 22 | echo "$1" >&2 |
| 23 | exit ${_ret} |
| 24 | } |
| 25 | |
| 26 | |
| 27 | # THE DEFAULTS INITIALIZATION - OPTIONALS |
| 28 | _arg_clean=off |
| 29 | |
| 30 | print_help () |
| 31 | { |
| 32 | printf "%s\n" "Compile OpenSCAP, perform tests and execute ABI check." |
| 33 | printf 'Usage: %s [-c|--(no-)clean] [-h|--help]\n' "$0" |
| 34 | printf "\t%s\n" "-c,--clean,--no-clean: Clean the repository before proceeding. Use with care, as you will lose all uncommitted local modifications and all untracked files. (off by default)" |
| 35 | printf "\t%s\n" "-h,--help: Prints help" |
| 36 | echo |
| 37 | echo 'Short options stacking mode is not supported.' |
| 38 | } |
| 39 | |
| 40 | parse_commandline () |
| 41 | { |
| 42 | while test $# -gt 0 |
| 43 | do |
| 44 | _key="$1" |
| 45 | case "$_key" in |
| 46 | -c|--no-clean|--clean) |
| 47 | _arg_clean="on" |
| 48 | test "${1:0:5}" = "--no-" && _arg_clean="off" |
| 49 | ;; |
| 50 | -h|--help) |
| 51 | print_help |
| 52 | exit 0 |
| 53 | ;; |
| 54 | *) |
| 55 | _PRINT_HELP=yes die "FATAL ERROR: Got an unexpected argument '$1'" 1 |
| 56 | ;; |
| 57 | esac |
| 58 | shift |
| 59 | done |
| 60 | } |
| 61 | |
| 62 | parse_commandline "$@" |
| 63 | |
| 64 | # OTHER STUFF GENERATED BY Argbash |
| 65 | script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" || die "Couldn't determine the script's running directory, which probably matters, bailing out" 2 |
| 66 | |
| 67 | ### END OF CODE GENERATED BY Argbash (sortof) ### ]) |
| 68 | # [ <-- needed because of Argbash |
| 69 | |
| 70 | |
| 71 | . "$script_dir/release.sh" |
| 72 | |
| 73 | build_stderr=build-stderr.log |
| 74 | build_stdout=build-stdout.log |
| 75 | |
| 76 | if [ "$_arg_clean" = "on" ]; then |
| 77 | echo Cleaning the repository... |
| 78 | clean_repository |
| 79 | clean_repository_aggressively |
| 80 | fi |
| 81 | |
| 82 | |
| 83 | echo Checking whether the repository is clean... |
| 84 | check_for_clean_repo |
| 85 | echo Building and executing tests... |
| 86 | execute_local_tests > "$build_stdout" 2> "$build_stderr" || die "The build or tests failed, check '$build_stdout' and '$build_stderr' for errors." |
| 87 | echo Arranging the API check... |
| 88 | check_abi |
| 89 | |
| 90 | # ] <-- needed because of Argbash |