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 mark_to_use(self, volume_url, mountpoint, do_format, fs): volume_path = self.resolver.pm_resolve_volume_path(volume_url) SpawnedSU.do_script(f""" while [ ! -d {volume_path} ] do sleep 1 echo "waiting for {volume_path} ..." done touch {volume_path}/existing touch {volume_path}/formatable touch {volume_path}/use_filesystem echo "{mountpoint}" > {volume_path}/mountpoint if [ "{do_format}" == "True" ]; then touch {volume_path}/format echo "format" > {volume_path}/method echo "{fs}" > {volume_path}/filesystem echo "{fs}" > {volume_path}/acting_filesystem else echo "keep" > {volume_path}/method while [ ! -f {volume_path}/detected_filesystem ] do sleep 1 echo "waiting for {volume_path}/detected_filesystem ..." done cat {volume_path}/detected_filesystem > {volume_path}/acting_filesystem cat {volume_path}/detected_filesystem > {volume_path}/filesystem fi # replace visuals echo "{mountpoint}" > {volume_path}/visual_mountpoint python3 "{self.visuals_updater}" "{volume_path}/view" "{do_format}" "{mountpoint}" python3 "{self.visuals_updater}" "{volume_path}/../partition_tree_cache" "{do_format}" "{mountpoint}" python3 "{self.visuals_updater}" "{PARTMAN_BASE}/snoop" "{do_format}" "{mountpoint}" """)
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()