示例#1
0
    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")
示例#2
0
    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)
                )