From 362c7b9f6cd57421a18c0148fb6eb9bda165bcd2 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 20 Mar 2023 22:52:41 -0500 Subject: [PATCH] Bugfix: Out of date repository build scripts. The repository build scripts are very much out of date. A recent bugfix, commit 9a021eb4044cf8cb63bcef6f8851566b4bc574c7, attempted to partially address this. It turns out that there is a lot more that needs to be done. All of the repository build scripts are now updated. Make sure the copyright parameter is available. Make sure the "+Q/++quiet" and "+E/++error" parameters are correct and working. This is a copy of the changes from commit 736d99ce416da505e859c9ee3890b3adf119260f from the 0.7.0 development branch. The 0.7.0 parameters "+F/++line_first_no" and "+L/++line_last_no" are removed as they are not available in 0.6.0 stable branch versions. The relevant code remains, it is just unused. Improve return status handling. The goal here is to avoid calling "exit". The use of "exit" is not safe as under certain conditions it can close terminals that the script is running in. --- build/scripts/bootstrap-example.sh | 107 +++++-- build/scripts/bootstrap.sh | 299 +++++++++++++---- build/scripts/install.sh | 260 +++++++-------- build/scripts/package.sh | 635 +++++++++++++++++++++++++++++-------- build/scripts/test.sh | 377 +++++++++++++++++----- 5 files changed, 1250 insertions(+), 428 deletions(-) diff --git a/build/scripts/bootstrap-example.sh b/build/scripts/bootstrap-example.sh index 74dd0e6..8f0b848 100644 --- a/build/scripts/bootstrap-example.sh +++ b/build/scripts/bootstrap-example.sh @@ -7,11 +7,27 @@ # Instead this provides a functional example on what commands to perform to perform the bootstrap. # # This only accepts one argument, followed by these optional arguments: -# 1) One of "individual", "level", "monolithic", "fake-individual", "fake-level", "fake-monolithic", "programs-individual", "programs-level", or "programs-monolithic". -# 2) Optional, may be one of: +V, +q, +n, +l, +d, --enable-shared, --enable-static, --disable-shared, --disable-static. +# 1) One of "Modes" from below. +# 2) Optional, may be one of: +d, +l, +n, +V, +Q, +E, +N, +D, --enable-shared, --enable-static, --disable-shared, --disable-static. # 3) Optional, may be one of: -w, --work. # 4) Optional, may be: clang. # +# Modes: +# - "individual" +# - "level" +# - "monolithic" +# - "fake-individual" +# - "fake-level" +# - "fake-monolithic" +# - "fake-stand_alone" +# - "utf8-individual" +# - "utf8-level" +# - "utf8-monolithic" +# - "utf8-stand_alone" +# - "programs-individual" +# - "programs-level" +# - "programs-monolithic" +# # The -w/--work requires the path to the work directory following it. # The clang parameter does not need the "-m". # @@ -37,7 +53,12 @@ shared= static= version=0.6.5 clang= +mode_part= +mode_parameter= +mode_path= +mode_value= shell_command=bash +suppress_first="" if [[ $SHELL_ENGINE == "zsh" ]] ; then shell_command=zsh @@ -60,8 +81,11 @@ while [[ $i -le $# ]] ; do color="+l" elif [[ $p == "+n" ]] ; then color="+n" - elif [[ $p == "+q" ]] ; then - verbose="+q" + elif [[ $p == "+Q" ]] ; then + verbose="+Q" + verbose_common= + elif [[ $p == "+E" ]] ; then + verbose="+E" verbose_common= elif [[ $p == "+N" ]] ; then verbose="+N" @@ -101,16 +125,16 @@ if [[ $1 == "individual" ]] ; then $shell_command build/scripts/package.sh $verbose $color rebuild -i if [[ $? -eq 0 ]] ; then - for i in f_type f_status f_memory f_type_array f_string f_utf f_account f_capability f_color f_console f_control_group f_conversion f_directory f_environment f_execute f_file f_fss f_iki f_limit f_path f_pipe f_print f_status_string f_serialize f_signal f_socket f_thread fl_control_group fl_conversion fl_directory fl_environment fl_execute fl_fss fl_iki fl_print fl_signal fl_string fl_utf fl_utf_file fll_control_group fll_error fll_execute fll_file fll_fss fll_fss_status_string fll_iki fll_path fll_print fll_program fll_status_string ; do + for i in f_type f_status f_memory f_type_array f_string f_utf f_account f_capability f_color f_console f_control_group f_conversion f_directory f_environment f_execute f_file f_fss f_iki f_limit f_path f_pipe f_print f_status_string f_serialize f_signal f_socket f_thread fl_control_group fl_conversion fl_directory fl_environment fl_execute fl_fss fl_iki fl_path fl_print fl_signal fl_string fl_utf fl_utf_file fll_control_group fll_error fll_execute fll_file fll_fss fll_fss_status_string fll_iki fll_print fll_program fll_status_string ; do echo && echo "Processing $i." && cd package/individual/$i-$version/ && - $shell_command ./bootstrap.sh clean $verbose $color && + $shell_command ./bootstrap.sh clean $verbose $color $suppress_first && - $shell_command ./bootstrap.sh build $verbose $color $shared $static -w $path_work -m individual $clang && + $shell_command ./bootstrap.sh build $verbose $color $suppress_first $shared $static -w $path_work -m individual $clang && - $shell_command ./install.sh $verbose $color $shared $static -w $path_work && + $shell_command ./install.sh $verbose $color $suppress_first $shared $static -w $path_work && cd $path_original || break done @@ -122,31 +146,31 @@ if [[ $1 == "level" ]] ; then cd package/level/fll-level_0-$version/ && - $shell_command ./bootstrap.sh clean $verbose $color && + $shell_command ./bootstrap.sh clean $verbose $color $suppress_first && - $shell_command ./bootstrap.sh build $verbose $color $shared $static -w $path_work -m level $clang && + $shell_command ./bootstrap.sh build $verbose $color $suppress_first $shared $static -w $path_work -m level $clang && - $shell_command ./install.sh $verbose $color $shared $static -w $path_work && + $shell_command ./install.sh $verbose $color $suppress_first $shared $static -w $path_work && cd $path_original && cd package/level/fll-level_1-$version/ && - $shell_command ./bootstrap.sh clean $verbose $color && + $shell_command ./bootstrap.sh clean $verbose $color $suppress_first && - $shell_command ./bootstrap.sh build $verbose $color $shared $static -w $path_work -m level && + $shell_command ./bootstrap.sh build $verbose $color $suppress_first $shared $static -w $path_work -m level && - $shell_command ./install.sh $verbose $color $shared $static -w $path_work && + $shell_command ./install.sh $verbose $color $suppress_first $shared $static -w $path_work && cd $path_original && cd package/level/fll-level_2-$version/ && - $shell_command ./bootstrap.sh clean $verbose $color && + $shell_command ./bootstrap.sh clean $verbose $color $suppress_first && - $shell_command ./bootstrap.sh build $verbose $color $shared $static -w $path_work -m level && + $shell_command ./bootstrap.sh build $verbose $color $suppress_first $shared $static -w $path_work -m level && - $shell_command ./install.sh $verbose $color $shared $static -w $path_work + $shell_command ./install.sh $verbose $color $suppress_first $shared $static -w $path_work fi if [[ $1 == "monolithic" ]] ; then @@ -154,32 +178,49 @@ if [[ $1 == "monolithic" ]] ; then cd package/monolithic/fll-$version/ && - $shell_command ./bootstrap.sh clean $verbose $color && + $shell_command ./bootstrap.sh clean $verbose $color $suppress_first && - $shell_command ./bootstrap.sh build $verbose $color $shared $static -w $path_work -m monolithic $clang && + $shell_command ./bootstrap.sh build $verbose $color $suppress_first $shared $static -w $path_work -m monolithic $clang && - $shell_command ./install.sh $verbose $color $shared $static -w $path_work + $shell_command ./install.sh $verbose $color $shared $suppress_first $static -w $path_work fi -# The following in an example on building the Featureless Make project (fake) using the project bootstrapped from above. -if [[ $1 == "fake-individual" || $1 == "fake-level" || $1 == "fake-monolithic" ]] ; then - if [[ $1 == "fake-individual" ]] ; then +# The following in an example on building individual projects. +for mode_part in fake utf8 ; do + if [[ $1 == "$mode_part-individual" || $1 == "$mode_part-level" || $1 == "$mode_part-monolithic" || $1 == "$mode_part-stand_alone" ]] ; then + break; + fi + + mode_part= +done + +if [[ $mode_part != "" ]] ; then + mode_parameter="-p" + mode_path="program" + mode_value= + + if [[ $1 == "$mode_part-individual" ]] ; then build_mode="individual" - elif [[ $1 == "fake-level" ]] ; then + elif [[ $1 == "$mode_part-level" ]] ; then build_mode="level" - elif [[ $1 == "fake-monolithic" ]] ; then + elif [[ $1 == "$mode_part-monolithic" ]] ; then build_mode="monolithic" + elif [[ $1 == "$mode_part-stand_alone" ]] ; then + build_mode="stand_alone" + mode_path="stand_alone" + mode_parameter="-S" + mode_value="$mode_part" fi - $shell_command build/scripts/package.sh $verbose $color rebuild -p && + $shell_command build/scripts/package.sh $verbose $color rebuild $mode_parameter $mode_value && - cd package/program/fake-$version/ && + cd package/$mode_path/$mode_part-$version/ && - $shell_command ./bootstrap.sh clean $verbose $color && + $shell_command ./bootstrap.sh clean $verbose $color $suppress_first && - $shell_command ./bootstrap.sh build $verbose $color $shared $static -w $path_work -m $build_mode && + $shell_command ./bootstrap.sh build $verbose $color $suppress_first $shared $static -w $path_work -m $build_mode && - $shell_command ./install.sh $verbose $color $shared $static -w $path_work + $shell_command ./install.sh $verbose $color $suppress_first $shared $static -w $path_work # The following in an example on building all FLL program projects using the project bootstrapped from above. elif [[ $1 == "programs-individual" || $1 == "programs-level" || $1 == "programs-monolithic" ]] ; then @@ -201,11 +242,11 @@ elif [[ $1 == "programs-individual" || $1 == "programs-level" || $1 == "programs cd ${path_original}package/program/$i && - $shell_command ./bootstrap.sh clean $verbose $color && + $shell_command ./bootstrap.sh clean $verbose $color $suppress_first && - $shell_command ./bootstrap.sh build $verbose $color $shared $static -w $path_work -m $build_mode && + $shell_command ./bootstrap.sh build $verbose $color $suppress_first $shared $static -w $path_work -m $build_mode && - $shell_command ./install.sh $verbose $color $shared $static -w $path_work || + $shell_command ./install.sh $verbose $color $suppress_first $shared $static -w $path_work || break done diff --git a/build/scripts/bootstrap.sh b/build/scripts/bootstrap.sh index ce11552..7110b13 100644 --- a/build/scripts/bootstrap.sh +++ b/build/scripts/bootstrap.sh @@ -26,6 +26,7 @@ bootstrap_main() { local grab_next= local do_color=dark local do_help= + local do_copyright= local i=0 local m= local p= @@ -43,6 +44,7 @@ bootstrap_main() { local key= local -A variables=() + local failure= local settings_name=settings local settings_file= local settings_defines= @@ -59,6 +61,8 @@ bootstrap_main() { local path_sources=sources/ local path_language=c/ local path_work= + local print_line_first="yes" + local print_line_last="yes" local project_built= local project_built_shared= local project_built_static= @@ -92,6 +96,8 @@ bootstrap_main() { if [[ $grab_next == "" ]] ; then if [[ $p == "-h" || $p == "--help" ]] ; then do_help=yes + elif [[ $p == "+C" || $p == "++copyright" ]] ; then + do_copyright="yes" elif [[ $p == "+d" || $p == "++dark" ]] ; then do_color=dark context="+d" @@ -101,9 +107,13 @@ bootstrap_main() { elif [[ $p == "+n" || $p == "++no_color" ]] ; then do_color=none context="+n" - elif [[ $p == "+q" || $p == "++quiet" ]] ; then + elif [[ $p == "+Q" || $p == "++quiet" ]] ; then verbosity="quiet" - verbose="+q" + verbose="+Q" + verbose_common= + elif [[ $p == "+E" || $p == "++error" ]] ; then + verbosity="error" + verbose="+E" verbose_common= elif [[ $p == "+N" || $p == "++normal" ]] ; then verbosity= @@ -119,7 +129,7 @@ bootstrap_main() { verbose_common="-v" elif [[ $p == "+v" || $p == "++version" ]] ; then echo $version - return + return 0 elif [[ $p == "-d" || $p == "--define" ]] ; then grab_next=define_extra elif [[ $p == "-m" || $p == "--mode" ]] ; then @@ -183,6 +193,11 @@ bootstrap_main() { p= fi + if [[ $verbosity == "quiet" ]] ; then + print_line_first="no" + print_line_last="no" + fi + # If the settings_name has a directory separator, then assume it is a path to the settings file. if [[ $(echo $settings_name | grep -s -o '/') == "" ]] ; then settings_file="${path_data}build/$settings_name" @@ -207,6 +222,13 @@ bootstrap_main() { return 0 fi + if [[ $do_copyright == "yes" ]] ; then + bootstrap_copyright + bootstrap_cleanup + + return 0 + fi + bootstrap_load_settings # FSS and Featurless Make supports more flexible mode names, but for the purpose of this bootstrap script and avoiding potential problems, keep it simple. @@ -214,7 +236,11 @@ bootstrap_main() { for mode in $modes ; do if [[ $(echo "$mode" | grep -s -o "[^_[:alnum:]+-]") != "" ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: The mode ${c_notice}${mode}${c_error} includes invalid characters, only alphanumeric, underscore, minus, and plus are allowed.${c_reset}" + + bootstrap_print_last fi bootstrap_cleanup @@ -250,7 +276,11 @@ bootstrap_main() { if [[ $modes_available == "" ]] ; then if [[ $modes != "" ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: The mode(s) ${c_notice}${modes}${c_error} are not a valid modes, there are no available modes.${c_error}${c_reset}" + + bootstrap_print_last fi bootstrap_cleanup @@ -275,7 +305,11 @@ bootstrap_main() { if [[ $i -eq 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: The mode(s) ${c_notice}${modes}${c_error} are not valid modes, they must be one of: ${c_notice}$modes_available${c_error}.${c_reset}" + + bootstrap_print_last fi bootstrap_cleanup @@ -287,7 +321,11 @@ bootstrap_main() { bootstrap_id "build_name" if [[ ${variables[$key]} == "" ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: The required setting '${c_notice}build_name${c_error}' is not specified in the build settings file '${c_notice}${settings_file}${c_error}'.${c_reset}" + + bootstrap_print_last fi bootstrap_cleanup @@ -298,7 +336,11 @@ bootstrap_main() { bootstrap_id "version_major" if [[ ${variables[$key]} == "" ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: The required setting '${c_notice}version_major${c_error}' is not specified in the build settings file '${c_notice}${settings_file}${c_error}'.${c_reset}" + + bootstrap_print_last fi bootstrap_cleanup @@ -309,7 +351,11 @@ bootstrap_main() { bootstrap_id "version_minor" if [[ ${variables[$key]} == "" ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: The required setting '${c_notice}version_minor${c_error}' is not specified in the build settings file '${c_notice}${settings_file}${c_error}'.${c_reset}" + + bootstrap_print_last fi bootstrap_cleanup @@ -320,7 +366,11 @@ bootstrap_main() { bootstrap_id "version_micro" if [[ ${variables[$key]} == "" ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: The required setting '${c_notice}version_micro${c_error}' is not specified in the build settings file '${c_notice}${settings_file}${c_error}'.${c_reset}" + + bootstrap_print_last fi bootstrap_cleanup @@ -330,7 +380,11 @@ bootstrap_main() { if [[ $path_data == "" || ! -d $path_data ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: The data directory ${c_notice}${path_data}${c_error} is not a valid directory.${c_reset}" + + bootstrap_print_last fi bootstrap_cleanup @@ -340,7 +394,11 @@ bootstrap_main() { if [[ $path_sources == "" || ! -d $path_sources ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: The sources directory ${c_notice}${path_sources}${c_error} is not a valid directory.${c_reset}" + + bootstrap_print_last fi bootstrap_cleanup @@ -350,7 +408,11 @@ bootstrap_main() { if [[ $path_work != "" && ! -d $path_work ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: The work directory ${c_notice}${path_work}${c_error} is not a valid directory.${c_reset}" + + bootstrap_print_last fi bootstrap_cleanup @@ -378,15 +440,20 @@ bootstrap_main() { if [[ $operation_failure == "fail-multiple" ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: Only one operation may be specified at a time.${c_reset}" + + bootstrap_print_last fi bootstrap_cleanup return 1 elif [[ $operation == "build" ]] ; then - if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + bootstrap_print_first + echo -e "${c_highlight}Building:${c_reset} ${c_notice}${project_label}${c_highlight}.${c_reset}" fi @@ -408,14 +475,17 @@ bootstrap_main() { return 1 fi elif [[ $operation == "clean" ]] ; then - if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + bootstrap_print_first + echo -e "${c_highlight}Cleaning Project:${c_reset} ${c_notice}${project_label}${c_highlight}.${c_reset}" fi bootstrap_operation_clean elif [[ $operation == "" ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: No operation was given.${c_reset}" fi @@ -424,7 +494,11 @@ bootstrap_main() { return 1 else if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: The operation ${c_notice}${operation}${c_error} was not recognized.${c_reset}" + + bootstrap_print_last fi bootstrap_cleanup @@ -432,6 +506,12 @@ bootstrap_main() { return 1 fi + if [[ $verbosity != "quiet" ]] ; then + if [[ $failure != "" || $verbosity != "error" ]] ; then + bootstrap_print_last + fi + fi + bootstrap_cleanup return 0 @@ -461,7 +541,8 @@ bootstrap_handle_colors() { bootstrap_help() { - echo + bootstrap_print_first + echo -e "${c_title}${public_name}${c_reset}" echo -e " ${c_notice}Version ${version}${c_reset}" echo @@ -470,15 +551,17 @@ bootstrap_help() { echo -e " ${c_important}clean${c_reset} Delete all build files." echo echo -e "${c_highlight}Options:${c_reset}" - echo -e " -${c_important}h${c_reset}, --${c_important}help${c_reset} Print this help screen." - echo -e " +${c_important}d${c_reset}, ++${c_important}dark${c_reset} Use color modes that show up better on dark backgrounds." - echo -e " +${c_important}l${c_reset}, ++${c_important}light${c_reset} Use color modes that show up better on light backgrounds." - echo -e " +${c_important}n${c_reset}, ++${c_important}no_color${c_reset} Do not use color." - echo -e " +${c_important}q${c_reset}, ++${c_important}quiet${c_reset} Decrease verbosity, silencing most output." - echo -e " +${c_important}N${c_reset}, ++${c_important}normal${c_reset} Set verbosity to normal." - echo -e " +${c_important}V${c_reset}, ++${c_important}verbose${c_reset} Increase verbosity beyond normal output." - echo -e " +${c_important}D${c_reset}, ++${c_important}debug${c_reset} Enable debugging, significantly increasing verbosity beyond normal output." - echo -e " +${c_important}v${c_reset}, ++${c_important}version${c_reset} Print the version number of this program." + echo -e " -${c_important}h${c_reset}, --${c_important}help${c_reset} Print this help message." + echo -e " +${c_important}C${c_reset}, ++${c_important}copyright${c_reset} Print the copyright." + echo -e " +${c_important}d${c_reset}, ++${c_important}dark${c_reset} Output using colors that show up better on dark backgrounds." + echo -e " +${c_important}l${c_reset}, ++${c_important}light${c_reset} Output using colors that show up better on light backgrounds." + echo -e " +${c_important}n${c_reset}, ++${c_important}no_color${c_reset} Do not print using color." + echo -e " +${c_important}Q${c_reset}, ++${c_important}quiet${c_reset} Decrease verbosity, silencing most print.to." + echo -e " +${c_important}E${c_reset}, ++${c_important}error${c_reset} Decrease verbosity, using only error print.to." + echo -e " +${c_important}N${c_reset}, ++${c_important}normal${c_reset} Set verbosity to normal." + echo -e " +${c_important}V${c_reset}, ++${c_important}verbose${c_reset} Increase verbosity beyond normal print.to." + echo -e " +${c_important}D${c_reset}, ++${c_important}debug${c_reset} Enable debugging, significantly increasing verbosity beyond normal print.to." + echo -e " +${c_important}v${c_reset}, ++${c_important}version${c_reset} Print only the version number." echo echo -e "${c_highlight}Bootstrap Options:${c_reset}" echo -e " -${c_important}d${c_reset}, --${c_important}define${c_reset} Append an additional define after defines from settings file." @@ -498,7 +581,21 @@ bootstrap_help() { echo -e " --${c_important}disable-shared${c_reset} Forcibly do not build shared files." echo -e " --${c_important}enable-static${c_reset} Forcibly do build static files." echo -e " --${c_important}disable-static${c_reset} Forcibly do not build static files." + + bootstrap_print_last +} + +bootstrap_copyright() { + + bootstrap_print_first + + echo "Copyright © 2007-2023 Kevin Day." echo + echo "Source code license lgpl-2.1-or-later." + echo "Standard and specification license open-standard-license-1.0." + echo "Documentation license cc-by-sa-4.0." + + bootstrap_print_last } bootstrap_id() { @@ -733,26 +830,29 @@ bootstrap_id() { } bootstrap_load_settings() { - local -i failure=0 local i= local key= local value= if [[ ! -d ${path_data}build/ ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: No build settings directory '${c_notice}${path_data}build/${c_error}' could not be found or is not a valid directory.${c_reset}" fi let failure=1 elif [[ ! -f $settings_file ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: No settings file ${c_notice}${settings_file}${c_error} could not be found or is not a valid file.${c_reset}" fi let failure=1 fi - if [[ $failure -eq 1 ]] ; then + if [[ $failure != "" ]] ; then return 1 fi @@ -775,7 +875,7 @@ bootstrap_load_settings() { bootstrap_id "$i" if [[ $key == "" ]] ; then - if [[ $verbosity != "quiet" ]] ; then + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then echo -e "${c_warning}WARNING: Failed to find index for '${c_notice}${i}${c_warning}' when calling ${c_notice}bootstrap_id()${c_warning}.${c_reset}" fi @@ -818,7 +918,7 @@ bootstrap_load_settings() { bootstrap_id "$i" if [[ $key == "" ]] ; then - if [[ $verbosity != "quiet" ]] ; then + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then echo -e "${c_warning}WARNING: Failed to find index for '${c_notice}${i}${c_warning}' when calling ${c_notice}bootstrap_id()${c_warning}.${c_reset}" fi @@ -870,7 +970,7 @@ bootstrap_load_settings_mode() { bootstrap_id "${i}-mode" if [[ $key == "" ]] ; then - if [[ $verbosity != "quiet" ]] ; then + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then echo -e "${c_warning}WARNING: Failed to find index for '${c_notice}$i-$m${c_warning}' when calling ${c_notice}bootstrap_id()${c_warning}.${c_reset}" fi @@ -913,7 +1013,7 @@ bootstrap_load_settings_mode() { bootstrap_id "${i}-mode" if [[ $key == "" ]] ; then - if [[ $verbosity != "quiet" ]] ; then + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then echo -e "${c_warning}WARNING: Failed to find index for '${c_notice}${i}-${m}${c_warning}' when calling ${c_notice}bootstrap_id()${c_warning}.${c_reset}" fi @@ -953,18 +1053,17 @@ bootstrap_load_settings_mode() { } bootstrap_prepare_build() { - local -i failure=0 local alt=$1 local i= mkdir $verbose_common -p ${path_build}{documents,includes,libraries/{script,shared,static},objects/{script,shared,static},programs/{script,shared,static},settings,stage} || failure=1 - if [[ $failure -eq 1 ]] ; then - if [[ $verbosity != "quiet" ]] ; then + if [[ $failure != "" ]] ; then + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then echo -e "${c_warning}WARNING: Failed to create build directories in '${c_notice}${path_build}${c_error}'.${c_reset}" fi - return $failure + return 1 fi bootstrap_id "path_headers-mode" @@ -978,19 +1077,24 @@ bootstrap_prepare_build() { fi fi - if [[ $failure -eq 1 ]] ; then - if [[ $verbosity != "quiet" ]] ; then + if [[ $failure != "" ]] ; then + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then echo -e "${c_warning}WARNING: Failed to create ${c_notice}path_heades${c_error} build directories in '${c_notice}${path_build}${c_error}'.${c_reset}" fi - return $failure + return 1 fi touch ${project_built}-${settings_name}.prepared + + if [[ $failure == "" ]] ; then + return 0 + fi + + return 1 } bootstrap_operation_build() { - local -i failure=0 local i= local n= local version_file= @@ -1260,7 +1364,7 @@ bootstrap_operation_build() { bootstrap_operation_build_prepare_remaining if [[ $build_shared == "yes" && -f ${project_built_shared}.built || $build_static == "yes" && -f ${project_built_static}.built ]] ; then - if [[ $verbosity != "quiet" ]] ; then + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then echo -e "${c_warning}WARNING: This project has already been built.${c_reset}" fi @@ -1287,7 +1391,7 @@ bootstrap_operation_build() { bootstrap_operation_build_validate_build - if [[ $failure -eq 1 ]] ; then + if [[ $failure != "" ]] ; then return 1 fi @@ -1300,7 +1404,7 @@ bootstrap_operation_build() { else mkdir $verbose_common -p ${path_build}documentation/${directory} || failure=1 - if [[ $failure -eq 0 ]] ; then + if [[ $failure == "" ]] ; then cp $verbose_common -R ${path_documentation}${i} ${path_build}documentation/${directory}/ || failure=1 fi fi @@ -1316,14 +1420,14 @@ bootstrap_operation_build() { else mkdir $verbose_common -p ${path_build}settings/${directory} || failure=1 - if [[ $failure -eq 0 ]] ; then + if [[ $failure == "" ]] ; then cp $verbose_common -R ${path_settings}${i} ${path_build}settings/${directory}/ || failure=1 fi fi done fi - if [[ $failure -eq 0 && $sources_headers != "" ]] ; then + if [[ $failure == "" && $sources_headers != "" ]] ; then if [[ $preserve_path_headers == "yes" ]] ; then for i in $sources_headers ; do directory=$(dirname $i) @@ -1335,7 +1439,7 @@ bootstrap_operation_build() { mkdir $verbose_common -p ${path_build}includes/${path_headers}${directory} || failure=1 fi - if [[ $failure -eq 0 ]] ; then + if [[ $failure == "" ]] ; then cp $verbose_common -f ${path_sources}${path_language}${i} ${path_build}includes/${path_headers}${i} || failure=1 fi fi @@ -1347,7 +1451,7 @@ bootstrap_operation_build() { fi fi - if [[ $failure -eq 0 && $build_shared == "yes" && ! -f ${project_built_shared}.built ]] ; then + if [[ $failure == "" && $build_shared == "yes" && ! -f ${project_built_shared}.built ]] ; then if [[ $sources_object != "" || $sources_object_shared != "" ]] ; then sources= let count=0 @@ -1359,13 +1463,14 @@ bootstrap_operation_build() { done if [[ $count -gt 1 ]] ; then - if [[ $verbosity != "quiet" ]] ; then + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then echo -e "${c_warning}WARNING: Multiple '${c_notice}sources_object_shared${c_warning}' found, only using the first one found is going to be used.${c_reset}" fi fi for i in $sources_object_shared ; do sources="${path_sources_object}${path_language}${i} " + break done else @@ -1374,13 +1479,14 @@ bootstrap_operation_build() { done if [[ $count -gt 1 ]] ; then - if [[ $verbosity != "quiet" ]] ; then + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then echo -e "${c_warning}WARNING: Multiple '${c_notice}sources_object${c_warning}' found, only using the first one found is going to be used.${c_reset}" fi fi for i in $sources_object ; do sources="${path_sources_object}${path_language}${i} " + break done fi @@ -1411,20 +1517,20 @@ bootstrap_operation_build() { $build_compiler $sources -shared -Wl,-soname,lib${build_name}.so${version_target} -o ${path_build}libraries/${path_library_shared}lib${build_name}.so$version_file $arguments_shared $arguments_include $libraries $libraries_shared $flags $flags_shared $flags_library $flags_library_shared $defines $defines_shared $defines_library $defines_library_shared $define_extra || failure=1 - if [[ $failure -eq 0 ]] ; then + if [[ $failure == "" ]] ; then if [[ $version_file_value != "major" ]] ; then if [[ $version_file_value == "minor" ]] ; then ln $verbose_common -sf lib${build_name}.so${version_file} ${path_build}libraries/${path_library_shared}lib${build_name}.so${version_major_prefix}${version_major} || failure=1 else ln $verbose_common -sf lib${build_name}.so${version_major_prefix}${version_major}${version_minor_prefix}${version_minor} ${path_build}libraries/${path_library_shared}lib${build_name}.so${version_major_prefix}${version_major} || failure=1 - if [[ $failure -eq 0 ]] ; then + if [[ $failure == "" ]] ; then if [[ $version_file_value == "micro" ]] ; then ln $verbose_common -sf lib$build_name.so$version_file ${path_build}libraries/${path_library_shared}lib$build_name.so$version_major_prefix$version_major$version_minor_prefix$version_minor || failure=1 else ln $verbose_common -sf lib${build_name}.so${version_major_prefix}${version_major}${version_minor_prefix}${version_minor}${version_micro_prefix}${version_micro} ${path_build}libraries/${path_library_shared}lib${build_name}.so${version_major_prefix}${version_major}${version_minor_prefix}${version_minor} || failure=1 - if [[ $failure -eq 0 ]] ; then + if [[ $failure == "" ]] ; then ln $verbose_common -sf lib${build_name}.so${version_file} ${path_build}libraries/${path_library_shared}lib${build_name}.so${version_major_prefix}${version_major}${version_minor_prefix}${version_minor_prefix}${version_minor}${version_micro_prefix}${version_micro} || failure=1 fi fi @@ -1432,13 +1538,13 @@ bootstrap_operation_build() { fi fi - if [[ $failure -eq 0 ]] ; then + if [[ $failure == "" ]] ; then ln ${verbose_common} -sf lib${build_name}.so${version_major_prefix}${version_major} ${path_build}libraries/${path_library_shared}lib${build_name}.so || failure=1 fi fi fi - if [[ $failure -eq 0 && $sources_program != "" ]] ; then + if [[ $failure == "" && $sources_program != "" ]] ; then sources= links= @@ -1463,12 +1569,12 @@ bootstrap_operation_build() { $build_compiler $sources -o ${path_build}programs/${path_program_shared}${build_name} $arguments_shared $arguments_include $links $libraries $libraries_shared $flags $flags_shared $flags_program $flags_program_shared $defines $defines_shared $defines_program $defines_program_shared $define_extra || failure=1 fi - if [[ $failure -eq 0 ]] ; then + if [[ $failure == "" ]] ; then touch ${project_built_shared}-${settings_name}.built fi fi - if [[ $failure -eq 0 && $build_static == "yes" && ! -f ${project_built_static}.built ]] ; then + if [[ $failure == "" && $build_static == "yes" && ! -f ${project_built_static}.built ]] ; then if [[ $sources_object != "" || $sources_object_static != "" ]] ; then let count=0 @@ -1479,13 +1585,14 @@ bootstrap_operation_build() { done if [[ $count -gt 1 ]] ; then - if [[ $verbosity != "quiet" ]] ; then + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then echo -e "${c_warning}WARNING: Multiple '${c_notice}sources_object_static${c_warning}' found, only using the first one found is going to be used.${c_reset}" fi fi for i in $sources_object_static ; do sources="${path_sources_object}${path_language}${i} " + break done else @@ -1494,13 +1601,14 @@ bootstrap_operation_build() { done if [[ $count -gt 1 ]] ; then - if [[ $verbosity != "quiet" ]] ; then + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then echo -e "${c_warning}WARNING: Multiple '${c_notice}sources_object${c_warning}' found, only using the first one found is going to be used.${c_reset}" fi fi for i in $sources_object ; do sources="${path_sources_object}${path_language}${i} " + break done fi @@ -1544,12 +1652,12 @@ bootstrap_operation_build() { $build_compiler ${path_sources}${path_language}${i} -c -static -o ${path_build}objects/${directory}/${n}.o $arguments_static $arguments_include $libraries $libraries_static $flags $flags_static $flags_library $flags_library_static $defines $defines_static $defines_library $defines_library_static $define_extra || failure=1 - if [[ $failure -eq 1 ]] ; then + if [[ $failure != "" ]] ; then break; fi done - if [[ $failure -eq 0 && ( $sources_library != "" || $sources_library_static != "" ) ]] ; then + if [[ $failure == "" && ( $sources_library != "" || $sources_library_static != "" ) ]] ; then if [[ $verbosity == "verbose" ]] ; then echo $build_indexer $build_indexer_arguments ${path_build}libraries/${path_library_static}lib${build_name}.a $sources @@ -1559,7 +1667,7 @@ bootstrap_operation_build() { fi fi - if [[ $failure -eq 0 && $sources_program != "" ]] ; then + if [[ $failure == "" && $sources_program != "" ]] ; then sources= links= @@ -1584,18 +1692,28 @@ bootstrap_operation_build() { $build_compiler $sources -static -o ${path_build}programs/${path_program_static}${build_name} $arguments_static $arguments_include $links $libraries $libraries_static $flags $flags_static $flags_program $flags_program_static $defines $defines_static $defines_program $defines_program_static $define_extra || failure=1 fi - if [[ $failure -eq 0 ]] ; then + if [[ $failure == "" ]] ; then touch ${project_built_static}-${settings_name}.built fi fi - if [[ $failure -eq 1 ]] ; then + if [[ $failure != "" ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: Failed to build.${c_reset}" fi + let failure=1 + return 1 fi + + if [[ $failure == "" ]] ; then + return 0 + fi + + return 1 } bootstrap_operation_build_prepare_defaults() { @@ -2646,6 +2764,8 @@ bootstrap_operation_build_validate_build() { if [[ $build_compiler == "" ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: Cannot Build, no '${c_notice}build_compiler${c_error}' specified, such as '${c_notice}gcc${c_error}'.${c_reset}" fi @@ -2654,30 +2774,48 @@ bootstrap_operation_build_validate_build() { if [[ $build_indexer == "" ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: Cannot Build, no '${c_notice}build_indexer${c_error}' specified, such as '${c_notice}ar${c_error}'.${c_reset}" fi let failure=1 fi + + if [[ $failure == "" ]] ; then + return 0 + fi + + return 1 } bootstrap_operation_build_validate_paths() { if [[ $path_sources == "" || ! -d $path_sources ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: The sources directory ${c_notice}${path_sources}${c_error} is not a valid directory.${c_reset}" fi let failure=1 fi - if [[ $failure -eq 0 && $path_sources_object != "" && ! -d $path_sources_object ]] ; then + if [[ $failure == "" && $path_sources_object != "" && ! -d $path_sources_object ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: The sources object directory ${c_notice}${path_sources_object}${c_error} is not a valid directory.${c_reset}" fi let failure=1 fi + + if [[ $failure == "" ]] ; then + return 0 + fi + + return 1 } bootstrap_operation_build_validate_search() { @@ -2692,6 +2830,8 @@ bootstrap_operation_build_validate_shared_static() { if [[ $build_shared != "yes" && $build_static != "yes" ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: Cannot Build, either build_shared or build_static must be set to 'yes'.${c_reset}" fi @@ -2700,11 +2840,19 @@ bootstrap_operation_build_validate_shared_static() { if [[ $search_shared != "yes" && $search_static != "yes" ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: Cannot Build, either search_shared or search_static must be set to 'yes'.${c_reset}" fi let failure=1 fi + + if [[ $failure == "" ]] ; then + return 0 + fi + + return 1 } bootstrap_operation_build_validate_sources() { @@ -2712,6 +2860,8 @@ bootstrap_operation_build_validate_sources() { for i in $sources_script ; do if [[ $i != "$(echo $i | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_script path provided: '${i}'.${c_reset}" fi @@ -2722,6 +2872,8 @@ bootstrap_operation_build_validate_sources() { for i in $sources_headers ; do if [[ $i != "$(echo $i | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_headers path provided: '${i}'.${c_reset}" fi @@ -2732,6 +2884,8 @@ bootstrap_operation_build_validate_sources() { for i in $sources_library ; do if [[ $i != "$(echo $i | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_library path provided: '${i}'.${c_reset}" fi @@ -2742,6 +2896,8 @@ bootstrap_operation_build_validate_sources() { for i in $sources_library_object ; do if [[ $i != "$(echo $i | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_library_object path provided: '${i}'.${c_reset}" fi @@ -2752,6 +2908,8 @@ bootstrap_operation_build_validate_sources() { for i in $sources_program_object ; do if [[ $i != "$(echo $i | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_program_object path provided: '${i}'.${c_reset}" fi @@ -2762,6 +2920,8 @@ bootstrap_operation_build_validate_sources() { for i in $sources_program ; do if [[ $i != "$(echo $i | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_program path provided: '${i}'.${c_reset}" fi @@ -2772,6 +2932,8 @@ bootstrap_operation_build_validate_sources() { for i in $sources_documentation ; do if [[ $i != "$(echo $i | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_documentation path provided: '${i}'.${c_reset}" fi @@ -2782,12 +2944,20 @@ bootstrap_operation_build_validate_sources() { for i in $sources_setting ; do if [[ $i != "$(echo $i | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then if [[ $verbosity != "quiet" ]] ; then + bootstrap_print_first + echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_setting path provided: '${i}'.${c_reset}" fi let failure=1 fi done + + if [[ $failure == "" ]] ; then + return 0 + fi + + return 1 } bootstrap_operation_build_prepare_versions() { @@ -2871,8 +3041,25 @@ bootstrap_operation_clean() { fi } +bootstrap_print_first() { + + if [[ $print_line_first == "yes" ]] ; then + echo + + print_line_first= + fi +} + +bootstrap_print_last() { + + if [[ $print_line_last == "yes" ]] ; then + echo + fi +} + bootstrap_cleanup() { + unset bootstrap_copyright unset bootstrap_main unset bootstrap_handle_colors unset bootstrap_help @@ -2900,6 +3087,8 @@ bootstrap_cleanup() { unset bootstrap_operation_build_validate_shared_static unset bootstrap_operation_build_validate_sources unset bootstrap_operation_clean + unset bootstrap_print_first + unset bootstrap_print_last unset bootstrap_cleanup } diff --git a/build/scripts/install.sh b/build/scripts/install.sh index d03fcce..1ec62f1 100644 --- a/build/scripts/install.sh +++ b/build/scripts/install.sh @@ -43,6 +43,7 @@ install_main() { local c_subtle="\\033[1;30m" local c_prefix="\\" + local failure= local operation= local operation_failure= local verbosity=normal @@ -131,7 +132,7 @@ install_main() { verbose_common="-v" elif [[ $p == "+v" || $p == "++version" ]] ; then echo $version - return + return 0 elif [[ $p == "-b" || $p == "--build" ]] ; then grab_next=path_build elif [[ $p == "-P" || $p == "--prefix" ]] ; then @@ -222,6 +223,11 @@ install_main() { p= fi + if [[ $verbosity == "quiet" ]] ; then + print_line_first="no" + print_line_last="no" + fi + install_handle_colors if [[ $do_help == "yes" ]] ; then @@ -240,15 +246,11 @@ install_main() { if [[ $operation_failure == "fail-unsupported" ]] ; then if [[ $verbosity != "quiet" ]] ; then - if [[ $print_line_first == "yes" ]] ; then - echo - fi + install_print_first echo -e "${c_error}ERROR: The operation ${c_notice}$operation${c_error} was not recognized.${c_reset}" - if [[ $print_line_last == "yes" ]] ; then - echo - fi + install_print_last fi install_cleanup @@ -258,15 +260,11 @@ install_main() { if [[ ! -d $path_build ]] ; then if [[ $verbosity != "quiet" ]] ; then - if [[ $print_line_first == "yes" ]] ; then - echo - fi + install_print_first echo -e "${c_error}ERROR: The build path ${c_notice}$path_build${c_error} is not a valid directory.${c_reset}" - if [[ $print_line_last == "yes" ]] ; then - echo - fi + install_print_last fi install_cleanup @@ -276,15 +274,11 @@ install_main() { if [[ $work == "" && $destination_prefix != "" && ! -d $destination_prefix ]] ; then if [[ $verbosity != "quiet" ]] ; then - if [[ $print_line_first == "yes" ]] ; then - echo - fi + install_print_first echo -e "${c_error}ERROR: The destination prefix ${c_notice}$destination_prefix${c_error} is not a valid directory.${c_reset}" - if [[ $print_line_last == "yes" ]] ; then - echo - fi + install_print_last fi install_cleanup @@ -348,15 +342,11 @@ install_main() { if [[ $work != "" && ! -d $work ]] ; then if [[ $verbosity != "quiet" ]] ; then - if [[ $print_line_first == "yes" ]] ; then - echo - fi + install_print_first echo -e "${c_error}ERROR: The work directory ${c_notice}$work${c_error} is not a valid directory.${c_reset}" - if [[ $print_line_last == "yes" ]] ; then - echo - fi + install_print_last fi install_cleanup @@ -366,15 +356,11 @@ install_main() { if [[ $work == "" && -e $destination_programs && ! -d $destination_programs ]] ; then if [[ $verbosity != "quiet" ]] ; then - if [[ $print_line_first == "yes" ]] ; then - echo - fi + install_print_first echo -e "${c_error}ERROR: The destination bindir ${c_notice}$destination_programs${c_error} is not a valid directory.${c_reset}" - if [[ $print_line_last == "yes" ]] ; then - echo - fi + install_print_last fi install_cleanup @@ -384,15 +370,11 @@ install_main() { if [[ $work == "" && -e $destination_programs_static && ! -d $destination_programs_static ]] ; then if [[ $verbosity != "quiet" ]] ; then - if [[ $print_line_first == "yes" ]] ; then - echo - fi + install_print_first echo -e "${c_error}ERROR: The destination (${c_notice}static${c_error}) bindir ${c_notice}$destination_programs_static${c_error} is not a valid directory.${c_reset}" - if [[ $print_line_last == "yes" ]] ; then - echo - fi + install_print_last fi install_cleanup @@ -402,15 +384,11 @@ install_main() { if [[ $work == "" && -e $destination_programs_shared && ! -d $destination_programs_shared ]] ; then if [[ $verbosity != "quiet" ]] ; then - if [[ $print_line_first == "yes" ]] ; then - echo - fi + install_print_first echo -e "${c_error}ERROR: The destination (${c_notice}shared${c_error}) bindir ${c_notice}$destination_programs_shared${c_error} is not a valid directory.${c_reset}" - if [[ $print_line_last == "yes" ]] ; then - echo - fi + install_print_last fi install_cleanup @@ -420,15 +398,11 @@ install_main() { if [[ $work == "" && -e $destination_includes && ! -d $destination_includes ]] ; then if [[ $verbosity != "quiet" ]] ; then - if [[ $print_line_first == "yes" ]] ; then - echo - fi + install_print_first echo -e "${c_error}ERROR: The destination incluedir ${c_notice}$destination_includes${c_error} is not a valid directory.${c_reset}" - if [[ $print_line_last == "yes" ]] ; then - echo - fi + install_print_last fi install_cleanup @@ -438,15 +412,11 @@ install_main() { if [[ $work == "" && -e $destination_libraries_static && ! -d $destination_libraries_static ]] ; then if [[ $verbosity != "quiet" ]] ; then - if [[ $print_line_first == "yes" ]] ; then - echo - fi + install_print_first echo -e "${c_error}ERROR: The destination (${c_notice}static${c_error}) libdir ${c_notice}$destination_libraries_static${c_error} is not a valid directory.${c_reset}" - if [[ $print_line_last == "yes" ]] ; then - echo - fi + install_print_last fi install_cleanup @@ -456,15 +426,11 @@ install_main() { if [[ $work == "" && -e $destination_libraries_shared && ! -d $destination_libraries_shared ]] ; then if [[ $verbosity != "quiet" ]] ; then - if [[ $print_line_first == "yes" ]] ; then - echo - fi + install_print_first echo -e "${c_error}ERROR: The destination (${c_notice}shared${c_error}) libdir ${c_notice}$destination_libraries_shared${c_error} is not a valid directory.${c_reset}" - if [[ $print_line_last == "yes" ]] ; then - echo - fi + install_print_last fi install_cleanup @@ -474,9 +440,19 @@ install_main() { install_perform_install + if [[ $verbosity != "quiet" ]] ; then + if [[ $failure != "" || $verbosity != "error" ]] ; then + install_print_last + fi + fi + install_cleanup - return 0 + if [[ $failure == "" ]] ; then + return 0 + fi + + return 1 } install_handle_colors() { @@ -503,9 +479,7 @@ install_handle_colors() { install_help() { - if [[ $print_line_first == "yes" ]] ; then - echo - fi + install_print_first echo -e "${c_title}${public_name}${c_reset}" echo -e " ${c_notice}Version ${version}${c_reset}" @@ -555,16 +529,12 @@ install_help() { echo -e " --${c_important}programs-static${c_reset} Custom destination for static programs." echo -e " --${c_important}programs-shared${c_reset} Custom destination for shared programs." - if [[ $print_line_last == "yes" ]] ; then - echo - fi + install_print_last } install_copyright() { - if [[ $print_line_first == "yes" ]] ; then - echo - fi + install_print_first echo "Copyright © 2007-2023 Kevin Day." echo @@ -572,16 +542,13 @@ install_copyright() { echo "Standard and specification license open-standard-license-1.0." echo "Documentation license cc-by-sa-4.0." - if [[ $print_line_last == "yes" ]] ; then - echo - fi + install_print_last } install_perform_install() { local key= local i= local path= - local failure= local message= if [[ $enable_shared == "no" ]] ; then @@ -610,21 +577,17 @@ install_perform_install() { destination_settings=${work}settings/ fi - if [[ $verbosity != "quiet" && $print_line_first == "yes" ]] ; then - echo - fi - - print_line_first="done" - if [[ ! -d ${destination_prefix} ]] ; then mkdir $verbose_common ${destination_prefix} if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + install_print_first + echo -e "${c_error}ERROR: Failed to create install ${message} ${c_notice}${destination_prefix}${c_error}.${c_reset}" fi - failure=1 + let failure=1 fi fi @@ -634,10 +597,12 @@ install_perform_install() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + install_print_first + echo -e "${c_error}ERROR: Failed to create install ${message} ${c_notice}${destination_programs}${c_error}.${c_reset}" fi - failure=1 + let failure=1 fi fi @@ -646,10 +611,12 @@ install_perform_install() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + install_print_first + echo -e "${c_error}ERROR: Failed to create install ${message} ${c_notice}${destination_programs_shared}${c_error}.${c_reset}" fi - failure=1 + let failure=1 fi fi @@ -658,10 +625,12 @@ install_perform_install() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + install_print_first + echo -e "${c_error}ERROR: Failed to create install ${message} ${c_notice}${destination_programs_static}${c_error}.${c_reset}" fi - failure=1 + let failure=1 fi fi fi @@ -672,10 +641,12 @@ install_perform_install() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + install_print_first + echo -e "${c_error}ERROR: Failed to create install ${message} ${c_notice}${destination_libraries}${c_error}.${c_reset}" fi - failure=1 + let failure=1 fi fi @@ -684,10 +655,12 @@ install_perform_install() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + install_print_first + echo -e "${c_error}ERROR: Failed to create ${message} ${c_notice}${destination_libraries_shared}${c_error}.${c_reset}" fi - failure=1 + let failure=1 fi fi @@ -696,10 +669,12 @@ install_perform_install() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + install_print_first + echo -e "${c_error}ERROR: Failed to create ${message} ${c_notice}${destination_libraries_static}${c_error}.${c_reset}" fi - failure=1 + let failure=1 fi fi fi @@ -710,10 +685,12 @@ install_perform_install() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + install_print_first + echo -e "${c_error}ERROR: Failed to create ${message} ${c_notice}${destination_includes}${c_error}.${c_reset}" fi - failure=1 + let failure=1 fi fi fi @@ -724,10 +701,12 @@ install_perform_install() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + install_print_first + echo -e "${c_error}ERROR: Failed to create ${message} ${c_notice}${destination_documentation}${c_error}.${c_reset}" fi - failure=1 + let failure=1 fi fi fi @@ -738,10 +717,12 @@ install_perform_install() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + install_print_first + echo -e "${c_error}ERROR: Failed to create ${message} ${c_notice}${destination_settings}${c_error}.${c_reset}" fi - failure=1 + let failure=1 fi fi fi @@ -759,8 +740,8 @@ install_perform_install() { fi if [[ $file != "" ]] ; then - if [[ $verbosity != "quiet" ]] ; then - install_print_first + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + install_print_first_or_always echo -e "${c_highlight}Installing Includes to: ${c_reset}${c_notice}${destination_includes}${c_reset}${c_highlight}.${c_reset}" fi @@ -769,10 +750,12 @@ install_perform_install() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + install_print_first + echo -e "${c_error}ERROR: Failed to copy include files from ${c_notice}${path_build}${path_includes}${c_error} to ${c_notice}${destination_includes}${c_error}.${c_reset}" fi - failure=1 + let failure=1 fi fi fi @@ -791,8 +774,8 @@ install_perform_install() { fi if [[ $file != "" ]] ; then - if [[ $verbosity != "quiet" ]] ; then - install_print_first + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + install_print_first_or_always echo -e "${c_highlight}Installing (${c_notice}static${c_highlight}) Libraries to: ${c_reset}${c_notice}${destination_libraries_static}${c_reset}${c_highlight}.${c_reset}" fi @@ -801,10 +784,12 @@ install_perform_install() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + install_print_first + echo -e "${c_error}ERROR: Failed to copy (${c_notice}static${c_error}) library files from ${c_notice}${path_build}${path_libraries}${path_static}${c_error} to ${c_notice}${destination_libraries_static}${c_error}.${c_reset}" fi - failure=1 + let failure=1 fi fi fi @@ -822,8 +807,8 @@ install_perform_install() { fi if [[ $file != "" ]] ; then - if [[ $verbosity != "quiet" ]] ; then - install_print_first + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + install_print_first_or_always echo -e "${c_highlight}Installing (${c_notice}shared${c_highlight}) Libraries to: ${c_reset}${c_notice}${destination_libraries_shared}${c_reset}${c_highlight}.${c_reset}" fi @@ -832,10 +817,12 @@ install_perform_install() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + install_print_first + echo -e "${c_error}ERROR: Failed to copy (${c_notice}shared${c_error}) library files from ${c_notice}${path_build}${path_libraries}${path_shared}${c_error} to ${c_notice}${destination_libraries_shared}${c_error}.${c_reset}" fi - failure=1 + let failure=1 fi fi fi @@ -855,8 +842,8 @@ install_perform_install() { fi if [[ $file != "" && $enable_static_programs == "yes" ]] ; then - if [[ $verbosity != "quiet" ]] ; then - install_print_first + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + install_print_first_or_always echo -e "${c_highlight}Installing (${c_notice}static${c_highlight}) Programs to: ${c_reset}${c_notice}${destination_programs_static}${c_reset}${c_highlight}.${c_reset}" fi @@ -865,10 +852,12 @@ install_perform_install() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + install_print_first + echo -e "${c_error}ERROR: failed to copy (${c_notice}static${c_error}) program files from ${c_notice}${path_build}${path_programs}${path_static}${c_error} to ${c_notice}${destination_programs_static}${c_error}.${c_reset}" fi - failure=1 + let failure=1 fi fi fi @@ -886,8 +875,8 @@ install_perform_install() { fi if [[ $file != "" ]] ; then - if [[ $verbosity != "quiet" ]] ; then - install_print_first + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + install_print_first_or_always echo -e "${c_highlight}Installing (${c_notice}shared${c_highlight}) Programs to: ${c_reset}${c_notice}${destination_programs_shared}${c_reset}${c_highlight}.${c_reset}" fi @@ -896,16 +885,18 @@ install_perform_install() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + install_print_first + echo -e "${c_error}ERROR: failed to copy (${c_notice}shared${c_error}) program files from ${c_notice}${path_build}${path_programs}${path_shared}${c_error} to ${c_notice}${destination_programs_shared}${c_error}.${c_reset}" fi - failure=1 + let failure=1 fi fi fi fi - if [[ $failure == "" && -d ${path_build}${path_settings} && $verbosity != "quiet" ]] ; then + if [[ $failure == "" && -d ${path_build}${path_settings} && $enable_settings == "yes" ]] ; then for i in ${path_build}${path_settings}* ; do file=$(echo $i | sed -e "s|^${path_build}${path_settings}||") @@ -918,20 +909,22 @@ install_perform_install() { fi if [[ $file != "" ]] ; then - if [[ $verbosity != "quiet" ]] ; then - install_print_first + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + install_print_first_or_always - echo -e "${c_highlight}Installing Documentation to: ${c_reset}${c_notice}${destination_settings}${c_reset}${c_highlight}.${c_reset}" + echo -e "${c_highlight}Installing Settings to: ${c_reset}${c_notice}${destination_settings}${c_reset}${c_highlight}.${c_reset}" fi cp $verbose_common -R ${path_build}${path_settings}* ${destination_settings} if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo -e "${c_error}ERROR: failed to copy documentation files from ${c_notice}${path_build}${path_programs}${path_static}${c_error} to ${c_notice}${destination_settings}${c_error}.${c_reset}" + install_print_first + + echo -e "${c_error}ERROR: failed to copy settings files from ${c_notice}${path_build}${path_settings}${c_error} to ${c_notice}${destination_settings}${c_error}.${c_reset}" fi - failure=1 + let failure=1 fi fi fi @@ -949,8 +942,8 @@ install_perform_install() { fi if [[ $file != "" ]] ; then - if [[ $verbosity != "quiet" ]] ; then - install_print_first + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + install_print_first_or_always echo -e "${c_highlight}Installing Documentation to: ${c_reset}${c_notice}${destination_documentation}${c_reset}${c_highlight}.${c_reset}" fi @@ -959,34 +952,52 @@ install_perform_install() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo -e "${c_error}ERROR: failed to copy documentation files from ${c_notice}${path_build}${path_programs}${path_static}${c_error} to ${c_notice}${destination_documentation}${c_error}.${c_reset}" + install_print_first + + echo -e "${c_error}ERROR: failed to copy documentation files from ${c_notice}${path_build}${path_documentation}${c_error} to ${c_notice}${destination_documentation}${c_error}.${c_reset}" fi - failure=1 + let failure=1 fi fi fi - if [[ $verbosity != "quiet" && $print_line_last == "yes" ]] ; then - echo + if [[ $failure == "" ]] ; then + return 0 fi - if [[ $failure != "" ]] ; then - install_cleanup + return 1 +} + +install_print_first() { + + if [[ $print_line_first == "yes" ]] ; then + echo - exit $failure + print_line_first= fi } -install_print_first() { +install_print_first_or_always() { - if [[ $print_line_first == "done" ]] ; then + if [[ $print_line_first == "yes" ]] ; then + echo + + print_line_first= + elif [[ $print_line_first == "no" ]] ; then print_line_first= else echo fi } +install_print_last() { + + if [[ $print_line_last == "yes" ]] ; then + echo + fi +} + install_cleanup() { unset install_copyright @@ -995,7 +1006,8 @@ install_cleanup() { unset install_help unset install_perform_install unset install_print_first - + unset install_print_first_or_always + unset install_print_last unset install_cleanup } diff --git a/build/scripts/package.sh b/build/scripts/package.sh index be431ea..ade8d01 100644 --- a/build/scripts/package.sh +++ b/build/scripts/package.sh @@ -25,6 +25,7 @@ package_main() { local grab_next= local do_color=dark local do_help= + local do_copyright= local i=0 local p= local t=0 @@ -40,6 +41,7 @@ package_main() { local c_prefix="\\" local -A variables=() + local failure= local operation= local operation_failure= local mode_individual= @@ -51,6 +53,8 @@ package_main() { local path_destination=package/ local path_sources=./ local prepend= + local print_line_first="yes" + local print_line_last="yes" local verbosity=normal local verbose= local verbose_common= @@ -71,6 +75,8 @@ package_main() { if [[ $grab_next == "" ]] ; then if [[ $p == "-h" || $p == "--help" ]] ; then do_help=yes + elif [[ $p == "+C" || $p == "++copyright" ]] ; then + do_copyright="yes" elif [[ $p == "+d" || $p == "++dark" ]] ; then do_color=dark context="+d" @@ -80,9 +86,13 @@ package_main() { elif [[ $p == "+n" || $p == "++no_color" ]] ; then do_color=none context="+n" - elif [[ $p == "+q" || $p == "++quiet" ]] ; then + elif [[ $p == "+Q" || $p == "++quiet" ]] ; then verbosity="quiet" - verbose="+q" + verbose="+Q" + verbose_common= + elif [[ $p == "+E" || $p == "++error" ]] ; then + verbosity="error" + verbose="+E" verbose_common= elif [[ $p == "+N" || $p == "++normal" ]] ; then verbosity= @@ -98,7 +108,7 @@ package_main() { verbose_common="-v" elif [[ $p == "+v" || $p == "++version" ]] ; then echo $version - return + return 0 elif [[ $p == "-b" || $p == "--build" ]] ; then grab_next=path_build elif [[ $p == "-d" || $p == "--destination" ]] ; then @@ -145,6 +155,11 @@ package_main() { p= fi + if [[ $verbosity == "quiet" ]] ; then + print_line_first="no" + print_line_last="no" + fi + package_handle_colors if [[ $do_help == "yes" ]] ; then @@ -154,9 +169,20 @@ package_main() { return 0 fi + if [[ $do_copyright == "yes" ]] ; then + package_copyright + package_cleanup + + return 0 + fi + if [[ $operation_failure == "fail-multiple" ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Only one operation may be specified at a time.${c_reset}" + + package_print_last fi package_cleanup @@ -175,7 +201,11 @@ package_main() { if [[ ! -f build/stand_alone/$i.settings ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Unknown or unsupported stand alone program '${c_notice}$i${c_error}'.${c_reset}" + + package_print_last fi package_cleanup @@ -197,7 +227,11 @@ package_main() { if [[ $operation == "build" || $operation == "rebuild" ]] ; then if [[ ! -d $path_build ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Build directory '${c_notice}$path_build${c_error}' is invalid or missing.${c_reset}" + + package_print_last fi package_cleanup @@ -207,9 +241,14 @@ package_main() { if [[ ! -d $path_destination ]] ; then mkdir $verbose_common -p $path_destination + if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Package directory '${c_notice}$path_destination${c_error}' is invalid or could not be created.${c_reset}" + + package_print_last fi package_cleanup @@ -220,7 +259,11 @@ package_main() { if [[ ! -d $path_sources ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Sources directory '${c_notice}$path_sources${c_error}' is invalid or missing.${c_reset}" + + package_print_last fi package_cleanup @@ -230,7 +273,11 @@ package_main() { if [[ ! -d ${path_sources}level_0/ ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Build sources directory '${c_notice}${path_sources}level_0/${c_error}' is invalid or missing.${c_reset}" + + package_print_last fi package_cleanup @@ -240,7 +287,11 @@ package_main() { if [[ ! -d ${path_sources}level_1/ ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Build sources directory '${c_notice}${path_sources}level_1/${c_error}' is invalid or missing.${c_reset}" + + package_print_last fi package_cleanup @@ -250,7 +301,11 @@ package_main() { if [[ ! -d ${path_sources}level_2/ ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Build sources directory '${c_notice}${path_sources}level_2/${c_error}' is invalid or missing.${c_reset}" + + package_print_last fi package_cleanup @@ -260,7 +315,11 @@ package_main() { if [[ ! -d ${path_sources}level_3/ ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Build sources directory '${c_notice}${path_sources}level_3/${c_error}' is invalid or missing.${c_reset}" + + package_print_last fi package_cleanup @@ -271,8 +330,8 @@ package_main() { if [[ $operation == "rebuild" ]] ; then package_operation_clean - if [[ $failure -ne 0 ]] ; then - return 1 + if [[ $? -ne 0 ]] ; then + failure=1 fi fi @@ -280,29 +339,53 @@ package_main() { mode_individual="yes" fi - if [[ $mode_individual == "yes" ]] ; then + if [[ $failure == "" && $mode_individual == "yes" ]] ; then package_operation_individual + + if [[ $? -ne 0 ]] ; then + failure=1 + fi fi - if [[ $mode_level == "yes" ]] ; then + if [[ $failure == "" && $mode_level == "yes" ]] ; then package_operation_level + + if [[ $? -ne 0 ]] ; then + failure=1 + fi fi - if [[ $mode_monolithic == "yes" ]] ; then + if [[ $failure == "" && $mode_monolithic == "yes" ]] ; then package_operation_monolithic + + if [[ $? -ne 0 ]] ; then + failure=1 + fi fi - if [[ $mode_program == "yes" ]] ; then + if [[ $failure == "" && $mode_program == "yes" ]] ; then package_operation_program + + if [[ $? -ne 0 ]] ; then + failure=1 + fi fi - if [[ $mode_stand_alone != "" ]] ; then + if [[ $failure == "" && $mode_stand_alone != "" ]] ; then package_operation_stand_alone + + if [[ $? -ne 0 ]] ; then + failure=1 + fi fi elif [[ $operation == "dependencies" ]] ; then if [[ ! -d $path_sources ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Sources directory '${c_notice}${path_sources}${c_error}' is invalid or missing.${c_reset}" + + package_print_last fi package_cleanup @@ -313,8 +396,12 @@ package_main() { package_operation_dependencies elif [[ $operation == "clean" ]] ; then if [[ ! -d $path_destination ]] ; then - if [[ $verbosity != "quiet" ]] ; then + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + package_print_first + echo -e "${c_warning}WARNING: Package directory '${c_notice}${path_destination}${c_error}' does not exist, there is nothing to clean.${c_reset}" + + package_print_last fi package_cleanup @@ -325,7 +412,11 @@ package_main() { package_operation_clean elif [[ $operation == "" ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: No operation was given.${c_reset}" + + package_print_last fi package_cleanup @@ -333,7 +424,11 @@ package_main() { return 1 else if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: The operation ${c_notice}${operation}${c_error} was not recognized.${c_reset}" + + package_print_last fi package_cleanup @@ -341,14 +436,19 @@ package_main() { return 1 fi - # Always append a new line at the end. if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $failure != "" || $verbosity != "error" ]] ; then + package_print_last + fi fi package_cleanup - return 0 + if [[ $failure == "" ]] ; then + return 0 + fi + + return 1 } package_handle_colors() { @@ -375,7 +475,8 @@ package_handle_colors() { package_help() { - echo + package_print_first + echo -e "${c_title}${public_name}${c_reset}" echo -e " ${c_notice}Version ${version}${c_reset}" echo @@ -386,15 +487,17 @@ package_help() { echo -e " ${c_important}rebuild${c_reset} Delete all built packages then build the package." echo echo -e "${c_highlight}Options:${c_reset}" - echo -e " -${c_important}h${c_reset}, --${c_important}help${c_reset} Print this help screen." - echo -e " +${c_important}d${c_reset}, ++${c_important}dark${c_reset} Use color modes that show up better on dark backgrounds." - echo -e " +${c_important}l${c_reset}, ++${c_important}light${c_reset} Use color modes that show up better on light backgrounds." - echo -e " +${c_important}n${c_reset}, ++${c_important}no_color${c_reset} Do not use color." - echo -e " +${c_important}q${c_reset}, ++${c_important}quiet${c_reset} Decrease verbosity, silencing most output." - echo -e " +${c_important}N${c_reset}, ++${c_important}normal${c_reset} Set verbosity to normal." - echo -e " +${c_important}V${c_reset}, ++${c_important}verbose${c_reset} Increase verbosity beyond normal output." - echo -e " +${c_important}D${c_reset}, ++${c_important}debug${c_reset} Enable debugging, significantly increasing verbosity beyond normal output." - echo -e " +${c_important}v${c_reset}, ++${c_important}version${c_reset} Print the version number of this program." + echo -e " -${c_important}h${c_reset}, --${c_important}help${c_reset} Print this help message." + echo -e " +${c_important}C${c_reset}, ++${c_important}copyright${c_reset} Print the copyright." + echo -e " +${c_important}d${c_reset}, ++${c_important}dark${c_reset} Output using colors that show up better on dark backgrounds." + echo -e " +${c_important}l${c_reset}, ++${c_important}light${c_reset} Output using colors that show up better on light backgrounds." + echo -e " +${c_important}n${c_reset}, ++${c_important}no_color${c_reset} Do not print using color." + echo -e " +${c_important}Q${c_reset}, ++${c_important}quiet${c_reset} Decrease verbosity, silencing most print.to." + echo -e " +${c_important}E${c_reset}, ++${c_important}error${c_reset} Decrease verbosity, using only error print.to." + echo -e " +${c_important}N${c_reset}, ++${c_important}normal${c_reset} Set verbosity to normal." + echo -e " +${c_important}V${c_reset}, ++${c_important}verbose${c_reset} Increase verbosity beyond normal print.to." + echo -e " +${c_important}D${c_reset}, ++${c_important}debug${c_reset} Enable debugging, significantly increasing verbosity beyond normal print.to." + echo -e " +${c_important}v${c_reset}, ++${c_important}version${c_reset} Print only the version number." echo echo -e "${c_highlight}Package Options:${c_reset}" echo -e " -${c_important}d${c_reset}, --${c_important}destination${c_reset} Specify a custom package destination directory." @@ -409,6 +512,19 @@ package_help() { echo } +package_copyright() { + + package_print_first + + echo "Copyright © 2007-2023 Kevin Day." + echo + echo "Source code license lgpl-2.1-or-later." + echo "Standard and specification license open-standard-license-1.0." + echo "Documentation license cc-by-sa-4.0." + + package_print_last +} + package_create_base_files() { if [[ ! -d $package ]] ; then @@ -416,6 +532,8 @@ package_create_base_files() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${package}${c_error}.${c_reset}" fi @@ -425,6 +543,8 @@ package_create_base_files() { if [[ $failure == "" && ! -d ${path_build}documents ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: The build directory ${c_notice}${path_build}documents${c_error} cannot be found or is invalid.${c_reset}" fi @@ -436,6 +556,8 @@ package_create_base_files() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to copy directory ${c_notice}${path_build}documents${c_error} to ${c_notice}$package${c_error}.${c_reset}" fi @@ -449,6 +571,8 @@ package_create_base_files() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to copy directory ${c_notice}${path_build}licenses${c_error} to ${c_notice}${package}${c_error}.${c_reset}" fi @@ -459,6 +583,8 @@ package_create_base_files() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to copy directory ${c_notice}${path_build}../licenses${c_error} to ${c_notice}${package}${c_error}.${c_reset}" fi @@ -466,6 +592,8 @@ package_create_base_files() { fi else if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Neither directory ${c_notice}${path_build}licenses${c_error} nor ${c_notice}${path_build}../licenses${c_error} can be found or are invalid.${c_reset}" fi @@ -478,6 +606,8 @@ package_create_base_files() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to copy script ${c_notice}${path_build}bootstrap.sh${c_error} to ${c_notice}${package}${c_error}.${c_reset}" fi @@ -489,6 +619,8 @@ package_create_base_files() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to set executable permissions on script ${c_notice}${package}bootstrap.sh${c_error}.${c_reset}" fi @@ -501,6 +633,8 @@ package_create_base_files() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to copy script ${c_notice}${path_build}install.sh${c_error} to ${c_notice}${package}${c_error}.${c_reset}" fi @@ -513,6 +647,8 @@ package_create_base_files() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to set executable permissions on script ${c_notice}${package}install.sh${c_error}.${c_reset}" fi @@ -526,6 +662,8 @@ package_create_base_files() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${package}build${c_error}.${c_reset}" fi @@ -538,6 +676,8 @@ package_create_base_files() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${package}sources${c_error}.${c_reset}" fi @@ -550,6 +690,8 @@ package_create_base_files() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${package}documents${c_error}.${c_reset}" fi @@ -562,6 +704,8 @@ package_create_base_files() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${package}licenses${c_error}.${c_reset}" fi @@ -569,11 +713,11 @@ package_create_base_files() { fi fi - if [[ $failure != "" ]] ; then - package_cleanup - - exit $failure + if [[ $failure == "" ]] ; then + return 0 fi + + return 1 } package_dependencies_individual() { @@ -607,13 +751,16 @@ package_dependencies_individual() { level_current="$(echo $directory | grep -o '\||g") if [[ $verbosity == "verbose" ]] ; then + package_print_first + echo -e " (threadless) $dependencies_individual_threadless" fi @@ -826,6 +993,8 @@ package_dependencies_individual() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to update settings file ${c_notice}${settings}${c_error}.${c_reset}" fi @@ -842,6 +1011,8 @@ package_dependencies_individual() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to update settings file ${c_notice}${settings}${c_error}.${c_reset}" fi @@ -855,6 +1026,8 @@ package_dependencies_individual() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to update settings file ${c_notice}${settings}${c_error}.${c_reset}" fi @@ -869,6 +1042,12 @@ package_dependencies_individual() { break; fi done + + if [[ $failure == "" ]] ; then + return 0 + fi + + return 1 } package_dependencies_individual_append() { @@ -880,12 +1059,14 @@ package_dependencies_individual_append() { settings=${path_sources}${level}/${dependency}/data/build/settings if [[ ! -f $settings ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to find dependency settings file ${c_notice}${settings}${c_error}.${c_reset}" fi let failure=1 - return + return 1 fi libraries=$(grep -o '^\s*build_sources_library\s.*$' $settings | sed -e 's|^\s*build_sources_library\>||' -e 's|^\s*||' -e 's|\s*$||') @@ -934,6 +1115,12 @@ package_dependencies_individual_append() { fi fi fi + + if [[ $failure == "" ]] ; then + return 0 + fi + + return 1 } package_dependencies_level() { @@ -947,17 +1134,19 @@ package_dependencies_level() { package_dependencies_level_update "level_0" "" - if [[ $failure != "" ]] ; then - return; + if [[ $failure == "" ]] ; then + package_dependencies_level_update "level_1" " -lfll_0" fi - package_dependencies_level_update "level_1" " -lfll_0" + if [[ $failure == "" ]] ; then + package_dependencies_level_update "level_2" " -lfll_1 -lfll_0" + fi - if [[ $failure != "" ]] ; then - return; + if [[ $failure == "" ]] ; then + return 0 fi - package_dependencies_level_update "level_2" " -lfll_1 -lfll_0" + return 1 } package_dependencies_level_update() { @@ -972,8 +1161,9 @@ package_dependencies_level_update() { local monolithic_libraries_threaded= local monolithic_headers_threaded= - if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + package_print_first_or_always + echo -e "${c_highlight}Building Dependencies: ${c_notice}${level}${c_highlight}.${c_reset}" fi @@ -984,12 +1174,14 @@ package_dependencies_level_update() { settings=${directory}/data/build/settings if [[ ! -f $settings ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to find settings file ${c_notice}${settings}${c_error}.${c_reset}" fi let failure=1 - return + return 1 fi libraries=$(grep -o '^\s*build_sources_library\s.*$' $settings | sed -e 's|^\s*build_sources_library\>||' -e 's|^\s*||' -e 's|\s*$||') @@ -1023,12 +1215,14 @@ package_dependencies_level_update() { if [[ ! -f $settings ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to find settings file ${c_notice}${settings}${c_error}.${c_reset}" fi let failure=1 - return + return 1 fi sed -i -e "s|^\s*build_libraries-level\s.*\$|build_libraries-level${level_libraries}|" $settings && @@ -1038,12 +1232,14 @@ package_dependencies_level_update() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to update libraries for settings file ${c_notice}${settings}${c_error}.${c_reset}" fi let failure=1 - return + return 1 fi level_sources_library=$(echo "$level_sources_library" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||') @@ -1059,12 +1255,14 @@ package_dependencies_level_update() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to update libraries for settings file ${c_notice}${settings}${c_error}.${c_reset}" fi let failure=1 - return + return 1 fi level_sources_headers=$(echo "$level_sources_headers" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||') @@ -1080,12 +1278,14 @@ package_dependencies_level_update() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to update headers for settings file ${c_notice}${settings}${c_error}.${c_reset}" fi let failure=1 - return + return 1 fi if [[ $level == "level_0" ]] ; then @@ -1107,6 +1307,8 @@ package_dependencies_level_update() { level_2_libraries_threaded=$(echo "$monolithic_libraries_threaded" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||') level_2_headers_threaded=$(echo "$monolithic_headers_threaded" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||') fi + + return 0 } package_dependencies_monolithic() { @@ -1115,8 +1317,9 @@ package_dependencies_monolithic() { local monolithic_headers="" local monolithic_headers_threaded="" - if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + package_print_first_or_always + echo -e "${c_highlight}Building Dependencies: ${c_notice}monolithic${c_highlight}.${c_reset}" fi @@ -1203,7 +1406,7 @@ package_dependencies_monolithic() { settings=${path_sources}/build/monolithic/settings if [[ $monolithic_libraries != "" ]] ; then - if [[ $verbosity != "quiet" ]] ; then + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then echo " $monolithic_libraries" fi @@ -1211,7 +1414,7 @@ package_dependencies_monolithic() { fi if [[ $monolithic_libraries_threaded != "" ]] ; then - if [[ $verbosity != "quiet" ]] ; then + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then echo " (threaded) $monolithic_libraries_threaded" fi @@ -1225,16 +1428,18 @@ package_dependencies_monolithic() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to update libraries for settings file ${c_notice}${settings}${c_error}.${c_reset}" fi let failure=1 - return + return 1 fi if [[ $monolithic_headers != "" ]] ; then - if [[ $verbosity != "quiet" ]] ; then + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then echo " $monolithic_headers" fi @@ -1242,7 +1447,7 @@ package_dependencies_monolithic() { fi if [[ $monolithic_headers_threaded != "" ]] ; then - if [[ $verbosity != "quiet" ]] ; then + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then echo " (threaded) $monolithic_headers_threaded" fi @@ -1256,18 +1461,28 @@ package_dependencies_monolithic() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to update headers for settings file ${c_notice}${settings}${c_error}.${c_reset}" fi let failure=1 - return + return 1 fi + + return 0 } package_operation_clean() { local i= + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + package_print_first_or_always + + echo -e "${c_highlight}Cleaning Package Directory '${c_reset}${c_notice}${path_destination}${c_reset}${c_highlight}'.${c_reset}" + fi + if [[ $mode_individual == "yes" ]] ; then if [[ -d ${path_destination}individual ]] ; then rm $verbose_common -Rf ${path_destination}individual @@ -1275,12 +1490,13 @@ package_operation_clean() { if [[ $? -ne 0 ]] ; then let failure=1 - return + return 1 fi fi - if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + package_print_first_or_always + echo "Cleaned '${path_destination}individual'." fi fi @@ -1292,12 +1508,13 @@ package_operation_clean() { if [[ $? -ne 0 ]] ; then let failure=1 - return + return 1 fi fi - if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + package_print_first_or_always + echo "Cleaned '${path_destination}level'." fi fi @@ -1309,12 +1526,13 @@ package_operation_clean() { if [[ $? -ne 0 ]] ; then let failure=1 - return + return 1 fi fi - if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + package_print_first_or_always + echo "Cleaned '${path_destination}monolithic'." fi fi @@ -1326,12 +1544,13 @@ package_operation_clean() { if [[ $? -ne 0 ]] ; then let failure=1 - return + return 1 fi fi - if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + package_print_first_or_always + echo "Cleaned '${path_destination}program'." fi fi @@ -1347,24 +1566,28 @@ package_operation_clean() { if [[ $? -ne 0 ]] ; then let failure=1 - return + return 1 fi fi - if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + package_print_first_or_always + echo "Cleaned '${path_destination}stand_alone/${prepend}${i}-${version}/'." fi done rmdir $verbose_common --ignore-fail-on-non-empty ${path_destination}stand_alone - if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + package_print_first_or_always + echo "Cleaned '${path_destination}stand_alone'." fi fi fi + + return 0 } package_operation_copy_package() { @@ -1374,24 +1597,28 @@ package_operation_copy_package() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to copy the data directory ${c_notice}${package}sources/data${c_error} to ${c_notice}$package${c_error}.${c_reset}" fi let failure=1 - return $failure + return 1 fi rm $verbose_common -Rf ${package}sources/data if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to remove directory ${c_notice}${package}sources/data${c_error}.${c_reset}" fi let failure=1 - return $failure + return 1 fi package_operation_create_config_stubs @@ -1402,24 +1629,28 @@ package_operation_copy_package() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to move sources documents directory ${c_notice}${path_sources}sources/documents${c_error} to ${c_notice}${package}${c_error}.${c_reset}" fi let failure=1 - return $failure + return 1 fi rm $verbose_common -Rf ${package}sources/documents/ if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to remove sources documents directory ${c_notice}${path_sources}sources/documents${c_error} to ${c_notice}${package}${c_error}.${c_reset}" fi let failure=1 - return $failure + return 1 fi fi @@ -1428,24 +1659,28 @@ package_operation_copy_package() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to move sources licenses directory ${c_notice}${path_sources}sources/licenses${c_error} to ${c_notice}${package}${c_error}.${c_reset}" fi let failure=1 - return $failure + return 1 fi rm $verbose_common -Rf ${package}sources/licenses/ if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to remove sources licenses directory ${c_notice}${path_sources}sources/licenses${c_error} to ${c_notice}${package}${c_error}.${c_reset}" fi let failure=1 - return $failure + return 1 fi fi @@ -1454,6 +1689,8 @@ package_operation_copy_package() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to move sources specifications directory ${c_notice}${path_sources}sources/specifications${c_error} to ${c_notice}${package}${c_error}.${c_reset}" fi @@ -1466,12 +1703,14 @@ package_operation_copy_package() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to remove sources specifications directory ${c_notice}${path_sources}sources/specifications${c_error} to ${c_notice}${package}${c_error}.${c_reset}" fi let failure=1 - return $failure + return 1 fi fi @@ -1480,24 +1719,28 @@ package_operation_copy_package() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to move sources tests directory ${c_notice}${path_sources}sources/tests${c_error} to ${c_notice}${package}${c_error}.${c_reset}" fi let failure=1 - return $failure + return 1 fi rm $verbose_common -Rf ${package}sources/tests/ if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to remove sources tests directory ${c_notice}${path_sources}sources/tests${c_error} to ${c_notice}${package}${c_error}.${c_reset}" fi let failure=1 - return $failure + return 1 fi fi } @@ -1524,6 +1767,8 @@ package_operation_create_config_stubs() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to insert the config.c into ${c_notice}${package}data/build/settings${c_error}.${c_reset}" fi @@ -1536,6 +1781,8 @@ package_operation_create_config_stubs() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to insert the config.c into ${c_notice}${package}data/build/settings${c_error}.${c_reset}" fi @@ -1551,6 +1798,8 @@ package_operation_create_config_stubs() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to create the config.c at ${c_notice}${package}sources/c/config.c${c_error}.${c_reset}" fi @@ -1565,6 +1814,8 @@ package_operation_create_config_stubs() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to insert the config.cpp into ${c_notice}${package}data/build/settings${c_error}.${c_reset}" fi @@ -1577,6 +1828,8 @@ package_operation_create_config_stubs() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to insert the config.cpp into ${c_notice}${package}data/build/settings${c_error}.${c_reset}" fi @@ -1592,6 +1845,8 @@ package_operation_create_config_stubs() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to create the config.cpp at ${c_notice}${package}sources/c++/config.cpp${c_error}.${c_reset}" fi @@ -1608,6 +1863,8 @@ package_operation_create_config_stubs() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to create the config.cpp at ${c_notice}${package}sources/c/config.h${c_error}.${c_reset}" fi @@ -1620,6 +1877,8 @@ package_operation_create_config_stubs() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to create the config.cpp at ${c_notice}${package}sources/c++/config.h${c_error}.${c_reset}" fi @@ -1629,10 +1888,11 @@ package_operation_create_config_stubs() { fi fi fi + + return 0 } package_operation_dependencies() { - local failure= local level_0_libraries= local level_1_libraries= local level_2_libraries= @@ -1643,20 +1903,21 @@ package_operation_dependencies() { package_dependencies_individual if [[ $failure != "" ]] ; then - return; + return $failure; fi package_dependencies_level if [[ $failure != "" ]] ; then - return; + return $failure; fi package_dependencies_monolithic + + return 0 } package_operation_individual() { - local failure= local name= local directory= local package= @@ -1666,12 +1927,12 @@ package_operation_individual() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${path_destination}individual${c_error}.${c_reset}" fi - package_cleanup - - exit $failure + return $failure fi fi @@ -1680,8 +1941,9 @@ package_operation_individual() { name="$(echo $directory | sed -e "s|${path_sources}level_0/||" -e "s|${path_sources}level_1/||" -e "s|${path_sources}level_2/||")" package="${path_destination}individual/${prepend}${name}-${version}/" - if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + package_print_first_or_always + echo -e "${c_highlight}Packaging Project${c_reset} (individual) ${c_notice}${prepend}${name}-${version}${c_reset}${c_highlight}.${c_reset}" fi @@ -1691,6 +1953,8 @@ package_operation_individual() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to copy sources directory ${c_notice}${directory}${c_error} to ${c_notice}${package}sources${c_error}.${c_reset}" fi @@ -1706,15 +1970,14 @@ package_operation_individual() { fi done - if [[ $failure != "" ]] ; then - package_cleanup - - exit $failure + if [[ $failure == "" ]] ; then + return 0 fi + + return 1 } package_operation_level() { - local failure= local name= local level= local directory= @@ -1725,13 +1988,16 @@ package_operation_level() { name="fll-$level" package="${path_destination}level/${prepend}${name}-${version}/" - if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + package_print_first_or_always + echo -e "${c_highlight}Packaging Project${c_reset} (level) ${c_notice}${prepend}${name}-${version}${c_reset}${c_highlight}.${c_reset}" fi if [[ ! -d $path_build$level ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Build settings directory ${c_notice}${path_build}${level}${c_error} is invalid or missing.${c_reset}" fi @@ -1747,6 +2013,8 @@ package_operation_level() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${package}data${c_error}.${c_reset}" fi @@ -1764,6 +2032,8 @@ package_operation_level() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to move the directory ${c_notice}${path_build}${level}${c_error} as ${c_notice}${path_build}${level}build${c_error}.${c_reset}" fi @@ -1777,6 +2047,8 @@ package_operation_level() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${package}sources${c_error}.${c_reset}" fi @@ -1792,6 +2064,8 @@ package_operation_level() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to copy files from sources directory ${c_notice}${directory}${c_error} to ${c_notice}${package}sources${c_error}.${c_reset}" fi @@ -1804,6 +2078,8 @@ package_operation_level() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to remove directory ${c_notice}${package}sources/data/build${c_error}.${c_reset}" fi @@ -1823,15 +2099,14 @@ package_operation_level() { fi done - if [[ $failure != "" ]] ; then - package_cleanup - - exit $failure + if [[ $failure == "" ]] ; then + return 0 fi + + return 1 } package_operation_monolithic() { - local failure= local name= local level= local directory= @@ -1842,13 +2117,16 @@ package_operation_monolithic() { name="fll" package="${path_destination}monolithic/${prepend}${name}-${version}/" - if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + package_print_first_or_always + echo -e "${c_highlight}Packaging Project${c_reset} (monolithic) ${c_notice}${prepend}${name}-${version}${c_reset}${c_highlight}.${c_reset}" fi if [[ ! -d ${path_build}monolithic ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Build settings directory ${c_notice}${path_build}monolithic${c_error} is invalid or missing.${c_reset}" fi @@ -1864,6 +2142,8 @@ package_operation_monolithic() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${package}data${c_error}.${c_reset}" fi @@ -1881,6 +2161,8 @@ package_operation_monolithic() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to move the directory ${c_notice}${path_build}${level}${c_error} as ${c_notice}${path_build}${level}build${c_error}.${c_reset}" fi @@ -1894,6 +2176,8 @@ package_operation_monolithic() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${package}sources${c_error}.${c_reset}" fi @@ -1908,6 +2192,8 @@ package_operation_monolithic() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${package}tests${c_error}.${c_reset}" fi @@ -1931,6 +2217,8 @@ package_operation_monolithic() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to create package data directory ${c_notice}${package}data/${level}${c_error}.${c_reset}" fi @@ -1944,6 +2232,8 @@ package_operation_monolithic() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to copy files from data directory ${c_notice}${directory_sub}${c_error} to ${c_notice}${package}sources/data$level${c_error}.${c_reset}" fi @@ -1956,6 +2246,8 @@ package_operation_monolithic() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to remove directory ${c_notice}${package}sources/data/build${c_error}.${c_reset}" fi @@ -1969,6 +2261,8 @@ package_operation_monolithic() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to copy the data directory ${c_notice}${package}sources/data/${level}/data${c_error} to ${c_notice}${package}data/${level}${c_error}.${c_reset}" fi @@ -1982,6 +2276,8 @@ package_operation_monolithic() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to remove directory ${c_notice}${package}sources/data${c_error}.${c_reset}" fi @@ -1994,6 +2290,8 @@ package_operation_monolithic() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to copy files from data directory ${c_notice}${directory_sub}${c_error} to ${c_notice}${package}sources/documents${c_error}.${c_reset}" fi @@ -2006,6 +2304,8 @@ package_operation_monolithic() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to copy files from data directory ${c_notice}${directory_sub}${c_error} to ${c_notice}${package}sources/licenses${c_error}.${c_reset}" fi @@ -2018,6 +2318,8 @@ package_operation_monolithic() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to copy files from data directory ${c_notice}${directory_sub}${c_error} to ${c_notice}${package}sources/specifications${c_error}.${c_reset}" fi @@ -2030,6 +2332,8 @@ package_operation_monolithic() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to copy files from data directory ${c_notice}${directory_sub}${c_error} to ${c_notice}${package}tests${c_error}.${c_reset}" fi @@ -2043,6 +2347,8 @@ package_operation_monolithic() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to create package sources directory ${c_notice}${package}sources/${path_name}/${level}${c_error}.${c_reset}" fi @@ -2056,6 +2362,8 @@ package_operation_monolithic() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to copy files from sources directory ${c_notice}${directory_sub}${c_error} to ${c_notice}${package}sources/${path_name}/${level}${c_error}.${c_reset}" fi @@ -2078,17 +2386,20 @@ package_operation_monolithic() { if [[ $failure == "" ]] ; then package_operation_create_config_stubs - fi - if [[ $failure != "" ]] ; then - package_cleanup + if [[ $? -ne 0 ]] ; then + let failure=1 + fi + fi - exit $failure + if [[ $failure == "" ]] ; then + return 0 fi + + return 1 } package_operation_program() { - local failure= local name= local directory= local package= @@ -2098,6 +2409,8 @@ package_operation_program() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${path_destination}program${c_error}.${c_reset}" fi @@ -2112,8 +2425,9 @@ package_operation_program() { name="$(echo $directory | sed -e "s|${path_sources}level_3/||")" package="${path_destination}program/${prepend}${name}-${version}/" - if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + package_print_first_or_always + echo -e "${c_highlight}Packaging Project${c_reset} (program) ${c_notice}${prepend}${name}-${version}${c_reset}${c_highlight}.${c_reset}" fi @@ -2123,6 +2437,8 @@ package_operation_program() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to copy sources directory ${c_notice}${directory}${c_error} to ${c_notice}${package}sources${c_error}.${c_reset}" fi @@ -2133,20 +2449,21 @@ package_operation_program() { package_operation_copy_package - if [[ $failure != "" ]] ; then + if [[ $? -ne 0 ]] ; then + let failure=1 + break fi done - if [[ $failure != "" ]] ; then - package_cleanup - - exit $failure + if [[ $failure == "" ]] ; then + return 0 fi + + return 1 } package_operation_stand_alone() { - local failure= local name= local directory= local directory_level= @@ -2165,12 +2482,14 @@ package_operation_stand_alone() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${path_destination}stand_alone${c_error}.${c_reset}" fi package_cleanup - exit $failure + return 1 fi fi @@ -2179,17 +2498,26 @@ package_operation_stand_alone() { directory="${path_sources}level_3/${name}" package="${path_destination}stand_alone/${prepend}${name}-${version}/" - if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + package_print_first_or_always + echo -e "${c_highlight}Packaging Project${c_reset} (stand_alone) ${c_notice}${prepend}${name}-${version}${c_reset}${c_highlight}.${c_reset}" fi package_create_base_files + if [[ $? -ne 0 ]] ; then + let failure=1 + + break + fi + cp $verbose_common -R $directory ${package}sources/ if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to copy sources directory ${c_notice}${directory}${c_error} to ${c_notice}${package}sources${c_error}.${c_reset}" fi @@ -2200,7 +2528,9 @@ package_operation_stand_alone() { package_operation_copy_package - if [[ $failure != "" ]] ; then + if [[ $? -ne 0 ]] ; then + let failure=1 + break fi @@ -2208,6 +2538,8 @@ package_operation_stand_alone() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to copy file ${c_notice}${path_build}stand_alone/${name}.settings${c_error} to ${c_notice}${package}data/build/settings${c_error}.${c_reset}" fi @@ -2221,6 +2553,8 @@ package_operation_stand_alone() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to create package sources directory ${c_notice}${package}sources/c/program/${name}/${c_error}.${c_reset}" fi @@ -2249,6 +2583,8 @@ package_operation_stand_alone() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to create package sources directory ${c_notice}${package}sources/${path_name}/program/${name}/${c_error}.${c_reset}" fi @@ -2262,6 +2598,8 @@ package_operation_stand_alone() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to move path ${c_notice}${path_sub}${c_error} to ${c_notice}${package}sources/${path_name}/program/${name}/${c_error}.${c_reset}" fi @@ -2285,6 +2623,8 @@ package_operation_stand_alone() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to copy file ${c_notice}${path_build}stand_alone/config.h${c_error} to ${c_notice}${package}sources/c/${c_error}.${c_reset}" fi @@ -2328,6 +2668,8 @@ package_operation_stand_alone() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to create package sources directory ${c_notice}${package}sources/${path_name}/fll/${level}/${c_error}.${c_reset}" fi @@ -2341,6 +2683,8 @@ package_operation_stand_alone() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + package_print_first + echo -e "${c_error}ERROR: Failed to copy files from sources directory ${c_notice}${directory_level}${path_name}/${c_error} to ${c_notice}${package}sources/${path_name}/fll/${level}/${c_error}.${c_reset}" fi @@ -2362,15 +2706,45 @@ package_operation_stand_alone() { fi done - if [[ $failure != "" ]] ; then - package_cleanup + if [[ $failure == "" ]] ; then + return 0 + fi + + return 1 +} + +package_print_first() { + + if [[ $print_line_first == "yes" ]] ; then + echo + + print_line_first= + fi +} - exit $failure +package_print_first_or_always() { + + if [[ $print_line_first == "yes" ]] ; then + echo + + print_line_first= + elif [[ $print_line_first == "no" ]] ; then + print_line_first= + else + echo + fi +} + +package_print_last() { + + if [[ $print_line_last == "yes" ]] ; then + echo fi } package_cleanup() { + unset package_copyright unset package_main unset package_handle_colors unset package_help @@ -2390,6 +2764,9 @@ package_cleanup() { unset package_operation_monolithic unset package_operation_program unset package_operation_stand_alone + unset package_print_first + unset package_print_first_or_always + unset package_print_last unset package_cleanup } diff --git a/build/scripts/test.sh b/build/scripts/test.sh index dd27825..f239128 100644 --- a/build/scripts/test.sh +++ b/build/scripts/test.sh @@ -30,6 +30,7 @@ test_main() { local grab_next= local do_color=dark local do_help= + local do_copyright= local i=0 local p= local t=0 @@ -54,6 +55,8 @@ test_main() { local path_test_work=${path_test}work/ local path_test_package_individual=${path_test_package}individual/ local path_test_package_stand_alone=${path_test_package}stand_alone/ + local print_line_first="yes" + local print_line_last="yes" local test_system= local context= @@ -64,7 +67,7 @@ test_main() { local verbose= local verbose_common= - local projects="f_type f_status f_memory f_type_array f_string f_utf f_account f_capability f_color f_console f_control_group f_conversion f_directory f_environment f_execute f_file f_fss f_iki f_limit f_path f_pipe f_print f_serialize f_signal f_socket f_status_string f_thread fl_control_group fl_conversion fl_directory fl_environment fl_execute fl_fss fl_iki fl_print fl_signal fl_string fl_utf fl_utf_file fll_control_group fll_error fll_execute fll_file fll_fss fll_fss_status_string fll_iki fll_path fll_print fll_program fll_status_string" + local projects="f_type f_status f_memory f_type_array f_string f_utf f_account f_capability f_color f_console f_control_group f_conversion f_directory f_environment f_execute f_file f_fss f_iki f_limit f_path f_pipe f_print f_serialize f_signal f_socket f_status_string f_thread fl_control_group fl_conversion fl_directory fl_environment fl_execute fl_fss fl_iki fl_path fl_print fl_signal fl_string fl_utf fl_utf_file fll_control_group fll_error fll_execute fll_file fll_fss fll_fss_status_string fll_iki fll_print fll_program fll_status_string" local projects_no_tests="f_type" let failure=0 @@ -85,6 +88,8 @@ test_main() { if [[ $grab_next == "" ]] ; then if [[ $p == "-h" || $p == "--help" ]] ; then do_help=yes + elif [[ $p == "+C" || $p == "++copyright" ]] ; then + do_copyright="yes" elif [[ $p == "+d" || $p == "++dark" ]] ; then do_color=dark context="+d" @@ -94,9 +99,13 @@ test_main() { elif [[ $p == "+n" || $p == "++no_color" ]] ; then do_color=none context="+n" - elif [[ $p == "+q" || $p == "++quiet" ]] ; then + elif [[ $p == "+Q" || $p == "++quiet" ]] ; then verbosity="quiet" - verbose="+q" + verbose="+Q" + verbose_common= + elif [[ $p == "+E" || $p == "++error" ]] ; then + verbosity="error" + verbose="+E" verbose_common= elif [[ $p == "+N" || $p == "++normal" ]] ; then verbosity= @@ -112,7 +121,7 @@ test_main() { verbose_common="-v" elif [[ $p == "+v" || $p == "++version" ]] ; then echo $version - return + return 0 elif [[ $p == "-c" || $p == "--compiler" ]] ; then grab_next=build_compiler elif [[ $p == "-p" || $p == "--project" ]] ; then @@ -151,6 +160,11 @@ test_main() { p= fi + if [[ $verbosity == "quiet" ]] ; then + print_line_first="no" + print_line_last="no" + fi + test_handle_colors if [[ $do_help == "yes" ]] ; then @@ -160,8 +174,17 @@ test_main() { return 0 fi + if [[ $do_copyright == "yes" ]] ; then + test_copyright + test_cleanup + + return 0 + fi + if [[ $operation_failure == "fail-too_many" ]] ; then if [[ $verbosity != "quiet" ]] ; then + test_print_first + echo -e "${c_error}ERROR: Only a single build system is supported, received the following test systems ${c_notice}${test_system} ${operation}${c_error} was not recognized.${c_reset}" fi @@ -178,6 +201,8 @@ test_main() { if [[ $failure -eq 0 && $test_system != "normal" && $test_system != "github" && $test_system != "gitlab" ]] ; then if [[ $verbosity != "quiet" ]] ; then + test_print_first + echo -e "${c_error}ERROR: The test system must be one of ${c_notice}normal${c_error}, ${c_notice}github${c_error}, or ${c_notice}gitlab${c_error}.${c_reset}" fi @@ -186,6 +211,8 @@ test_main() { if [[ $failure -eq 0 && $build_compiler != "gcc" && $build_compiler != "clang" ]] ; then if [[ $verbosity != "quiet" ]] ; then + test_print_first + echo -e "${c_error}ERROR: The build compiler ${c_notice}${build_compiler}${c_error} is not currently directly supported.${c_reset}" fi @@ -194,6 +221,8 @@ test_main() { if [[ $failure -eq 0 && ! -d $path_scripts ]] ; then if [[ $verbosity != "quiet" ]] ; then + test_print_first + echo -e "${c_error}ERROR: The build scripts path ${c_notice}${path_scripts}${c_error} is not a valid directory.${c_reset}" fi @@ -202,6 +231,8 @@ test_main() { if [[ $failure -eq 0 && ! -f $path_scripts_package ]] ; then if [[ $verbosity != "quiet" ]] ; then + test_print_first + echo -e "${c_error}ERROR: Unable to find the package build script file under the build scripts path at ${c_notice}${path_scripts_package}${c_error}.${c_reset}" fi @@ -213,6 +244,8 @@ test_main() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + print_line_first + echo -e "${c_error}ERROR: The test path ${c_notice}${path_test}${c_error}, does not exist and could not be created or exists and is not a valid directory.${c_reset}" fi @@ -225,6 +258,8 @@ test_main() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + print_line_first + echo -e "${c_error}ERROR: The package path ${c_notice}${path_test_package}${c_error}, does not exist and could not be created or exists and is not a valid directory.${c_reset}" fi @@ -237,6 +272,8 @@ test_main() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + print_line_first + echo -e "${c_error}ERROR: The test project path ${c_notice}${path_test_project}${c_error}, does not exist and could not be created or exists and is not a valid directory.${c_reset}" fi @@ -249,6 +286,8 @@ test_main() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then + print_line_first + echo -e "${c_error}ERROR: The test work path ${c_notice}${path_test_work}${c_error}, does not exist and could not be created or exists and is not a valid directory.${c_reset}" fi @@ -262,12 +301,18 @@ test_main() { fi if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $failure != "" || $verbosity != "error" ]] ; then + test_print_last + fi fi test_cleanup - return $failure + if [[ $failure == "" ]] ; then + return 0 + fi + + return 1 } test_handle_colors() { @@ -294,7 +339,8 @@ test_handle_colors() { test_help() { - echo + test_print_first + echo -e "${c_title}${public_name}${c_reset}" echo -e " ${c_notice}Version ${version}${c_reset}" echo @@ -304,22 +350,38 @@ test_help() { echo -e " ${c_important}gitlab${c_reset} Perform a test meant to be used within Gitlab (not yet supported)." echo echo -e "${c_highlight}Options:${c_reset}" - echo -e " -${c_important}h${c_reset}, --${c_important}help${c_reset} Print this help screen." - echo -e " +${c_important}d${c_reset}, ++${c_important}dark${c_reset} Use color modes that show up better on dark backgrounds." - echo -e " +${c_important}l${c_reset}, ++${c_important}light${c_reset} Use color modes that show up better on light backgrounds." - echo -e " +${c_important}n${c_reset}, ++${c_important}no_color${c_reset} Do not use color." - echo -e " +${c_important}q${c_reset}, ++${c_important}quiet${c_reset} Decrease verbosity, silencing most output." - echo -e " +${c_important}N${c_reset}, ++${c_important}normal${c_reset} Set verbosity to normal." - echo -e " +${c_important}V${c_reset}, ++${c_important}verbose${c_reset} Increase verbosity beyond normal output." - echo -e " +${c_important}D${c_reset}, ++${c_important}debug${c_reset} Enable debugging, significantly increasing verbosity beyond normal output." - echo -e " +${c_important}v${c_reset}, ++${c_important}version${c_reset} Print the version number of this program." + echo -e " -${c_important}h${c_reset}, --${c_important}help${c_reset} Print this help message." + echo -e " +${c_important}C${c_reset}, ++${c_important}copyright${c_reset} Print the copyright." + echo -e " +${c_important}d${c_reset}, ++${c_important}dark${c_reset} Output using colors that show up better on dark backgrounds." + echo -e " +${c_important}l${c_reset}, ++${c_important}light${c_reset} Output using colors that show up better on light backgrounds." + echo -e " +${c_important}n${c_reset}, ++${c_important}no_color${c_reset} Do not print using color." + echo -e " +${c_important}Q${c_reset}, ++${c_important}quiet${c_reset} Decrease verbosity, silencing most print.to." + echo -e " +${c_important}E${c_reset}, ++${c_important}error${c_reset} Decrease verbosity, using only error print.to." + echo -e " +${c_important}N${c_reset}, ++${c_important}normal${c_reset} Set verbosity to normal." + echo -e " +${c_important}V${c_reset}, ++${c_important}verbose${c_reset} Increase verbosity beyond normal print.to." + echo -e " +${c_important}D${c_reset}, ++${c_important}debug${c_reset} Enable debugging, significantly increasing verbosity beyond normal print.to." + echo -e " +${c_important}v${c_reset}, ++${c_important}version${c_reset} Print only the version number." echo echo -e "${c_highlight}Install Options:${c_reset}" echo -e " -${c_important}c${c_reset}, --${c_important}compiler${c_reset} Specify the compiler, either gcc (default) or clang." echo -e " -${c_important}p${c_reset}, --${c_important}project${c_reset} Designate that the project files must also be built." echo -e " -${c_important}s${c_reset}, --${c_important}path_scripts${c_reset} Specify a custom directory where the build scripts are found." echo -e " -${c_important}t${c_reset}, --${c_important}path_test${c_reset} Specify a custom directory where the test environment is found." + + test_print_last +} + +test_copyright() { + + test_print_first + + echo "Copyright © 2007-2023 Kevin Day." echo + echo "Source code license lgpl-2.1-or-later." + echo "Standard and specification license open-standard-license-1.0." + echo "Documentation license cc-by-sa-4.0." + + test_print_last } test_operate() { @@ -344,6 +406,8 @@ test_operate() { test_operate_ci_prebuild if [[ $? -ne 0 ]] ; then + let failure=1 + return 1 fi fi @@ -352,6 +416,8 @@ test_operate() { test_operate_build_tools if [[ $? -ne 0 ]] ; then + let failure=1 + return 1 fi fi @@ -359,6 +425,8 @@ test_operate() { test_operate_build_individual if [[ $? -ne 0 ]] ; then + let failure=1 + return 1 fi @@ -366,6 +434,8 @@ test_operate() { test_operate_ci_pretest if [[ $? -ne 0 ]] ; then + let failure=1 + return 1 fi fi @@ -376,18 +446,19 @@ test_operate() { } test_operate_build_individual() { - local -i failure=0 local project= local path_original="$PWD/" - if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + test_print_first_or_always + echo -e "${c_highlight}Cleaning and building package.${c_reset}" echo -e "${c_title}------------------------------${c_reset}" fi if [[ $verbosity == "debug" ]] ; then - echo + test_print_first_or_always + echo "$shell_command ${path_scripts_package} $verbose $context -d $path_test_package -i rebuild" fi @@ -395,7 +466,8 @@ test_operate_build_individual() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + test_print_first + echo -e "${c_error}ERROR: Failed to clean and build the individual packages.${c_reset}" fi @@ -417,7 +489,11 @@ test_operate_build_individual() { cd $path_original done - return $failure + if [[ $failure == "" ]] ; then + return 0 + fi + + return 1 } test_operate_build_project() { @@ -429,7 +505,8 @@ test_operate_build_project() { if [[ ! -d ${path_}${project}-${version}/ ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + test_print_first + echo -e "${c_error}ERROR: Package directory '${c_notice}${path_}${project}-${version}${c_error}' is invalid or missing.${c_reset}" fi @@ -437,7 +514,8 @@ test_operate_build_project() { fi if [[ $verbosity == "debug" ]] ; then - echo + test_print_first_or_always + echo -e "Running '${c_notice}cd ${path_}${project}-${version}/${c_reset}'." fi @@ -445,16 +523,19 @@ test_operate_build_project() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + test_print_first + echo -e "${c_error}ERROR: Failed to change into directory '${c_notice}${path_}${project}-${version}${c_error}'.${c_reset}" fi + let failure=1 + return 1 fi if [[ $bootstrap == "" ]] ; then if [[ $verbosity == "debug" ]] ; then - echo + test_print_first_or_always if [[ $build_compiler == "gcc" ]] ; then echo "PATH=\"$env_path\" LD_LIBRARY_PATH=\"$env_libs\" fake $verbose $context -w \"$destination\" -m $mode clean build $ci_arguments" @@ -471,7 +552,7 @@ test_operate_build_project() { else if [[ $SHELL_ENGINE == "zsh" ]] ; then if [[ $verbosity == "debug" ]] ; then - echo + test_print_first_or_always if [[ $build_compiler == "gcc" ]] ; then echo "zsh ./bootstrap.sh $verbose $context -w \"$destination\" -m $mode -m test build" @@ -487,7 +568,7 @@ test_operate_build_project() { fi else if [[ $verbosity == "debug" ]] ; then - echo + test_print_first_or_always if [[ $build_compiler == "gcc" ]] ; then echo "./bootstrap.sh $verbose $context -w \"$destination\" -m $mode -m test build" @@ -506,16 +587,19 @@ test_operate_build_project() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + test_print_first + echo -e "${c_error}ERROR: Failed to build $mode project '${c_notice}$project${c_reset}${c_error}'.${c_reset}" fi + let failure=1 + return 1 fi - if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then echo -e "Installing $mode project '${c_notice}$project${c_reset}'." + echo fi if [[ $SHELL_ENGINE == "zsh" ]] ; then @@ -526,10 +610,13 @@ test_operate_build_project() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + test_print_first + echo -e "${c_error}ERROR: Failed to install $mode project '${c_notice}$project${c_reset}${c_error}'.${c_reset}" fi + let failure=1 + return 1 fi @@ -537,17 +624,18 @@ test_operate_build_project() { } test_operate_build_tools() { - local -i failure=0 local path_original="$PWD/" - if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + test_print_first_or_always + echo -e "${c_highlight}Building project build tools.${c_reset}" echo -e "${c_title}-----------------------------${c_reset}" fi if [[ $verbosity == "debug" ]] ; then - echo + test_print_first_or_always + echo "$shell_command ${path_scripts_package} $verbose $context -d $path_test_package -S fake rebuild" fi @@ -555,7 +643,8 @@ test_operate_build_tools() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + test_print_first + echo -e "${c_error}ERROR: Failed to clean and build the stand_alone fake package.${c_reset}" fi @@ -570,7 +659,11 @@ test_operate_build_tools() { cd $path_original - return $failure + if [[ $failure == "" ]] ; then + return 0 + fi + + return 1 } test_operate_ci_prebuild() { @@ -582,18 +675,26 @@ test_operate_ci_prebuild() { clone_quiet="-q" fi - if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + test_print_first_or_always + echo -e "${c_highlight}Performing Github Specific Pre-Build Operations.${c_reset}" echo -e "${c_title}------------------------------------------------${c_reset}" fi test_operate_ci_prebuild_libcap - result=$? + + if [[ $? -ne 0 ]] ; then + let failure=1 + fi cd ${path_original} - return $result + if [[ $failure == "" ]] ; then + return 0 + fi + + return 1 } test_operate_ci_pretest() { @@ -605,18 +706,26 @@ test_operate_ci_pretest() { clone_quiet="-q" fi - if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + test_print_first_or_always + echo -e "${c_highlight}Performing Github Specific Pre-Test Operations.${c_reset}" echo -e "${c_title}-----------------------------------------------${c_reset}" fi test_operate_ci_pretest_cmocka - result=$? + + if [[ $? -ne 0 ]] ; then + let failure=1 + fi cd ${path_original} - return $result + if [[ $failure == "" ]] ; then + return 0 + fi + + return 1 } test_operate_ci_pretest_cmocka() { @@ -628,8 +737,9 @@ test_operate_ci_pretest_cmocka() { local cmocka_branch="cmocka-1.1.5" if [[ -d $cmocka_path ]] ; then - if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + test_print_first_or_always + echo -e "Detected existing cmocka repository at \"${c_notice}$cmocka_path${c_reset}\", skipping the cmocka process." fi @@ -637,7 +747,8 @@ test_operate_ci_pretest_cmocka() { fi if [[ $verbosity == "debug" ]] ; then - echo + test_print_first_or_always + echo "git clone $clone_quiet --single-branch -b $cmocka_branch \"$cmocka_uri\" $cmocka_path" fi @@ -645,15 +756,19 @@ test_operate_ci_pretest_cmocka() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + test_print_first + echo -e "${c_error}ERROR: Failed to git clone '${c_notice}$cmocka_uri${c_error}' onto '${c_notice}$cmocka_path${c_error}'.${c_reset}" fi + let failure=1 + return 1 fi if [[ $verbosity == "debug" ]] ; then - echo + test_print_first_or_always + echo "mkdir $verbose_common -p $cmocka_data" fi @@ -661,15 +776,19 @@ test_operate_ci_pretest_cmocka() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + test_print_first + echo -e "${c_error}ERROR: Failed to create cmocka build data directory '${c_notice}$cmocka_data${c_error}'.${c_reset}" fi + let failure=1 + return 1 fi if [[ $verbosity == "debug" ]] ; then - echo + test_print_first_or_always + echo "cp $verbose_common $cmocka_settings $cmocka_data" fi @@ -677,15 +796,19 @@ test_operate_ci_pretest_cmocka() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + test_print_first + echo -e "${c_error}ERROR: Failed to copy cmocka build settings: '${c_notice}$cmocka_settings${c_error}'.${c_reset}" fi + let failure=1 + return 1 fi if [[ $verbosity == "debug" ]] ; then - echo + test_print_first_or_always + echo "cd $cmocka_path" fi @@ -693,15 +816,19 @@ test_operate_ci_pretest_cmocka() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + test_print_first + echo -e "${c_error}ERROR: Failed to change cmocka source directory '${c_notice}$cmocka_path${c_error}'.${c_reset}" fi + let failure=1 + return 1 fi if [[ $verbosity == "debug" ]] ; then - echo + test_print_first_or_always + echo "PATH=\"$env_path\" LD_LIBRARY_PATH=\"$env_libs\" fake $verbose $context -w \"$path_test_work\" -m $build_compiler clean build $ci_arguments" fi @@ -709,15 +836,19 @@ test_operate_ci_pretest_cmocka() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + test_print_first + echo -e "${c_error}ERROR: Failed to build '${c_notice}cmocka${c_error}'.${c_reset}" fi + let failure=1 + return 1 fi if [[ $verbosity == "debug" ]] ; then - echo + test_print_first_or_always + echo "cp $verbose_common -R ${cmocka_build}includes/* ${work_path}includes/" fi @@ -725,15 +856,19 @@ test_operate_ci_pretest_cmocka() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + test_print_first + echo -e "${c_error}ERROR: Failed to install cmocka headers to '${c_notice}${work_path}includes/${c_error}'.${c_reset}" fi + let failure=1 + return 1 fi if [[ $verbosity == "debug" ]] ; then - echo + test_print_first_or_always + echo "cp $verbose_common -R ${cmocka_build}libraries/shared/* ${work_path}libraries/shared/" fi @@ -741,10 +876,13 @@ test_operate_ci_pretest_cmocka() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + test_print_first + echo -e "${c_error}ERROR: Failed to install cmocka libraries to '${c_notice}${work_path}libraries/shared/${c_error}'.${c_reset}" fi + let failure=1 + return 1 fi @@ -757,8 +895,9 @@ test_operate_ci_prebuild_libcap() { local libcap_branch="master" if [[ -d $libcap_path ]] ; then - if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + test_print_first_or_always + echo -e "Detected existing libcap repository at \"${c_notice}$libcap_path${c_reset}\", skipping the libcap process." fi @@ -766,7 +905,8 @@ test_operate_ci_prebuild_libcap() { fi if [[ $verbosity == "debug" ]] ; then - echo + test_print_first_or_always + echo "git clone $clone_quiet --single-branch -b $libcap_branch \"$libcap_uri\" $libcap_path" fi @@ -774,15 +914,19 @@ test_operate_ci_prebuild_libcap() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + test_print_first + echo -e "${c_error}ERROR: Failed to git clone '${c_notice}$libcap_uri${c_error}' onto '${c_notice}$libcap_path${c_error}'.${c_reset}" fi + let failure=1 + return 1 fi if [[ $verbosity == "debug" ]] ; then - echo + test_print_first_or_always + echo "cd $libcap_path" fi @@ -790,15 +934,21 @@ test_operate_ci_prebuild_libcap() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + test_print_first + echo -e "${c_error}ERROR: Failed to change libcap source directory '${c_notice}$libcap_path${c_error}'.${c_reset}" + + test_print_last fi + let failure=1 + return 1 fi if [[ $verbosity == "debug" ]] ; then - echo + test_print_first_or_always + echo "make MANDIR=${work_path}fake/ SBINDIR=${work_path}fake/ INCDIR=${work_path}includes/ LIBDIR=${work_path}libraries/shared/ PKGCONFIGDIR=${work_path}fake/ install" fi @@ -806,10 +956,15 @@ test_operate_ci_prebuild_libcap() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + test_print_first + echo -e "${c_error}ERROR: Failed to build and install libcap into the work directory '${c_notice}${work_path}${c_error}'.${c_reset}" + + test_print_last fi + let failure=1 + return 1 fi @@ -817,37 +972,42 @@ test_operate_ci_prebuild_libcap() { } test_operate_tests() { - local -i failure=0 local project= local path_original="$PWD/" local destination="$path_test_work" for project in $projects ; do - if [[ $verbosity != "quiet" ]] ; then - echo + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then + test_print_first_or_always + echo -e "${c_highlight}Testing Project $project.${c_reset}" echo -e "${c_title}--------------------------------------${c_reset}" fi if [[ ! -d $path_test_package_individual$project-$version/ ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + test_print_first + echo -e "${c_error}ERROR: Package directory '${c_notice}$path_test_package_individual$project-$version${c_error}' is invalid or missing.${c_reset}" + + test_print_last fi let failure=1 fi - if [[ $failure -eq 0 ]] ; then + if [[ $failure == "" ]] ; then if [[ ! -f $path_test_package_individual$project-$version/data/build/testfile ]] ; then if [[ $(echo $projects_no_tests | grep -o "\<$project\>") == "" ]] ; then if [[ $verbosity == "verbose" || $verbosity == "debug" ]] ; then - echo + test_print_first_or_always + echo -e "${c_warning}WARNING: Project '${c_notice}$project${c_warning}' does not have a testfile.${c_reset}" fi else - echo + test_print_first_or_always + echo -e "Project '${c_notice}$project${c_reset}' has no tests and is not expected to.${c_reset}" fi @@ -855,9 +1015,10 @@ test_operate_tests() { fi fi - if [[ $failure -eq 0 ]] ; then + if [[ $failure == "" ]] ; then if [[ $verbosity == "debug" ]] ; then - echo + test_print_first_or_always + echo -e "Running '${c_notice}cd $path_test_package_individual$project-$version/${c_reset}'." fi @@ -865,17 +1026,20 @@ test_operate_tests() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + test_print_first + echo -e "${c_error}ERROR: Failed to change into directory '${c_notice}$path_test_package_individual$project-$version${c_error}'.${c_reset}" + + test_print_last fi let failure=1 fi fi - if [[ $failure -eq 0 ]] ; then + if [[ $failure == "" ]] ; then if [[ $verbosity == "debug" ]] ; then - echo + test_print_first_or_always if [[ $build_compiler == "gcc" ]] ; then echo "PATH=\"$env_path\" LD_LIBRARY_PATH=\"$env_libs\" fake $verbose $context -w \"$destination\" -m individual -m test clean make -f testfile $ci_arguments" @@ -892,8 +1056,11 @@ test_operate_tests() { if [[ $? -ne 0 ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + test_print_first + echo -e "${c_error}ERROR: Failure while testing project '${c_notice}$project${c_reset}${c_error}'.${c_reset}" + + test_print_last fi let failure=1 @@ -902,21 +1069,53 @@ test_operate_tests() { cd $path_original - if [[ $failure -ne 0 ]] ; then + if [[ $failure != "" ]] ; then break; fi done - return $failure + if [[ $failure == "" ]] ; then + return 0 + fi + + return 1 +} + +test_print_first() { + + if [[ $print_line_first == "yes" ]] ; then + echo + + print_line_first= + fi +} + +test_print_first_or_always() { + + if [[ $print_line_first == "yes" ]] ; then + echo + + print_line_first= + elif [[ $print_line_first == "no" ]] ; then + print_line_first= + else + echo + fi +} + +test_print_last() { + + if [[ $print_line_last == "yes" ]] ; then + echo + fi } test_cleanup() { + unset test_copyright unset test_main unset test_handle_colors unset test_help - - unset test_cleanup unset test_operate unset test_operate_build_individual unset test_operate_build_project @@ -926,6 +1125,10 @@ test_cleanup() { unset test_operate_ci_pretest unset test_operate_ci_pretest_cmocka unset test_operate_tests + unset test_print_first + unset test_print_first_or_always + unset test_print_last + unset test_cleanup } test_main $* -- 1.8.3.1