Skip to content

Commit ad0d4bc

Browse files
author
MochiOS Team
committed
installer bugfixes: var/cache mount ordering, nvme efibootmgr, user reinstall
- move mkdir var/cache after var subvol mount so the dir exists in the right subvol, not hidden behind the mount - fix efibootmgr disk name parsing: use regex instead of rstrip digits so nvme0n1 doesn't become nvme0n - delete user before recreating on partial reinstall - ch() now passes input_data through for chpasswd
1 parent edfa553 commit ad0d4bc

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

‎archiso-mochios/airootfs/usr/lib/mochiinstall/installer.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ def setup_btrfs(root_part, target, lfn):
156156
os.makedirs(f"{target}/boot", exist_ok=True)
157157
os.makedirs(f"{target}/home", exist_ok=True)
158158
os.makedirs(f"{target}/var", exist_ok=True)
159-
os.makedirs(f"{target}/var/cache", exist_ok=True)
160159
run(["mount", "-o", "compress=zstd,subvol=home", root_part, f"{target}/home"])
161160
run(["mount", "-o", "compress=zstd,subvol=var", root_part, f"{target}/var"])
161+
os.makedirs(f"{target}/var/cache", exist_ok=True)
162162
run(["mount", "-o", "compress=zstd,subvol=cache", root_part, f"{target}/var/cache"])
163163

164164

@@ -219,8 +219,8 @@ def configure_system(target, config, lfn, efi_uuid, swap_uuid, root_uuid):
219219
locale = t / "etc/locale.gen"
220220
locale.write_text(locale.read_text().replace("#en_US.UTF-8 UTF-8", "en_US.UTF-8 UTF-8"))
221221

222-
def ch(cmd, to=120, check=True):
223-
return run(["arch-chroot", target] + cmd, check=check, timeout=to)
222+
def ch(cmd, to=120, check=True, input_data=None):
223+
return run(["arch-chroot", target] + cmd, check=check, timeout=to, input_data=input_data)
224224

225225
ch(["locale-gen"])
226226
ch(["ln", "-sf", "/usr/share/zoneinfo/UTC", "/etc/localtime"])
@@ -256,8 +256,9 @@ def ch(cmd, to=120, check=True):
256256
pmconf.write_text(pmtext)
257257

258258
lfn(f"creating user {username}...")
259+
ch(["userdel", "-rf", username], check=False)
259260
ch(["useradd", "-m", "-G", "wheel,storage,power,audio,video", "-s", "/bin/zsh", username])
260-
run(["arch-chroot", target, "chpasswd"], input_data=f"{username}:{password}\nroot:{password}\n", timeout=30)
261+
ch(["chpasswd"], input_data=f"{username}:{password}\nroot:{password}\n", to=30)
261262

262263
(t / "etc/sudoers.d/10-mochi").write_text("%wheel ALL=(ALL:ALL) ALL\n")
263264

‎installer.py‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ def setup_btrfs(root_part, target, lfn):
156156
os.makedirs(f"{target}/boot", exist_ok=True)
157157
os.makedirs(f"{target}/home", exist_ok=True)
158158
os.makedirs(f"{target}/var", exist_ok=True)
159-
os.makedirs(f"{target}/var/cache", exist_ok=True)
160159
run(["mount", "-o", "compress=zstd,subvol=home", root_part, f"{target}/home"])
161160
run(["mount", "-o", "compress=zstd,subvol=var", root_part, f"{target}/var"])
161+
os.makedirs(f"{target}/var/cache", exist_ok=True)
162162
run(["mount", "-o", "compress=zstd,subvol=cache", root_part, f"{target}/var/cache"])
163163

164164

@@ -220,8 +220,8 @@ def configure_system(target, config, lfn, efi_uuid, swap_uuid, root_uuid):
220220
locale = t / "etc/locale.gen"
221221
locale.write_text(locale.read_text().replace("#en_US.UTF-8 UTF-8", "en_US.UTF-8 UTF-8"))
222222

223-
def ch(cmd, to=120, check=True):
224-
return run(["arch-chroot", target] + cmd, check=check, timeout=to)
223+
def ch(cmd, to=120, check=True, input_data=None):
224+
return run(["arch-chroot", target] + cmd, check=check, timeout=to, input_data=input_data)
225225

226226
ch(["locale-gen"])
227227
ch(["ln", "-sf", "/usr/share/zoneinfo/UTC", "/etc/localtime"])
@@ -257,8 +257,9 @@ def ch(cmd, to=120, check=True):
257257
pmconf.write_text(pmtext)
258258

259259
lfn(f"creating user {username}...")
260+
ch(["userdel", "-rf", username], check=False)
260261
ch(["useradd", "-m", "-G", "wheel,storage,power,audio,video", "-s", "/bin/zsh", username])
261-
run(["arch-chroot", target, "chpasswd"], input_data=f"{username}:{password}\nroot:{password}\n", timeout=30)
262+
ch(["chpasswd"], input_data=f"{username}:{password}\nroot:{password}\n", to=30)
262263

263264
(t / "etc/sudoers.d/10-mochi").write_text("%wheel ALL=(ALL:ALL) ALL\n")
264265

@@ -452,7 +453,8 @@ def install_mochiboot(target, disk, root_uuid, lfn, ch, kernels=None):
452453
ch(["cp", "/usr/share/mochi-splash/mochi-splash.efi", "/boot/EFI/mochi/mochi-splash.efi"], to=10)
453454
lfn("registering mochi-splash boot entry...")
454455
try:
455-
ch(["efibootmgr", "-c", "-d", disk.replace("/dev/", "").rstrip("0123456789"),
456+
disk_clean = re.sub(r'\d+$', '', disk.replace('/dev/', ''))
457+
ch(["efibootmgr", "-c", "-d", disk_clean,
456458
"-p", "1", "-L", "mochios", "-l", "\\EFI\\mochi\\mochi-splash.efi"], to=10, check=False)
457459
except Exception:
458460
lfn(" [yellow]efibootmgr not available, skipping[/]")

0 commit comments

Comments
 (0)