-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall-feat.sh
More file actions
executable file
·69 lines (54 loc) · 2.23 KB
/
Copy pathinstall-feat.sh
File metadata and controls
executable file
·69 lines (54 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
# Installs a single devcontainer feature and its tomgrv/devcontainer-features dependencies.
# Uses install.sh as the orchestrator for recursive dependency installation.
# A tracker file (INSTALL_FEAT_TRACKER) prevents re-installation within the same session.
#
# Usage: install-feat <source_dir> <feature> [--stubs]
_source="$1"
_feature="$2"
_stubs="${3:-}"
if [ -z "$_source" ] || [ -z "$_feature" ]; then
echo "Usage: install-feat <source_dir> <feature> [--stubs]" >&2
exit 1
fi
# Prevent re-installation within the same install session
_tracker="${INSTALL_FEAT_TRACKER:-/tmp/.install-feat-$$}"
export INSTALL_FEAT_TRACKER="$_tracker"
if grep -qxF "$_feature" "$_tracker" 2>/dev/null; then
exit 0
fi
echo "$_feature" >>"$_tracker"
# Install each dependency first, using install.sh as orchestrator (recursive)
for _dep in $(sh "$_source/install-deps.sh" "$_source" "$_feature"); do
[ "$_dep" = "$_feature" ] && continue
sh "$_source/install.sh" add "$_dep"
done
# Check if the script is running inside a container
if [ "$CODESPACES" != "true" ] && [ "$REMOTE_CONTAINERS" != "true" ] && [ -z "$DEV_CONTAINER_FILE_PATH" ]; then
# Install the feature itself
if [ -f "$_source/src/$_feature/install.sh" ]; then
sh "$_source/src/$_feature/install.sh" || exit 1
else
echo "Feature $_feature not found in $_source/src/" >&2
exit 1
fi
# Configure the feature after installation
_featureSource=""
if [ -d "/tmp/$_feature" ]; then
_featureSource="/tmp/$_feature"
elif [ -d "/usr/local/share/$_feature" ]; then
_featureSource="/usr/local/share/$_feature"
fi
if [ -n "$_featureSource" ]; then
sh "$_source/src/common-utils/_configure-feature.sh" -s "$_featureSource" "$_feature"
else
echo "Feature $_feature installation target not found" >&2
exit 1
fi
elif [ -n "$_stubs" ]; then
# In container with stubs: deploy stubs for this feature
sh "$_source/src/common-utils/_configure-feature.sh" -s "$_source/src/$_feature" "$_feature"
else
# Inside a container without stubs: suggest using as devcontainer feature
echo "You are in a container: use as devcontainer feature: ghcr.io/tomgrv/devcontainer-features/$_feature"
fi