From cad708d210196690c2cc537004e556b075dc758c Mon Sep 17 00:00:00 2001 From: Paul Fagerburg Date: Wed, 25 Sep 2019 09:31:57 -0600 Subject: util/mb/google/hatch: fix style issues in shell script * Use all caps for variables. * Use a single exit code for failures. * No need to popd before exiting the script. * Do ${var,,} and ${var^^} into variables instead of using it everywhere. * Add more punctuation in comments. * Specify LC_ALL=C so that upper/lower case show the desired behavior. Signed-off-by: Paul Fagerburg Change-Id: I63aa0aa633f36b9543e809fc42fac955da5960a3 Reviewed-on: https://review.coreboot.org/c/coreboot/+/35605 Tested-by: build bot (Jenkins) Reviewed-by: Andrew McRae Reviewed-by: Edward O'Callaghan --- .../google/hatch/create_coreboot_variant.sh | 52 +++++++++++----------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'util/mainboard/google/hatch') diff --git a/util/mainboard/google/hatch/create_coreboot_variant.sh b/util/mainboard/google/hatch/create_coreboot_variant.sh index d4256a6ccc..739c2f1ac0 100755 --- a/util/mainboard/google/hatch/create_coreboot_variant.sh +++ b/util/mainboard/google/hatch/create_coreboot_variant.sh @@ -13,6 +13,8 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. +export LC_ALL=C + if [[ "$#" -ne 1 ]]; then echo "Usage: $0 variant_name" echo "e.g. $0 kohaku" @@ -26,54 +28,52 @@ fi # you to specify the baseboard as one of the cmdline arguments. # # This is the name of the base board that we're cloning to make the variant. -base="hatch" -# This is the name of the variant that is being cloned -# ${var,,} converts to all lowercase -variant="${1,,}" +BASE="hatch" +# This is the name of the variant that is being cloned. +# ${var,,} converts to all lowercase; ${var^^} is all uppercase. +VARIANT="${1,,}" +VARIANT_UPPER="${VARIANT^^}" # This script and the templates live in util/mainboard/google/hatch # We need to create files in src/mainboard/google/hatch -pushd "${BASH_SOURCE%/*}" || exit +pushd "${BASH_SOURCE%/*}" || exit 1 SRC=$(pwd) -popd || exit -pushd "${SRC}/../../../../src/mainboard/google/${base}" || { - echo "The baseboard directory for ${base} does not exist."; - exit; } +popd || exit 1 +pushd "${SRC}/../../../../src/mainboard/google/${BASE}" || { + echo "The baseboard directory for ${BASE} does not exist."; + exit 1; } -# Make sure the variant doesn't already exist -if [[ -e variants/${variant} ]]; then - echo "variants/${variant} already exists." +# Make sure the variant doesn't already exist. +if [[ -e variants/${VARIANT} ]]; then + echo "variants/${VARIANT} already exists." echo "Have you already created this variant?" - popd || exit - exit 2 + exit 1 fi # Start a branch. Use YMD timestamp to avoid collisions. DATE=$(date +%Y%m%d) -git checkout -b "create_${variant}_${DATE}" +git checkout -b "create_${VARIANT}_${DATE}" || exit 1 -# Copy the template tree to the target -mkdir -p "variants/${variant}/" -cp -pr "${SRC}/template/." "variants/${variant}/" -git add "variants/${variant}/" +# Copy the template tree to the target. +mkdir -p "variants/${VARIANT}/" +cp -pr "${SRC}/template/." "variants/${VARIANT}/" +git add "variants/${VARIANT}/" # Now add the new variant to Kconfig and Kconfig.name # These files are in the current directory, e.g. src/mainboard/google/hatch -"${SRC}/kconfig.py" --name "${variant}" +"${SRC}/kconfig.py" --name "${VARIANT}" mv Kconfig.new Kconfig mv Kconfig.name.new Kconfig.name git add Kconfig Kconfig.name -# Now commit the files -git commit -sm "${base}: Create ${variant} variant +# Now commit the files. +git commit -sm "${BASE}: Create ${VARIANT} variant BUG=none -TEST=util/abuild/abuild -p none -t google/${base} -x -a -make sure the build includes GOOGLE_${variant^^}" - -popd || exit +TEST=util/abuild/abuild -p none -t google/${BASE} -x -a +make sure the build includes GOOGLE_${VARIANT_UPPER}" echo "Please check all the files (git show), make any changes you want," echo "and then push to coreboot HEAD:refs/for/master" -- cgit v1.2.3