Skip to content

Commit 33034b6

Browse files
authored
Add mkdir and symlink actions. (#366)
I think it makes sense to have these as actions rather than requiring `run { cmd = "/bin/ln ..." }`
1 parent 8b038d9 commit 33034b6

File tree

15 files changed

+198
-8
lines changed

15 files changed

+198
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.henv
2+
.venv
23
/docs/.hugo_build.lock
34
testdata/env
45
build

docs/docs/packaging/schema/mkdir.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: "on > mkdir"
3+
---
4+
5+
Create a directory and any missing parents.
6+
7+
Used by: [on](../on#blocks)
8+
9+
10+
## Attributes
11+
12+
| Attribute | Type | Description |
13+
|-----------|------|-------------|
14+
| `dir` | `string` | The absolute directory to create. |
15+
| `mode` | `number?` | File mode of directory. |

docs/docs/packaging/schema/on.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ Used by: [channel](../channel#blocks) [darwin](../darwin#blocks) [linux](../linu
1515
| [`copy { … }`](../copy) | A file to copy when the event is triggered. |
1616
| [`delete { … }`](../delete) | Delete files. |
1717
| [`message { … }`](../message) | Display a message to the user. |
18+
| [`mkdir { … }`](../mkdir) | Create a directory and any missing parents. |
1819
| [`rename { … }`](../rename) | Rename a file. |
1920
| [`run { … }`](../run) | A command to run when the event is triggered. |
21+
| [`symlink { … }`](../symlink) | Create a symbolic link. |

docs/docs/packaging/schema/symlink.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: "on > symlink"
3+
---
4+
5+
Create a symbolic link.
6+
7+
Used by: [on](../on#blocks)
8+
9+
10+
## Attributes
11+
12+
| Attribute | Type | Description |
13+
|-----------|------|-------------|
14+
| `from` | `string` | The absolute source file to symlink from. |
15+
| `to` | `string` | The absolute destination to symlink to. |

docs/mkdocs.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,21 @@ nav:
4949
- packaging/schema/index.md
5050
- packaging/schema/auto-version.md
5151
- packaging/schema/channel.md
52-
- packaging/schema/chmod.md
53-
- packaging/schema/copy.md
5452
- packaging/schema/darwin.md
55-
- packaging/schema/delete.md
5653
- packaging/schema/html.md
5754
- packaging/schema/linux.md
5855
- packaging/schema/manifest.md
59-
- packaging/schema/message.md
60-
- packaging/schema/on.md
6156
- packaging/schema/platform.md
57+
- packaging/schema/version.md
58+
- packaging/schema/on.md
59+
- packaging/schema/chmod.md
60+
- packaging/schema/copy.md
61+
- packaging/schema/delete.md
62+
- packaging/schema/message.md
63+
- packaging/schema/mkdir.md
6264
- packaging/schema/rename.md
6365
- packaging/schema/run.md
64-
- packaging/schema/version.md
66+
- packaging/schema/symlink.md
6567

6668
theme:
6769
name: material

integration/integration_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,15 @@ func TestIntegration(t *testing.T) {
246246
`,
247247
expectations: exp{outputContains("testbin1-1.0.0 hook"), outputContains("testbin1-1.0.1 hook")},
248248
},
249+
{name: "SymlinkAndMkdirActionsWork",
250+
preparations: prep{fixture("testenv3"), activate(".")},
251+
script: `
252+
hermit install testbin1
253+
testbin1
254+
testbin2
255+
`,
256+
expectations: exp{outputContains("testbin1 1.0.1")},
257+
},
249258
}
250259

251260
checkForShells(t)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Hermit environment
2+
3+
This is a [Hermit](https://github.com/cashapp/hermit) bin directory.
4+
5+
The symlinks in this directory are managed by Hermit and will automatically
6+
download and install Hermit itself as well as packages. These packages are
7+
local to this environment.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
# This file must be used with "source bin/activate-hermit" from bash or zsh.
3+
# You cannot run it directly
4+
#
5+
# THIS FILE IS GENERATED; DO NOT MODIFY
6+
7+
if [ "${BASH_SOURCE-}" = "$0" ]; then
8+
echo "You must source this script: \$ source $0" >&2
9+
exit 33
10+
fi
11+
12+
BIN_DIR="$(dirname "${BASH_SOURCE[0]:-${(%):-%x}}")"
13+
if "${BIN_DIR}/hermit" noop > /dev/null; then
14+
eval "$("${BIN_DIR}/hermit" activate "${BIN_DIR}/..")"
15+
16+
if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ]; then
17+
hash -r 2>/dev/null
18+
fi
19+
20+
echo "Hermit environment $("${HERMIT_ENV}"/bin/hermit env HERMIT_ENV) activated"
21+
fi
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
#
3+
# THIS FILE IS GENERATED; DO NOT MODIFY
4+
5+
set -eo pipefail
6+
7+
export HERMIT_USER_HOME=~
8+
9+
if [ -z "${HERMIT_STATE_DIR}" ]; then
10+
case "$(uname -s)" in
11+
Darwin)
12+
export HERMIT_STATE_DIR="${HERMIT_USER_HOME}/Library/Caches/hermit"
13+
;;
14+
Linux)
15+
export HERMIT_STATE_DIR="${XDG_CACHE_HOME:-${HERMIT_USER_HOME}/.cache}/hermit"
16+
;;
17+
esac
18+
fi
19+
20+
export HERMIT_DIST_URL="${HERMIT_DIST_URL:-https://github.com/cashapp/hermit/releases/download/stable}"
21+
HERMIT_CHANNEL="$(basename "${HERMIT_DIST_URL}")"
22+
export HERMIT_CHANNEL
23+
export HERMIT_EXE=${HERMIT_EXE:-${HERMIT_STATE_DIR}/pkg/hermit@${HERMIT_CHANNEL}/hermit}
24+
25+
if [ ! -x "${HERMIT_EXE}" ]; then
26+
echo "Bootstrapping ${HERMIT_EXE} from ${HERMIT_DIST_URL}" 1>&2
27+
INSTALL_SCRIPT="$(mktemp)"
28+
# This value must match that of the install script
29+
INSTALL_SCRIPT_SHA256="180e997dd837f839a3072a5e2f558619b6d12555cd5452d3ab19d87720704e38"
30+
if [ "${INSTALL_SCRIPT_SHA256}" = "BYPASS" ]; then
31+
curl -fsSL "${HERMIT_DIST_URL}/install.sh" -o "${INSTALL_SCRIPT}"
32+
else
33+
# Install script is versioned by its sha256sum value
34+
curl -fsSL "${HERMIT_DIST_URL}/install-${INSTALL_SCRIPT_SHA256}.sh" -o "${INSTALL_SCRIPT}"
35+
# Verify install script's sha256sum
36+
openssl dgst -sha256 "${INSTALL_SCRIPT}" | \
37+
awk -v EXPECTED="$INSTALL_SCRIPT_SHA256" \
38+
'$2!=EXPECTED {print "Install script sha256 " $2 " does not match " EXPECTED; exit 1}'
39+
fi
40+
/bin/bash "${INSTALL_SCRIPT}" 1>&2
41+
fi
42+
43+
exec "${HERMIT_EXE}" --level=fatal exec "$0" -- "$@"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
env = {
2+
TESTENV3: "yes",
3+
}
4+
sources = ["env:///packages"]

0 commit comments

Comments
 (0)