Please calm down a little @mechatroniac. I don't know whether you're trolling or just aggro by nature, but it's not going to get you anywhere here.
My previous comment was just a joke. Maybe you didn't notice that I paraphrased your "Software and tech security is not achieved by relying on the internet."
I will quibble with your "arcane programming discipline" statement though. This is really fundamental stuff that would serve someone like yourself well if you could get past your attitude.
Even though I would never write it for you, I just so happen to have the exact things you are asking for (even though I wrote them for another purpose). But I'm not interested in providing support for using them, so if you have problems you'll either have to figure it out for yourself or else hope that someone else can help you out (I'm sure they will if you take a bit more of a positive tone to your requests).
#!/bin/bash
# Install the latest release of every library in the Library Manager index
readonly LIBRARY_LIST="$(arduino-cli lib search --names --format json)"
# Install libraries
IFS=
Even though I think we've determined that your original request for a download of the arduino-libraries GitHub organization's repositories was not really what you wanted, I'll throw in that one as a bonus:
#!/bin/bash
readonly GH_TOKEN="$1"
readonly EXCLUDE_SKETCH_REPOS="false"
readonly EXCLUDE_LIBRARY_REPOS="false"
readonly EXCLUDE_PLATFORM_REPOS="false"
readonly EXCLUDE_PRIVATE="false"
readonly EXCLUDE_FORKS="true"
readonly EXCLUDE_ARCHIVED="true"
readonly CLONE_REPOS="true" # Set to false to download .zip of repo, which is faster
readonly SKETCH_REPO_LIST='
"arduino/arduino-examples"
"arduino/ArduinoTensorFlowLiteTutorials"
"arduino/cloud-examples"
"arduino/Summer-camp-robot-examples"
'
# There are some additional libraries outside the arduino-libraries organization.
# NOTE: there are many more in the bcmi-labs organization which are not included in this list.
readonly ADDITIONAL_LIBRARY_REPO_LIST='
"arduino/Adafruit-GFX-Library"
"arduino/Adafruit-ST7735-Library"
"arduino/ArduinoCloudProviderExamples"
"arduino/EduIntro"
"arduino/BasicEducationShield"
"arduino/CTC-Arduino"
"arduino/HMC5983"
"arduino/pubsubclient"
"arduino/Library-Arduino-Cbor"
"arduino/TFT"
"vidor-libraries/VidorBoot"
"vidor-libraries/USBBlaster"
"vidor-libraries/VidorPeripherals"
"vidor-libraries/VidorGraphics"
'
function get_github_api_response() {
local -r APIURL="$1"
curl --silent --header "Authorization: token $GH_TOKEN" "$APIURL"
}
function parse_api_response() {
local -r apiResponse="$1"
local -r key="$2"
# jq uses the system EOL, so when the script is run on Windows you get CRLF. It's easiest just to get rid of that right away, thus the `tr` in this command
echo "$apiResponse" | jq "$key" | tr --delete '\r'
}
# Get all the repositories in the arduino-libraries organization.
# Inexplicably, there are some non-library repos in this organization, but only a few.
if [[ "$EXCLUDE_LIBRARY_REPOS" == "false" ]]; then
readonly ORGANIZATION_REPO_LIST_API_RESPONSE="$(get_github_api_response "https://api.github.com/orgs/arduino-libraries/repos?per_page=100")"
readonly LIBRARY_REPO_LIST="$(parse_api_response "$ORGANIZATION_REPO_LIST_API_RESPONSE" ".[].full_name")$ADDITIONAL_LIBRARY_REPO_LIST"
fi
# NOTE: there are more in the bcmi-labs organization which are not included in this list.
readonly PLATFORM_REPO_LIST='
"arduino/ArduinoCore-avr"
"arduino/ArduinoCore-samd"
"arduino/ArduinoCore-sam"
"arduino/ArduinoCore-arc32"
"arduino/ArduinoCore-mbed"
"arduino/ArduinoCore-megaavr"
"arduino/ArduinoCore-API"
"arduino/ArduinoCore-Z80-MBC"
'
# Generate the list of non-excluded project types repo
if [[ "$EXCLUDE_SKETCH_REPOS" == "false" ]]; then
REPO_LIST="${REPO_LIST}${SKETCH_REPO_LIST}"
fi
if [[ "$EXCLUDE_LIBRARY_REPOS" == "false" ]]; then
REPO_LIST="${REPO_LIST}${LIBRARY_REPO_LIST}"
fi
if [[ "$EXCLUDE_PLATFORM_REPOS" == "false" ]]; then
REPO_LIST="${REPO_LIST}${PLATFORM_REPO_LIST}"
fi
function exclude_repo() {
local -r exclusion_enabled="$1"
local -r apiResponse="$2"
local -r exclusionKey="$3"
local -r exclusionValue="$4"
if [[ ("$exclusion_enabled" == "true") && ("$(parse_api_response "$apiResponse" "$exclusionKey")" == "$exclusionValue") ]]; then
echo "true"
else
echo "false"
fi
}
# Filter the list of repos
while IFS='' read -r repo_slug; do
if [[ -n "$repo_slug" ]]; then
REPO_API_URL="https://api.github.com/repos/${repo_slug//\"/}"
API_RESPONSE="$(get_github_api_response "$REPO_API_URL")"
if [[ "$(exclude_repo "$EXCLUDE_PRIVATE" "$API_RESPONSE" ".private" "true")" == "false" ]]; then
if [[ "$(exclude_repo "$EXCLUDE_FORKS" "$API_RESPONSE" ".fork" "true")" == "false" ]]; then
if [[ "$(exclude_repo "$EXCLUDE_ARCHIVED" "$API_RESPONSE" ".archived" "true")" == "false" ]]; then
FILTERED_REPO_LIST="$FILTERED_REPO_LIST"
\n'
export ARDUINO_DIRECTORIES_USER="${PWD}"
for library in $(echo "$LIBRARY_LIST" | jq -r ".libraries[] | .name" | tr --delete '\r'); do
if ! [[ -d "${ARDUINO_DIRECTORIES_USER}/libraries/${library// /_}" ]]; then
arduino-cli lib install "$library" --no-deps
fi
done
Even though I think we've determined that your original request for a download of the arduino-libraries GitHub organization's repositories was not really what you wanted, I'll throw in that one as a bonus:
~~~
§_DISCOURSE_HOISTED_CODE_1_§
~~~
\n'"$repo_slug"
fi
fi
fi
fi
done <<<"$REPO_LIST"
# Download the repos
while IFS='' read -r repo_slug; do
if [[ -n "$repo_slug" ]]; then
REPO_SLUG_WITHOUT_QUOTES="${repo_slug//\"/}"
if [[ -d "$REPO_SLUG_WITHOUT_QUOTES" ]]; then
echo "WARNING: directory $REPO_SLUG_WITHOUT_QUOTES already exists, skipping"
continue
fi
if [[ "$CLONE_REPOS" == "true" ]]; then
git clone --depth 1 "https://github.com/${REPO_SLUG_WITHOUT_QUOTES}" "${REPO_SLUG_WITHOUT_QUOTES}"
else
REPO_API_URL="https://api.github.com/repos/${REPO_SLUG_WITHOUT_QUOTES}"
API_RESPONSE="$(get_github_api_response "$REPO_API_URL")"
DEFAULT_BRANCH_NAME="$(parse_api_response "$API_RESPONSE" ".default_branch")"
DEFAULT_BRANCH_NAME_WITHOUT_QUOTES="${DEFAULT_BRANCH_NAME//\"/}"
# Since we don't need the repository data, it's more efficient to use the .zip downloads provided by GitHub instead of `git clone`
wget --header="Authorization: token $GH_TOKEN" "https://github.com/${REPO_SLUG_WITHOUT_QUOTES}/archive/${DEFAULT_BRANCH_NAME_WITHOUT_QUOTES}.zip"
ARCHIVE_FILENAME="${DEFAULT_BRANCH_NAME_WITHOUT_QUOTES}.zip"
mkdir --parents "$REPO_SLUG_WITHOUT_QUOTES"
unzip -q "$ARCHIVE_FILENAME" -d "$REPO_SLUG_WITHOUT_QUOTES"
rm "$ARCHIVE_FILENAME"
fi
fi
done <<<"$FILTERED_REPO_LIST"
~~~
\n'
export ARDUINO_DIRECTORIES_USER="${PWD}"
for library in $(echo "$LIBRARY_LIST" | jq -r ".libraries[] | .name" | tr --delete '\r'); do
if ! [[ -d "${ARDUINO_DIRECTORIES_USER}/libraries/${library// /_}" ]]; then
arduino-cli lib install "$library" --no-deps
fi
done
Even though I think we've determined that your original request for a download of the arduino-libraries GitHub organization's repositories was not really what you wanted, I'll throw in that one as a bonus:
§_DISCOURSE_HOISTED_CODE_1_§