fix(os): read DEBIAN_VERSION_FULL from /etc/os-release first
All checks were successful
Build and Release .deb / build-deb (push) Successful in 21s
All checks were successful
Build and Release .deb / build-deb (push) Successful in 21s
- Check DEBIAN_VERSION_FULL (ex: 13.4) as primary source - Fallback to VERSION, then VERSION_ID, then /etc/debian_version
This commit is contained in:
parent
d90f74dd8f
commit
f0f59f0468
1 changed files with 24 additions and 16 deletions
|
|
@ -140,33 +140,41 @@ def scan_os(target: Target) -> str:
|
|||
"""Récupère le nom, la version complète et le codename de l'OS."""
|
||||
prefix = [] if target.is_host else ["pct", "exec", target.target_id, "--"]
|
||||
|
||||
# 1. Lire /etc/os-release pour VERSION_ID (ex: 12.9) et PRETTY_NAME
|
||||
# 1. Lire /etc/os-release
|
||||
ok, osrel_out, _ = run_cmd(prefix + ["cat", "/etc/os-release"], timeout=30)
|
||||
version_id = ""
|
||||
pretty_name = ""
|
||||
codename = ""
|
||||
if ok:
|
||||
# Priorité 1 : DEBIAN_VERSION_FULL (ex: 13.4)
|
||||
ver_full_match = re.search(r'DEBIAN_VERSION_FULL="?([^"\n]+)"?', osrel_out)
|
||||
if ver_full_match:
|
||||
version_id = ver_full_match.group(1).strip()
|
||||
# Priorité 2 : VERSION (ex: "13 (trixie)")
|
||||
if not version_id:
|
||||
ver_match = re.search(r'VERSION="([^"]+)"', osrel_out)
|
||||
if ver_match:
|
||||
version_id = ver_match.group(1).strip()
|
||||
# Priorité 3 : VERSION_ID (ex: "13")
|
||||
if not version_id:
|
||||
ver_match = re.search(r'VERSION_ID="([^"]+)"', osrel_out)
|
||||
if ver_match:
|
||||
version_id = ver_match.group(1)
|
||||
version_id = ver_match.group(1).strip()
|
||||
# Nom affichable
|
||||
pretty_match = re.search(r'PRETTY_NAME="([^"]+)"', osrel_out)
|
||||
if pretty_match:
|
||||
pretty_name = pretty_match.group(1)
|
||||
pretty_name = pretty_match.group(1).strip()
|
||||
# Codename
|
||||
code_match = re.search(r'VERSION_CODENAME="?([^"\n]+)"?', osrel_out)
|
||||
if code_match:
|
||||
codename = code_match.group(1).strip()
|
||||
|
||||
# 2. Récupérer le codename via lsb_release
|
||||
ok, code_out, _ = run_cmd(prefix + ["lsb_release", "-cs"], timeout=30)
|
||||
codename = code_out.strip() if ok else ""
|
||||
|
||||
# 3. Fallback sur /etc/debian_version si VERSION_ID vide
|
||||
# 2. Fallback sur /etc/debian_version si tout vide
|
||||
if not version_id:
|
||||
ok, ver_out, _ = run_cmd(prefix + ["cat", "/etc/debian_version"], timeout=30)
|
||||
version_id = ver_out.strip() if ok else ""
|
||||
|
||||
# 4. Fallback sur lsb_release -rs
|
||||
if not version_id:
|
||||
ok, ver_out, _ = run_cmd(prefix + ["lsb_release", "-rs"], timeout=30)
|
||||
version_id = ver_out.strip() if ok else ""
|
||||
|
||||
# 5. Récupérer le nom via lsb_release
|
||||
# 3. Récupérer le nom via lsb_release
|
||||
ok, name_out, _ = run_cmd(prefix + ["lsb_release", "-is"], timeout=30)
|
||||
os_name = name_out.strip() if ok else ""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue