Skip to content

Commit 835845f

Browse files
committed
Eliminate the use of sudo and use symbolic links for installation
Thanks to some advice from @majekw, I discovered that sudo was only necessary because of the use of /usr/local/share as the folder the Arduino IDE was installed to. By changing to the use of a subfolder of $HOME I was able to do without sudo. Hopefully this will decrease the build time. I also am able to use symbolic links for installation, which makes it unnecessary to uninstall the IDE by moving it back to the version folder. This should be faster than using mv for installation and uninstallation.
1 parent 914af84 commit 835845f

File tree

2 files changed

+12
-33
lines changed

2 files changed

+12
-33
lines changed

.travis.yml

-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
# This file is used to test the script with Travis CI
22

33
language: bash
4-
sudo: required
54

65

76
env:
87
global:
98
# The Arduino IDE will be installed at APPLICATION_FOLDER/arduino
10-
- APPLICATION_FOLDER="/usr/local/share"
11-
- SKETCHBOOK_FOLDER="${HOME}/Arduino"
129

1310
matrix:
1411
# Test install_ide with no argument (using full version list). This would cause the Travis CI build to take much longer so I have it disabled

arduino-ci-script.sh

+12-30
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ FULL_IDE_VERSION_LIST_ARRAY="${IDE_VERSION_LIST_ARRAY_DECLARATION}"'("1.5.2" "1.
2020

2121

2222
TEMPORARY_FOLDER="${HOME}/temporary/arduino-ci-script"
23+
IDE_INSTALLATION_FOLDER="arduino"
2324
VERIFICATION_OUTPUT_FILENAME="${TEMPORARY_FOLDER}/verification_output.txt"
2425
REPORT_FILENAME="travis_ci_job_report_$(printf "%05d\n" "${TRAVIS_BUILD_NUMBER}").$(printf "%03d\n" "$(echo "$TRAVIS_JOB_NUMBER" | cut -d'.' -f 2)").tsv"
2526
REPORT_FOLDER="${HOME}/arduino-ci-script_report"
@@ -213,6 +214,7 @@ function install_ide()
213214
determine_ide_version_extremes "$INSTALLED_IDE_VERSION_LIST_ARRAY"
214215
NEWEST_INSTALLED_IDE_VERSION="$DETERMINED_NEWEST_IDE_VERSION"
215216

217+
create_folder "$APPLICATION_FOLDER"
216218

217219
# This runs the command contained in the $INSTALLED_IDE_VERSION_LIST_ARRAY string, thus declaring the array locally as $IDEversionListArray. This must be done in any function that uses the array
218220
# Dummy declaration to fix the "referenced but not assigned" warning.
@@ -234,20 +236,18 @@ function install_ide()
234236
wget "http://downloads.arduino.cc/arduino-nightly-linux64.${downloadFileExtension}"
235237
tar xf "arduino-nightly-linux64.${downloadFileExtension}"
236238
rm "arduino-nightly-linux64.${downloadFileExtension}"
237-
sudo mv "arduino-nightly" "$APPLICATION_FOLDER/arduino-${IDEversion}"
239+
mv "arduino-nightly" "$APPLICATION_FOLDER/arduino-${IDEversion}"
238240

239241
else
240242
wget "http://downloads.arduino.cc/arduino-${IDEversion}-linux64.${downloadFileExtension}"
241243
tar xf "arduino-${IDEversion}-linux64.${downloadFileExtension}"
242244
rm "arduino-${IDEversion}-linux64.${downloadFileExtension}"
243-
sudo mv "arduino-${IDEversion}" "$APPLICATION_FOLDER/arduino-${IDEversion}"
245+
mv "arduino-${IDEversion}" "$APPLICATION_FOLDER/arduino-${IDEversion}"
244246
fi
245247
done
246248

247249
# Temporarily install the latest IDE version
248250
install_ide_version "$NEWEST_INSTALLED_IDE_VERSION"
249-
# Create the link that will be used for all IDE installations
250-
sudo ln --symbolic "$APPLICATION_FOLDER/arduino/arduino" /usr/local/bin/arduino
251251

252252
# Set the preferences
253253
# --pref option is only supported by Arduino IDE 1.5.6 and newer
@@ -259,16 +259,13 @@ function install_ide()
259259
# --save-prefs was added in Arduino IDE 1.5.8
260260
local regex="1.5.[6-7]"
261261
if ! [[ "$NEWEST_INSTALLED_IDE_VERSION" =~ $regex ]]; then
262-
arduino --pref compiler.warning_level=all --pref sketchbook.path="$SKETCHBOOK_FOLDER" --save-prefs
262+
${APPLICATION_FOLDER}/${IDE_INSTALLATION_FOLDER}/arduino --pref compiler.warning_level=all --pref sketchbook.path="$SKETCHBOOK_FOLDER" --save-prefs
263263
else
264264
# Arduino IDE 1.5.6 - 1.5.7 load the GUI if you only set preferences without doing a verify. So I am doing an unnecessary verification just to set the preferences in those versions. Definitely a hack but I prefer to keep the preferences setting code all here instead of cluttering build_sketch and this will pretty much never be used.
265-
arduino --pref compiler.warning_level=all --pref sketchbook.path="$SKETCHBOOK_FOLDER" --verify "${APPLICATION_FOLDER}/arduino/examples/01.Basics/BareMinimum/BareMinimum.ino"
265+
${APPLICATION_FOLDER}/${IDE_INSTALLATION_FOLDER}/arduino --pref compiler.warning_level=all --pref sketchbook.path="$SKETCHBOOK_FOLDER" --verify "${APPLICATION_FOLDER}/arduino/examples/01.Basics/BareMinimum/BareMinimum.ino"
266266
fi
267267
fi
268268

269-
# Uninstall the IDE
270-
uninstall_ide_version "$NEWEST_INSTALLED_IDE_VERSION"
271-
272269
# Return errexit to the default state
273270
set +o errexit
274271

@@ -394,18 +391,9 @@ function install_ide_version()
394391
enable_verbosity
395392

396393
local IDEversion="$1"
397-
sudo mv "${APPLICATION_FOLDER}/arduino-${IDEversion}" "${APPLICATION_FOLDER}/arduino"
398-
399-
disable_verbosity
400-
}
401-
402394

403-
function uninstall_ide_version()
404-
{
405-
enable_verbosity
406-
407-
local IDEversion="$1"
408-
sudo mv "${APPLICATION_FOLDER}/arduino" "${APPLICATION_FOLDER}/arduino-${IDEversion}"
395+
# Create a symbolic link so that the Arduino IDE can always be referenced from the same path no matter which version is being used.
396+
ln -sf "${APPLICATION_FOLDER}/arduino-${IDEversion}" "${APPLICATION_FOLDER}/${IDE_INSTALLATION_FOLDER}"
409397

410398
disable_verbosity
411399
}
@@ -484,14 +472,12 @@ function install_package()
484472

485473
# If defined add the boards manager URL to preferences
486474
if [[ "$packageURL" != "" ]]; then
487-
arduino --pref boardsmanager.additional.urls="$packageURL" --save-prefs
475+
${APPLICATION_FOLDER}/${IDE_INSTALLATION_FOLDER}/arduino --pref boardsmanager.additional.urls="$packageURL" --save-prefs
488476
fi
489477

490478
# Install the package
491-
arduino --install-boards "$packageID"
479+
${APPLICATION_FOLDER}/${IDE_INSTALLATION_FOLDER}/arduino --install-boards "$packageID"
492480

493-
# Uninstall the IDE
494-
uninstall_ide_version "$NEWEST_INSTALLED_IDE_VERSION"
495481
fi
496482
fi
497483

@@ -571,10 +557,8 @@ function install_library()
571557
install_ide_version "$NEWEST_INSTALLED_IDE_VERSION"
572558

573559
# Install the library
574-
arduino --install-library "$libraryName"
560+
${APPLICATION_FOLDER}/${IDE_INSTALLATION_FOLDER}/arduino --install-library "$libraryName"
575561

576-
# Uninstall the IDE
577-
uninstall_ide_version "$NEWEST_INSTALLED_IDE_VERSION"
578562
fi
579563
fi
580564

@@ -662,8 +646,6 @@ function build_sketch()
662646
fi
663647
done
664648
fi
665-
# Uninstall the IDE
666-
uninstall_ide_version "$IDEversion"
667649
done
668650

669651
disable_verbosity
@@ -700,7 +682,7 @@ function build_this_sketch()
700682
# Retry the verification if arduino returns an exit code that indicates there may have been a temporary error not caused by a bug in the sketch or the arduino command
701683
while [[ $arduinoExitCode -gt $HIGHEST_ACCEPTABLE_ARDUINO_EXIT_CODE && $verifyCount -le $SKETCH_VERIFY_RETRIES ]]; do
702684
# Verify the sketch
703-
arduino $VERBOSE_BUILD --verify "$sketchName" --board "$boardID" 2>&1 | tee "$VERIFICATION_OUTPUT_FILENAME"; local arduinoExitCode="${PIPESTATUS[0]}"
685+
${APPLICATION_FOLDER}/${IDE_INSTALLATION_FOLDER}/arduino $VERBOSE_BUILD --verify "$sketchName" --board "$boardID" 2>&1 | tee "$VERIFICATION_OUTPUT_FILENAME"; local arduinoExitCode="${PIPESTATUS[0]}"
704686
local verifyCount=$((verifyCount + 1))
705687
done
706688

0 commit comments

Comments
 (0)