Skip to content

Commit 6259385

Browse files
authored
Small checker for obsidian iso's (#12)
* added gentoo system * added openrc support * added network service for openrc systems * Some cleanup of the code * Fixes for Base Installer Removed my specific testing code to reflect the upstream code, from there, fixed the variable name to point to the correct location/file. * Support for obsidian iso's. Removed ID_LIKE, because it is not found in os-release. On ObsidianOS iso's, the Name and ID are obsidianos and obsidian instead of the underlying distro (arch, gentoo etc.). That is why I used package managers as an check. * small fix Name should be obsidianos instead of obsidian
1 parent 4e30fde commit 6259385

1 file changed

Lines changed: 31 additions & 9 deletions

File tree

obsidian-wizard.py

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,38 @@ def _detect_distro():
9898
break
9999
except FileNotFoundError:
100100
continue
101-
return vals.get("ID", "").lower(), vals.get("ID_LIKE", "").lower()
102101

103-
DISTRO_ID, DISTRO_ID_LIKE = _detect_distro()
104-
IS_ARCH_LIKE = "arch" in DISTRO_ID or "arch" in DISTRO_ID_LIKE
105-
IS_GENTOO_LIKE = "gentoo" in DISTRO_ID or "gentoo" in DISTRO_ID_LIKE
106-
107-
# Pick the right template for the running distro
108-
DEFAULT_MKOBSFS_CONTENT = (
109-
DEFAULT_MKOBSFS_CONTENT_GENTOO if IS_GENTOO_LIKE else DEFAULT_MKOBSFS_CONTENT_ARCH
110-
)
102+
d_id = vals.get("ID", "").lower()
103+
name = vals.get("NAME", "").lower()
104+
d_name_first = name.split()[0] if name else ""
105+
106+
# If on ObsidianOS ISO, detect it via the package manager
107+
if "obsidian" in d_id or "obsidianos" in d_name_first:
108+
if shutil.which("pacman"):
109+
d_id = "arch"
110+
elif shutil.which("emerge"):
111+
d_id = "gentoo"
112+
elif shutil.which("xbps-install"):
113+
d_id = "void"
114+
elif shutil.which("apk"):
115+
d_id = "alpine"
116+
elif shutil.which("apt-get") or shutil.which("apt") or shutil.which("dpkg"):
117+
d_id = "debian"
118+
return d_id, d_name_first
119+
120+
DISTROS = ("arch", "gentoo", "void", "alpine", "debian")
121+
DISTRO_ID, DISTRO_NAME = _detect_distro()
122+
123+
MATCHED_DISTRO = DISTROS[0]
124+
for distro in DISTROS:
125+
is_match = (distro == DISTRO_ID)
126+
globals()[f"IS_{distro.upper()}_LIKE"] = is_match
127+
128+
if is_match:
129+
MATCHED_DISTRO = distro
130+
131+
TEMPLATE_CONTENT = f"DEFAULT_MKOBSFS_CONTENT_{MATCHED_DISTRO.upper()}"
132+
DEFAULT_MKOBSFS_CONTENT = globals().get(TEMPLATE_CONTENT, DEFAULT_MKOBSFS_CONTENT_ARCH)
111133

112134
# True when running from a live ISO/USB (system.sfs is the live image)
113135
IS_ARCHISO = os.path.isfile("/etc/system.sfs")

0 commit comments

Comments
 (0)