mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-11 17:44:28 +05:00
fix(moonraker): use os-release file to get distro info (#633)
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -53,8 +53,7 @@ from utils.sys_utils import (
|
||||
cmd_sysctl_manage,
|
||||
cmd_sysctl_service,
|
||||
create_python_venv,
|
||||
get_distro_name,
|
||||
get_distro_version,
|
||||
get_distro_info,
|
||||
install_python_requirements,
|
||||
parse_packages_from_file,
|
||||
)
|
||||
@@ -163,8 +162,10 @@ def install_moonraker_packages() -> None:
|
||||
f"Parsing system dependencies from {MOONRAKER_DEPS_JSON_FILE.name} ..."
|
||||
)
|
||||
parsed_sysdeps = parse_sysdeps_file(MOONRAKER_DEPS_JSON_FILE)
|
||||
distro_name = get_distro_name().lower()
|
||||
distro_version = get_distro_version()
|
||||
distro_name, distro_version = get_distro_info()
|
||||
|
||||
Logger.print_info(f"Distro name: {distro_name}")
|
||||
Logger.print_info(f"Distro version: {distro_version}")
|
||||
|
||||
for dep in parsed_sysdeps.get(distro_name, []):
|
||||
pkg = dep[0].strip()
|
||||
|
||||
@@ -19,7 +19,7 @@ import urllib.error
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
from subprocess import DEVNULL, PIPE, CalledProcessError, Popen, check_output, run
|
||||
from typing import List, Literal, Set
|
||||
from typing import List, Literal, Set, Tuple
|
||||
|
||||
from core.constants import SYSTEMD
|
||||
from core.logger import Logger
|
||||
@@ -540,9 +540,31 @@ def get_service_file_path(instance_type: type, suffix: str) -> Path:
|
||||
|
||||
return file_path
|
||||
|
||||
def get_distro_name() -> str:
|
||||
return check_output(["lsb_release", "-is"]).decode().strip()
|
||||
|
||||
def get_distro_info() -> Tuple[str, str]:
|
||||
distro_info: str = check_output(["cat", "/etc/os-release"]).decode().strip()
|
||||
|
||||
def get_distro_version() -> str:
|
||||
return check_output(["lsb_release", "-rs"]).decode().strip()
|
||||
if not distro_info:
|
||||
raise ValueError("Error reading distro info!")
|
||||
|
||||
distro_id: str = ""
|
||||
distro_id_like: str = ""
|
||||
distro_version: str = ""
|
||||
|
||||
for line in distro_info.split("\n"):
|
||||
if line.startswith("ID="):
|
||||
distro_id = line.split("=")[1].strip('"').strip()
|
||||
if line.startswith("ID_LIKE="):
|
||||
distro_id_like = line.split("=")[1].strip('"').strip()
|
||||
if line.startswith("VERSION_ID="):
|
||||
distro_version = line.split("=")[1].strip('"').strip()
|
||||
|
||||
if distro_id == "raspbian":
|
||||
distro_id = distro_id_like
|
||||
|
||||
if not distro_id:
|
||||
raise ValueError("Error reading distro id!")
|
||||
if not distro_version:
|
||||
raise ValueError("Error reading distro version!")
|
||||
|
||||
return distro_id.lower(), distro_version
|
||||
|
||||
Reference in New Issue
Block a user