blob: f321717a51f549a9d8a15fb0c3db5ce64f002949 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import os.path
import re
def check_debian_derivative_version(name: str) -> None | str:
if not os.path.isfile("/etc/os-release"):
return None
with open("/etc/os-release", "r") as f:
content = f.read()
if f"ID={name}" not in content:
return None
m = re.search(r'VERSION_ID="(.+)"', content)
if m is None:
return None
return m.group(1)
def check_ubuntu_version() -> None | str:
return check_debian_derivative_version("ubuntu")
def check_debian_version() -> None | str:
return check_debian_derivative_version("debian")
|