From 7c91fd2966bee1ae093d9c13e7955c8ac28d6dd7 Mon Sep 17 00:00:00 2001 From: Garritt McCune Date: Sun, 8 Mar 2020 23:28:32 -0500 Subject: [PATCH] Fixed a bug in the build number Bash script where it would decement meta build numbers when they are zero. --- build_numbers.c | 4 ++-- inc_or_dec_build_numbers.sh | 29 +++++++++-------------------- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/build_numbers.c b/build_numbers.c index 270452b..9e4aa14 100644 --- a/build_numbers.c +++ b/build_numbers.c @@ -1,6 +1,6 @@ #ifndef KERNEL_VERSION_NUMBER -#define KERNEL_VERSION_NUMBER "1.4.10-47" +#define KERNEL_VERSION_NUMBER "1.4.10-40" #endif #ifndef CONSOLE_VERSION_NUMBER -#define CONSOLE_VERSION_NUMBER "0.4.5-48" +#define CONSOLE_VERSION_NUMBER "0.4.5-0" #endif diff --git a/inc_or_dec_build_numbers.sh b/inc_or_dec_build_numbers.sh index 20156bd..a560d5a 100644 --- a/inc_or_dec_build_numbers.sh +++ b/inc_or_dec_build_numbers.sh @@ -7,13 +7,7 @@ patch_level=0 #And there is a fourth additional label for the build metadata. #These labels are for pre-release and build metadata. meta=0 - -folder=$(dirname "$1") -parent_folder=$(basename "$folder") -#Capitalize the folder name so it matches the format in the C #define files. -parent_folder=${parent_folder^^} -define_count=0 file_contents="" #Looping code from #https://stackoverflow.com/questions/10929453/read-a-file-line-by-line-assigning-the-value-to-a-variable @@ -25,16 +19,11 @@ while IFS=' ' read -ra line; do continue fi #Lob off the quotes surrounding the version number. - #version_number="${line[2]:1:-1}" + #After lobbing off the quotes, replace all instances of '-' with a period. version_number=($(echo ${line[2]:1:-1} | tr "-" ".")) #The symbol name that #define was setting (i.e. KERNEL_VERSION_NUMBER). symbol=${line[1]} - - for i in "${my_array[@]}" - do - echo $i - done - + #Read in the version number and split it on all periods. IFS='.' read -a chunks <<<$version_number version_part_counter=0 @@ -58,11 +47,16 @@ while IFS=' ' read -ra line; do #number, otherwise we decrement. if [ "$2" == "" ] then + echo "Incrementing meta build number." meta=$(($i + 1)) else - if [ $meta > 0 ] + if [ "$i" -gt 0 ] then + echo "Decrementing meta build number." meta=$(($i - 1)) + else + echo "Meta build number already zero, nothing to be done." + meta=0 fi fi ;; @@ -72,13 +66,8 @@ while IFS=' ' read -ra line; do done ver="$major.$minor.$patch_level-$meta" - tmp="#ifndef ${symbol}\n#define ${symbol} \"$ver\"\n#endif\n" - file_contents="$file_contents$tmp" - - define_count=$(($define_count + 1)) + file_contents="$file_contents#ifndef ${symbol}\n#define ${symbol} \"$ver\"\n#endif\n" done < "$1" -printf "$file_contents" -echo "$1" printf "$file_contents" > "$1"