From da8552507645659d50f825150bc1a63bd8c9e7fa Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 8 Jan 2020 20:53:25 -0800 Subject: [PATCH] Deal with pollution of the --get-pref output introduced in Arduino IDE 1.8.10 https://github.com/arduino/Arduino/pull/9023 changed the Arduino IDE CLI's output. Due to this, when no boardsmanager.additional.urls preference is set, the output from Arduino IDE 1.8.10 (and onwards likely) caused priorBoardsmanagerAdditionalURLs to be set to "Set log4j store directory /home/travis/.arduino15". The solution was to check the exit status of the arduino --get-pref command and if it is 4 (Preference passed to --get-pref does not exist), overwrite the spurious value. --- arduino-ci-script.sh | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/arduino-ci-script.sh b/arduino-ci-script.sh index 686a14c..0fc3b49 100644 --- a/arduino-ci-script.sh +++ b/arduino-ci-script.sh @@ -534,13 +534,35 @@ function install_package() { if [[ "$packageURL" != "" ]]; then # Get the current Additional Boards Manager URLs preference value so it won't be overwritten when the new URL is added local priorBoardsmanagerAdditionalURLs + local getPrefExitStatus + # arduino --get-pref returns 4 when the preference does not exist, which is an acceptable circumstance. So it's necessary to unset errexit + set +o errexit if [[ "$ARDUINO_CI_SCRIPT_VERBOSITY_LEVEL" -eq 0 ]]; then - priorBoardsmanagerAdditionalURLs=$("${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER}/${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER}/${ARDUINO_CI_SCRIPT_ARDUINO_COMMAND}" --get-pref boardsmanager.additional.urls 2>/dev/null | tail --lines=1) + priorBoardsmanagerAdditionalURLs=$( + "${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER}/${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER}/${ARDUINO_CI_SCRIPT_ARDUINO_COMMAND}" --get-pref boardsmanager.additional.urls 2>/dev/null | tail --lines=1 + exit "${PIPESTATUS[0]}" + ) + getPrefExitStatus="$?" elif [[ "$ARDUINO_CI_SCRIPT_VERBOSITY_LEVEL" -eq 1 ]]; then - priorBoardsmanagerAdditionalURLs=$("${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER}/${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER}/${ARDUINO_CI_SCRIPT_ARDUINO_COMMAND}" --get-pref boardsmanager.additional.urls | tail --lines=1) + priorBoardsmanagerAdditionalURLs=$( + "${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER}/${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER}/${ARDUINO_CI_SCRIPT_ARDUINO_COMMAND}" --get-pref boardsmanager.additional.urls | tail --lines=1 + exit "${PIPESTATUS[0]}" + ) + getPrefExitStatus="$?" else - priorBoardsmanagerAdditionalURLs=$("${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER}/${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER}/${ARDUINO_CI_SCRIPT_ARDUINO_COMMAND}" --get-pref boardsmanager.additional.urls | tee /dev/tty | tail --lines=1) + priorBoardsmanagerAdditionalURLs=$( + "${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER}/${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER}/${ARDUINO_CI_SCRIPT_ARDUINO_COMMAND}" --get-pref boardsmanager.additional.urls | tee /dev/tty | tail --lines=1 + exit "${PIPESTATUS[0]}" + ) + getPrefExitStatus="$?" fi + set -o errexit + + if [[ "$getPrefExitStatus" == "4" ]]; then + # No boardsmanager.additional.urls preference was set. This causes priorBoardsmanagerAdditionalURLs to have a garbage value with Arduino IDE 1.8.10 and newer. + priorBoardsmanagerAdditionalURLs="" + fi + local -r blankregex="^[ ]*$" if [[ "$priorBoardsmanagerAdditionalURLs" =~ $blankregex ]]; then # There is no previous Additional Boards Manager URLs preference value