Skip to content

Commit 29e3108

Browse files
authored
Merge pull request #217 from per1234/install-script
Sync installation assets from template
2 parents 42a40f3 + 403b8f4 commit 29e3108

File tree

2 files changed

+27
-34
lines changed

2 files changed

+27
-34
lines changed

Diff for: docs/installation.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<!-- Source: https://github.com/arduino/tooling-project-assets/blob/main/other/installation-script/installation.md -->
2+
13
## Use the install script
24

35
The script requires `sh`, which is always available on Linux and macOS. `sh` is not available by default on Windows. The
@@ -81,5 +83,5 @@ Checksums for the nightly builds are available at
8183

8284
### Build from source
8385

84-
If youre familiar with Golang or if you want to contribute to the project, you will probably build Arduino Lint locally
86+
If you're familiar with Golang or if you want to contribute to the project, you will probably build Arduino Lint locally
8587
with your Go toolchain. See the ["How to contribute"](CONTRIBUTING.md#building-the-source-code) page for instructions.

Diff for: etc/install.sh

+24-33
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
#!/bin/sh
2+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/other/installation-script/install.sh
23

34
# The original version of this script (https://github.com/Masterminds/glide.sh/blob/master/get) is licensed under the
45
# MIT license. See https://github.com/Masterminds/glide/blob/master/LICENSE for more details and copyright notice.
56

6-
#
7-
# Usage:
8-
#
9-
# To install the latest version of Arduino Lint:
10-
# ./install.sh
11-
#
12-
# To pin a specific release of Arduino Lint:
13-
# ./install.sh 0.9.0
14-
#
15-
167
PROJECT_OWNER="arduino"
178
PROJECT_NAME="arduino-lint"
189

@@ -89,7 +80,7 @@ checkLatestVersion() {
8980
elif [ "$DOWNLOAD_TOOL" = "wget" ]; then
9081
CHECKLATESTVERSION_TAG=$(wget -q -O - $CHECKLATESTVERSION_LATEST_URL | grep -o "<title>Release $CHECKLATESTVERSION_REGEX · ${PROJECT_OWNER}/${PROJECT_NAME}" | grep -o "$CHECKLATESTVERSION_REGEX")
9182
fi
92-
if [ "x$CHECKLATESTVERSION_TAG" = "x" ]; then
83+
if [ "$CHECKLATESTVERSION_TAG" = "" ]; then
9384
echo "Cannot determine latest tag."
9485
exit 1
9586
fi
@@ -135,54 +126,54 @@ downloadFile() {
135126
fi
136127
# arduino-lint_0.4.0-rc1_Linux_64bit.[tar.gz, zip]
137128
if [ "$OS" = "Windows" ]; then
138-
ARDUINO_LINT_DIST="${PROJECT_NAME}_${TAG}_${OS}_${ARCH}.zip"
129+
APPLICATION_DIST="${PROJECT_NAME}_${TAG}_${OS}_${ARCH}.zip"
139130
else
140-
ARDUINO_LINT_DIST="${PROJECT_NAME}_${TAG}_${OS}_${ARCH}.tar.gz"
131+
APPLICATION_DIST="${PROJECT_NAME}_${TAG}_${OS}_${ARCH}.tar.gz"
141132
fi
142133

143134
# Support specifying nightly build versions (e.g., "nightly-latest") via the script argument.
144135
case "$TAG" in
145136
nightly*)
146-
DOWNLOAD_URL="https://downloads.arduino.cc/${PROJECT_NAME}/nightly/${ARDUINO_LINT_DIST}"
137+
DOWNLOAD_URL="https://downloads.arduino.cc/${PROJECT_NAME}/nightly/${APPLICATION_DIST}"
147138
;;
148139
*)
149-
DOWNLOAD_URL="https://downloads.arduino.cc/${PROJECT_NAME}/${ARDUINO_LINT_DIST}"
140+
DOWNLOAD_URL="https://downloads.arduino.cc/${PROJECT_NAME}/${APPLICATION_DIST}"
150141
;;
151142
esac
152143

153-
ARDUINO_LINT_TMP_FILE="/tmp/$ARDUINO_LINT_DIST"
144+
INSTALLATION_TMP_FILE="/tmp/$APPLICATION_DIST"
154145
echo "Downloading $DOWNLOAD_URL"
155-
httpStatusCode=$(getFile "$DOWNLOAD_URL" "$ARDUINO_LINT_TMP_FILE")
146+
httpStatusCode=$(getFile "$DOWNLOAD_URL" "$INSTALLATION_TMP_FILE")
156147
if [ "$httpStatusCode" -ne 200 ]; then
157148
echo "Did not find a release for your system: $OS $ARCH"
158149
echo "Trying to find a release using the GitHub API."
159150
LATEST_RELEASE_URL="https://api.github.com/repos/${PROJECT_OWNER}/$PROJECT_NAME/releases/tags/$TAG"
160151
echo "LATEST_RELEASE_URL=$LATEST_RELEASE_URL"
161152
get LATEST_RELEASE_JSON "$LATEST_RELEASE_URL"
162153
# || true forces this command to not catch error if grep does not find anything
163-
DOWNLOAD_URL=$(echo "$LATEST_RELEASE_JSON" | grep 'browser_' | cut -d\" -f4 | grep "$ARDUINO_LINT_DIST") || true
154+
DOWNLOAD_URL=$(echo "$LATEST_RELEASE_JSON" | grep 'browser_' | cut -d\" -f4 | grep "$APPLICATION_DIST") || true
164155
if [ -z "$DOWNLOAD_URL" ]; then
165156
echo "Sorry, we dont have a dist for your system: $OS $ARCH"
166157
fail "You can request one here: https://github.com/${PROJECT_OWNER}/$PROJECT_NAME/issues"
167158
else
168159
echo "Downloading $DOWNLOAD_URL"
169-
getFile "$DOWNLOAD_URL" "$ARDUINO_LINT_TMP_FILE"
160+
getFile "$DOWNLOAD_URL" "$INSTALLATION_TMP_FILE"
170161
fi
171162
fi
172163
}
173164

174165
installFile() {
175-
ARDUINO_LINT_TMP="/tmp/$PROJECT_NAME"
176-
mkdir -p "$ARDUINO_LINT_TMP"
166+
INSTALLATION_TMP_DIR="/tmp/$PROJECT_NAME"
167+
mkdir -p "$INSTALLATION_TMP_DIR"
177168
if [ "$OS" = "Windows" ]; then
178-
unzip -d "$ARDUINO_LINT_TMP" "$ARDUINO_LINT_TMP_FILE"
169+
unzip -d "$INSTALLATION_TMP_DIR" "$INSTALLATION_TMP_FILE"
179170
else
180-
tar xf "$ARDUINO_LINT_TMP_FILE" -C "$ARDUINO_LINT_TMP"
171+
tar xf "$INSTALLATION_TMP_FILE" -C "$INSTALLATION_TMP_DIR"
181172
fi
182-
ARDUINO_LINT_TMP_BIN="$ARDUINO_LINT_TMP/$PROJECT_NAME"
183-
cp "$ARDUINO_LINT_TMP_BIN" "$EFFECTIVE_BINDIR"
184-
rm -rf "$ARDUINO_LINT_TMP"
185-
rm -f "$ARDUINO_LINT_TMP_FILE"
173+
INSTALLATION_TMP_BIN="$INSTALLATION_TMP_DIR/$PROJECT_NAME"
174+
cp "$INSTALLATION_TMP_BIN" "$EFFECTIVE_BINDIR"
175+
rm -rf "$INSTALLATION_TMP_DIR"
176+
rm -f "$INSTALLATION_TMP_FILE"
186177
}
187178

188179
bye() {
@@ -195,24 +186,24 @@ bye() {
195186

196187
testVersion() {
197188
set +e
198-
ARDUINO_LINT="$(which $PROJECT_NAME)"
189+
EXECUTABLE_PATH="$(command -v $PROJECT_NAME)"
199190
if [ "$?" = "1" ]; then
200191
# $PATH is intentionally a literal in this message.
201192
# shellcheck disable=SC2016
202193
echo "$PROJECT_NAME not found. You might want to add \"$EFFECTIVE_BINDIR\" to your "'$PATH'
203194
else
204195
# Convert to resolved, absolute paths before comparison
205-
ARDUINO_LINT_REALPATH="$(cd -- "$(dirname -- "$ARDUINO_LINT")" && pwd -P)"
196+
EXECUTABLE_REALPATH="$(cd -- "$(dirname -- "$EXECUTABLE_PATH")" && pwd -P)"
206197
EFFECTIVE_BINDIR_REALPATH="$(cd -- "$EFFECTIVE_BINDIR" && pwd -P)"
207-
if [ "$ARDUINO_LINT_REALPATH" != "$EFFECTIVE_BINDIR_REALPATH" ]; then
198+
if [ "$EXECUTABLE_REALPATH" != "$EFFECTIVE_BINDIR_REALPATH" ]; then
208199
# shellcheck disable=SC2016
209-
echo "An existing $PROJECT_NAME was found at $ARDUINO_LINT. Please prepend \"$EFFECTIVE_BINDIR\" to your "'$PATH'" or remove the existing one."
200+
echo "An existing $PROJECT_NAME was found at $EXECUTABLE_PATH. Please prepend \"$EFFECTIVE_BINDIR\" to your "'$PATH'" or remove the existing one."
210201
fi
211202
fi
212203

213204
set -e
214-
ARDUINO_LINT_VERSION="$("$EFFECTIVE_BINDIR/$PROJECT_NAME" --version)"
215-
echo "$ARDUINO_LINT_VERSION installed successfully in $EFFECTIVE_BINDIR"
205+
APPLICATION_VERSION="$("$EFFECTIVE_BINDIR/$PROJECT_NAME" --version)"
206+
echo "$APPLICATION_VERSION installed successfully in $EFFECTIVE_BINDIR"
216207
}
217208

218209
# Execution

0 commit comments

Comments
 (0)