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

Commit e7b99dc

Browse files
authored
add fish-debian.sh as a feature (#1263)
1 parent 61ec933 commit e7b99dc

File tree

6 files changed

+93
-7
lines changed

6 files changed

+93
-7
lines changed

script-library/container-features/src/devcontainer-features.json

+42
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,48 @@
609609
"python-3-postgres"
610610
]
611611
},
612+
{
613+
"id": "fish",
614+
"name": "fish shell and Fisher",
615+
"documentationURL": "https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/fish.md",
616+
"options": {
617+
"version": {
618+
"type": "string",
619+
"enum": ["latest"],
620+
"default": "latest",
621+
"description": "Currently unused."
622+
}
623+
},
624+
"buildArg": "_VSC_INSTALL_FISH",
625+
"include": [
626+
"cpp",
627+
"kubernetes-helm",
628+
"kubernetes-helm-minikube",
629+
"docker-from-docker",
630+
"docker-in-docker",
631+
"dotnet",
632+
"dotnet-fsharp",
633+
"dotnet-mssql",
634+
"powershell",
635+
"java",
636+
"go",
637+
"php",
638+
"ruby",
639+
"rust",
640+
"typescript-node",
641+
"javascript-node",
642+
"python-3",
643+
"python-3-anaconda",
644+
"python-3-miniconda",
645+
"ubuntu",
646+
"debian",
647+
"javascript-node-mongo",
648+
"javascript-node-postgres",
649+
"php-mariadb",
650+
"ruby-rails-postgres",
651+
"python-3-postgres"
652+
]
653+
},
612654
{
613655
"id": "node",
614656
"name": "Node.js (via nvm) and yarn",

script-library/container-features/src/feature-scripts.env

+1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ _VSC_INSTALL_RUST="rust-debian.sh /usr/local/cargo /usr/local/rustup automatic t
2121
_VSC_INSTALL_POWERSHELL="powershell-debian.sh ${_BUILD_ARG_POWERSHELL_VERSION:-latest}"
2222
_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}"
2323
_VSC_INSTALL_DOTNET="dotnet-debian.sh ${_BUILD_ARG_DOTNET_VERSION:-latest} ${_BUILD_ARG_DOTNET_RUNTIMEONLY:-false} automatic true /usr/local/dotnet dotnet"
24+
_VSC_INSTALL_FISH="fish-debian.sh"
2425
_VSC_INSTALL_JUPYTERLAB="jupyterlab-debian.sh ${_BUILD_ARG_JUPYTERLAB_VERSION:-latest}"

script-library/container-features/test-features.env

+1
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@ _VSC_INSTALL_DESKTOP_LITE=true
5050
_VSC_INSTALL_DOTNET=true
5151
_BUILD_ARG_DOTNET_VERSION=latest
5252
_BUILD_ARG_DOTNET_RUNTIMEONLY=false
53+
_VSC_INSTALL_FISH=true
5354
_VSC_INSTALL_AWS_CLI=true

script-library/docs/fish.md

+25-5
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,41 @@
88

99
**OS support**: Debian 9+, Ubuntu 16.04+.
1010

11-
**Maintainer:** [@andreiborisov](https://github.com/andreiborisov)
11+
**Maintainer:** [@andreiborisov](https://github.com/andreiborisov), [@eitsupi](https://github.com/eitsupi)
1212

1313
## Syntax
1414

1515
```text
1616
./fish-debian.sh [Install Fisher flag] [Non-root user]
1717
```
1818

19-
|Argument|Default|Description|
20-
|--------|-------|-----------|
21-
| Install Fisher flag | `true` | A `true`/`false` flag that indicates whether to install [Fisher plugin manager](https://github.com/jorgebucaran/fisher). |
22-
|Non-root user|`automatic`| Specifies a user in the container other than root that will use fish shell. 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`. |
19+
Or as a feature:
20+
21+
```json
22+
"features": {
23+
"fish": "latest"
24+
}
25+
```
26+
27+
| Argument | Feature option | Default | Description |
28+
| ------------------- | -------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
29+
| Install Fisher flag | | `true` | A `true`/`false` flag that indicates whether to install [Fisher plugin manager](https://github.com/jorgebucaran/fisher). |
30+
| Non-root user | | `automatic` | Specifies a user in the container other than root that will use fish shell. 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`. |
2331

2432
## Usage
2533

34+
### Feature use
35+
36+
To install these capabilities in your primary dev container, reference it in `devcontainer.json` as follows:
37+
38+
```json
39+
"features": {
40+
"fish": "latest"
41+
}
42+
```
43+
44+
### Script use
45+
2646
Usage:
2747

2848
1. Add [`fish-debian.sh`](../fish-debian.sh) to `.devcontainer/library-scripts`

script-library/fish-debian.sh

+23-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ if [ "$(id -u)" -ne 0 ]; then
2020
exit 1
2121
fi
2222

23+
export DEBIAN_FRONTEND=noninteractive
24+
2325
# Determine the appropriate non-root user
2426
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
2527
USERNAME=""
@@ -37,13 +39,32 @@ elif [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
3739
USERNAME=root
3840
fi
3941

40-
export DEBIAN_FRONTEND=noninteractive
42+
# Function to run apt-get if needed
43+
apt_get_update_if_needed()
44+
{
45+
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
46+
echo "Running apt-get update..."
47+
apt-get update
48+
else
49+
echo "Skipping apt-get update."
50+
fi
51+
}
52+
53+
# Checks if packages are installed and installs them if not
54+
check_packages() {
55+
if ! dpkg -s "$@" > /dev/null 2>&1; then
56+
apt_get_update_if_needed
57+
apt-get -y install --no-install-recommends "$@"
58+
fi
59+
}
60+
61+
check_packages curl ca-certificates gnupg2 apt-transport-https
4162

4263
# Install fish shell
4364
echo "Installing fish shell..."
4465
if grep -q 'Ubuntu' < /etc/os-release; then
4566
apt-get -y install --no-install-recommends software-properties-common
46-
apt-add-repository ppa:fish-shell/release-3
67+
apt-add-repository -y ppa:fish-shell/release-3
4768
apt-get update
4869
apt-get -y install --no-install-recommends fish
4970
apt-get autoremove -y

script-library/test/regression/run-scripts.sh

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ if [ "${DISTRO}" = "debian" ]; then
9191
runScript desktop-lite "${USERNAME} changeme false"
9292
runScript docker-in-docker "false ${USERNAME} false"
9393
runScript powershell
94+
runScript fish
9495
if [ "${architecture}" = "amd64" ] || [ "${architecture}" = "x86_64" ] || [ "${architecture}" = "arm64" ] || [ "${architecture}" = "aarch64" ]; then
9596
runScript java "13.0.2.j9-adpt /usr/local/sdkman2 ${USERNAME} false"
9697
fi

0 commit comments

Comments
 (0)