| 1 |
#!/usr/bin/python3 |
| 2 |
|
| 3 |
# Determine if Read Only Berkeley Database is needed. |
| 4 |
# |
| 5 |
# argv[1] is BUNDLE_LIBDB |
| 6 |
import os |
| 7 |
import sys |
| 8 |
import re |
| 9 |
from contextlib import suppress |
| 10 |
|
| 11 |
|
| 12 |
def rc(val): |
| 13 |
if (val): |
| 14 |
print("1") |
| 15 |
else: |
| 16 |
print("0") |
| 17 |
sys.exit(0) |
| 18 |
|
| 19 |
def checkVersion(path, version, result): |
| 20 |
with suppress(FileNotFoundError): |
| 21 |
with open(path, 'rt') as fd: |
| 22 |
line = fd.readline().lower() |
| 23 |
print(f'MYDBG: line={line}') |
| 24 |
match = re.match(r'.* release (\d+) ', line) |
| 25 |
print(f'MYDBG: match={match}') |
| 26 |
if match and int(match.group(1)) >= version: |
| 27 |
rc(result) |
| 28 |
|
| 29 |
# Not needed if bundled libdb is available (Typically on RHEL) |
| 30 |
with suppress(IndexError): |
| 31 |
if sys.argv[1] == "1": |
| 32 |
rc(False) |
| 33 |
|
| 34 |
# Regular bdb is not installed ==> lets use Read Only Berkeley Database |
| 35 |
if not os.path.isfile('/usr/include/db.h'): |
| 36 |
rc(True) |
| 37 |
|
| 38 |
if os.getenv("WITH_ROBDB") is not None: |
| 39 |
rc(True) |
| 40 |
|
| 41 |
if os.getenv("WITHOUT_ROBDB") is not None: |
| 42 |
rc(False) |
| 43 |
|
| 44 |
checkVersion('/etc/fedora-release', 43, True) |
| 45 |
rc(False) |