From 72b7d5a801df74a772ab1547a45955d256efc0f8 Mon Sep 17 00:00:00 2001 From: Andrei Borisov Date: Mon, 25 Apr 2022 19:21:55 +0300 Subject: [PATCH] Update Homebrew script (#1416) * Fix Homebrew installation Update the link to the core Homebrew repo used during installation. * Allow installing Homebrew using shallow clone as a feature * Fix typing error in _VSC_INSTALL_HOMEBREW args --- .../src/devcontainer-features.json | 5 +++++ .../container-features/src/feature-scripts.env | 2 +- script-library/docs/homebrew.md | 12 +++++++++--- script-library/homebrew-debian.sh | 4 ++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/script-library/container-features/src/devcontainer-features.json b/script-library/container-features/src/devcontainer-features.json index 371339d964..be6e39d0c1 100644 --- a/script-library/container-features/src/devcontainer-features.json +++ b/script-library/container-features/src/devcontainer-features.json @@ -590,6 +590,11 @@ "enum": ["latest"], "default": "latest", "description": "Currently unused." + }, + "shallow": { + "type": "boolean", + "default": false, + "description": "Use shallow clone for faster container build." } }, "buildArg": "_VSC_INSTALL_HOMEBREW", diff --git a/script-library/container-features/src/feature-scripts.env b/script-library/container-features/src/feature-scripts.env index 2beaeb4c2e..20214a620c 100644 --- a/script-library/container-features/src/feature-scripts.env +++ b/script-library/container-features/src/feature-scripts.env @@ -16,7 +16,7 @@ _VSC_INSTALL_JAVA="java-wrapper.sh ${_BUILD_ARG_JAVA_VERSION:-latest}" _VSC_INSTALL_GRADLE="gradle-debian.sh ${_BUILD_ARG_GRADLE_VERSION:-latest}" _VSC_INSTALL_MAVEN="maven-debian.sh ${_BUILD_ARG_MAVEN_VERSION:-latest}" _VSC_INSTALL_RUBY="ruby-debian.sh ${_BUILD_ARG_RUBY_VERSION:-latest}" -_VSC_INSTALL_HOMEBREW=homebrew-debian.sh +_VSC_INSTALL_HOMEBREW="homebrew-debian.sh automatic true ${_BUILD_ARG_HOMEBREW_SHALLOW:-false}" _VSC_INSTALL_RUST="rust-debian.sh /usr/local/cargo /usr/local/rustup automatic true false ${_BUILD_ARG_RUST_VERSION:-latest} ${_BUILD_ARG_RUST_PROFILE:-minimal}" _VSC_INSTALL_POWERSHELL="powershell-debian.sh ${_BUILD_ARG_POWERSHELL_VERSION:-latest}" _VSC_INSTALL_DESKTOP_LITE="desktop-lite-debian.sh automatic ${_BUILD_ARG_DESKTOP_LITE_PASSWORD:-vscode} true ${_BUILD_ARG_DESKTOP_LITE_VNCPORT:-5901} ${_BUILD_ARG_DESKTOP_LITE_WEBPORT:-6080}" diff --git a/script-library/docs/homebrew.md b/script-library/docs/homebrew.md index 7e1a31e8fb..f069be1151 100644 --- a/script-library/docs/homebrew.md +++ b/script-library/docs/homebrew.md @@ -20,7 +20,10 @@ Or as a feature: ```json "features": { - "homebrew": "latest" + "homebrew": { + "version": "latest", + "shallow": false + } } ``` @@ -28,7 +31,7 @@ Or as a feature: |--------|----------------|-------|-----------| |Non-root user| | `automatic`| Specifies a user in the container other than root that will use Homebrew. A value of `automatic` will cause the script to check for a user called `vscode`, then `node`, `codespace`, and finally a user with a UID of `1000` before falling back to `root`. | | Add to rc files flag | | `true` | A `true`/`false` flag that indicates whether the `PATH` should be updated via `/etc/bash.bashrc` and `/etc/zsh/zshrc`. | -| Use shallow clone flag | | `false` | A `true`/`false` flag that indicates whether the script should install Homebrew using shallow clone. Shallow clone allows significantly reduce installation size at the expense of not being able to run `brew update` meaning the package index will be frozen at the moment of image creation. | +| Use shallow clone flag | `shallow` | `false` | A `true`/`false` flag that indicates whether the script should install Homebrew using shallow clone. Shallow clone allows significantly reduce installation size at the expense of not being able to run `brew update` meaning the package index will be frozen at the moment of image creation. | | BREW_PREFIX | | `/home/linuxbrew/.linuxbrew` | Location to install Homebrew. Please note that changing this setting will prevent you from using some of the precompiled binaries and therefore isn't recommended. | ## Usage @@ -39,7 +42,10 @@ You can use this script for your primary dev container by adding it to the `feat ```json "features": { - "homebrew": "latest" + "homebrew": { + "version": "latest", + "shallow": false + } } ``` diff --git a/script-library/homebrew-debian.sh b/script-library/homebrew-debian.sh index 24cda015b0..17adc61841 100755 --- a/script-library/homebrew-debian.sh +++ b/script-library/homebrew-debian.sh @@ -117,12 +117,12 @@ if [ "${USE_SHALLOW_CLONE}" = "false" ]; then echo "Installing Homebrew..." git clone https://github.com/Homebrew/brew "${BREW_PREFIX}/Homebrew" mkdir -p "${BREW_PREFIX}/Homebrew/Library/Taps/homebrew" - git clone https://github.com/Homebrew/linuxbrew-core "${BREW_PREFIX}/Homebrew/Library/Taps/homebrew/homebrew-core" + git clone https://github.com/Homebrew/homebrew-core "${BREW_PREFIX}/Homebrew/Library/Taps/homebrew/homebrew-core" else echo "Installing Homebrew with shallow clone..." git clone --depth 1 https://github.com/Homebrew/brew "${BREW_PREFIX}/Homebrew" mkdir -p "${BREW_PREFIX}/Homebrew/Library/Taps/homebrew" - git clone --depth 1 https://github.com/Homebrew/linuxbrew-core "${BREW_PREFIX}/Homebrew/Library/Taps/homebrew/homebrew-core" + git clone --depth 1 https://github.com/Homebrew/homebrew-core "${BREW_PREFIX}/Homebrew/Library/Taps/homebrew/homebrew-core" # Disable automatic updates as they are not allowed with shallow clone installation updaterc "export HOMEBREW_NO_AUTO_UPDATE=1" updatefishconfig "set -gx HOMEBREW_NO_AUTO_UPDATE 1"