diff options
Diffstat (limited to 'tools/copland/scripts/fossil-env.sh')
| -rwxr-xr-x | tools/copland/scripts/fossil-env.sh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tools/copland/scripts/fossil-env.sh b/tools/copland/scripts/fossil-env.sh new file mode 100755 index 0000000..4df9a7b --- /dev/null +++ b/tools/copland/scripts/fossil-env.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +if [[ -z "${FOSSIL:-}" ]]; then + FOSSIL=fossil +fi +export FOSSIL + +fossil_binary_path() { + if [[ "$FOSSIL" == */* ]]; then + if [[ ! -x "$FOSSIL" ]]; then + printf 'Fossil binary is not executable: %s\n' "$FOSSIL" >&2 + return 1 + fi + (CDPATH= cd -- "$(dirname -- "$FOSSIL")" && printf '%s/%s\n' "$PWD" "$(basename -- "$FOSSIL")") + else + command -v "$FOSSIL" + fi +} + +require_org_fossil() { + local binary_path + if ! binary_path=$(fossil_binary_path); then + printf 'Fossil was not found. Run `make fossil` or set FOSSIL=/path/to/fossil.\n' >&2 + return 1 + fi + if ! "$FOSSIL" help test-org-render >/dev/null 2>&1; then + printf 'Fossil at %s has no native Org renderer. Run `make fossil` or set FOSSIL to the patched binary.\n' "$binary_path" >&2 + return 1 + fi + printf 'Fossil binary: %s\n' "$binary_path" +} + +verify_org_mime() { + local repository=$1 + local mime_result + mime_result=$("$FOSSIL" test-mimetype -R "$repository" probe.org) + if [[ "$mime_result" != *"text/x-org"* ]]; then + printf 'Selected Fossil does not map .org to text/x-org: %s\n' "$mime_result" >&2 + return 1 + fi + printf 'Org MIME check: text/x-org\n' +} |
