Skip to content
This repository was archived by the owner on Jan 12, 2025. It is now read-only.

Commit ad72212

Browse files
Danielbraun89/issue520 (#543)
* fix: elixir use of wildcard in apt-get installation * fix: update nanolayer and library scripts version for feature elixir-asdf * fix: usage of apt-get wildcards in erlang feature allows for multiple debian and ubuntu compatibility
1 parent f0d2711 commit ad72212

14 files changed

+120
-67
lines changed

src/elixir-asdf/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "elixir-asdf",
3-
"version": "2.0.18",
3+
"version": "2.0.19",
44
"name": "Elixir (via asdf)",
55
"documentationURL": "http://github.com/devcontainers-contrib/features/tree/main/src/elixir-asdf",
66
"description": "Elixir is a functional, concurrent, general-purpose programming language that runs on the BEAM virtual machine which is also used to implement the Erlang programming language.",

src/elixir-asdf/install.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
#!/bin/bash -i
21

32
set -e
43

5-
source ./library_scripts.sh
4+
. ./library_scripts.sh
65

76
# nanolayer is a cli utility which keeps container layers as small as possible
87
# source code: https://github.com/devcontainers-contrib/nanolayer
98
# `ensure_nanolayer` is a bash function that will find any existing nanolayer installations,
109
# and if missing - will download a temporary copy that automatically get deleted at the end
1110
# of the script
12-
ensure_nanolayer nanolayer_location "v0.4.45"
11+
ensure_nanolayer nanolayer_location "v0.5.5"
1312

1413

1514
$nanolayer_location \
1615
install \
1716
devcontainer-feature \
18-
"ghcr.io/devcontainers-contrib/features/apt-get-packages:1.0.4" \
19-
--option packages='build-essential,autoconf,m4,libncurses5-dev,libwxgtk3.0-gtk3-dev,libwxgtk-webview3.0-gtk3-dev,libgl1-mesa-dev,libglu1-mesa-dev,libpng-dev,libssh-dev,unixodbc-dev,xsltproc,fop,libxml2-utils,libncurses-dev,openjdk-11-jdk,procps'
17+
"ghcr.io/devcontainers-contrib/features/apt-get-packages:1.0.6" \
18+
--option packages='build-essential,autoconf,m4,libncurses5-dev,libwxgtk3.*-dev,libwxgtk-webview3.*-dev,libgl1-mesa-dev,libglu1-mesa-dev,libpng-dev,libssh-dev,unixodbc-dev,xsltproc,fop,libxml2-utils,libncurses-dev,openjdk-1*-jdk,procps'
2019

2120

2221

src/elixir-asdf/library_scripts.sh

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/bin/bash -i
21

32

43
clean_download() {
@@ -10,13 +9,13 @@ clean_download() {
109
# The above steps will minimize the leftovers being created while installing the downloader
1110
# Supported distros:
1211
# debian/ubuntu/alpine
13-
12+
1413
url=$1
1514
output_location=$2
1615
tempdir=$(mktemp -d)
1716
downloader_installed=""
1817

19-
function _apt_get_install() {
18+
_apt_get_install() {
2019
tempdir=$1
2120

2221
# copy current state of apt list - in order to revert back later (minimize contianer layer size)
@@ -25,7 +24,7 @@ clean_download() {
2524
apt-get -y install --no-install-recommends wget ca-certificates
2625
}
2726

28-
function _apt_get_cleanup() {
27+
_apt_get_cleanup() {
2928
tempdir=$1
3029

3130
echo "removing wget"
@@ -36,15 +35,15 @@ clean_download() {
3635
rm -r /var/lib/apt/lists && mv $tempdir/lists /var/lib/apt/lists
3736
}
3837

39-
function _apk_install() {
38+
_apk_install() {
4039
tempdir=$1
4140
# copy current state of apk cache - in order to revert back later (minimize contianer layer size)
4241
cp -p -R /var/cache/apk $tempdir
4342

4443
apk add --no-cache wget
4544
}
4645

47-
function _apk_cleanup() {
46+
_apk_cleanup() {
4847
tempdir=$1
4948

5049
echo "removing wget"
@@ -100,45 +99,39 @@ ensure_nanolayer() {
10099
local variable_name=$1
101100

102101
local required_version=$2
103-
# normalize version
104-
if ! [[ $required_version == v* ]]; then
105-
required_version=v$required_version
106-
fi
107102

108-
local nanolayer_location=""
103+
local __nanolayer_location=""
109104

110105
# If possible - try to use an already installed nanolayer
111-
if [[ -z "${NANOLAYER_FORCE_CLI_INSTALLATION}" ]]; then
112-
if [[ -z "${NANOLAYER_CLI_LOCATION}" ]]; then
106+
if [ -z "${NANOLAYER_FORCE_CLI_INSTALLATION}" ]; then
107+
if [ -z "${NANOLAYER_CLI_LOCATION}" ]; then
113108
if type nanolayer >/dev/null 2>&1; then
114109
echo "Found a pre-existing nanolayer in PATH"
115-
nanolayer_location=nanolayer
110+
__nanolayer_location=nanolayer
116111
fi
117112
elif [ -f "${NANOLAYER_CLI_LOCATION}" ] && [ -x "${NANOLAYER_CLI_LOCATION}" ] ; then
118-
nanolayer_location=${NANOLAYER_CLI_LOCATION}
119-
echo "Found a pre-existing nanolayer which were given in env variable: $nanolayer_location"
113+
__nanolayer_location=${NANOLAYER_CLI_LOCATION}
114+
echo "Found a pre-existing nanolayer which were given in env variable: $__nanolayer_location"
120115
fi
121116

122117
# make sure its of the required version
123-
if ! [[ -z "${nanolayer_location}" ]]; then
118+
if ! [ -z "${__nanolayer_location}" ]; then
124119
local current_version
125-
current_version=$($nanolayer_location --version)
126-
if ! [[ $current_version == v* ]]; then
127-
current_version=v$current_version
128-
fi
120+
current_version=$($__nanolayer_location --version)
121+
129122

130123
if ! [ $current_version == $required_version ]; then
131124
echo "skipping usage of pre-existing nanolayer. (required version $required_version does not match existing version $current_version)"
132-
nanolayer_location=""
125+
__nanolayer_location=""
133126
fi
134127
fi
135128

136129
fi
137130

138131
# If not previuse installation found, download it temporarly and delete at the end of the script
139-
if [[ -z "${nanolayer_location}" ]]; then
132+
if [ -z "${__nanolayer_location}" ]; then
140133

141-
if [ "$(uname -sm)" == "Linux x86_64" ] || [ "$(uname -sm)" == "Linux aarch64" ]; then
134+
if [ "$(uname -sm)" = 'Linux x86_64' ] || [ "$(uname -sm)" = "Linux aarch64" ]; then
142135
tmp_dir=$(mktemp -d -t nanolayer-XXXXXXXXXX)
143136

144137
clean_up () {
@@ -162,7 +155,7 @@ ensure_nanolayer() {
162155

163156
tar xfzv $tmp_dir/$tar_filename -C "$tmp_dir"
164157
chmod a+x $tmp_dir/nanolayer
165-
nanolayer_location=$tmp_dir/nanolayer
158+
__nanolayer_location=$tmp_dir/nanolayer
166159

167160

168161
else
@@ -172,7 +165,7 @@ ensure_nanolayer() {
172165
fi
173166

174167
# Expose outside the resolved location
175-
declare -g ${variable_name}=$nanolayer_location
168+
export ${variable_name}=$__nanolayer_location
176169

177170
}
178171

src/erlang-asdf/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "erlang-asdf",
3-
"version": "2.0.17",
3+
"version": "2.0.18",
44
"name": "Erlang (via asdf)",
55
"documentationURL": "http://github.com/devcontainers-contrib/features/tree/main/src/erlang-asdf",
66
"description": "Erlang is a general-purpose, concurrent, functional programming language, and a garbage-collected runtime system.",

src/erlang-asdf/install.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
#!/bin/bash -i
21

32
set -e
43

5-
source ./library_scripts.sh
4+
. ./library_scripts.sh
65

76
# nanolayer is a cli utility which keeps container layers as small as possible
87
# source code: https://github.com/devcontainers-contrib/nanolayer
98
# `ensure_nanolayer` is a bash function that will find any existing nanolayer installations,
109
# and if missing - will download a temporary copy that automatically get deleted at the end
1110
# of the script
12-
ensure_nanolayer nanolayer_location "v0.4.45"
11+
ensure_nanolayer nanolayer_location "v0.5.5"
1312

1413

1514
$nanolayer_location \
1615
install \
1716
devcontainer-feature \
18-
"ghcr.io/devcontainers-contrib/features/apt-get-packages:1.0.4" \
19-
--option packages='build-essential,autoconf,m4,libncurses5-dev,libwxgtk3.0-gtk3-dev,libwxgtk-webview3.0-gtk3-dev,libgl1-mesa-dev,libglu1-mesa-dev,libpng-dev,libssh-dev,unixodbc-dev,xsltproc,fop,libxml2-utils,libncurses-dev,openjdk-11-jdk,procps'
17+
"ghcr.io/devcontainers-contrib/features/apt-get-packages:1.0.6" \
18+
--option packages='build-essential,autoconf,m4,libncurses5-dev,libwxgtk3.*-dev,libwxgtk-webview3.*-dev,libgl1-mesa-dev,libglu1-mesa-dev,libpng-dev,libssh-dev,unixodbc-dev,xsltproc,fop,libxml2-utils,libncurses-dev,openjdk-1*-jdk,procps'
2019

2120

2221

src/erlang-asdf/library_scripts.sh

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/bin/bash -i
21

32

43
clean_download() {
@@ -10,13 +9,13 @@ clean_download() {
109
# The above steps will minimize the leftovers being created while installing the downloader
1110
# Supported distros:
1211
# debian/ubuntu/alpine
13-
12+
1413
url=$1
1514
output_location=$2
1615
tempdir=$(mktemp -d)
1716
downloader_installed=""
1817

19-
function _apt_get_install() {
18+
_apt_get_install() {
2019
tempdir=$1
2120

2221
# copy current state of apt list - in order to revert back later (minimize contianer layer size)
@@ -25,7 +24,7 @@ clean_download() {
2524
apt-get -y install --no-install-recommends wget ca-certificates
2625
}
2726

28-
function _apt_get_cleanup() {
27+
_apt_get_cleanup() {
2928
tempdir=$1
3029

3130
echo "removing wget"
@@ -36,15 +35,15 @@ clean_download() {
3635
rm -r /var/lib/apt/lists && mv $tempdir/lists /var/lib/apt/lists
3736
}
3837

39-
function _apk_install() {
38+
_apk_install() {
4039
tempdir=$1
4140
# copy current state of apk cache - in order to revert back later (minimize contianer layer size)
4241
cp -p -R /var/cache/apk $tempdir
4342

4443
apk add --no-cache wget
4544
}
4645

47-
function _apk_cleanup() {
46+
_apk_cleanup() {
4847
tempdir=$1
4948

5049
echo "removing wget"
@@ -100,45 +99,39 @@ ensure_nanolayer() {
10099
local variable_name=$1
101100

102101
local required_version=$2
103-
# normalize version
104-
if ! [[ $required_version == v* ]]; then
105-
required_version=v$required_version
106-
fi
107102

108-
local nanolayer_location=""
103+
local __nanolayer_location=""
109104

110105
# If possible - try to use an already installed nanolayer
111-
if [[ -z "${NANOLAYER_FORCE_CLI_INSTALLATION}" ]]; then
112-
if [[ -z "${NANOLAYER_CLI_LOCATION}" ]]; then
106+
if [ -z "${NANOLAYER_FORCE_CLI_INSTALLATION}" ]; then
107+
if [ -z "${NANOLAYER_CLI_LOCATION}" ]; then
113108
if type nanolayer >/dev/null 2>&1; then
114109
echo "Found a pre-existing nanolayer in PATH"
115-
nanolayer_location=nanolayer
110+
__nanolayer_location=nanolayer
116111
fi
117112
elif [ -f "${NANOLAYER_CLI_LOCATION}" ] && [ -x "${NANOLAYER_CLI_LOCATION}" ] ; then
118-
nanolayer_location=${NANOLAYER_CLI_LOCATION}
119-
echo "Found a pre-existing nanolayer which were given in env variable: $nanolayer_location"
113+
__nanolayer_location=${NANOLAYER_CLI_LOCATION}
114+
echo "Found a pre-existing nanolayer which were given in env variable: $__nanolayer_location"
120115
fi
121116

122117
# make sure its of the required version
123-
if ! [[ -z "${nanolayer_location}" ]]; then
118+
if ! [ -z "${__nanolayer_location}" ]; then
124119
local current_version
125-
current_version=$($nanolayer_location --version)
126-
if ! [[ $current_version == v* ]]; then
127-
current_version=v$current_version
128-
fi
120+
current_version=$($__nanolayer_location --version)
121+
129122

130123
if ! [ $current_version == $required_version ]; then
131124
echo "skipping usage of pre-existing nanolayer. (required version $required_version does not match existing version $current_version)"
132-
nanolayer_location=""
125+
__nanolayer_location=""
133126
fi
134127
fi
135128

136129
fi
137130

138131
# If not previuse installation found, download it temporarly and delete at the end of the script
139-
if [[ -z "${nanolayer_location}" ]]; then
132+
if [ -z "${__nanolayer_location}" ]; then
140133

141-
if [ "$(uname -sm)" == "Linux x86_64" ] || [ "$(uname -sm)" == "Linux aarch64" ]; then
134+
if [ "$(uname -sm)" = 'Linux x86_64' ] || [ "$(uname -sm)" = "Linux aarch64" ]; then
142135
tmp_dir=$(mktemp -d -t nanolayer-XXXXXXXXXX)
143136

144137
clean_up () {
@@ -162,7 +155,7 @@ ensure_nanolayer() {
162155

163156
tar xfzv $tmp_dir/$tar_filename -C "$tmp_dir"
164157
chmod a+x $tmp_dir/nanolayer
165-
nanolayer_location=$tmp_dir/nanolayer
158+
__nanolayer_location=$tmp_dir/nanolayer
166159

167160

168161
else
@@ -172,7 +165,7 @@ ensure_nanolayer() {
172165
fi
173166

174167
# Expose outside the resolved location
175-
declare -g ${variable_name}=$nanolayer_location
168+
export ${variable_name}=$__nanolayer_location
176169

177170
}
178171

test/elixir-asdf/scenarios.json

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
{
2-
"test": {
3-
"image": "mcr.microsoft.com/devcontainers/base:debian",
2+
"test_debian_11": {
3+
"image": "mcr.microsoft.com/devcontainers/base:debian-11",
4+
"features": {
5+
"elixir-asdf": {}
6+
}
7+
},
8+
"test_debian_12": {
9+
"image": "mcr.microsoft.com/devcontainers/base:debian-12",
10+
"features": {
11+
"elixir-asdf": {}
12+
}
13+
},
14+
"test_ubuntu_2004": {
15+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu-20.04",
16+
"features": {
17+
"elixir-asdf": {}
18+
}
19+
},
20+
"test_ubuntu_2204": {
21+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu-22.04",
422
"features": {
523
"elixir-asdf": {}
624
}
File renamed without changes.

test/elixir-asdf/test_debian_12.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash -i
2+
3+
set -e
4+
5+
source dev-container-features-test-lib
6+
7+
check "elixir --version" elixir --version
8+
9+
reportResults

test/elixir-asdf/test_ubuntu_2004.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash -i
2+
3+
set -e
4+
5+
source dev-container-features-test-lib
6+
7+
check "elixir --version" elixir --version
8+
9+
reportResults

0 commit comments

Comments
 (0)