From: Kevin Day Date: Tue, 21 Mar 2023 03:50:55 +0000 (-0500) Subject: Bugfix: Out of date repository build scripts. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=736d99ce416da505e859c9ee3890b3adf119260f;p=fll Bugfix: Out of date repository build scripts. The repository build scripts are very much out of date. A recent bugfix, commit 831e5d8b0dce5279964987baa43201b63c12c203, 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. Make sue the "+F/++line_first_no" and "+L/++line_last_no" parameters are working. Utilize "+F" and "+L" where reasonably possible in the example bootstrap and test scripts. 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. --- diff --git a/build/scripts/bootstrap-example.sh b/build/scripts/bootstrap-example.sh index 27819a9..1de3fe1 100644 --- a/build/scripts/bootstrap-example.sh +++ b/build/scripts/bootstrap-example.sh @@ -8,7 +8,7 @@ # # This only accepts one argument, followed by these optional arguments: # 1) One of "Modes" from below. -# 2) Optional, may be one of: +V, +q, +n, +l, +d, --enable-shared, --enable-static, --disable-shared, --disable-static. +# 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. # @@ -58,6 +58,7 @@ mode_parameter= mode_path= mode_value= shell_command=bash +suppress_first="+F" if [[ $SHELL_ENGINE == "zsh" ]] ; then shell_command=zsh @@ -80,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" @@ -126,11 +130,11 @@ if [[ $1 == "individual" ]] ; then 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 @@ -142,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 @@ -174,11 +178,11 @@ 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 individual projects. @@ -212,11 +216,11 @@ if [[ $mode_part != "" ]] ; then 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 @@ -238,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 e40e67d..4ef5f0d 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= @@ -117,9 +127,13 @@ bootstrap_main() { verbosity="debug" verbose="+D" verbose_common="-v" + elif [[ $p == "+F" || $p == "++line_first_no" ]] ; then + print_line_first="no" + elif [[ $p == "+L" || $p == "++line_last_no" ]] ; then + print_line_last="no" 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 +197,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 +226,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 +240,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 +280,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 +309,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 +325,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 +340,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 +355,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 +370,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 +384,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 +398,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 +412,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 +444,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 +479,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 +498,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 +510,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 +545,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 +555,19 @@ 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 -e " +${c_important}F${c_reset}, ++${c_important}line_first_no${c_reset} Disable printing of first line." + echo -e " +${c_important}L${c_reset}, ++${c_important}line_last_no${c_reset} Disable printing of last line." 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 +587,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 +836,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 +881,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 +924,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 +976,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 +1019,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 +1059,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 +1083,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 +1370,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 +1397,7 @@ bootstrap_operation_build() { bootstrap_operation_build_validate_build - if [[ $failure -eq 1 ]] ; then + if [[ $failure != "" ]] ; then return 1 fi @@ -1300,7 +1410,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 +1426,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 +1445,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 +1457,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 +1469,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 +1485,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 +1523,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 +1544,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 +1575,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 +1591,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 +1607,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 +1658,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 +1673,7 @@ bootstrap_operation_build() { fi fi - if [[ $failure -eq 0 && $sources_program != "" ]] ; then + if [[ $failure == "" && $sources_program != "" ]] ; then sources= links= @@ -1584,18 +1698,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 +2770,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 +2780,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 +2836,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 +2846,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 +2866,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 +2878,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 +2890,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 +2902,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 +2914,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 +2926,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 +2938,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 +2950,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 +3047,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 +3093,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 f4c6147..5dfbb02 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 @@ -135,7 +136,7 @@ install_main() { print_line_last="no" 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 @@ -226,6 +227,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 @@ -244,15 +250,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 @@ -262,15 +264,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 @@ -280,15 +278,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 @@ -352,15 +346,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 @@ -370,15 +360,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 @@ -388,15 +374,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 @@ -406,15 +388,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 @@ -424,15 +402,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 @@ -442,15 +416,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 @@ -460,15 +430,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 @@ -478,9 +444,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() { @@ -507,9 +483,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}" @@ -561,16 +535,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 @@ -578,16 +548,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 @@ -616,21 +583,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 @@ -640,10 +603,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 @@ -652,10 +617,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 @@ -664,10 +631,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 @@ -678,10 +647,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 @@ -690,10 +661,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 @@ -702,10 +675,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 @@ -716,10 +691,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 @@ -730,10 +707,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 @@ -744,10 +723,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 @@ -765,8 +746,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 @@ -775,10 +756,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 @@ -797,8 +780,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 @@ -807,10 +790,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 @@ -828,8 +813,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 @@ -838,10 +823,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 @@ -861,8 +848,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 @@ -871,10 +858,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 @@ -892,8 +881,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 @@ -902,16 +891,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}||") @@ -924,20 +915,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 @@ -955,8 +948,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 @@ -965,34 +958,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 @@ -1001,7 +1012,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 278fdde..c045d60 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= @@ -96,9 +106,13 @@ package_main() { verbosity="debug" verbose="+D" verbose_common="-v" + elif [[ $p == "+F" || $p == "++line_first_no" ]] ; then + print_line_first="no" + elif [[ $p == "+L" || $p == "++line_last_no" ]] ; then + print_line_last="no" 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 +159,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 +173,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 +205,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 +231,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 +245,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 +263,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 +277,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 +291,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 +305,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 +319,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 +334,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 +343,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 +400,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 +416,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 +428,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 +440,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 +479,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 +491,19 @@ 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 -e " +${c_important}F${c_reset}, ++${c_important}line_first_no${c_reset} Disable printing of first line." + echo -e " +${c_important}L${c_reset}, ++${c_important}line_last_no${c_reset} Disable printing of last line." 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 +518,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 +538,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 +549,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 +562,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 +577,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 +589,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 +598,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 +612,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 +625,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 +639,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 +653,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 +668,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 +682,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 +696,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 +710,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 +719,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 +757,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 +999,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 +1017,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 +1032,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 +1048,12 @@ package_dependencies_individual() { break; fi done + + if [[ $failure == "" ]] ; then + return 0 + fi + + return 1 } package_dependencies_individual_append() { @@ -880,12 +1065,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 +1121,12 @@ package_dependencies_individual_append() { fi fi fi + + if [[ $failure == "" ]] ; then + return 0 + fi + + return 1 } package_dependencies_level() { @@ -947,17 +1140,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 +1167,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 +1180,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 +1221,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 +1238,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 +1261,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 +1284,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 +1313,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 +1323,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 +1412,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 +1420,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 +1434,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 +1453,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 +1467,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 +1496,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 +1514,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 +1532,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 +1550,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 +1572,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 +1603,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 +1635,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 +1665,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 +1695,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 +1709,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 +1725,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 +1773,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 +1787,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 +1804,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 +1820,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 +1834,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 +1851,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 +1869,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 +1883,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 +1894,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 +1909,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 +1933,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 +1947,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 +1959,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 +1976,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 +1994,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 +2019,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 +2038,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 +2053,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 +2070,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 +2084,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 +2105,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 +2123,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 +2148,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 +2167,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 +2182,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 +2198,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 +2223,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 +2238,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 +2252,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 +2267,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 +2282,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 +2296,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 +2310,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 +2324,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 +2338,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 +2353,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 +2368,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 +2392,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 +2415,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 +2431,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 +2443,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 +2455,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 +2488,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 +2504,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 +2534,9 @@ package_operation_stand_alone() { package_operation_copy_package - if [[ $failure != "" ]] ; then + if [[ $? -ne 0 ]] ; then + let failure=1 + break fi @@ -2208,6 +2544,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 +2559,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 +2589,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 +2604,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 +2629,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 +2674,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 +2689,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 +2712,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 +2770,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 a627e2b..ae27b0b 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= @@ -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= @@ -110,9 +119,13 @@ test_main() { verbosity="debug" verbose="+D" verbose_common="-v" + elif [[ $p == "+F" || $p == "++line_first_no" ]] ; then + print_line_first="no" + elif [[ $p == "+L" || $p == "++line_last_no" ]] ; then + print_line_last="no" 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 +164,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 +178,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 +205,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 +215,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 +225,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 +235,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 +248,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 +262,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 +276,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 +290,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 +305,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 +343,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 +354,40 @@ 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 -e " +${c_important}F${c_reset}, ++${c_important}line_first_no${c_reset} Disable printing of first line." + echo -e " +${c_important}L${c_reset}, ++${c_important}line_last_no${c_reset} Disable printing of last line." 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 +412,8 @@ test_operate() { test_operate_ci_prebuild if [[ $? -ne 0 ]] ; then + let failure=1 + return 1 fi fi @@ -352,6 +422,8 @@ test_operate() { test_operate_build_tools if [[ $? -ne 0 ]] ; then + let failure=1 + return 1 fi fi @@ -359,6 +431,8 @@ test_operate() { test_operate_build_individual if [[ $? -ne 0 ]] ; then + let failure=1 + return 1 fi @@ -366,6 +440,8 @@ test_operate() { test_operate_ci_pretest if [[ $? -ne 0 ]] ; then + let failure=1 + return 1 fi fi @@ -376,26 +452,29 @@ 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}" + echo fi if [[ $verbosity == "debug" ]] ; then - echo - echo "$shell_command ${path_scripts_package} $verbose $context -d $path_test_package -i rebuild" + test_print_first_or_always + + echo "$shell_command ${path_scripts_package} $verbose $context +F -d $path_test_package -i rebuild" fi - $shell_command ${path_scripts_package} $verbose $context -d $path_test_package -i rebuild + $shell_command ${path_scripts_package} $verbose $context +F -d $path_test_package -i rebuild 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 +496,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 +512,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 +521,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 +530,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,65 +559,71 @@ 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" + echo "zsh ./bootstrap.sh $verbose $context +F -w \"$destination\" -m $mode -m test build" else - echo "zsh ./bootstrap.sh $verbose $context -w \"$destination\" -m $mode -m test -m $build_compiler build" + echo "zsh ./bootstrap.sh $verbose $context +F -w \"$destination\" -m $mode -m test -m $build_compiler build" fi fi if [[ $build_compiler == "gcc" ]] ; then - zsh ./bootstrap.sh $verbose $context -w "$destination" -m $mode -m test build + zsh ./bootstrap.sh $verbose $context +F -w "$destination" -m $mode -m test build else - zsh ./bootstrap.sh $verbose $context -w "$destination" -m $mode -m test -m $build_compiler build + zsh ./bootstrap.sh $verbose $context +F -w "$destination" -m $mode -m test -m $build_compiler build 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" + echo "./bootstrap.sh $verbose $context +F -w \"$destination\" -m $mode -m test build" else - echo "./bootstrap.sh $verbose $context -w \"$destination\" -m $mode -m test -m $build_compiler build" + echo "./bootstrap.sh $verbose $context +F -w \"$destination\" -m $mode -m test -m $build_compiler build" fi fi if [[ $build_compiler == "gcc" ]] ; then - ./bootstrap.sh $verbose $context -w "$destination" -m $mode -m test build + ./bootstrap.sh $verbose $context +F -w "$destination" -m $mode -m test build else - ./bootstrap.sh $verbose $context -w "$destination" -m $mode -m test -m $build_compiler build + ./bootstrap.sh $verbose $context +F -w "$destination" -m $mode -m test -m $build_compiler build fi fi fi 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 - zsh ./install.sh $verbose $context -w "$destination" + zsh ./install.sh $verbose $context +F +L -w "$destination" else - ./install.sh $verbose $context -w "$destination" + ./install.sh $verbose $context +F +L -w "$destination" fi 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,25 +631,28 @@ 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}" + echo fi if [[ $verbosity == "debug" ]] ; then - echo - echo "$shell_command ${path_scripts_package} $verbose $context -d $path_test_package -S fake rebuild" + test_print_first_or_always + + echo "$shell_command ${path_scripts_package} $verbose $context +F -d $path_test_package -S fake rebuild" fi - $shell_command ${path_scripts_package} $verbose $context -d $path_test_package -S fake rebuild + $shell_command ${path_scripts_package} $verbose $context +F -d $path_test_package -S fake rebuild 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 +667,11 @@ test_operate_build_tools() { cd $path_original - return $failure + if [[ $failure == "" ]] ; then + return 0 + fi + + return 1 } test_operate_ci_prebuild() { @@ -582,18 +683,27 @@ 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}" + echo 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 +715,27 @@ 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}" + echo 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 +747,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 +757,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 +766,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 +786,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 +806,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 +826,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 +846,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 +866,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 +886,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 +905,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 +915,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 +924,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 +944,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 +966,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 +982,43 @@ 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}" + echo 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 +1026,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 +1037,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 +1067,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 +1080,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 +1136,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 $*