def CopyFirmware(cls): if Firmware.IsEnabled(): Tools.Info("Copying firmware...") if os.path.isdir("/lib/firmware/"): if Firmware.IsCopyAllEnabled(): shutil.copytree("/lib/firmware/", var.temp + "/lib/firmware/") else: # Copy the firmware in the files list if Firmware.GetFiles(): try: for fw in Firmware.GetFiles(): Tools.Copy( fw, directoryPrefix=var.firmwareDirectory) except FileNotFoundError: Tools.Warn( "An error occured while copying the following firmware: " + fw) else: Tools.Warn( "No firmware files were found in the firmware list!" ) else: Tools.Fail("The /lib/firmware/ directory does not exist")
def CopyFirmware(cls): """Copies the firmware files/directories if necessary.""" if Firmware.IsEnabled(): Tools.Info("Copying firmware...") if os.path.isdir(var.firmwareDirectory): if Firmware.IsCopyAllEnabled(): Tools.CopyTree( var.firmwareDirectory, var.temp + var.firmwareDirectory ) else: # Copy the firmware files if Firmware.GetFiles(): try: for fw in Firmware.GetFiles(): Tools.Into(fw, directoryPrefix=var.firmwareDirectory) except FileNotFoundError: Tools.Warn( "An error occurred while copying the following firmware file: {}".format( fw ) ) # Copy the firmware directories if Firmware.GetDirectories(): try: for fw in Firmware.GetDirectories(): sourceFirmwareDirectory = os.path.join( var.firmwareDirectory, fw ) targetFirmwareDirectory = ( var.temp + sourceFirmwareDirectory ) Tools.CopyTree( sourceFirmwareDirectory, targetFirmwareDirectory ) except FileNotFoundError: Tools.Warn( "An error occurred while copying the following directory: {}".format( fw ) ) else: Tools.Fail( "The {} directory does not exist".format(var.firmwareDirectory) )
def DumpSystemKeymap(cls): pathToKeymap = var.temp + "/etc/keymap" result = call("dumpkeys > " + pathToKeymap, shell=True) if result != 0 or not os.path.isfile(pathToKeymap): Tools.Warn( "There was an error dumping the system's current keymap. Ignoring." )
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(",") for feature in var.features: if feature == "zfs": Zfs.Enable() Modules.AddFile("zfs") 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 elif feature == "exit": Tools.Warn("Exiting.") quit(0) else: Tools.Warn("Invalid Option. Exiting.") quit(1)
def CompressAlgo(cls, vAlgo): # If the user didn't pass their desired compress algos through the command # line, we will use gzip by default. if not var.cmpalgos: var.cmpalgos = vAlgo if var.cmpalgos: var.cmpalgos = Tools._algos[int(var.cmpalgos)].lower() else: var.cmpalgos = "gzip" Tools.NewLine() if var.cmpalgos == "gzip": compress_cmd = 'gzip -9' elif var.cmpalgos == "lz4": compress_cmd = 'lz4 -lz' elif var.cmpalgos == "xz": compress_cmd = 'xz -z9e -C crc32' else: Tools.Warn("Exiting.") quit(1) return compress_cmd
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)