-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
95970c6
commit ccd4c1f
Showing
5 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "apt-get packages", | ||
"id": "apt-get-packages", | ||
"version": "1.0.0", | ||
"description": "Installs an apt-get packages (debian).", | ||
"documentationURL": "http://github.com/devcontainers-contrib/features/tree/main/src/apt-get-package", | ||
"installAfter": [], | ||
"options": { | ||
"packages": { | ||
"type": "string", | ||
"proposals": [ | ||
"gcc", | ||
"curl" | ||
], | ||
"default": "", | ||
"description": "Space delimitered apt-get packages to install." | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
|
||
PACKAGES="${PACKAGES:-""}" | ||
|
||
# Clean up | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
if [ -z "$PACKAGES" ]; then | ||
echo -e "'packages' variable is empty, skipping" | ||
exit 0 | ||
fi | ||
|
||
if [ "$(id -u)" -ne 0 ]; then | ||
echo -e 'Script must be run as | ||
root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' | ||
exit 1 | ||
fi | ||
|
||
check_packages() { | ||
# This is part of devcontainers-contrib script library | ||
# source: https://github.com/devcontainers-contrib/features/tree/v1.1.8/script-library | ||
if ! dpkg -s "$@" >/dev/null 2>&1; then | ||
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then | ||
echo "Running apt-get update..." | ||
apt-get update -y | ||
fi | ||
apt-get -y install --no-install-recommends "$@" | ||
fi | ||
} | ||
|
||
packages_array=("$PACKAGES") | ||
check_packages ${packages_array[@]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
source dev-container-features-test-lib | ||
|
||
check 'dpkg -l | grep "ii cowsay"' dpkg -l | grep "ii cowsay" | ||
check 'dpkg -l | grep "ii build-essential"' dpkg -l | grep "ii build-essential" | ||
|
||
|
||
reportResults |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"install_cowsay_build_essential": { | ||
"image": "debian:bullseye", | ||
"features": { | ||
"apt-get-packages": { | ||
"version": "latest", | ||
"packages": "cowsay build-essential" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
source dev-container-features-test-lib | ||
|
||
check "nothing is installted when package is empty" exit 0 | ||
|
||
reportResults |