summaryrefslogtreecommitdiff
path: root/tools/copland/scripts/fossil-env.sh
diff options
context:
space:
mode:
authorcashmere <cashmere@autistici.org>2026-09-04 09:05:24 +0200
committercashmere <cashmere@autistici.org>2026-09-04 09:05:24 +0200
commit4f49b16079b27d7ce633619e4cddfdf2bffbc952 (patch)
treec296c1e7f3c3e2f6859c6d3a1b1b208779b89679 /tools/copland/scripts/fossil-env.sh
downloadrelic-4f49b16079b27d7ce633619e4cddfdf2bffbc952.tar.gz
initial commitHEADmaster
Diffstat (limited to 'tools/copland/scripts/fossil-env.sh')
-rwxr-xr-xtools/copland/scripts/fossil-env.sh42
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'
+}