From f0c997f0a54276b67d26c60d57d28751af2a5a82 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 22 Jul 2019 22:58:01 -0500 Subject: [PATCH] Update: Add additional options, fix minor problems, and other miscellaneous fixes in regards to generate.sh and package.sh scripts Add functionality provided in install.sh, such as configure based system compatible options: --enable-statuc, --disable-static, --enable-shared, and --disable-shared. Fix some typos (such as failire which should instead be failure). Tweak highlight colors used. Use a separate "operation_failure" variable instead of recycling "operation" for parameter operation problems. Add -S/--path_s parameter option for specifying a custom settings path. If paths have a leading slash (/), remove duplicate slashes (such as "///bin/" -> "/bin/"). Make sure the new install.sh script gets added by the package.sh script. The variable "sources_settings" is using the wrong source path (which was "path_c"). Instead, use the newly added "path_s". --- build/scripts/generate.sh | 69 +++++++++++++++++++++++++++++++++++------------ build/scripts/package.sh | 53 +++++++++++++++++++++++++----------- 2 files changed, 90 insertions(+), 32 deletions(-) diff --git a/build/scripts/generate.sh b/build/scripts/generate.sh index a73a632..1903e88 100644 --- a/build/scripts/generate.sh +++ b/build/scripts/generate.sh @@ -31,11 +31,16 @@ generate_main(){ local variables= local settings_file=data/build/settings local operation= + local operation_failure= local path_build=build/ local path_c=sources/c/ + local path_s=data/settings/ local path_bash=sources/bash/ local project_built= + local enable_shared= + local enable_static= + if [[ $# -gt 0 ]] ; then t=$# @@ -61,22 +66,34 @@ generate_main(){ grab_next=path_bash elif [[ $p == "-c" || $p == "--c_path" ]] ; then grab_next=path_c + elif [[ $p == "-S" || $p == "--s_path" ]] ; then + grab_next=path_s elif [[ $p == "-p" || $p == "--project" ]] ; then grab_next=project_built + elif [[ $p == "--enable-shared" ]] ; then + enable_shared="yes" + elif [[ $p == "--disable-shared" ]] ; then + enable_shared="no" + elif [[ $p == "--enable-static" ]] ; then + enable_static="yes" + elif [[ $p == "--disable-static" ]] ; then + enable_static="no" elif [[ $operation == "" ]] ; then - operation=$p - else - operation=fail-multiple + operation="$p" + elif [[ $operation_failure == "" ]] ; then + operation_failure=fail-multiple fi else if [[ $grab_next == "path_build" ]] ; then path_build=$(echo $p | sed -e 's|^//*|/|' -e 's|/*$|/|') elif [[ $grab_next == "settings_file" ]] ; then - settings_file=$(echo $p | sed -e 's|^//*|/|') + settings_file=$(echo $p | sed -e 's|^//*|/|' -e 's|^//*|/|') elif [[ $grab_next == "path_bash" ]] ; then - path_bash=$(echo $p | sed -e 's|/*$|/|') + path_bash=$(echo $p | sed -e 's|^//*|/|' -e 's|/*$|/|') elif [[ $grab_next == "path_c" ]] ; then - path_c=$(echo $p | sed -e 's|/*$|/|') + path_c=$(echo $p | sed -e 's|^//*|/|' -e 's|/*$|/|') + elif [[ $grab_next == "path_s" ]] ; then + path_s=$(echo $p | sed -e 's|^//*|/|' -e 's|/*$|/|') elif [[ $grab_next == "project_built" ]] ; then project_built="-$(echo $p | sed -e 's|/*$||')" fi @@ -111,7 +128,9 @@ generate_main(){ exit 0 fi - if [[ $operation == "build" ]] ; then + if [[ $operation_failure == "fail-multiple" ]] ; then + echo -e "${c_error}ERROR: only one operation may be specified at a time.$c_reset" + elif [[ $operation == "build" ]] ; then if [[ -f ${path_build}.built$project_built ]] ; then echo -e "${c_warning}WARNING: this project has already been built.$c_reset" else @@ -123,8 +142,6 @@ generate_main(){ fi elif [[ $operation == "clean" ]] ; then generate_operation_clean - elif [[ $operation == "fail-multiple" ]] ; then - echo -e "${c_error}ERROR: only one operation may be specified at a time.$c_reset" elif [[ $operation == "" ]] ; then echo -e "${c_error}ERROR: no operation was given.$c_reset" else @@ -159,8 +176,8 @@ generate_help(){ echo -e " ${c_notice}Version $version$c_reset" echo echo -e "$c_highlight$system_name$c_reset $c_notice<${c_reset}operation$c_notice>$c_reset" - echo -e " ${c_important}build${c_reset} Build or compile the code" - echo -e " ${c_important}clean${c_reset} Delete all build files" + echo -e " ${c_important}build${c_reset} Build or compile the code" + 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" @@ -169,11 +186,18 @@ generate_help(){ echo -e " +${c_important}v$c_reset, ++${c_important}version$c_reset Print the version number of this program" echo echo -e "${c_highlight}Generate Options:$c_reset" - echo -e " -${c_important}b$c_reset, --${c_important}build${c_reset} Specify a custom build directory" - echo -e " -${c_important}s$c_reset, --${c_important}settings${c_reset} Specify a custom build settings file" - echo -e " -${c_important}B$c_reset, --${c_important}bash_path${c_reset} Specify a custom path to the bash source files" - echo -e " -${c_important}c$c_reset, --${c_important}c_path${c_reset} Specify a custom path to the c source files" - echo -e " -${c_important}p$c_reset, --${c_important}project${c_reset} Specify a project name for storing built status" + echo -e " -${c_important}b$c_reset, --${c_important}build${c_reset} Specify a custom build directory" + echo -e " -${c_important}s$c_reset, --${c_important}settings${c_reset} Specify a custom build settings file" + echo -e " -${c_important}B$c_reset, --${c_important}bash_path${c_reset} Specify a custom path to the bash source files" + echo -e " -${c_important}c$c_reset, --${c_important}c_path${c_reset} Specify a custom path to the c source files" + echo -e " -${c_important}S$c_reset, --${c_important}s_path${c_reset} Specify a custom path to the settings files" + echo -e " -${c_important}p$c_reset, --${c_important}project${c_reset} Specify a project name for storing built status" + echo + echo -e "${c_highlight}Special Options:$c_reset" + echo -e " --${c_important}enable-shared${c_reset} Forcibly do install shared files" + echo -e " --${c_important}disable-shared${c_reset} Forcibly do not install shared files" + echo -e " --${c_important}enable-static${c_reset} Forcibly do install static files" + echo -e " --${c_important}disable-static${c_reset} Forcibly do not install static files" echo } @@ -285,6 +309,17 @@ generate_operation_build(){ local i= local alt=$1 + if [[ $enable_shared == "yes" ]] ; then + shared="yes" + elif [[ $enable_shared == "no" ]] ; then + shared="no" + fi + + if [[ $enable_static == "yes" ]] ; then + static="yes" + elif [[ $enable_static == "no" ]] ; then + static="no" + fi if [[ $shared != "yes" && $static != "yes" ]] ;then echo -e "${c_error}ERROR: Cannot Build, either build_shared or build_static must be set to 'yes'.$c_reset" @@ -294,7 +329,7 @@ generate_operation_build(){ if [[ $sources_settings != "" ]] ; then for i in $sources_settings ; do - cp -vf $path_c$i ${path_build}settings/ || failure=1 + cp -vR $path_s$i ${path_build}settings/ || failure=1 done fi diff --git a/build/scripts/package.sh b/build/scripts/package.sh index e9b07349..e81fc2c 100644 --- a/build/scripts/package.sh +++ b/build/scripts/package.sh @@ -31,6 +31,7 @@ package_main(){ local variables= local operation= + local operation_failure= local mode_individual= local mode_level= local mode_monolithic= @@ -71,17 +72,18 @@ package_main(){ elif [[ $p == "-s" || $p == "--sources" ]] ; then grab_next=path_sources elif [[ $operation == "" ]] ; then - operation=$p - else - operation=fail-multiple + operation="$p" + elif [[ $operation_failure == "" ]] ; then + operation_failure=fail-multiple + operation="$p" fi else if [[ $grab_next == "path_build" ]] ; then path_build=$(echo $p | sed -e 's|^//*|/|' -e 's|/*$|/|') elif [[ $grab_next == "path_destination" ]] ; then - path_destination=$(echo $p | sed -e 's|/*$|/|') + path_destination=$(echo $p | sed -e 's|^//*|/|' -e 's|/*$|/|') elif [[ $grab_next == "path_sources" ]] ; then - path_sources=$(echo $p | sed -e 's|/*$|/|') + path_sources=$(echo $p | sed -e 's|^//*|/|' -e 's|/*$|/|') fi grab_next= @@ -137,7 +139,9 @@ package_main(){ exit 1 fi - if [[ $operation == "build" ]] ; then + if [[ $operation_failure == "fail-multiple" ]] ; then + echo -e "${c_error}ERROR: only one operation may be specified at a time.$c_reset" + elif [[ $operation == "build" ]] ; then if [[ $mode_individual == "" && $mode_level == "" && $mode_monolithic == "" && $mode_program == "" ]] ; then mode_individual="yes" fi @@ -159,8 +163,6 @@ package_main(){ fi elif [[ $operation == "clean" ]] ; then package_operation_clean - elif [[ $operation == "fail-multiple" ]] ; then - echo -e "${c_error}ERROR: only one operation may be specified at a time.$c_reset" elif [[ $operation == "" ]] ; then echo -e "${c_error}ERROR: no operation was given.$c_reset" else @@ -195,8 +197,8 @@ package_help(){ echo -e " ${c_notice}Version $version$c_reset" echo echo -e "$c_highlight$system_name$c_reset $c_notice<${c_reset}operation$c_notice>$c_reset" - echo -e " ${c_important}build${c_reset} Build the package" - echo -e " ${c_important}clean${c_reset} Delete all built packages" + echo -e " ${c_important}build${c_reset} Build the package" + echo -e " ${c_important}clean${c_reset} Delete all built packages" echo echo -e "${c_highlight}Options:$c_reset" echo -e " -${c_important}h$c_reset, --${c_important}help$c_reset Print this help screen" @@ -204,7 +206,7 @@ package_help(){ echo -e " +${c_important}n$c_reset, ++${c_important}no_color$c_reset Do not use color" echo -e " +${c_important}v$c_reset, ++${c_important}version$c_reset Print the version number of this program" echo - echo -e "${c_highlight}Generate Options:$c_reset" + 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" echo -e " -${c_important}b$c_reset, --${c_important}build${c_reset} Specify a custom build directory" echo -e " -${c_important}i$c_reset, --${c_important}individual${c_reset} Build packages by individual package (levels 0. 1. and 2)" @@ -269,7 +271,7 @@ package_create_base_files() { failure=1 fi - if [[ $failire == "" ]] ; then + if [[ $failure == "" ]] ; then chmod ugo+x ${package}generate.sh if [[ $? -ne 0 ]] ; then @@ -277,6 +279,24 @@ package_create_base_files() { failure=1 fi fi + + if [[ $failure == "" ]] ; then + cp -vR ${path_build}scripts/install.sh $package + + if [[ $? -ne 0 ]] ; then + 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" + failure=1 + fi + fi + + if [[ $failure == "" ]] ; then + chmod ugo+x ${package}install.sh + + if [[ $? -ne 0 ]] ; then + echo -e "${c_error}ERROR: failed to set executable permissions on script $c_notice${package}install.sh$c_error.$c_reset" + failure=1 + fi + fi fi if [[ $failure != "" && ! -d ${package}build ]] ; then @@ -323,7 +343,8 @@ 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/${name}-${version}/" - echo -e "${c_important}Processing Package $c_reset$c_notice$package$c_reset${c_important}.$c_reset" + echo + echo -e "${c_highlight}Processing Package$c_reset (individual) $c_notice${name}-${version}$c_reset${c_highlight}.$c_reset" package_create_base_files @@ -362,7 +383,8 @@ package_operation_level(){ name="fll-$level" package="${path_destination}level/${name}-${version}/" - echo -e "${c_important}Processing Package $c_reset$c_notice$package$c_reset${c_important}.$c_reset" + echo + echo -e "${c_highlight}Processing Package$c_reset (level) $c_notice${name}-${version}$c_reset${c_highlight}.$c_reset" if [[ ! -d $path_build$level ]] ; then echo -e "${c_error}ERROR: build settings directory $c_notice$path_build$level$c_error is invalid or missing.$c_reset" @@ -485,7 +507,8 @@ package_operation_program(){ name="$(echo $directory | sed -e "s|${path_sources}level_3/||")" package="${path_destination}program/${name}-${version}/" - echo -e "${c_important}Processing Package $c_reset$c_notice$package$c_reset${c_important}.$c_reset" + echo + echo -e "${c_highlight}Processing Package$c_reset (program) $c_notice${name}-${version}$c_reset${c_highlight}.$c_reset" package_create_base_files -- 1.8.3.1