From 831e5d8b0dce5279964987baa43201b63c12c203 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sun, 19 Mar 2023 22:16:30 -0500 Subject: [PATCH] Bugfix: Out of date install.sh and Featureless Make helper scripts. It seems that I never looked at these in a while and they are rather out of date. Fix the parameters. There are other scripts that need to be looked at as well and are not solved by this commit. --- build/scripts/install.sh | 197 ++++++++++++++++++++++++++++---- level_3/fake/data/build/process_post.sh | 55 +++++---- level_3/fake/data/build/process_pre.sh | 55 +++++---- 3 files changed, 228 insertions(+), 79 deletions(-) diff --git a/build/scripts/install.sh b/build/scripts/install.sh index f8b3179..f4c6147 100644 --- a/build/scripts/install.sh +++ b/build/scripts/install.sh @@ -27,6 +27,7 @@ install_main() { local grab_next= local do_color=dark local do_help= + local do_copyright= local i=0 local p= local t=0 @@ -79,6 +80,8 @@ install_main() { local enable_static_programs="yes" local enable_static_libraries="yes" local enable_includes="yes" + local print_line_first="yes" + local print_line_last="yes" if [[ $# -gt 0 ]] ; then t=$# @@ -95,23 +98,29 @@ install_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 + do_color="dark" context="+d" elif [[ $p == "+l" || $p == "++light" ]] ; then - do_color=light + do_color="light" context="+l" 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 == "+N" || $p == "++normal" ]] ; then verbosity= verbose="+N" verbose_common= + elif [[ $p == "+E" || $p == "++error" ]] ; then + verbosity="error" + verbose="+E" + verbose_common= elif [[ $p == "+V" || $p == "++verbose" ]] ; then verbosity="verbose" verbose="+V" @@ -120,6 +129,10 @@ install_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 @@ -222,9 +235,24 @@ install_main() { return 0 fi + if [[ $do_copyright == "yes" ]] ; then + install_copyright + install_cleanup + + return 0 + fi + if [[ $operation_failure == "fail-unsupported" ]] ; then if [[ $verbosity != "quiet" ]] ; then + if [[ $print_line_first == "yes" ]] ; then + echo + fi + 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 fi install_cleanup @@ -234,7 +262,15 @@ install_main() { if [[ ! -d $path_build ]] ; then if [[ $verbosity != "quiet" ]] ; then + if [[ $print_line_first == "yes" ]] ; then + echo + fi + 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 fi install_cleanup @@ -244,7 +280,15 @@ install_main() { if [[ $work == "" && $destination_prefix != "" && ! -d $destination_prefix ]] ; then if [[ $verbosity != "quiet" ]] ; then + if [[ $print_line_first == "yes" ]] ; then + echo + fi + 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 fi install_cleanup @@ -308,7 +352,15 @@ install_main() { if [[ $work != "" && ! -d $work ]] ; then if [[ $verbosity != "quiet" ]] ; then + if [[ $print_line_first == "yes" ]] ; then + echo + fi + 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 fi install_cleanup @@ -318,7 +370,15 @@ install_main() { if [[ $work == "" && -e $destination_programs && ! -d $destination_programs ]] ; then if [[ $verbosity != "quiet" ]] ; then + if [[ $print_line_first == "yes" ]] ; then + echo + fi + 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 fi install_cleanup @@ -328,7 +388,15 @@ 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 + 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 fi install_cleanup @@ -338,7 +406,15 @@ 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 + 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 fi install_cleanup @@ -348,7 +424,15 @@ install_main() { if [[ $work == "" && -e $destination_includes && ! -d $destination_includes ]] ; then if [[ $verbosity != "quiet" ]] ; then + if [[ $print_line_first == "yes" ]] ; then + echo + fi + 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 fi install_cleanup @@ -358,7 +442,15 @@ 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 + 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 fi install_cleanup @@ -368,7 +460,15 @@ 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 + 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 fi install_cleanup @@ -407,22 +507,29 @@ install_handle_colors() { install_help() { - echo + if [[ $print_line_first == "yes" ]] ; then + echo + fi + echo -e "${c_title}${public_name}${c_reset}" echo -e " ${c_notice}Version ${version}${c_reset}" echo echo -e "${c_highlight}${system_name}${c_reset} ${c_notice}[${c_reset} options ${c_notice}]${c_reset}" 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}b${c_reset}, --${c_important}build${c_reset} Custom build directory." @@ -453,7 +560,27 @@ install_help() { echo -e " --${c_important}libraries-shared${c_reset} Custom destination for shared libraries." 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_copyright() { + + if [[ $print_line_first == "yes" ]] ; then + echo + fi + + 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." + + if [[ $print_line_last == "yes" ]] ; then + echo + fi } install_perform_install() { @@ -489,6 +616,12 @@ 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} @@ -633,7 +766,8 @@ install_perform_install() { if [[ $file != "" ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + install_print_first + echo -e "${c_highlight}Installing Includes to: ${c_reset}${c_notice}${destination_includes}${c_reset}${c_highlight}.${c_reset}" fi @@ -664,7 +798,8 @@ install_perform_install() { if [[ $file != "" ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + install_print_first + 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 @@ -694,7 +829,8 @@ install_perform_install() { if [[ $file != "" ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + install_print_first + 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 @@ -726,7 +862,8 @@ install_perform_install() { if [[ $file != "" && $enable_static_programs == "yes" ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + install_print_first + 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 @@ -756,7 +893,8 @@ install_perform_install() { if [[ $file != "" ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + install_print_first + 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 @@ -787,7 +925,8 @@ install_perform_install() { if [[ $file != "" ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + install_print_first + echo -e "${c_highlight}Installing Documentation to: ${c_reset}${c_notice}${destination_settings}${c_reset}${c_highlight}.${c_reset}" fi @@ -817,7 +956,8 @@ install_perform_install() { if [[ $file != "" ]] ; then if [[ $verbosity != "quiet" ]] ; then - echo + install_print_first + echo -e "${c_highlight}Installing Documentation to: ${c_reset}${c_notice}${destination_documentation}${c_reset}${c_highlight}.${c_reset}" fi @@ -833,6 +973,10 @@ install_perform_install() { fi fi + if [[ $verbosity != "quiet" && $print_line_last == "yes" ]] ; then + echo + fi + if [[ $failure != "" ]] ; then install_cleanup @@ -840,12 +984,23 @@ install_perform_install() { fi } +install_print_first() { + + if [[ $print_line_first == "done" ]] ; then + print_line_first= + else + echo + fi +} + install_cleanup() { + unset install_copyright unset install_main unset install_handle_colors unset install_help unset install_perform_install + unset install_print_first unset install_cleanup } diff --git a/level_3/fake/data/build/process_post.sh b/level_3/fake/data/build/process_post.sh index 7193783..4415b48 100755 --- a/level_3/fake/data/build/process_post.sh +++ b/level_3/fake/data/build/process_post.sh @@ -7,9 +7,9 @@ # # The dependencies of this script are: bash and sed. # -process_post_main(){ +process_post_main() { local grab_next= - local do_color=normal + local do_color=dark local i=0 local p= local t=0 @@ -35,8 +35,7 @@ process_post_main(){ local path_data= local path_sources= local path_work= - local verbosity= - local build_status= + local verbosity=normal # generated paths and standard paths. local path_directory_separator="/" @@ -89,38 +88,38 @@ process_post_main(){ if [[ $operation == "" ]] ; then operation=$p fi - elif [[ $p == "-d" ]] ; then + elif [[ $p == "-d" || $p == "--define" ]] ; then grab_next="defines" - elif [[ $p == "-m" ]] ; then + elif [[ $p == "-m" || $p == "--mode" ]] ; then grab_next="modes" - elif [[ $p == "-o" ]] ; then + elif [[ $p == "-p" || $p == "--process" ]] ; then grab_next="process" - elif [[ $p == "-s" ]] ; then + elif [[ $p == "-s" || $p == "--settings" ]] ; then grab_next="file_settings" - elif [[ $p == "-b" ]] ; then + elif [[ $p == "-b" || $p == "--build" ]] ; then grab_next="path_build" - elif [[ $p == "-D" ]] ; then + elif [[ $p == "-D" || $p == "--data" ]] ; then grab_next="path_data" - elif [[ $p == "-S" ]] ; then + elif [[ $p == "-S" || $p == "--sources" ]] ; then grab_next="path_sources" - elif [[ $p == "-w" ]] ; then + elif [[ $p == "-w" || $p == "--work" ]] ; then grab_next="path_work" - elif [[ $p == "+D" ]] ; then + elif [[ $p == "+D" || $p == "++debug" ]] ; then verbosity=debug - elif [[ $p == "+q" ]] ; then + elif [[ $p == "+E" || $p == "++error" ]] ; then + verbosity=error + elif [[ $p == "+N" || $p == "++normal" ]] ; then + verbosity=normal + elif [[ $p == "+Q" || $p == "++quiet" ]] ; then verbosity=quiet - elif [[ $p == "+V" ]] ; then + elif [[ $p == "+V" || $p == "++verbose" ]] ; then verbosity=verbose - elif [[ $p == "+l" ]] ; then - if [[ $do_color == "normal" ]] ; then - do_color=light - fi - elif [[ $p == "+n" ]] ; then - if [[ $do_color == "normal" ]] ; then - do_color=none - fi - elif [[ $p == "++status" ]] ; then - grab_next=build_status + elif [[ $p == "+l" || $p == "++light" ]] ; then + do_color=light + elif [[ $p == "+d" || $p == "++dark" ]] ; then + do_color=dark + elif [[ $p == "+n" || $p == "++no_color" ]] ; then + do_color=none fi else if [[ $grab_next == "defines" ]] ; then @@ -157,8 +156,6 @@ process_post_main(){ path_source_settings=$(process_post_path_fix $p) elif [[ $grab_next == "path_work" ]] ; then path_work=$(process_post_path_fix $p) - elif [[ $grab_next == "build_status" ]] ; then - build_status="$p" fi grab_next= @@ -224,7 +221,7 @@ process_post_main(){ file_data_build_settings="${path_data_build}settings" file_documents_readme="${path_documents}readme" - if [[ $verbosity != "quiet" ]] ; then + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then echo echo -e "${c_title}Completed Operation: $c_reset$c_notice$operation$c_reset" @@ -243,7 +240,7 @@ process_post_main(){ return 0 } -process_post_path_fix(){ +process_post_path_fix() { echo -n $* | sed -e "s|^${path_directory_separator}${path_directory_separator}*|${path_directory_separator}|" -e "s|${path_directory_separator}*$|${path_directory_separator}|" } diff --git a/level_3/fake/data/build/process_pre.sh b/level_3/fake/data/build/process_pre.sh index 2a9c92d..51da85a 100755 --- a/level_3/fake/data/build/process_pre.sh +++ b/level_3/fake/data/build/process_pre.sh @@ -7,9 +7,9 @@ # # The dependencies of this script are: bash and sed. # -process_pre_main(){ +process_pre_main() { local grab_next= - local do_color=normal + local do_color=dark local i=0 local p= local t=0 @@ -35,8 +35,7 @@ process_pre_main(){ local path_data= local path_sources= local path_work= - local verbosity= - local build_status= + local verbosity=normal # generated paths and standard paths. local path_directory_separator="/" @@ -89,38 +88,38 @@ process_pre_main(){ if [[ $operation == "" ]] ; then operation=$p fi - elif [[ $p == "-d" ]] ; then + elif [[ $p == "-d" || $p == "--define" ]] ; then grab_next="defines" - elif [[ $p == "-m" ]] ; then + elif [[ $p == "-m" || $p == "--mode" ]] ; then grab_next="modes" - elif [[ $p == "-o" ]] ; then + elif [[ $p == "-p" || $p == "--process" ]] ; then grab_next="process" - elif [[ $p == "-s" ]] ; then + elif [[ $p == "-s" || $p == "--settings" ]] ; then grab_next="file_settings" - elif [[ $p == "-b" ]] ; then + elif [[ $p == "-b" || $p == "--build" ]] ; then grab_next="path_build" - elif [[ $p == "-D" ]] ; then + elif [[ $p == "-D" || $p == "--data" ]] ; then grab_next="path_data" - elif [[ $p == "-S" ]] ; then + elif [[ $p == "-S" || $p == "--sources" ]] ; then grab_next="path_sources" - elif [[ $p == "-w" ]] ; then + elif [[ $p == "-w" || $p == "--work" ]] ; then grab_next="path_work" - elif [[ $p == "+D" ]] ; then + elif [[ $p == "+D" || $p == "++debug" ]] ; then verbosity=debug - elif [[ $p == "+q" ]] ; then + elif [[ $p == "+E" || $p == "++error" ]] ; then + verbosity=error + elif [[ $p == "+N" || $p == "++normal" ]] ; then + verbosity=normal + elif [[ $p == "+Q" || $p == "++quiet" ]] ; then verbosity=quiet - elif [[ $p == "+V" ]] ; then + elif [[ $p == "+V" || $p == "++verbose" ]] ; then verbosity=verbose - elif [[ $p == "+l" ]] ; then - if [[ $do_color == "normal" ]] ; then - do_color=light - fi - elif [[ $p == "+n" ]] ; then - if [[ $do_color == "normal" ]] ; then - do_color=none - fi - elif [[ $p == "++status" ]] ; then - grab_next=build_status + elif [[ $p == "+l" || $p == "++light" ]] ; then + do_color=light + elif [[ $p == "+d" || $p == "++dark" ]] ; then + do_color=dark + elif [[ $p == "+n" || $p == "++no_color" ]] ; then + do_color=none fi else if [[ $grab_next == "defines" ]] ; then @@ -157,8 +156,6 @@ process_pre_main(){ path_source_settings=$(process_pre_path_fix $p) elif [[ $grab_next == "path_work" ]] ; then path_work=$(process_pre_path_fix $p) - elif [[ $grab_next == "build_status" ]] ; then - build_status="$p" fi grab_next= @@ -224,7 +221,7 @@ process_pre_main(){ file_data_build_settings="${path_data_build}settings" file_documents_readme="${path_documents}readme" - if [[ $verbosity != "quiet" ]] ; then + if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then echo echo -e "${c_title}Processing Operation: $c_reset$c_notice$operation$c_reset" @@ -243,7 +240,7 @@ process_pre_main(){ return 0 } -process_pre_path_fix(){ +process_pre_path_fix() { echo -n $* | sed -e "s|^${path_directory_separator}${path_directory_separator}*|${path_directory_separator}|" -e "s|${path_directory_separator}*$|${path_directory_separator}|" } -- 1.8.3.1