Skip to content

Commit da85525

Browse files
committed
Deal with pollution of the --get-pref output introduced in Arduino IDE 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.
1 parent 6a7eefd commit da85525

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

Diff for: arduino-ci-script.sh

+25-3
Original file line numberDiff line numberDiff line change
@@ -534,13 +534,35 @@ function install_package() {
534534
if [[ "$packageURL" != "" ]]; then
535535
# Get the current Additional Boards Manager URLs preference value so it won't be overwritten when the new URL is added
536536
local priorBoardsmanagerAdditionalURLs
537+
local getPrefExitStatus
538+
# arduino --get-pref returns 4 when the preference does not exist, which is an acceptable circumstance. So it's necessary to unset errexit
539+
set +o errexit
537540
if [[ "$ARDUINO_CI_SCRIPT_VERBOSITY_LEVEL" -eq 0 ]]; then
538-
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)
541+
priorBoardsmanagerAdditionalURLs=$(
542+
"${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
543+
exit "${PIPESTATUS[0]}"
544+
)
545+
getPrefExitStatus="$?"
539546
elif [[ "$ARDUINO_CI_SCRIPT_VERBOSITY_LEVEL" -eq 1 ]]; then
540-
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)
547+
priorBoardsmanagerAdditionalURLs=$(
548+
"${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER}/${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER}/${ARDUINO_CI_SCRIPT_ARDUINO_COMMAND}" --get-pref boardsmanager.additional.urls | tail --lines=1
549+
exit "${PIPESTATUS[0]}"
550+
)
551+
getPrefExitStatus="$?"
541552
else
542-
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)
553+
priorBoardsmanagerAdditionalURLs=$(
554+
"${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
555+
exit "${PIPESTATUS[0]}"
556+
)
557+
getPrefExitStatus="$?"
543558
fi
559+
set -o errexit
560+
561+
if [[ "$getPrefExitStatus" == "4" ]]; then
562+
# No boardsmanager.additional.urls preference was set. This causes priorBoardsmanagerAdditionalURLs to have a garbage value with Arduino IDE 1.8.10 and newer.
563+
priorBoardsmanagerAdditionalURLs=""
564+
fi
565+
544566
local -r blankregex="^[ ]*$"
545567
if [[ "$priorBoardsmanagerAdditionalURLs" =~ $blankregex ]]; then
546568
# There is no previous Additional Boards Manager URLs preference value

0 commit comments

Comments
 (0)