Skip to content

Commit

Permalink
CCI and POSIX perm fixes(#74)
Browse files Browse the repository at this point in the history
* only run CCI on PRs part 2

* only run CCI on PRs part 3

* only run CCI on PRs part 4

* only run CCI on PRs part 5

* only run CCI on PRs part 6

* only run CCI on PRs part 7

* rework autoexec to be more itemized

* linter

* mix in other linix and macos circleci tests

* mix in other linix and macos circleci tests part 2

* mix in other linix and macos circleci tests part 3

* mix in other linix and macos circleci tests part 4

* mix in other linix and macos circleci tests part 5

* mix in other linix and macos circleci tests part 6

* mix in other linix and macos circleci tests part 7

* mix in other linix and macos circleci tests part 8

* mix in other linix and macos circleci tests part 9

* switch to stable and rerun
  • Loading branch information
pirog authored Nov 27, 2024
1 parent cc67d61 commit 48214f8
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 61 deletions.
59 changes: 29 additions & 30 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,39 @@
version: 2.1

jobs:
install-on-linux:
machine:
image: ubuntu-2204:current
steps:
- checkout
- run:
name: Install Lando on Linux
command: ./setup-lando.sh --no-setup && lando version --all
setup-on-linux:
machine:
image: ubuntu-2204:current
steps:
- checkout
- run:
name: Setup Lando on Linux
command: |
pwd
env
whoami
lsa -lsa ~
chmod +x ./setup-lando.sh
./setup-lando.sh --debug --version "3-dev" --no-setup
lando version
command: ./setup-lando.sh && lando version --all

# setup-on-macos:
# macos:
# xcode: "14.2.0"
# steps:
# - checkout
# - run:
# name: Run Bash Script on macOS
# command: |
# chmod +x ./setup-lando.sh
# ./setup-lando.sh --debug --version "3-dev" --no-setup
# lando version
install-on-macos:
macos:
xcode: "14.2.0"
steps:
- checkout
- run:
name: Install Lando on macOS
command: ./setup-lando.sh --no-setup && lando version --all
setup-on-macos:
macos:
xcode: "14.2.0"
steps:
- checkout
- run:
name: Setup Lando on macOS
command: ./setup-lando.sh --no-setup && lando setup -y --skip-networking && lando version --all

# setup-on-windows:
# machine:
Expand All @@ -44,14 +50,7 @@ jobs:
workflows:
setup-lando:
jobs:
- setup-on-linux:
filters:
branches:
ignore: /.*/
pull_requests:
types:
- opened
- synchronize
- reopened
# - setup-on-macos
# - setup-on-windows
- install-on-linux
- install-on-macos
- setup-on-linux
- setup-on-macos
1 change: 0 additions & 1 deletion .github/workflows/pr-actions-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ jobs:
with:
lando-version: ${{ matrix.lando-version }}
auto-setup: ${{ matrix.setup-string }}
debug: true
telemetry: false
config: |
setup.skipCommonPlugins=true
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }})

* Added some `circleci` tests
* Fixed various permissions related bugs for `POSIX` installs

## v3.6.0 - [November 23, 2024](https://github.com/lando/setup-lando/releases/tag/v3.6.0)

### Changes

* Added `--syslink` to add symlink to `/usr/local/bin` on POSIX install, see notes below
Expand Down
109 changes: 79 additions & 30 deletions setup-lando.sh
Original file line number Diff line number Diff line change
Expand Up @@ -798,18 +798,73 @@ wait_for_user() {
fi
}

# determine the exec we need for sudo protected things
# we add /tmp in here because their are high security environments where /tmp is not universally writable
if needs_sudo; then
debug "auto_exec elevating to sudo"
auto_exec() {
execute_sudo "$@"
}
else
auto_exec() {
execute "$@"
}
fi
# helpers for more itemized sudoing
auto_link() {
local source="$1"
local dest="$2"
local perm_source
local perm_dest
perm_source="$(find_first_existing_parent "$source")"
perm_dest="$(find_first_existing_parent "$dest")"

if have_sudo_access && [[ ! -w "$perm_source" || ! -w "$perm_dest" ]]; then
execute_sudo ln -sf "$source" "$dest"
else
execute ln -sf "$source" "$dest"
fi
}

auto_mkdirp() {
local dir="$1"
local perm_dir
perm_dir="$(find_first_existing_parent "$dir")"

if have_sudo_access && [[ ! -w "$perm_dir" ]]; then
execute_sudo mkdir -p "$dir"
else
execute mkdir -p "$dir"
fi
}

auto_mv() {
local source="$1"
local dest="$2"
local perm_source
local perm_dest
perm_source="$(find_first_existing_parent "$source")"
perm_dest="$(find_first_existing_parent "$dest")"

if have_sudo_access && [[ ! -w "$perm_source" || ! -w "$perm_dest" ]]; then
execute_sudo mv -f "$source" "$dest"
else
execute mv -f "$source" "$dest"
fi
}

auto_curl_n_x() {
local dest="$1"
local url="$2"
local perm_dir
perm_dir="$(find_first_existing_parent "$dest")"

if have_sudo_access && [[ ! -w "$perm_dir" ]]; then
execute_sudo curl \
--fail \
--location \
--progress-bar \
--output "$dest" \
"$url"
execute_sudo chmod +x "$dest"
else
execute curl \
--fail \
--location \
--progress-bar \
--output "$dest" \
"$url"
execute chmod +x "$dest"
fi
}

# Invalidate sudo timestamp before exiting (if it wasn't active before).
if [[ -x /usr/bin/sudo ]] && ! /usr/bin/sudo -n -v 2>/dev/null; then
Expand Down Expand Up @@ -846,37 +901,31 @@ if needs_sudo; then
fi

# 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
if [[ ! -d "$LANDO_BINDIR" ]]; then execute mkdir -p "$LANDO_BINDIR"; fi
if [[ ! -d "$DEST" ]]; then auto_mkdirp "$DEST"; fi
if [[ ! -d "$LANDO_TMPDIR" ]]; then auto_mkdirp "$LANDO_TMPDIR"; fi
if [[ ! -d "$LANDO_BINDIR" ]]; then auto_mkdirp "$LANDO_BINDIR"; fi

# 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_TMPFILE" \
"$URL"

# make executable and weak "it works" test
auto_exec chmod +x "${LANDO_TMPFILE}"
auto_curl_n_x "$LANDO_TMPFILE" "$URL"

# weak "it works" test
execute "${LANDO_TMPFILE}" version >/dev/null

# if dest = symlinker then we need to actually mv 2 LANDO_DATADIR
# NOTE: we use mv here instead of cp because of https://developer.apple.com/forums/thread/130313
if [[ "$LANDO" == "$SYMLINKER" ]]; then
execute mkdir -p "${LANDO_DATADIR}/${VERSION}"
execute mv -f "$LANDO_TMPFILE" "$HIDDEN_LANDO"
execute ln -sf "$HIDDEN_LANDO" "$SYMLINKER"
auto_mkdirp "${LANDO_DATADIR}/${VERSION}"
auto_mv "$LANDO_TMPFILE" "$HIDDEN_LANDO"
auto_link "$HIDDEN_LANDO" "$SYMLINKER"
else
auto_exec mv -f "$LANDO_TMPFILE" "$LANDO"
auto_exec ln -sf "$LANDO" "$SYMLINKER"
auto_mv "$LANDO_TMPFILE" "$LANDO"
auto_link "$LANDO" "$SYMLINKER"
fi

# hook up the syslink here
if [[ "$SYSLINK" == "1" ]]; then
auto_exec ln -sf "$SYMLINKER" "$SYSLINKER"
auto_link "$SYMLINKER" "$SYSLINKER"
fi

# if lando 3 then we need to do some other cleanup things
Expand Down

0 comments on commit 48214f8

Please sign in to comment.