Skip to content

Commit

Permalink
Deal with pollution of the --get-pref output introduced in Arduino ID…
Browse files Browse the repository at this point in the history
…E 1.8.10

arduino/Arduino#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.
  • Loading branch information
per1234 committed Jan 9, 2020
1 parent 6a7eefd commit da85525
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions arduino-ci-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit da85525

Please sign in to comment.