Skip to content

Commit

Permalink
fix: added featmake checksum
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbraun89 authored Dec 28, 2022
1 parent 02d6ae4 commit bf5913b
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions devcontainer_contrib/features/dependencies_sh.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
FeatureDependencies,
FeatureDependency,
)

FEATMAKE_LINK = (
"https://github.com/devcontainers-contrib/cli/releases/download/v0.0.8/featmake"
)
FEATMAKE_LINK = "https://github.com/devcontainers-contrib/cli/releases/download/v0.0.9/featmake"
CHECKSUM_LINK = "https://github.com/devcontainers-contrib/cli/releases/download/v0.0.9/checksums.txt"

HEADER = """#!/usr/bin/env bash
# This code was generated by the devconainer-contrib cli
Expand All @@ -21,13 +19,36 @@
fi
}}
ensure_featmake () {{
if ! type featmake > /dev/null 2>&1; then
temp_dir=/tmp/featmake-download
mkdir -p $temp_dir
curl -sSL -o $temp_dir/featmake {featmake_link}
curl -sSL -o $temp_dir/checksums.txt {checksums_link}
(cd $temp_dir ; sha256sum --check --strict $temp_dir/checksums.txt)
chmod a+x $temp_dir/featmake
mv -f $temp_dir/featmake /usr/local/bin/featmake
rm -rf $temp_dir
fi
}}
ensure_curl
curl -sSL {featmake_link} -o featmake
ensure_featmake
{dependency_installation_lines}
"""

SINGLE_DEPENDENCY = """# installing {feature_oci}
{stringified_envs} featmake "{feature_oci}"
"""


class DependenciesSH:
REF_PREFIX = "$options."
Expand All @@ -46,7 +67,7 @@ def is_param_ref(param_value: str) -> bool:

def create_install_command(
self, feature_oci: str, params: Dict[str, Union[str, bool]]
):
) -> str:
envs = {}
for param_name, param_value in params.items():
if isinstance(param_value, str):
Expand All @@ -56,8 +77,7 @@ def create_install_command(

stringified_envs = " ".join([f'{env}="{val}"' for env, val in envs.items()])

comment = "# installing {feature_oci}\n"
return f'{comment}{stringified_envs} ./featmake "{feature_oci}"'
return SINGLE_DEPENDENCY.format(stringified_envs=stringified_envs,feature_oci=feature_oci)

@staticmethod
def resolve_param_ref(
Expand Down Expand Up @@ -100,4 +120,5 @@ def to_str(self) -> str:
return HEADER.format(
dependency_installation_lines="\n\n".join(installation_lines),
featmake_link=FEATMAKE_LINK,
checksums_link=CHECKSUM_LINK
)

0 comments on commit bf5913b

Please sign in to comment.