Skip to content

Commit

Permalink
#41: improve tmpdir detection
Browse files Browse the repository at this point in the history
  • Loading branch information
pirog committed May 3, 2024
1 parent 2e43c1f commit 923ec16
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## v3.1.1 - [April 22, 2024](https://github.com/lando/setup-lando/releases/tag/v3.1.1)
## v3.2.0 - [May 3, 2024](https://github.com/lando/setup-lando/releases/tag/v3.2.0)

### Windows/WSL Install Script

* Updated `windows` installer script switch names to follow PowerShell convention
* Improved `$TMPDIR` handling for non standard `/tmp` usage [#41](https://github.com/lando/setup-lando/issues/41)
* Improved `arch` detection with fallbacks [#42](https://github.com/lando/setup-lando/issues/42)
* Updated `windows` installer script switch names to follow `PowerShell` convention

## v3.1.0 - [April 22, 2024](https://github.com/lando/setup-lando/releases/tag/v3.1.0)

Expand Down
16 changes: 9 additions & 7 deletions setup-lando.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ set -u

# configuration things at the top for QOL
LANDO_DEFAULT_MV="3"
LANDO_TMPDIR=${TMPDIR:-/tmp}
MACOS_OLDEST_SUPPORTED="12.0"
REQUIRED_CURL_VERSION="7.41.0"
SEMVER_REGEX='^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$'
Expand Down Expand Up @@ -551,7 +552,7 @@ PERM_DIR="$(find_first_existing_parent "$DEST")"
debug "resolved install destination ${DEST} to a perm check on ${PERM_DIR}"

needs_sudo() {
if [[ ! -w "$PERM_DIR" ]] || [[ ! -w "/tmp" ]]; then
if [[ ! -w "$PERM_DIR" ]] || [[ ! -w "$LANDO_TMPDIR" ]]; then
return 0;
else
return 1;
Expand Down Expand Up @@ -784,29 +785,30 @@ if needs_sudo; then
execute_sudo true
fi

# Create directory if we need to
# Create directories if we need to
if [[ ! -d "$DEST" ]]; then auto_exec mkdir -p "$DEST"; fi
if [[ ! -d "$LANDO_TMPDIR" ]]; then auto_exec mkdir -p "$LANDO_TMPDIR"; fi

# LANDO
LANDO="${DEST}/lando"
LANDO_TMP="/tmp/${RANDOM}"
LANDO_TMPFILE="${LANDO_TMPDIR}/${RANDOM}"

# download lando
log "${tty_magenta}downloading${tty_reset} ${tty_bold}${URL}${tty_reset} to ${tty_bold}${LANDO}${tty_reset}"
auto_exec curl \
--fail \
--location \
--progress-bar \
--output "$LANDO_TMP" \
--output "$LANDO_TMPFILE" \
"$URL"

# make executable and weak "it works" test
auto_exec chmod +x "${LANDO_TMP}"
execute "${LANDO_TMP}" version >/dev/null
auto_exec chmod +x "${LANDO_TMPFILE}"
execute "${LANDO_TMPFILE}" version >/dev/null

# if we get here we should be good to move it to its final destination
# NOTE: we use mv here instead of cp because of https://developer.apple.com/forums/thread/130313
auto_exec mv -f "${LANDO_TMP}" "${LANDO}"
auto_exec mv -f "${LANDO_TMPFILE}" "${LANDO}"

# if lando 3 then --clear
if [[ $LMV == '3' ]]; then
Expand Down

0 comments on commit 923ec16

Please sign in to comment.