Oliver Smith | dac6499 | 2021-01-13 10:29:18 +0100 | [diff] [blame^] | 1 | #!/bin/sh -e |
| 2 | # Find OSMO_GSM_MANUALS_DIR and print it to stdout. Print where it was taken from to stderr. |
| 3 | |
| 4 | # Find it in env, pkg-conf and ../../../osmo-gsm-manuals |
| 5 | RET="$OSMO_GSM_MANUALS_DIR" |
| 6 | if [ -n "$RET" ]; then |
| 7 | RET="$(realpath $RET)" |
| 8 | echo "OSMO_GSM_MANUALS_DIR: $RET (from env)" >&2 |
| 9 | else |
| 10 | RET="$(pkg-config osmo-gsm-manuals --variable=osmogsmmanualsdir 2>/dev/null || true)" |
| 11 | if [ -n "$RET" ]; then |
| 12 | echo "OSMO_GSM_MANUALS_DIR: $RET (from pkg-conf)" >&2 |
| 13 | else |
| 14 | RET="$(realpath $(realpath $(dirname $0))/../../../osmo-gsm-manuals)" |
| 15 | echo "OSMO_GSM_MANUALS_DIR: $RET (fallback)" >&2 |
| 16 | fi |
| 17 | fi |
| 18 | |
| 19 | # Print the result or error message |
| 20 | if [ -d "$RET" ]; then |
| 21 | echo "$RET" |
| 22 | else |
| 23 | echo "ERROR: OSMO_GSM_MANUALS_DIR does not exist!" >&2 |
| 24 | echo "Install osmo-gsm-manuals or set OSMO_GSM_MANUALS_DIR." >&2 |
| 25 | exit 1 |
| 26 | fi |