diff --git a/CHANGELOG.md b/CHANGELOG.md index d701e7c..2286e2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,12 @@ brings it. `~/.cache/ccache` on the container's own file system, which a rebuild throws away, so the first `make check` after one compiled every host build again. The volume `-ccache` keeps it, as `-uv-cache` keeps uv's. +- **`make setup` tries a download three times:** arduino-cli gives up at once where a server + resets the connection, and a single reset of `core update-index` failed the dev container's + `postCreateCommand` on a rebuild of MaxMatrix; VS Code then skipped everything after it, the + compilation databases, and on that attach the copy of `.gitconfig` and `gh auth setup-git`. + `download` in `tools/common.sh` runs a command that downloads again after 10 and 20 seconds; + arduino-cli's setup and PlatformIO's go through it, and a third failure still fails. On the update: rebuild the dev container; the volume of ccache starts empty and fills with the first build. A project that added `avr/common.h` to `IgnoreHeaders` itself, or included it, can diff --git a/template/tools/README.md b/template/tools/README.md index c2801b5..d9cad3d 100644 --- a/template/tools/README.md +++ b/template/tools/README.md @@ -21,7 +21,7 @@ through. | `self_contained_headers.py` | `make headers`: every header compiled on its own | | `docs.sh` | `make docs`: Doxygen, failing on a gap | | `arduino_lint.sh` | `make arduino-lint` | -| `common.sh` | What the shell scripts share: the paths, the defaults of `project.sh`, the targets, `select_target()` and the `target_` functions each build system answers. A script of the project's own sources it as well | +| `common.sh` | What the shell scripts share: the paths, the defaults of `project.sh`, the targets, `select_target()`, the `target_` functions each build system answers, and `download`, which tries a download three times. A script of the project's own sources it as well | | `project.sh` | The project's: the targets, each with its board and core, the variants and the hooks | | `project.mk` | The project's: its own targets of the `Makefile` | | `lib/` | What the scripts above call, a target of none: `arduino_cli.sh`, `cmake.sh` and `platformio.sh`, the build systems of those names, for the scripts that build a target, and `clang_database.py`, which rewrites the database of a CMake or a PlatformIO build for clang-tidy; `doc_indent.py` and `cpplint_house.py`, cpplint with the NOLINT of a check of our own, for `lint.sh`, `tidy_module.sh` and the clang-tidy module in `tidy_module/` for `tidy.sh`, and `tidy_cache.py`, through which it calls clang-tidy and which skips a file that passed before on the same input | diff --git a/template/tools/common.sh b/template/tools/common.sh index 56e2cfe..fae5b7c 100755 --- a/template/tools/common.sh +++ b/template/tools/common.sh @@ -103,6 +103,27 @@ err() { echo "$*" >&2 } +# Runs a command that downloads, and again where it fails: a server resets a connection at times, +# and arduino-cli gives up at once, which failed the dev container's postCreateCommand and +# everything after it. Three tries, 10 and 20 seconds apart; the third's failure is returned. +# Arguments: +# the command and its arguments +download() { + local pause=10 + local try + local status + for try in 1 2 3; do + status=0 + "$@" || status=$? + if ((status == 0 || try == 3)); then + return "${status}" + fi + err "Failed with ${status}: $*. Again in ${pause} s (try ${try} of 3)." + sleep "${pause}" + pause=$((pause * 2)) + done +} + # Makes the target named the one the tools work on: TARGET is its name, and the settings of # TARGET_SETTINGS are those of tools/project.sh with what target_settings() sets for it. Fails on # a target TARGETS does not name or whose name is no folder's, and on a build system the template diff --git a/template/tools/lib/arduino_cli.sh b/template/tools/lib/arduino_cli.sh index ceb0e58..dd68cc5 100644 --- a/template/tools/lib/arduino_cli.sh +++ b/template/tools/lib/arduino_cli.sh @@ -37,8 +37,8 @@ arduino_cli_setup() { if [[ -n "${ARDUINO_BOARD_URLS}" ]]; then urls=(--additional-urls "${ARDUINO_BOARD_URLS}") fi - arduino-cli core update-index "${urls[@]}" - arduino-cli core install "${ARDUINO_CORE[@]}" "${urls[@]}" + download arduino-cli core update-index "${urls[@]}" + download arduino-cli core install "${ARDUINO_CORE[@]}" "${urls[@]}" } # Prints the bin directory of the avr-gcc that arduino-cli uses for FQBN. diff --git a/template/tools/lib/platformio.sh b/template/tools/lib/platformio.sh index c981b78..12a6f67 100644 --- a/template/tools/lib/platformio.sh +++ b/template/tools/lib/platformio.sh @@ -32,7 +32,7 @@ platformio_setup() { err "Target ${TARGET}: PIO_DIR=${PIO_DIR} holds no platformio.ini." return 1 fi - "${PIO[@]}" pkg install --silent -d "${ROOT_DIR}/${PIO_DIR}" -e "${PIO_ENV}" + download "${PIO[@]}" pkg install --silent -d "${ROOT_DIR}/${PIO_DIR}" -e "${PIO_ENV}" } # Prints the build folder of a variant.