Skip to content

Commit 0127a8f

Browse files
committed
more tools installed by checking sha
1 parent 9569fe5 commit 0127a8f

7 files changed

Lines changed: 124 additions & 5 deletions

File tree

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
direnv 2.37.1
21
actionlint 1.7.12
32
ruby 3.3.0
4-
yq 4.52.5

src/base/.devcontainer/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ ARG ASDF_VERSION="v0.18.1"
1313
ARG GITLEAKS_VERSION="8.30.1"
1414
ARG CFN_GUARD_VERSION="3.2.0"
1515
ARG SHELLCHECK_VERSION="v0.11.0"
16+
ARG DIRENV_VERSION="v2.37.1"
17+
ARG YQ_VERSION="v4.52.5"
1618

1719
ENV SCRIPTS_DIR=${SCRIPTS_DIR}
1820
ENV CONTAINER_NAME=${CONTAINER_NAME}
@@ -22,6 +24,8 @@ ENV ASDF_VERSION=${ASDF_VERSION}
2224
ENV GITLEAKS_VERSION=${GITLEAKS_VERSION}
2325
ENV CFN_GUARD_VERSION=${CFN_GUARD_VERSION}
2426
ENV SHELLCHECK_VERSION=${SHELLCHECK_VERSION}
27+
ENV DIRENV_VERSION=${DIRENV_VERSION}
28+
ENV YQ_VERSION=${YQ_VERSION}
2529

2630
COPY --chmod=755 scripts/lifecycle/*.sh ${SCRIPTS_DIR}/
2731
COPY --chmod=755 scripts/root_install.sh ${SCRIPTS_DIR}/${CONTAINER_NAME}/root_install.sh
@@ -30,6 +34,8 @@ COPY --chmod=755 scripts/install_asdf.sh ${SCRIPTS_DIR}/${CONTAINER_NAME}/instal
3034
COPY --chmod=755 scripts/install_gitleaks.sh ${SCRIPTS_DIR}/${CONTAINER_NAME}/install_gitleaks.sh
3135
COPY --chmod=755 scripts/install_cfn_guard.sh ${SCRIPTS_DIR}/${CONTAINER_NAME}/install_cfn_guard.sh
3236
COPY --chmod=755 scripts/install_shellcheck.sh ${SCRIPTS_DIR}/${CONTAINER_NAME}/install_shellcheck.sh
37+
COPY --chmod=755 scripts/install_direnv.sh ${SCRIPTS_DIR}/${CONTAINER_NAME}/install_direnv.sh
38+
COPY --chmod=755 scripts/install_yq.sh ${SCRIPTS_DIR}/${CONTAINER_NAME}/install_yq.sh
3339
COPY --chmod=755 Mk ${SCRIPTS_DIR}/Mk
3440

3541
WORKDIR ${SCRIPTS_DIR}/${CONTAINER_NAME}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
VERSION=${VERSION:-"v2.37.1"}
5+
# Expected SHA256 checksums taken from https://github.com/direnv/direnv/releases/tag/v2.37.1
6+
# When we change direnv versions, these must be changed
7+
sha256sum_expected_arm="sha256:2a9cef8d73521d6a3ec3f2871c4b747b8c4cc038628c1b57a7efa42b393a2d82"
8+
sha256sum_expected_amd64="sha256:1f1b93dd6f38523fde26dfac96151ef9d31a374e3005cd3345fb93555ae0c9b5"
9+
10+
if [ "$(id -u)" -ne 0 ]; then
11+
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
12+
exit 1
13+
fi
14+
15+
# Checks if packages are installed and installs them if not
16+
check_packages() {
17+
if ! dpkg -s "$@" > /dev/null 2>&1; then
18+
sudo apt-get -y install --no-install-recommends "$@"
19+
fi
20+
}
21+
22+
check_packages curl ca-certificates tar
23+
24+
install() {
25+
tmp_dir="$(mktemp -d)"
26+
trap 'rm -rf "${tmp_dir}"' EXIT
27+
28+
download_file="${tmp_dir}/direnv"
29+
30+
if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then
31+
download_url="https://github.com/direnv/direnv/releases/download/${VERSION}/direnv.linux-arm64"
32+
sha256sum_expected="${sha256sum_expected_arm}"
33+
else
34+
download_url="https://github.com/direnv/direnv/releases/download/${VERSION}/direnv.linux-amd64"
35+
sha256sum_expected="${sha256sum_expected_amd64}"
36+
fi
37+
echo "Downloading direnv from ${download_url}..."
38+
curl -fsSL "${download_url}" -o "${download_file}"
39+
40+
download_file_sha256sum=$(sha256sum "${download_file}" | awk '{print $1}')
41+
if [ "${download_file_sha256sum}" != "${sha256sum_expected#sha256:}" ]; then
42+
echo "SHA256 checksum mismatch for downloaded direnv archive"
43+
echo "Expected: ${sha256sum_expected}"
44+
echo "Actual: sha256:${download_file_sha256sum}"
45+
exit 1
46+
fi
47+
48+
mkdir -p /usr/bin
49+
mv "${download_file}" /usr/bin/direnv
50+
chmod +x /usr/bin/direnv
51+
}
52+
echo "(*) Installing direnv..."
53+
54+
install
55+
56+
echo "Done!"
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
VERSION=${VERSION:-"v4.52.5"}
5+
# Expected SHA256 checksums taken from https://github.com/mikefarah/yq/releases/tag/v4.52.5
6+
# When we change yq versions, these must be changed
7+
sha256sum_expected_arm="sha256:90fa510c50ee8ca75544dbfffed10c88ed59b36834df35916520cddc623d9aaa"
8+
sha256sum_expected_amd64="sha256:75d893a0d5940d1019cb7cdc60001d9e876623852c31cfc6267047bc31149fa9"
9+
10+
if [ "$(id -u)" -ne 0 ]; then
11+
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
12+
exit 1
13+
fi
14+
15+
# Checks if packages are installed and installs them if not
16+
check_packages() {
17+
if ! dpkg -s "$@" > /dev/null 2>&1; then
18+
sudo apt-get -y install --no-install-recommends "$@"
19+
fi
20+
}
21+
22+
check_packages curl ca-certificates tar
23+
24+
install() {
25+
tmp_dir="$(mktemp -d)"
26+
trap 'rm -rf "${tmp_dir}"' EXIT
27+
28+
download_file="${tmp_dir}/yq"
29+
30+
if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then
31+
download_url="https://github.com/mikefarah/yq/releases/download/${VERSION}/yq_linux_arm64"
32+
sha256sum_expected="${sha256sum_expected_arm}"
33+
else
34+
download_url="https://github.com/mikefarah/yq/releases/download/${VERSION}/yq_linux_amd64"
35+
sha256sum_expected="${sha256sum_expected_amd64}"
36+
fi
37+
echo "Downloading yq from ${download_url}..."
38+
curl -fsSL "${download_url}" -o "${download_file}"
39+
40+
download_file_sha256sum=$(sha256sum "${download_file}" | awk '{print $1}')
41+
if [ "${download_file_sha256sum}" != "${sha256sum_expected#sha256:}" ]; then
42+
echo "SHA256 checksum mismatch for downloaded yq archive"
43+
echo "Expected: ${sha256sum_expected}"
44+
echo "Actual: sha256:${download_file_sha256sum}"
45+
exit 1
46+
fi
47+
48+
mkdir -p /usr/bin
49+
mv "${download_file}" /usr/bin/yq
50+
chmod +x /usr/bin/yq
51+
}
52+
echo "(*) Installing yq..."
53+
54+
install
55+
56+
echo "Done!"

src/base/.devcontainer/scripts/root_install.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ VERSION="${ASDF_VERSION}" "${SCRIPTS_DIR}/${CONTAINER_NAME}/install_asdf.sh"
4040
VERSION="${GITLEAKS_VERSION}" "${SCRIPTS_DIR}/${CONTAINER_NAME}/install_gitleaks.sh"
4141
# install shellcheck
4242
VERSION="${SHELLCHECK_VERSION}" "${SCRIPTS_DIR}/${CONTAINER_NAME}/install_shellcheck.sh"
43+
# install direnv
44+
VERSION="${DIRENV_VERSION}" "${SCRIPTS_DIR}/${CONTAINER_NAME}/install_direnv.sh"
45+
# install yq
46+
VERSION="${YQ_VERSION}" "${SCRIPTS_DIR}/${CONTAINER_NAME}/install_yq.sh"
4347

4448
# install gitsecrets
4549
# this should be removed once we have migrated all repos to gitleaks

src/base/.devcontainer/scripts/vscode_install.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc
1212
echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc
1313

1414
# Install ASDF plugins
15-
asdf plugin add direnv
15+
# actionlint install is verified so can install via asdf
1616
asdf plugin add actionlint
1717
asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git
18-
asdf plugin add terraform https://github.com/asdf-community/asdf-hashicorp.git
19-
asdf plugin add yq https://github.com/sudermanjr/asdf-yq.git
2018

2119
# install cfn-guard
2220
VERSION="${CFN_GUARD_VERSION}" "${SCRIPTS_DIR}/${CONTAINER_NAME}/install_cfn_guard.sh"

src/projects/eps-storage-terraform/.devcontainer/scripts/vscode_install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
set -e
33

44
# install terraform using asdf
5+
# terraform is verified by asdf install
56
asdf plugin add terraform
67
asdf install

0 commit comments

Comments
 (0)