Skip to content

Commit

Permalink
justfile: Rework to support environment variables
Browse files Browse the repository at this point in the history
Adds support for setting BOULDER and BOULDER_ARGS env variables, both
from the command-line, via shell exports and via a .env file next to
the recipes/ justfile.

README.md has been updated to reflect the new capabilities.

Signed-off-by: Rune Morling <[email protected]>
  • Loading branch information
ermo committed Aug 3, 2024
1 parent 2c27b8f commit ff30689
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
.task

# Only use `stone.yaml` path now please.
stone.yml
stone.yml

# Used by just for loading environment variables specific to local systems
.env
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,25 @@ our local repository priority to take precedence.
$ boulder profile add local-x86_64 --repo name=volatile,uri=https://dev.serpentos.com/volatile/x86_64/stone.index,priority=0 --repo name=local,uri=file:///$HOME/.local_repo/stone.index,priority=10
```

**Create a `.env` file**

If you are not building on Serpent OS using the os-supplied boulder package, or if you want to specify custom arguments to the boulder invocation when using the `just` targets,
you might benefit from creating a `.env` file in the root of the `recipes/` directory, next to the supplied `justfile`.

_Example `.env` file:_

BOULDER="${HOME}/.local/bin/boulder"
BOULDER_ARGS="--data-dir=${HOME}/.local/share/boulder --config-dir=${HOME}/.config/boulder --moss-root=${HOME}/.cache/boulder""

The `justfile` is set up so you can also choose to specify either of the above environment variables on a command-line invocation of `just`:

_Example:_

BOULDER_ARGS="--data-dir=${HOME}/.local/share/boulder" just build

### Go go go

Well, actually Rust.. Anyway, quickly try to build `m/m4/stone.yaml` or `n/nano/stone.yaml` for a quick and easy confirmation that everything works OK.
Well, actually Rust.. Anyway, quickly try to `pushd m/m4/ && just build` or `pushd n/nano && just build` for a quick and easy confirmation that everything works OK.

## Git summary requirements

Expand Down
10 changes: 8 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
default: (_build build_file)

set dotenv-load
# respect BOULDER=<...> and BOULDER_ARGS=<...> set in .env file next to the present justfile
boulder := env_var_or_default('BOULDER', 'boulder')
boulder_args := env_var_or_default('BOULDER_ARGS', '')
boulder_profile := env_var_or_default('BOULDER_PROFILE', 'local-x86_64')
build_file := join(invocation_directory(), "stone.yaml")

# Build the stone.yaml recipe using boulder
_build target:
cd {{ invocation_directory() }}; boulder build -u {{ if path_exists(target) == "true" { target } else { error("Missing stone.yaml file") } }} -p {{ boulder_profile }}
cd {{ invocation_directory() }}
{{boulder}} {{boulder_args}} build -u {{ if path_exists(target) == "true" { target } else { error("Missing stone.yaml file") } }} -p {{ boulder_profile }}

# Build stone.yaml from the current directory
build: (_build build_file)

# Chroot into target from stone.yaml recipe with boulder
_chroot target:
cd {{ invocation_directory() }}; boulder chroot {{ if path_exists(target) == "true" { target } else { error("Missing stone.yaml file") } }}
cd {{ invocation_directory() }}
{{boulder}} {{boulder_args}} chroot {{ if path_exists(target) == "true" { target } else { error("Missing stone.yaml file") } }}

# Chroot into pkg from the current directory
chroot: (_chroot build_file)
Expand Down

0 comments on commit ff30689

Please sign in to comment.