mirror of
https://github.com/aclist/dztui.git
synced 2026-10-29 14:12:45 +01:00
Merge pull request #330 from aclist/feat/libgi-check
feat: check for missing local library
This commit is contained in:
1 file changed
+51
@@ -0,0 +1,51 @@
|
|||||||
|
import platform
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
LIB = "libgirepository-2.0"
|
||||||
|
|
||||||
|
|
||||||
|
def is_debian() -> bool:
|
||||||
|
"""
|
||||||
|
cf.
|
||||||
|
|
||||||
|
NAME="Debian GNU/Linux"
|
||||||
|
ID=debian
|
||||||
|
|
||||||
|
NAME="Ubuntu"
|
||||||
|
ID=ubuntu
|
||||||
|
ID_LIKE=debian
|
||||||
|
|
||||||
|
NAME="Linux Mint"
|
||||||
|
ID=linuxmint
|
||||||
|
ID_LIKE="ubuntu debian"
|
||||||
|
|
||||||
|
NAME="Pop!_OS"
|
||||||
|
ID=pop
|
||||||
|
ID_LIKE="ubuntu debian"
|
||||||
|
"""
|
||||||
|
release = platform.freedesktop_os_release()
|
||||||
|
strings = ["ubuntu debian", "debian"]
|
||||||
|
try:
|
||||||
|
self_id = release["ID"]
|
||||||
|
if self_id == "debian":
|
||||||
|
return True
|
||||||
|
id_like = release["ID_LIKE"]
|
||||||
|
return id_like in strings
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def has_libgi() -> bool:
|
||||||
|
parent_dir = Path("/usr/lib64")
|
||||||
|
exists = any(LIB in subdir.name for subdir in parent_dir.iterdir())
|
||||||
|
return exists
|
||||||
|
|
||||||
|
|
||||||
|
def test_missing_lib() -> bool:
|
||||||
|
if is_debian() and has_libgi() is False:
|
||||||
|
# TODO: clean up warning
|
||||||
|
print(f"sudo apt install {LIB}")
|
||||||
|
sys.exit(1)
|
||||||
Reference in new issue
Block a user