def GetDesiredKernel(cls): if not var.kernel: current_kernel = check_output(["uname", "-r"], universal_newlines=True).strip() message = ("Do you want to use the current kernel: " + current_kernel + " [Y/n]: ") choice = Tools.Question(message) Tools.NewLine() if choice == "y" or choice == "Y" or not choice: var.kernel = current_kernel elif choice == "n" or choice == "N": var.kernel = Tools.Question("Please enter the kernel name: ") Tools.NewLine() if not var.kernel: Tools.Fail("You didn't enter a kernel. Exiting...") else: Tools.Fail("Invalid Option. Exiting.") # Set modules path to correct location and sets kernel name for initramfs var.modules = "/lib/modules/" + var.kernel + "/" var.lmodules = var.temp + "/" + var.modules var.initrd = "initrd-" + var.kernel # Check modules directory cls.VerifyModulesDirectory()
def PrintMenuAndGetDesiredFeatures(cls): # If the user didn't pass their desired features through the command # line, then ask them which initramfs they would like to generate. if not var.features: print( "Which initramfs features do you want? (Separated by a comma):" ) Tools.PrintFeatures() var.features = Tools.Question("Features [1]: ") if var.features: var.features = cls.ConvertNumberedFeaturesToNamedList( var.features) else: var.features = ["zfs"] Tools.NewLine() else: var.features = var.features.split(",") # Enable the addons if the addon has files (modules) listed if Addon.GetFiles(): Addon.Enable() for feature in var.features: if feature == "zfs": Zfs.Enable() Addon.Enable() Addon.AddFile("zfs") elif feature == "lvm": Lvm.Enable() elif feature == "raid": Raid.Enable() elif feature == "luks": Luks.Enable() # Just a base initramfs with no additional stuff # This can be used with other options though # (i.e you have your rootfs directly on top of LUKS) elif feature == "basic": pass else: Tools.Warn("Exiting.") quit(1)
def CreateInitramfs(cls): Tools.PrintCompressAlgos() cmp_cmd = cls.CompressAlgo(Tools.Question("Algorithm [1]: ")) Tools.Info("Creating the initramfs ...") # The find command must use the `find .` and not `find ${T}` # because if not, then the initramfs layout will be prefixed with # the ${T} path. os.chdir(var.temp) call([ "find . -print0 | cpio -o --null --format=newc | " + cmp_cmd + " > " + var.home + "/" + var.initrd ], shell=True) if not os.path.isfile(var.home + "/" + var.initrd): Tools.Fail("Error creating the initramfs. Exiting.")
def PrintMenu(cls): # If the user didn't pass an option through the command line, # then ask them which initramfs they would like to generate. if not var.choice: print("Which initramfs would you like to generate:") Tools.PrintOptions() temp_choice = Tools.Question("Current choice [1]: ") # If the user leaves the choice blank (default choice), # we won't be able to convert an empty string into an int. # Do some checking beforehand. if temp_choice: var.choice = int(temp_choice) else: var.choice = 1 Tools.NewLine() # Enable the addons if the addon has files (modules) listed if Addon.GetFiles(): Addon.Enable() # ZFS if var.choice == 1: Zfs.Enable() Addon.Enable() Addon.AddFile("zfs") # LVM elif var.choice == 2: Lvm.Enable() # RAID elif var.choice == 3: Raid.Enable() # LVM on RAID elif var.choice == 4: Raid.Enable() Lvm.Enable() # Normal elif var.choice == 5: pass # Encrypted ZFS elif var.choice == 6: Luks.Enable() Zfs.Enable() Addon.Enable() Addon.AddFile("zfs") # Encrypted LVM elif var.choice == 7: Luks.Enable() Lvm.Enable() # Encrypted RAID elif var.choice == 8: Luks.Enable() Raid.Enable() # Encrypted LVM on RAID elif var.choice == 9: Luks.Enable() Raid.Enable() Lvm.Enable() # Encrypted Normal elif var.choice == 10: Luks.Enable() # Exit elif var.choice == 11: Tools.Warn("Exiting.") quit(1) # Invalid Option else: Tools.Warn("Invalid Option. Exiting.") quit(1) Tools.PrintDesiredOption(var.choice)