Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Commit

Permalink
Update Homebrew script (#1416)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
andreiborisov authored Apr 25, 2022
1 parent 15204de commit 72b7d5a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion script-library/container-features/src/feature-scripts.env
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
12 changes: 9 additions & 3 deletions script-library/docs/homebrew.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ Or as a feature:

```json
"features": {
"homebrew": "latest"
"homebrew": {
"version": "latest",
"shallow": false
}
}
```

|Argument| Feature option |Default|Description|
|--------|----------------|-------|-----------|
|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
Expand All @@ -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
}
}
```

Expand Down
4 changes: 2 additions & 2 deletions script-library/homebrew-debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 72b7d5a

Please sign in to comment.