def run(self): # Common vars self.packages = [] self.dest_dir = "/install" if not os.path.exists(self.dest_dir): os.makedirs(self.dest_dir) self.kernel_pkg = "linux" self.vmlinuz = "vmlinuz-%s" % self.kernel_pkg self.initramfs = "initramfs-%s" % self.kernel_pkg self.arch = os.uname()[-1] ## Create/Format partitions if self.method == 'automatic': self.auto_device = self.mount_devices["/"].replace("3","") cnchi_dir = self.settings.get("CNCHI_DIR") script_path = os.path.join(cnchi_dir, "scripts", _autopartition_script) try: self.queue_event('debug', "Automatic device: %s" % self.auto_device) self.queue_event('debug', "Running automatic script...") subprocess.check_call(["/bin/bash", script_path, self.auto_device]) self.queue_event('debug', "Automatic script done.") except subprocess.FileNotFoundError as e: self.queue_fatal_event(_("Can't execute the auto partition script")) return False except subprocess.CalledProcessError as e: self.queue_fatal_event("CalledProcessError.output = %s" % e.output) return False if self.method == 'alongside': # Alongside method shrinks selected partition # and creates root and swap partition in the available space # (error, msg) = fs.create_fs(self.mount_devices["/"], "ext4") boot_partition, root_partition = shrink(self.mount_devices["alongside"]) if self.method == 'advanced': root_partition = self.mount_devices["/"] if "/boot" in self.mount_devices: boot_partition = self.mount_devices["/boot"] else: boot_partition = "" if "swap" in self.mount_devices: swap_partition = self.mount_devices["swap"] # Advanced method formats root by default (error, msg) = fs.create_fs(self.mount_devices["/"], "ext4") if self.method == 'advanced': # TODO: format partitions using mkfs (but which ones?) # Is this really necessary? Won't they be previously formatted in # installation_advanced? pass # Create the directory where we will mount our new root partition if not os.path.exists(self.dest_dir): os.mkdir(self.dest_dir) # Mount root and boot partitions (only if it's needed) if self.method == 'alongside' or self.method == 'advanced': # not doing this in automatic mode as our script mounts the root and boot devices try: txt = _("Mounting partition %s into %s directory") % (root_partition, self.dest_dir) self.queue_event('debug', txt) subprocess.check_call(['mount', root_partition, self.dest_dir]) # We also mount the boot partition if it's needed subprocess.check_call(['mkdir', '-p', '%s/boot' % self.dest_dir]) if "/boot" in self.mount_devices: txt = _("Mounting partition %s into %s/boot directory") % (boot_partition, self.dest_dir) self.queue_event('debug', txt) subprocess.check_call(['mount', boot_partition, "%s/boot" % self.dest_dir]) except subprocess.CalledProcessError as e: self.queue_fatal_event(_("Couldn't mount root and boot partitions")) return False # In advanced mode, mount all partitions (root and boot are already mounted) if self.method == 'advanced': for path in self.mount_devices: mp = self.mount_devices[path] # Root and Boot are already mounted. # Just try to mount all the rest. if mp != root_partition and mp != boot_partition and mp != swap_partition: try: mount_dir = self.dest_dir + path if not os.path.exists(mount_dir): os.mkdir(mount_dir) txt = _("Mounting partition %s into %s directory") % (mp, mount_dir) self.queue_event('debug', txt) subprocess.check_call(['mount', mp, mount_dir]) except subprocess.CalledProcessError as e: # we try to continue as root and boot mounted ok self.queue_event('debug', _("Can't mount %s in %s") % (mp, mount_dir)) # self.queue_fatal_event(_("Couldn't mount %s") % mount_dir) # return False try: subprocess.check_call(['mkdir', '-p', '%s/var/lib/pacman' % self.dest_dir]) subprocess.check_call(['mkdir', '-p', '%s/etc/pacman.d/gnupg/' % self.dest_dir]) subprocess.check_call(['mkdir', '-p', '%s/var/log/' % self.dest_dir]) except subprocess.CalledProcessError as e: self.queue_fatal_event(_("Can't create necessary directories on destination system")) return False try: self.queue_event('debug', 'Selecting packages...') self.select_packages() self.queue_event('debug', 'Packages selected') if self.settings.get("use_aria2"): self.queue_event('debug', 'Downloading packages...') self.download_packages() self.queue_event('debug', 'Packages downloaded.') self.queue_event('debug', 'Installing packages...') self.install_packages() self.queue_event('debug', 'Packages installed.') self.queue_event('debug', 'Installing bootloader...') self.install_bootloader() self.queue_event('debug', 'Bootloader installed.') self.queue_event('debug', 'Configuring system...') self.configure_system() self.queue_event('debug', 'System configured.') except subprocess.CalledProcessError as e: self.queue_fatal_event("CalledProcessError.output = %s" % e.output) return False except InstallError as e: self.queue_fatal_event(e.value) return False # installation finished ok self.queue_event("finished") self.running = False return True
def run(self): # Common vars self.packages = [] self.dest_dir = "/install" if not os.path.exists(self.dest_dir): os.makedirs(self.dest_dir) self.kernel_pkg = "linux" self.vmlinuz = "vmlinuz-%s" % self.kernel_pkg self.initramfs = "initramfs-%s" % self.kernel_pkg self.arch = os.uname()[-1] ## Create/Format partitions # TODO: Check if /boot is in another partition than root. # (and then mount it) if self.method == 'automatic': self.auto_device = self.mount_devices["/"].replace("3","") cnchi_dir = self.settings.get("CNCHI_DIR") script_path = os.path.join(cnchi_dir, "scripts", _autopartition_script) try: self.queue_event('debug', "Automatic device: %s" % self.auto_device) self.queue_event('debug', "Running automatic script...") subprocess.check_call(["/bin/bash", script_path, self.auto_device]) self.queue_event('debug', "Automatic script done.") except subprocess.FileNotFoundError as e: self.queue_fatal_event(_("Can't execute the auto partition script")) return False except subprocess.CalledProcessError as e: self.queue_fatal_event("CalledProcessError.output = %s" % e.output) return False if self.method == 'easy' or self.method == 'advanced': root_partition = self.mount_devices["/"] if "/boot" in self.mount_devices: boot_partition = self.mount_devices["/boot"] else: boot_partition = "" if self.method == 'easy': # Easy method formats root by default (error, msg) = fs.create_fs(self.mount_devices["/"], "ext4") if self.method == 'advanced': # TODO: format partitions using mkfs (but which ones?) # Is this really necessary? Won't they be previously formatted in # installation_advanced? pass # Create the directory where we will mount our new root partition if not os.path.exists(self.dest_dir): os.mkdir(self.dest_dir) # Mount root and boot partitions (only if it's needed) if self.method == 'easy' or self.method == 'advanced': # not doing this in automatic mode as our script mounts the root and boot devices try: subprocess.check_call(['mount', root_partition, self.dest_dir]) # We also mount the boot partition if it's needed subprocess.check_call(['mkdir', '-p', '%s/boot' % self.dest_dir]) if "/boot" in self.mount_devices: subprocess.check_call(['mount', boot_partition, "%s/boot" % self.dest_dir]) except subprocess.CalledProcessError as e: self.queue_fatal_event(_("Couldn't mount root and boot partitions")) return False try: subprocess.check_call(['mkdir', '-p', '%s/var/lib/pacman' % self.dest_dir]) subprocess.check_call(['mkdir', '-p', '%s/etc/pacman.d/gnupg/' % self.dest_dir]) subprocess.check_call(['mkdir', '-p', '%s/var/log/' % self.dest_dir]) except subprocess.CalledProcessError as e: self.queue_fatal_event(_("Can't create necessary directories on destination system")) return False try: self.queue_event('debug', 'Selecting packages...') self.select_packages() self.queue_event('debug', 'Packages selected') self.queue_event('debug', 'Installing packages...') self.install_packages() self.queue_event('debug', 'Packages installed.') self.queue_event('debug', 'Installing bootloader...') self.install_bootloader() self.queue_event('debug', 'Bootloader installed.') self.queue_event('debug', 'Configuring system...') self.configure_system() self.queue_event('debug', 'System configured.') except subprocess.CalledProcessError as e: self.queue_fatal_event("CalledProcessError.output = %s" % e.output) return False except InstallError as e: self.queue_fatal_event(e.value) return False # installation finished ok self.queue_event("finished") self.running = False return True