Skip to content

Commit 5ebfe1a

Browse files
authored
add debug helper script and docs (eth-cscs#114)
1 parent 5f0eb92 commit 5ebfe1a

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed

Diff for: docs/development.doc

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Development
2+
3+
This page is for developers and maintainers of Stackinator.
4+
5+
## Debug environment
6+
7+
Debugging stack builds can be challenging, because the build uses an environment with paths mounted and remounted using bwrap and different environment variables than the calling shell.
8+
9+
A helper script that will open a new shell with the same environment as the stack build is generated in the build path.
10+
The script, `stack-debug.sh`, can be sourced to start the new bash shell:
11+
12+
```bash
13+
user@hostname:/dev/shm/project-build > source ./stack-debug.sh
14+
build-env >>>
15+
```
16+
17+
The new shell has `spack` in its path, and has the store path mounted at the environment's mount point.
18+
To finish debugging, exit the shell with `exit` or ctrl-d.
19+

Diff for: mkdocs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ nav:
99
- 'Cluster Configuration': cluster-config.md
1010
- 'Interfaces': interfaces.md
1111
- 'Build Caches': build-caches.md
12+
- 'Development': development.md
1213
# - Tutorial: tutorial.md
1314
theme:
1415
name: material

Diff for: stackinator/builder.py

+11
Original file line numberDiff line numberDiff line change
@@ -360,3 +360,14 @@ def generate(self, recipe):
360360
self._logger.debug(f"copying extra recipe meta data to {meta_extra_path}")
361361
shutil.copytree(recipe.user_extra, meta_extra_path)
362362

363+
# create debug helper script
364+
debug_script_path = self.path / "stack-debug.sh"
365+
debug_script_template = env.get_template("stack-debug.sh")
366+
with debug_script_path.open("w") as f:
367+
f.write(
368+
debug_script_template.render(
369+
mount_path=recipe.config["store"], build_path=str(self.path), verbose=False
370+
)
371+
)
372+
f.write("\n")
373+

Diff for: stackinator/etc/bwrap-mutable-root.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ for d in /*; do
77
args+=("--dev-bind" "$d" "$d")
88
fi
99
done
10-
bwrap "${args[@]}" "$@"
10+
PS1="\[\e[36;1m\]build-env >>> \[\e[0m\]" bwrap "${args[@]}" "$@"
11+

Diff for: stackinator/templates/stack-debug.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
env --ignore-environment PATH=/usr/bin:/bin:{{ build_path }}/spack/bin SOFTWARE_STACK_PROJECT={{ build_path }} STORE={{ mount_path }} SPACK_SYSTEM_CONFIG_PATH={{ build_path }}/config SPACK_USER_CACHE_PATH={{ build_path }}/cache SPACK=spack SPACK_COLOR=always SPACK_USER_CONFIG_PATH=/dev/null LC_ALL=en_US.UTF-8 TZ=UTC SOURCE_DATE_EPOCH=315576060 {{ build_path }}/bwrap-mutable-root.sh --tmpfs ~ --bind {{ build_path }}/tmp /tmp --bind {{ build_path }}/store {{ mount_path }} bash -noprofile -l

0 commit comments

Comments
 (0)