Skip to content

Commit 7593e86

Browse files
committed
check_library_properties/check_library_manager_compliance: Add reserved name check
library.properties name values that begin with arduino are no longer accepted for addition to the Library Manager index.
1 parent 176808e commit 7593e86

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

Diff for: .travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ matrix:
8282
- cd ..
8383
- git clone https://github.com/per1234/arduino-ci-script-tests
8484
- cd arduino-ci-script-tests
85-
- git checkout 6b9758211e957689803b05008e705cb88758bd2b
85+
- git checkout a3745f44577648bb34c3784ed564535d8196bcf7
8686
script:
8787
- bats check_keywords_txt.bats
8888
- bats check_library_manager_compliance.bats

Diff for: arduino-ci-script.sh

+38-1
Original file line numberDiff line numberDiff line change
@@ -1251,6 +1251,24 @@ function check_folder_name() {
12511251
return "$exitStatus"
12521252
}
12531253

1254+
ARDUINO_CI_SCRIPT_EXIT_STATUS_COUNTER=1
1255+
readonly ARDUINO_CI_SCRIPT_CHECK_LIBRARY_PROPERTIES_NAME_RESERVED_NAME_EXIT_STATUS=$ARDUINO_CI_SCRIPT_EXIT_STATUS_COUNTER
1256+
function check_library_properties_name() {
1257+
local -r name="$1"
1258+
1259+
local exitStatus=$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS
1260+
1261+
# Check if the library.properties name value starts with "arduino" (case-insensitive)
1262+
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#libraryproperties-file-format
1263+
local -r ReservedNameRegex="^arduino"
1264+
# Libraries with reserved names added to the Library Manager index before the enactment of the rule are grandfathered
1265+
local -r GrandfatheredNameRegex="^(Arduino Learning Board)|(Arduino LoRaWAN)|(Arduino OPL2)|(Arduino POST HTTP Parser)|(Arduino Smart Watch)|(arduino-async-modem)|(arduino-display-lcdkeypad)|(arduino-ess)|(arduino-fsm)|(Arduino-I2C-KM1)|(arduino-managed-serial-device)|(arduino-menusystem)|(arduino-NVM)|(arduino-sht)|(arduino-timer)|(arduino-timer-api)|(Arduino-Websocket-Fast)|(ArduinoArcherPanelClient)|(ArduinoBlue)|(ArduinoCloudStorage)|(ArduinoComponents)|(ArduinoESPAT)|(ArduinoFacil)|(arduinoFFT)|(ArduinoFritzApi)|(ArduinoHttpServer)|(ArduinoIHC)|(ArduinoINA219)|(ArduinoIRC)|(ArduinoJson)|(ArduinoLang)|(ArduinoLearningKitStarter)|(ArduinoLog)|(ArduinoMenu library)|(ArduinoMqtt)|(ArduinoOSC)|(ArduinoOTA)|(ArduinoQueue)|(ArduinoSensors)|(ArduinoSerialToTCPBridgeClient)|(ArduinoSTL)|(ArduinoTEA5767)|(ArduinoThread)|(ArduinoThreadRunOnce)|(ArduinoTrace)|(ArduinoUniqueID)|(ArduinoUnit)|(ArduinoUserInterface)|(arduinoVNC)|(ArduinoWebsockets)$"
1266+
if [[ "${name,,}" =~ $ReservedNameRegex ]] && ! [[ "$name" =~ $GrandfatheredNameRegex ]]; then
1267+
exitStatus=$(set_exit_status "$exitStatus" $ARDUINO_CI_SCRIPT_CHECK_LIBRARY_PROPERTIES_NAME_RESERVED_NAME_EXIT_STATUS)
1268+
fi
1269+
return "$exitStatus"
1270+
}
1271+
12541272
ARDUINO_CI_SCRIPT_EXIT_STATUS_COUNTER=1
12551273
readonly ARDUINO_CI_SCRIPT_CHECK_SKETCH_STRUCTURE_FOLDER_DOESNT_EXIST_EXIT_STATUS=$ARDUINO_CI_SCRIPT_EXIT_STATUS_COUNTER
12561274
ARDUINO_CI_SCRIPT_EXIT_STATUS_COUNTER=$((ARDUINO_CI_SCRIPT_EXIT_STATUS_COUNTER + 1))
@@ -1713,6 +1731,13 @@ function check_library_properties() {
17131731
if [[ $checkFolderNameExitStatus -ne $ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS ]]; then
17141732
echo "WARNING: ${normalizedLibraryPropertiesPath}/library.properties: Name value $nameValue does not meet the requirements of the Arduino Library Manager indexer. See: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#libraryproperties-file-format"
17151733
fi
1734+
1735+
# Check if the library.properties name value starts with "arduino" (case-insensitive)
1736+
check_library_properties_name "$nameValue"
1737+
local checkLibraryPropertiesNameExitStatus=$?
1738+
if [[ "$checkLibraryPropertiesNameExitStatus" == "$ARDUINO_CI_SCRIPT_CHECK_LIBRARY_PROPERTIES_NAME_RESERVED_NAME_EXIT_STATUS" ]]; then
1739+
echo "WARNING: ${normalizedLibraryPropertiesPath}/library.properties: name value: $nameValue starts with \"arduino\". These names are reserved for official Arduino libraries. Libraries using a reserved name will not be accepted in the Library Manager index."
1740+
fi
17161741
fi
17171742
fi
17181743

@@ -2270,6 +2295,8 @@ readonly ARDUINO_CI_SCRIPT_CHECK_LIBRARY_MANAGER_COMPLIANCE_NAME_HAS_INVALID_CHA
22702295
readonly ARDUINO_CI_SCRIPT_CHECK_LIBRARY_MANAGER_COMPLIANCE_NAME_TOO_LONG_EXIT_STATUS=$((ARDUINO_CI_SCRIPT_CHECK_LIBRARY_MANAGER_COMPLIANCE_CHECK_FOLDER_NAME_OFFSET + ARDUINO_CI_SCRIPT_CHECK_FOLDER_NAME_TOO_LONG_EXIT_STATUS))
22712296
ARDUINO_CI_SCRIPT_EXIT_STATUS_COUNTER=$((ARDUINO_CI_SCRIPT_CHECK_LIBRARY_MANAGER_COMPLIANCE_NAME_TOO_LONG_EXIT_STATUS + 1))
22722297
readonly ARDUINO_CI_SCRIPT_CHECK_LIBRARY_MANAGER_COMPLIANCE_BLANK_URL_EXIT_STATUS=$ARDUINO_CI_SCRIPT_EXIT_STATUS_COUNTER
2298+
ARDUINO_CI_SCRIPT_EXIT_STATUS_COUNTER=$((ARDUINO_CI_SCRIPT_EXIT_STATUS_COUNTER + 1))
2299+
readonly ARDUINO_CI_SCRIPT_CHECK_LIBRARY_MANAGER_COMPLIANCE_NAME_IS_RESERVED_EXIT_STATUS=$ARDUINO_CI_SCRIPT_EXIT_STATUS_COUNTER
22732300
function check_library_manager_compliance() {
22742301
local -r libraryPath="$1"
22752302
# Replace backslashes with slashes
@@ -2306,13 +2333,15 @@ function check_library_manager_compliance() {
23062333
exitStatus=$(set_exit_status "$exitStatus" $ARDUINO_CI_SCRIPT_CHECK_LIBRARY_MANAGER_COMPLIANCE_SYMLINK_FOUND_EXIT_STATUS)
23072334
fi
23082335

2309-
# Check for characters in the library.properties name value disallowed by the Library Manager indexer
2336+
# Check for problems with library.properties
23102337
if [[ -f "$normalizedLibraryPath/library.properties" ]]; then
23112338
# Get rid of the CRs
23122339
local libraryProperties
23132340
libraryProperties=$(tr "\r" "\n" <"$normalizedLibraryPath/library.properties")
23142341
local nameValue
23152342
nameValue="$(get_library_properties_field_value "$libraryProperties" 'name')"
2343+
2344+
# Check for characters in the library.properties name value disallowed by the Library Manager indexer
23162345
# Library Manager installs libraries to a folder that is the name field value with any spaces replaced with _
23172346
local -r libraryManagerFolderName="${nameValue// /_}"
23182347
check_folder_name "$libraryManagerFolderName"
@@ -2322,6 +2351,14 @@ function check_library_manager_compliance() {
23222351
exitStatus=$(set_exit_status "$exitStatus" $((ARDUINO_CI_SCRIPT_CHECK_LIBRARY_MANAGER_COMPLIANCE_CHECK_FOLDER_NAME_OFFSET + checkFolderNameExitStatus)))
23232352
fi
23242353

2354+
# Check if the library.properties name value starts with "arduino" (case-insensitive)
2355+
check_library_properties_name "$nameValue"
2356+
local checkLibraryPropertiesNameExitStatus=$?
2357+
if [[ "$checkLibraryPropertiesNameExitStatus" == "$ARDUINO_CI_SCRIPT_CHECK_LIBRARY_PROPERTIES_NAME_RESERVED_NAME_EXIT_STATUS" ]]; then
2358+
echo "ERROR: ${normalizedLibraryPath}/library.properties: name value: $nameValue starts with \"arduino\". These names are reserved for official Arduino libraries."
2359+
exitStatus=$(set_exit_status "$exitStatus" $ARDUINO_CI_SCRIPT_CHECK_LIBRARY_MANAGER_COMPLIANCE_NAME_IS_RESERVED_EXIT_STATUS)
2360+
fi
2361+
23252362
local urlValue
23262363
urlValue="$(get_library_properties_field_value "$libraryProperties" 'url')"
23272364
if [[ "$urlValue" == "" ]]; then

0 commit comments

Comments
 (0)