def _begin_installation(self): if 0: # calamares Spawned.do("/usr/bin/calamares_polkit", timeout=Spawned.TIMEOUT_INFINITE) else: # manjaro-architect # ensure the setup script is installed if not SpawnedSU.do("which setup || pacman -S manjaro-architect --noconfirm --needed --noprogressbar", with_status=True).success: _tlog("manjaro-architect isn't available. Abort...") app_exit() # run manjaro-architect t = SpawnedSU("setup", timeout=Spawned.TIMEOUT_INFINITE) t.interact_user() t.waitfor(SpawnedSU.TASK_END)
def read_upass_from_preseeding_file(pass_key): prefile = preseeding_file() if not prefile: return "" template = f"grep 'passwd/%s' {prefile} | grep -vP '#' | cut -d' ' -f4" return Spawned.do(template % pass_key)
def main(): Spawned.enable_logging() argparser = ArgParser(__package__) argparser.set_subcommand_handler(SUBCMD_DEFAULT, handle_subcmd_default) argparser.set_subcommand_handler(SUBCMD_SCHEME, handle_subcmd_scheme) register_plugins(argparser, PluginLoader()) op = argparser.parse() # set password before one needs it if op.p: SETENV("UPASS", op.p) if op.d: Spawned.enable_debug_commands() if op.selftest: # TODO check required linux commands, .seed file, ubiquity, ubiquity.desktop file, partman, debconf database app_exit() if op.version: print(app_version(__package__)) app_exit() target_disk = select_target_disk() scheme = partitioning.scheme(target_disk, op.P) if not scheme: logger.fail("Invalid partitioning scheme. Abort.") app_exit() runtime_config = RuntimeConfig(PluginLoader.API, target_disk, scheme, op) # call a bound function (defined by argparser) op.func(runtime_config)
def run(self): # check partman availability if not Spawned.do("which partman", with_status=True).success: _tlog("[II] partman not found => skip PartmanHelper actions") return script = re_script() self.visuals_updater = create_py_script(script) SpawnedSU.do_script(f""" echo "Waiting for PARTMAN files in '{PARTMAN_BASE}' ..." while [ ! -d {PARTMAN_BASE} ]; do sleep 1 done echo ""PARTMAN files found. Ready for processing."" """) for p in self.scheme: if p.mountpoint and not p.isspecial: self.mark_to_use(p.url, p.mountpoint, p.do_format, p.fs)
def _prepare_installation(self): # clear partman cache SpawnedSU.do("rm -rf /var/lib/partman") # clear debconf cache # note: removing the DB leads the ubiquity installer to crash SpawnedSU.do_script(""" if [ ! -d /var/cache/debconf.back ]; then cp -r /var/cache/debconf/ /var/cache/debconf.back else rm -rf /var/cache/debconf cp -r /var/cache/debconf.back /var/cache/debconf fi """) # ensure crypt/lvm volumes are available dm_list = Spawned.do(f"ls /dev/mapper", list_=True) for pt in [pt for pt in self.scheme if pt.mapperID]: if isinstance(pt.parent, Disk) and pt.mapperID not in dm_list: pt.execute(Involve()) # wait for Partman and modify values in background PartmanHelper(self.scheme).run()
def target_user(root_fs: str): return Spawned.do(f'ls {root_fs}/home/ | grep -v "lost+found"')
def distro_name(): return Spawned.do("less /etc/lsb-release | grep -oP '(?<=DISTRIB_ID=).*'")
def uefi_loaded(): return Spawned.do("mount | grep efivars", with_status=True).success
def content(self): lines = Spawned(f"cat {self.abs_filepath}", sudo=not util.system.is_readable(self.stat)).datalines return [ line_stripped for line in lines if (line_stripped := line.strip()) ]
def solid(volume_url): return Spawned.do( f"lsblk -n -d -o ROTA {volume_url}").strip() == "0" # 0 - SSD, 1 - HDD
def is_daemon_active(): return Spawned.do( "systemctl status udisks2.service | grep '(running)'", with_status=True).success
def _begin_installation(self): # parse the .desktop file to get the installation command; grep for 'ubiquity' to filter other .desktop files if any data = Spawned.do("grep '^Exec' ~/Desktop/*.desktop | grep 'ubiquity' | tail -1 | sed 's/^Exec=//'") cmd = data.replace("ubiquity", "ubiquity -b --automatic") Spawned(cmd).waitfor(Spawned.TASK_END, timeout=Spawned.TIMEOUT_INFINITE)
def save(self): tmpfile = Spawned.tmp_file_path() self.tree.write(tmpfile) self._execute(f"mv {tmpfile} {self.abs_filepath}")