blob: 4df9a7bf3eec6196f513e23efaa854f5b53dc5bc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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'
}
|