def install(self): """Finally installs the system.""" #mounting ##let's sort them out self.mountpoints.sort(key = lambda x: len(x.path.split('/'))) ##now mount for mountpoint in paths: if not os.path.exists(os.path.join(self.global_path, mountpoint)): os.mkdir(os.path.join(global_path, mountpoint)) mountpoint.mount() #generating fstab with open(self.global_path + "/etc/fstab", 'w') as fstab: fstab.write(storage.generate_fstab(self.mountpoints)) #installing packages os.environ({'XPKG_INSTALL_DIR': self.global_path}) subprocess.Popen(['xpkg', '-i'] + self.packages) #chrootting subprocess.Popen(["mount", "--bind", "/dev", self.global_path + "/dev"]) subprocess.Popen(["mount", "-t", "sysfs", "/proc", self.global_path + "/proc"]) os.chroot(global_path) #users stuff ##adding new users user_admin = libuser.admin() for chosen_one in self.users: user = user_admin.initUser(chosen_one["login"]) #some other stuff here user['PASSWORD'] = chosen_one["password"] user_admin.addUser(user) ##setting root password root_user = user_admin.initUser('root') admin.setpassUser(root_user, root_passwd, True) #network settings with open("/etc/hostname", 'w') as etc_hostname: etc_hostname.write(self.hostname) #locale settings os.symlink(os.path.join("/usr/share/zoneinfo/", self.timezone), "/etc/localtime") l10n.generate(self.locales) #installing grub grub.install(self.grub_device, self.locales)
def bootloader(): grub.install()