From fb79d31945939bba3a243bcf2e2a8db6ee08de21 Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Thu, 21 Nov 2024 08:45:24 -0500 Subject: [PATCH 1/4] add path based installation to posix install script --- .../pr-posix-script-versions-tests.yml | 13 ++++- CHANGELOG.md | 2 + setup-lando.sh | 48 ++++++++++++------- 3 files changed, 43 insertions(+), 20 deletions(-) diff --git a/.github/workflows/pr-posix-script-versions-tests.yml b/.github/workflows/pr-posix-script-versions-tests.yml index 61dc7ba..60bee32 100644 --- a/.github/workflows/pr-posix-script-versions-tests.yml +++ b/.github/workflows/pr-posix-script-versions-tests.yml @@ -13,6 +13,9 @@ jobs: matrix: os: - ubuntu-24.04 + - macos-14 + node-version: + - '20' fat: - --fat - '' @@ -28,17 +31,23 @@ jobs: - 'edge' - 'latest' - 'dev' - - 'skip' + - '/home/runner/work/setup-lando/setup-lando/bin/lando' + - 'set-with-envvar' steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Install node ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: npm - name: Setup Lando version ${{ matrix.success-version }} shell: bash run: | - if [[ "${{ matrix.success-version }}" == "skip" ]]; then + if [[ "${{ matrix.success-version }}" == "set-with-envvar" ]]; then LANDO_VERSION=v3.22.0 ./setup-lando.sh --no-setup ${{ matrix.fat }} else ./setup-lando.sh --version=${{ matrix.success-version }} --no-setup ${{ matrix.fat }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 6da901e..1f0a22e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }}) +* Added `path` based installation to POSIX `setup-lando.sh` script + ## v3.4.5 - [November 10, 2024](https://github.com/lando/setup-lando/releases/tag/v3.4.5) * Updated to [@lando/vitepress-theme-default-plus@v1.1.0-beta.19](https://github.com/lando/vitepress-theme-default-plus/releases/tag/v1.1.0-beta.19) diff --git a/setup-lando.sh b/setup-lando.sh index 4ede7d2..31a0a02 100755 --- a/setup-lando.sh +++ b/setup-lando.sh @@ -507,11 +507,14 @@ elif [[ "${VERSION}" == "3-dev" ]] || [[ "${VERSION}" == "3-latest" ]]; then URL="https://files.lando.dev/core/lando-${OS}-${ARCH}-dev" VERSION_DEV=1 -# CUSTOM -else - if [[ $VERSION != v* ]]; then - VERSION="v${VERSION}" - fi +# CUSTOM VERSION +elif [[ ! -f "$VERSION" ]] && [[ $VERSION != v* ]]; then + VERSION="v${VERSION}" + +# PATH VERSION +elif [[ -f "${VERSION}" ]]; then + URL=file://$VERSION + VERSION="$($VERSION version)" fi # Set some helper things @@ -525,19 +528,21 @@ else HRV="$VERSION" fi -# set url depending on non-dev LMVs -if [[ $LMV == '3' ]] && [[ -z "${VERSION_DEV-}" ]]; then - URL="https://github.com/lando/core/releases/download/${VERSION}/lando-${OS}-${ARCH}-${VERSION}" -elif [[ $LMV == '4' ]] && [[ -z "${VERSION_DEV-}" ]]; then - URL="https://github.com/lando/core-next/releases/download/${VERSION}/lando-${OS}-${ARCH}-${VERSION}" -fi +# Do extra URL parsing on non-files if needed +if [[ $URL != file://* ]]; then + if [[ $LMV == '3' ]] && [[ -z "${VERSION_DEV-}" ]]; then + URL="https://github.com/lando/core/releases/download/${VERSION}/lando-${OS}-${ARCH}-${VERSION}" + elif [[ $LMV == '4' ]] && [[ -z "${VERSION_DEV-}" ]]; then + URL="https://github.com/lando/core-next/releases/download/${VERSION}/lando-${OS}-${ARCH}-${VERSION}" + fi -# autoslim all v3 urls by default -# @TODO: --fat flag to stop this? -if [[ $LMV == '3' ]] && [[ $FAT != '1' ]]; then - URL="${URL}-slim" - HRV="$VERSION-slim" - debug "autoslimin url for lando 3" + # autoslim all v3 urls by default + # @TODO: restrict this to 3 < 3.24.0 at some point? + if [[ $LMV == '3' ]] && [[ $FAT != '1' ]]; then + URL="${URL}-slim" + HRV="$VERSION-slim" + debug "autoslimin url for lando 3" + fi fi # debug version resolution @@ -767,14 +772,21 @@ cd "/usr" || exit 1 if [[ -z "${NONINTERACTIVE-}" ]]; then log "${tty_bold}this script is about to:${tty_reset}" log + # sudo prompt if needs_sudo; then log "- ${tty_green}prompt${tty_reset} for ${tty_bold}sudo${tty_reset} password"; fi + # download - log "- ${tty_magenta}download${tty_reset} lando ${tty_bold}${HRV}${tty_reset} to ${tty_bold}${DEST}${tty_reset}" + if [[ $URL != file://* ]]; then log "- ${tty_magenta}download${tty_reset} lando ${tty_bold}${HRV}${tty_reset} to ${tty_bold}${DEST}${tty_reset}" + # or move + else log "- ${tty_magenta}move${tty_reset} lando ${tty_bold}${ORIGINAL_VERSION}${tty_reset} to ${tty_bold}${DEST}${tty_reset}"; fi + # setup if [[ "$SETUP" == "1" ]]; then log "- ${tty_blue}run${tty_reset} ${tty_bold}lando setup${tty_reset}"; fi + # shellenv log "- ${tty_blue}run${tty_reset} ${tty_bold}lando shellenv --add${tty_reset}" + # block for user wait_for_user fi From cbbc6e3e280111c7037d067445542ba8ed36a52f Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Thu, 21 Nov 2024 08:54:38 -0500 Subject: [PATCH 2/4] add path based installation to posix install script part 2 --- .../pr-posix-script-versions-tests.yml | 2 ++ setup-lando.sh | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pr-posix-script-versions-tests.yml b/.github/workflows/pr-posix-script-versions-tests.yml index 60bee32..cdcdcda 100644 --- a/.github/workflows/pr-posix-script-versions-tests.yml +++ b/.github/workflows/pr-posix-script-versions-tests.yml @@ -47,6 +47,8 @@ jobs: - name: Setup Lando version ${{ matrix.success-version }} shell: bash run: | + stat /home/runner/work/setup-lando/setup-lando/bin/lando + if [[ "${{ matrix.success-version }}" == "set-with-envvar" ]]; then LANDO_VERSION=v3.22.0 ./setup-lando.sh --no-setup ${{ matrix.fat }} else diff --git a/setup-lando.sh b/setup-lando.sh index 31a0a02..ca5710b 100755 --- a/setup-lando.sh +++ b/setup-lando.sh @@ -528,21 +528,21 @@ else HRV="$VERSION" fi -# Do extra URL parsing on non-files if needed -if [[ $URL != file://* ]]; then +# if URL is still not set at this point we assume its a github version download +if [[ -z "${URL-}" ]]; then if [[ $LMV == '3' ]] && [[ -z "${VERSION_DEV-}" ]]; then URL="https://github.com/lando/core/releases/download/${VERSION}/lando-${OS}-${ARCH}-${VERSION}" elif [[ $LMV == '4' ]] && [[ -z "${VERSION_DEV-}" ]]; then URL="https://github.com/lando/core-next/releases/download/${VERSION}/lando-${OS}-${ARCH}-${VERSION}" fi +fi - # autoslim all v3 urls by default - # @TODO: restrict this to 3 < 3.24.0 at some point? - if [[ $LMV == '3' ]] && [[ $FAT != '1' ]]; then - URL="${URL}-slim" - HRV="$VERSION-slim" - debug "autoslimin url for lando 3" - fi +# autoslim all v3 urls by default +# @TODO: restrict this to 3 < 3.24.0 at some point? +if [[ $URL != file://* ]] && [[ $LMV == '3' ]] && [[ $FAT != '1' ]]; then + URL="${URL}-slim" + HRV="$VERSION-slim" + debug "autoslimin url for lando 3" fi # debug version resolution From 053f356430fb7cbb6fccbe2e932ca1c05c18f52a Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Thu, 21 Nov 2024 09:06:46 -0500 Subject: [PATCH 3/4] add path based installation to posix install script part 3 --- .../workflows/pr-posix-script-versions-tests.yml | 12 +----------- setup-lando.sh | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pr-posix-script-versions-tests.yml b/.github/workflows/pr-posix-script-versions-tests.yml index cdcdcda..063614c 100644 --- a/.github/workflows/pr-posix-script-versions-tests.yml +++ b/.github/workflows/pr-posix-script-versions-tests.yml @@ -31,7 +31,7 @@ jobs: - 'edge' - 'latest' - 'dev' - - '/home/runner/work/setup-lando/setup-lando/bin/lando' + - 'bin/lando' - 'set-with-envvar' steps: @@ -56,13 +56,3 @@ jobs: fi lando version --all - - # test slim|fat on lando 3 - if lando version | grep "v3."; then - if [[ "${{ matrix.fat }}" == "--fat" ]]; then - lando config --path cli.slim | grep false - else - lando config --path cli.slim | grep true - fi - fi - diff --git a/setup-lando.sh b/setup-lando.sh index ca5710b..0515b73 100755 --- a/setup-lando.sh +++ b/setup-lando.sh @@ -513,7 +513,11 @@ elif [[ ! -f "$VERSION" ]] && [[ $VERSION != v* ]]; then # PATH VERSION elif [[ -f "${VERSION}" ]]; then - URL=file://$VERSION + if [[ "${VERSION}" == /* ]]; then + URL=file://$VERSION + else + URL=file://$(pwd)/$VERSION + fi VERSION="$($VERSION version)" fi @@ -537,6 +541,13 @@ if [[ -z "${URL-}" ]]; then fi fi +# abort if we have no URL at this point +if [[ -z "${URL-}" ]]; then + abort "could not resolve '${ORIGINAL_VERSION}' to a file or URL!" +else + debug "resolved v${LMV} version '${ORIGINAL_VERSION}' to ${VERSION} (${URL})" +fi + # autoslim all v3 urls by default # @TODO: restrict this to 3 < 3.24.0 at some point? if [[ $URL != file://* ]] && [[ $LMV == '3' ]] && [[ $FAT != '1' ]]; then @@ -545,9 +556,6 @@ if [[ $URL != file://* ]] && [[ $LMV == '3' ]] && [[ $FAT != '1' ]]; then debug "autoslimin url for lando 3" fi -# debug version resolution -debug "resolved v${LMV} version '${ORIGINAL_VERSION}' to ${VERSION} (${URL})" - # force setup to 0 if lando 4 if [[ $SETUP == '1' ]] && [[ $LMV == '4' ]]; then SETUP=0 From 4dc999771151b10cfef9c4fbc6f33d9a17f02f3a Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Thu, 21 Nov 2024 09:09:00 -0500 Subject: [PATCH 4/4] add path based installation to posix install script part 4 --- .github/workflows/pr-posix-script-versions-tests.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/pr-posix-script-versions-tests.yml b/.github/workflows/pr-posix-script-versions-tests.yml index 063614c..ba32fe6 100644 --- a/.github/workflows/pr-posix-script-versions-tests.yml +++ b/.github/workflows/pr-posix-script-versions-tests.yml @@ -47,8 +47,6 @@ jobs: - name: Setup Lando version ${{ matrix.success-version }} shell: bash run: | - stat /home/runner/work/setup-lando/setup-lando/bin/lando - if [[ "${{ matrix.success-version }}" == "set-with-envvar" ]]; then LANDO_VERSION=v3.22.0 ./setup-lando.sh --no-setup ${{ matrix.fat }} else