aboutsummaryrefslogtreecommitdiff
path: root/src/rust
diff options
context:
space:
mode:
authoreitsupi <50911393+eitsupi@users.noreply.github.com>2022-10-11 01:33:01 +0300
committerGitHub <noreply@github.com>2022-10-11 01:33:01 +0300
commita8cb375d460840bbf8c91599d16fc87d9ee8b996 (patch)
tree73dd647775325582c17a452816457f5cec82004d /src/rust
parent065b5ec9e19d4f289a070c3d5337696fd2394dc0 (diff)
Ensure remove apt-update cache at the beginning and end of the scripts (#210)
* remove apt lists * bump versions
Diffstat (limited to 'src/rust')
-rw-r--r--src/rust/devcontainer-feature.json2
-rwxr-xr-xsrc/rust/install.sh23
2 files changed, 20 insertions, 5 deletions
diff --git a/src/rust/devcontainer-feature.json b/src/rust/devcontainer-feature.json
index e843f22..5fb1049 100644
--- a/src/rust/devcontainer-feature.json
+++ b/src/rust/devcontainer-feature.json
@@ -1,6 +1,6 @@
{
"id": "rust",
- "version": "1.0.6",
+ "version": "1.0.7",
"name": "Rust",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/rust",
"description": "Installs Rust, common Rust utilities, and their required dependencies",
diff --git a/src/rust/install.sh b/src/rust/install.sh
index d8d3b74..e7cfb71 100755
--- a/src/rust/install.sh
+++ b/src/rust/install.sh
@@ -18,6 +18,9 @@ UPDATE_RUST=${UPDATE_RUST:-"false"}
set -e
+# Clean up
+rm -rf /var/lib/apt/lists/*
+
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
@@ -127,8 +130,18 @@ updaterc() {
apt_get_update()
{
- echo "Running apt-get update..."
- apt-get update -y
+ if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
+ echo "Running apt-get update..."
+ apt-get update -y
+ fi
+}
+
+# Checks if packages are installed and installs them if not
+check_packages() {
+ if ! dpkg -s "$@" >/dev/null 2>&1; then
+ apt_get_update
+ apt-get -y install --no-install-recommends "$@"
+ fi
}
export DEBIAN_FRONTEND=noninteractive
@@ -170,8 +183,7 @@ else
if [ "${RUST_VERSION}" != "latest" ] && [ "${RUST_VERSION}" != "lts" ] && [ "${RUST_VERSION}" != "stable" ]; then
# Find version using soft match
if ! type git > /dev/null 2>&1; then
- apt_get_update
- apt-get -y install --no-install-recommends git
+ check_packages git
fi
is_nightly=0
@@ -215,5 +227,8 @@ EOF
# Make files writable for rustlang group
chmod -R g+r+w "${RUSTUP_HOME}" "${CARGO_HOME}"
+# Clean up
+rm -rf /var/lib/apt/lists/*
+
echo "Done!"