Repository navigation
Expand file tree
/
Copy pathinstall-feat.sh
More file actions
executable file
·63 lines (53 loc) · 2.26 KB
/
Copy pathinstall-feat.sh
File metadata and controls
executable file
·63 lines (53 loc) · 2.26 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
#!/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>
_source="$1"
_feature="$2"
if [ -z "$_source" ] || [ -z "$_feature" ]; then
echo "Usage: install-feat <source_dir> <feature>" >&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"
_stub_count=$(find "$_source/src/$_feature/stubs" \( -type f -o -type l \) 2>/dev/null | wc -l | tr -d ' ')
zz-log i "Deploying {Purple $_feature} (${_stub_count} stub(s))..."
# 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
# Install the feature itself (host or container: install-*.sh scripts that
# genuinely need to tell the two apart already do so internally, e.g.
# gateway/install-wrapper.sh checks REMOTE_CONTAINERS/CODESPACES itself to
# decide whether to divert the system curl).
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, from wherever "feature-install"
# copied it to. Check /usr/local/share first, matching zz-context's own
# target preference (writable /usr/local/share, else /tmp) — otherwise a
# stale /tmp/<feature> left over from an earlier run (when /usr/local/share
# wasn't writable) would win over the fresh copy this run just made.
_featureSource=""
if [ -d "/usr/local/share/$_feature" ]; then
_featureSource="/usr/local/share/$_feature"
elif [ -d "/tmp/$_feature" ]; then
_featureSource="/tmp/$_feature"
fi
if [ -n "$_featureSource" ]; then
feature-configure -s "$_featureSource" "$_feature"
else
echo "Feature $_feature installation target not found" >&2
exit 1
fi