def install_grub(self, menu_lst, device): """Set up GRUB on the given device, writing menu_lst to /boot/grub/menu.lst. """ res = (mounting.mount() and mounting.run_mount_devprocsys("grubinstall", mounting.mount_point(), device) and backend.writefile(menu_lst, mounting.mount_point("/boot/grub/menu.lst"))) if (mounting.unmount() and res): return True errout(_("GRUB setup failed - see log")) return False
def run(self, partlist=[], out_mb=False, out_percent=False, keepsshhost=False, dbg_flags=""): self.dbg_flags = dbg_flags self.keepsshhost = keepsshhost self.out_mb = out_mb self.out_percent = out_percent self.nfiles = 0 self.partlist = backend.Partlist(partlist) # Format #debugging if "f" not in self.dbg_flags: #- # Maybe not formatting should be a genuine option? One might have done it # already ... if not self.format(): return 1 # Mount if not mounting.mount(): return 2 # Copy system #debugging if "i" not in self.dbg_flags: #- if not scripts.run("copy-init"): errout(_("Couldn't initialize file copy process")) return 8 # Start thread to count the files to be copied, -> self.nfiles if self.out_percent: t = threading.Thread(target=self.count_files, args=()) t.start() cc = 0 if not self.copysystem(): errout( _("Copying of system data failed")) cc = 3 if not scripts.run("copy-end"): errout(_("Couldn't finalize file copy process")) if cc == 0: return 9 if cc: return cc io.out("#>" + _("Copy finished:") + "%6.1f GB" % (float(self.installed) / 10**9)) if self.nfiles: io.out(":p>") # Clear percent progress io.out("#>" + _("Initial tweaks to installed system")) if not scripts.run("fix-system1", mounting.mount_point()): errout(_("Initial installed-system tweaks failed")) return 4 # Delivify (including running 'larch0' script) io.out("#>" + _("Removing live-system modifications")) if not scripts.run("fix-system2", mounting.mount_point(), "sshkeys" if self.keepsshhost else ""): errout(_("Failure while removing live-system modifications")) return 5 # initramfs io.out("#>" + _("Generating initramfs")) if not mounting.run_mount_devprocsys("do-mkinitcpio", mounting.mount_point()): errout(_("Problem building initramfs")) return 6 # /etc/fstab io.out("#>" + _("Generating /etc/fstab")) fst = fstab.generate(self.partlist) if fst and backend.writefile(fst, mounting.mount_point('/etc/fstab')): return 0 else: errout(_("Couldn't write /etc/fstab")) return 7