Fixed a bug in the build number Bash script where it would decement meta build numbers when they are zero.

This commit is contained in:
2020-03-08 23:28:32 -05:00
parent b9f68c4348
commit 7c91fd2966
2 changed files with 11 additions and 22 deletions
+2 -2
View File
@@ -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
+9 -20
View File
@@ -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"