def Main(): try: EdkLogger.Initialize() CommandOptions, InputFile = Options() if CommandOptions.LogLevel < EdkLogger.DEBUG_9: EdkLogger.SetLevel(CommandOptions.LogLevel + 1) else: EdkLogger.SetLevel(CommandOptions.LogLevel) except FatalError as X: return 1 try: if CommandOptions.FileType == "Vfr": if CommandOptions.OutputFile is None: CommandOptions.OutputFile = os.path.splitext( InputFile)[0] + '.iii' TrimPreprocessedVfr(InputFile, CommandOptions.OutputFile) elif CommandOptions.FileType == "Asl": if CommandOptions.OutputFile is None: CommandOptions.OutputFile = os.path.splitext( InputFile)[0] + '.iii' TrimAslFile(InputFile, CommandOptions.OutputFile, CommandOptions.IncludePathFile) elif CommandOptions.FileType == "EdkSourceCode": TrimEdkSources(InputFile, CommandOptions.OutputFile) elif CommandOptions.FileType == "VfrOffsetBin": GenerateVfrBinSec(CommandOptions.ModuleName, CommandOptions.DebugDir, CommandOptions.OutputFile) else: if CommandOptions.OutputFile is None: CommandOptions.OutputFile = os.path.splitext( InputFile)[0] + '.iii' TrimPreprocessedFile(InputFile, CommandOptions.OutputFile, CommandOptions.ConvertHex, CommandOptions.TrimLong) except FatalError as X: import platform import traceback if CommandOptions is not None and CommandOptions.LogLevel <= EdkLogger.DEBUG_9: EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc()) return 1 except: import traceback import platform EdkLogger.error( "\nTrim", CODE_ERROR, "Unknown fatal error when trimming [%s]" % InputFile, ExtraData= "\n(Please send email to [email protected] for help, attaching following call stack trace!)\n", RaiseError=False) EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc()) return 1 return 0
def Main(): try: # # Check input parameter # EdkLogger.Initialize() CommandOptions, InputFile = Options() if CommandOptions.LogLevel < EdkLogger.DEBUG_9: EdkLogger.SetLevel(CommandOptions.LogLevel + 1) else: EdkLogger.SetLevel(CommandOptions.LogLevel) if not os.path.exists (InputFile): EdkLogger.error("PatchPcdValue", FILE_NOT_FOUND, ExtraData=InputFile) return 1 if CommandOptions.PcdOffset is None or CommandOptions.PcdValue is None or CommandOptions.PcdTypeName is None: EdkLogger.error("PatchPcdValue", OPTION_MISSING, ExtraData="PcdOffset or PcdValue of PcdTypeName is not specified.") return 1 if CommandOptions.PcdTypeName.upper() not in TAB_PCD_NUMERIC_TYPES_VOID: EdkLogger.error("PatchPcdValue", PARAMETER_INVALID, ExtraData="PCD type %s is not valid." % (CommandOptions.PcdTypeName)) return 1 if CommandOptions.PcdTypeName.upper() == TAB_VOID and CommandOptions.PcdMaxSize is None: EdkLogger.error("PatchPcdValue", OPTION_MISSING, ExtraData="PcdMaxSize is not specified for VOID* type PCD.") return 1 # # Patch value into binary image. # ReturnValue, ErrorInfo = PatchBinaryFile (InputFile, CommandOptions.PcdOffset, CommandOptions.PcdTypeName, CommandOptions.PcdValue, CommandOptions.PcdMaxSize) if ReturnValue != 0: EdkLogger.error("PatchPcdValue", ReturnValue, ExtraData=ErrorInfo) return 1 return 0 except: return 1
def main(): global Options, Args # Initialize log system EdkLogger.Initialize() Options, Args = MyOptionParser() ReturnCode = 0 if Options.opt_verbose: EdkLogger.SetLevel(EdkLogger.VERBOSE) elif Options.opt_quiet: EdkLogger.SetLevel(EdkLogger.QUIET) elif Options.debug_level != None: EdkLogger.SetLevel(Options.debug_level + 1) else: EdkLogger.SetLevel(EdkLogger.INFO) if Options.bin_filename == None: EdkLogger.error("BPDG", ATTRIBUTE_NOT_AVAILABLE, "Please use the -o option to specify the file name for the VPD binary file") if Options.filename == None: EdkLogger.error("BPDG", ATTRIBUTE_NOT_AVAILABLE, "Please use the -m option to specify the file name for the mapping file") Force = False if Options.opt_force != None: Force = True if (Args[0] != None) : StartBpdg(Args[0], Options.filename, Options.bin_filename, Force) else : EdkLogger.error("BPDG", ATTRIBUTE_NOT_AVAILABLE, "Please specify the file which contain the VPD pcd info.", None) return ReturnCode
def Main(): EdkLogger.Initialize() Option, Input = GetOptions() # Set log level if Option.quiet: EdkLogger.SetLevel(EdkLogger.QUIET) elif Option.verbose: EdkLogger.SetLevel(EdkLogger.VERBOSE) elif Option.debug is not None: EdkLogger.SetLevel(Option.debug + 1) else: EdkLogger.SetLevel(EdkLogger.INFO) try: if Option.ModuleType is None or Option.ModuleType not in gType2Phase: EdkLogger.error("GenDepex", OPTION_MISSING, "Module type is not specified or supported") DxsFile = '' if len(Input) > 0 and Option.Expression == "": DxsFile = Input[0] DxsString = open(DxsFile, 'r').read().replace("\n", " ").replace("\r", " ") DxsString = gStartClosePattern.sub("\\1", DxsString) elif Option.Expression != "": if Option.Expression[0] == '"': DxsString = Option.Expression[1:-1] else: DxsString = Option.Expression else: EdkLogger.error("GenDepex", OPTION_MISSING, "No expression string or file given") Dpx = DependencyExpression(DxsString, Option.ModuleType, Option.Optimize) if Option.OutputFile is not None: FileChangeFlag = Dpx.Generate(Option.OutputFile) if not FileChangeFlag and DxsFile: # # Touch the output file if its time stamp is older than the original # DXS file to avoid re-invoke this tool for the dependency check in build rule. # if os.stat(DxsFile)[8] > os.stat(Option.OutputFile)[8]: os.utime(Option.OutputFile, None) else: Dpx.Generate() except BaseException as X: EdkLogger.quiet("") if Option is not None and Option.debug is not None: EdkLogger.quiet(traceback.format_exc()) else: EdkLogger.quiet(str(X)) return 1 return 0
def Main(): try: EdkLogger.Initialize() CommandOptions, InputFile = Options() if CommandOptions.LogLevel < EdkLogger.DEBUG_9: EdkLogger.SetLevel(CommandOptions.LogLevel + 1) else: EdkLogger.SetLevel(CommandOptions.LogLevel) except FatalError, X: return 1
def Main(): # Initialize an EdkLogger instance. EdkLogger.Initialize() try: # Parse the input arguments. CommandArguments = ParseArgs() if not CommandArguments: return 1 # Convert an AML file to a .hex file containing the AML bytecode stored # in a C array. AmlToHex(CommandArguments.InputFile, CommandArguments.OutputFile, CommandArguments.BaseName) except Exception as e: print(e) return 1 return 0
def Main(): EdkLogger.Initialize() Option, Input = GetOptions() # Set log level if Option.quiet: EdkLogger.SetLevel(EdkLogger.QUIET) elif Option.verbose: EdkLogger.SetLevel(EdkLogger.VERBOSE) elif Option.debug != None: EdkLogger.SetLevel(Option.debug + 1) else: EdkLogger.SetLevel(EdkLogger.INFO) try: if Option.ModuleType == None or Option.ModuleType not in gType2Phase: EdkLogger.error("GenDepex", OPTION_MISSING, "Module type is not specified or supported") DxsFile = '' if len(Input) > 0 and Option.Expression == "": DxsFile = Input[0] DxsString = open(DxsFile, 'r').read().replace("\n", " ").replace("\r", " ") DxsString = gStartClosePattern.sub("\\1", DxsString) elif Option.Expression != "": if Option.Expression[0] == '"': DxsString = Option.Expression[1:-1] else: DxsString = Option.Expression else: EdkLogger.error("GenDepex", OPTION_MISSING, "No expression string or file given") Dpx = DependencyExpression(DxsString, Option.ModuleType, Option.Optimize) if Option.OutputFile != None: Dpx.Generate(Option.OutputFile) else: Dpx.Generate() except BaseException, X: EdkLogger.quiet("") if Option != None and Option.debug != None: EdkLogger.quiet(traceback.format_exc()) else: EdkLogger.quiet(str(X)) return 1
parser.add_option( "-m", "--multithreadnum", action="callback", type="int", dest="NUM", callback=RangeCheckCallback, help= "Specify the multi-thread number which replace target.txt's MAX_CONCURRENT_THREAD_NUMBER. If the value is less than 2, MULTIPLE_THREAD will be disabled. If the value is larger than 1, MULTIPLE_THREAD will be enabled." ) (opt, args) = parser.parse_args() return (opt, args) if __name__ == '__main__': EdkLogger.Initialize() EdkLogger.SetLevel(EdkLogger.QUIET) if os.getenv('WORKSPACE') is None: print( "ERROR: WORKSPACE should be specified or edksetup script should be executed before run TargetTool" ) sys.exit(1) (opt, args) = MyOptionParser() if len(args) != 1 or (args[0].lower() != 'print' and args[0].lower() != 'clean' and args[0].lower() != 'set'): print("The number of args isn't 1 or the value of args is invalid.") sys.exit(1) if opt.NUM is not None and opt.NUM < 1: print("The MAX_CONCURRENT_THREAD_NUMBER must be larger than 0.")
def main(): global Options Options = myOptionParser() global Workspace Workspace = "" ArchList = None ReturnCode = 0 EdkLogger.Initialize() try: if Options.verbose is not None: EdkLogger.SetLevel(EdkLogger.VERBOSE) GenFdsGlobalVariable.VerboseMode = True if Options.FixedAddress is not None: GenFdsGlobalVariable.FixedLoadAddress = True if Options.quiet is not None: EdkLogger.SetLevel(EdkLogger.QUIET) if Options.debug is not None: EdkLogger.SetLevel(Options.debug + 1) GenFdsGlobalVariable.DebugLevel = Options.debug else: EdkLogger.SetLevel(EdkLogger.INFO) if (Options.Workspace is None): EdkLogger.error( "GenFds", OPTION_MISSING, "WORKSPACE not defined", ExtraData= "Please use '-w' switch to pass it or set the WORKSPACE environment variable." ) elif not os.path.exists(Options.Workspace): EdkLogger.error( "GenFds", PARAMETER_INVALID, "WORKSPACE is invalid", ExtraData= "Please use '-w' switch to pass it or set the WORKSPACE environment variable." ) else: Workspace = os.path.normcase(Options.Workspace) GenFdsGlobalVariable.WorkSpaceDir = Workspace if 'EDK_SOURCE' in os.environ: GenFdsGlobalVariable.EdkSourceDir = os.path.normcase( os.environ['EDK_SOURCE']) if (Options.debug): GenFdsGlobalVariable.VerboseLogger("Using Workspace:" + Workspace) if Options.GenfdsMultiThread: GenFdsGlobalVariable.EnableGenfdsMultiThread = True os.chdir(GenFdsGlobalVariable.WorkSpaceDir) # set multiple workspace PackagesPath = os.getenv("PACKAGES_PATH") mws.setWs(GenFdsGlobalVariable.WorkSpaceDir, PackagesPath) if (Options.filename): FdfFilename = Options.filename FdfFilename = GenFdsGlobalVariable.ReplaceWorkspaceMacro( FdfFilename) if FdfFilename[0:2] == '..': FdfFilename = os.path.realpath(FdfFilename) if not os.path.isabs(FdfFilename): FdfFilename = mws.join(GenFdsGlobalVariable.WorkSpaceDir, FdfFilename) if not os.path.exists(FdfFilename): EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=FdfFilename) GenFdsGlobalVariable.FdfFile = FdfFilename GenFdsGlobalVariable.FdfFileTimeStamp = os.path.getmtime( FdfFilename) else: EdkLogger.error("GenFds", OPTION_MISSING, "Missing FDF filename") if (Options.BuildTarget): GenFdsGlobalVariable.TargetName = Options.BuildTarget if (Options.ToolChain): GenFdsGlobalVariable.ToolChainTag = Options.ToolChain if (Options.activePlatform): ActivePlatform = Options.activePlatform ActivePlatform = GenFdsGlobalVariable.ReplaceWorkspaceMacro( ActivePlatform) if ActivePlatform[0:2] == '..': ActivePlatform = os.path.realpath(ActivePlatform) if not os.path.isabs(ActivePlatform): ActivePlatform = mws.join(GenFdsGlobalVariable.WorkSpaceDir, ActivePlatform) if not os.path.exists(ActivePlatform): EdkLogger.error("GenFds", FILE_NOT_FOUND, "ActivePlatform doesn't exist!") else: EdkLogger.error("GenFds", OPTION_MISSING, "Missing active platform") GlobalData.BuildOptionPcd = Options.OptionPcd if Options.OptionPcd else {} GenFdsGlobalVariable.ActivePlatform = PathClass( NormPath(ActivePlatform)) if (Options.ConfDirectory): # Get alternate Conf location, if it is absolute, then just use the absolute directory name ConfDirectoryPath = os.path.normpath(Options.ConfDirectory) if ConfDirectoryPath.startswith('"'): ConfDirectoryPath = ConfDirectoryPath[1:] if ConfDirectoryPath.endswith('"'): ConfDirectoryPath = ConfDirectoryPath[:-1] if not os.path.isabs(ConfDirectoryPath): # Since alternate directory name is not absolute, the alternate directory is located within the WORKSPACE # This also handles someone specifying the Conf directory in the workspace. Using --conf=Conf ConfDirectoryPath = os.path.join( GenFdsGlobalVariable.WorkSpaceDir, ConfDirectoryPath) else: if "CONF_PATH" in os.environ: ConfDirectoryPath = os.path.normcase(os.environ["CONF_PATH"]) else: # Get standard WORKSPACE/Conf, use the absolute path to the WORKSPACE/Conf ConfDirectoryPath = mws.join(GenFdsGlobalVariable.WorkSpaceDir, 'Conf') GenFdsGlobalVariable.ConfDir = ConfDirectoryPath if not GlobalData.gConfDirectory: GlobalData.gConfDirectory = GenFdsGlobalVariable.ConfDir BuildConfigurationFile = os.path.normpath( os.path.join(ConfDirectoryPath, "target.txt")) if os.path.isfile(BuildConfigurationFile) == True: TargetTxt = TargetTxtClassObject.TargetTxtClassObject() TargetTxt.LoadTargetTxtFile(BuildConfigurationFile) # if no build target given in command line, get it from target.txt if not GenFdsGlobalVariable.TargetName: BuildTargetList = TargetTxt.TargetTxtDictionary[ DataType.TAB_TAT_DEFINES_TARGET] if len(BuildTargetList) != 1: EdkLogger.error( "GenFds", OPTION_VALUE_INVALID, ExtraData="Only allows one instance for Target.") GenFdsGlobalVariable.TargetName = BuildTargetList[0] # if no tool chain given in command line, get it from target.txt if not GenFdsGlobalVariable.ToolChainTag: ToolChainList = TargetTxt.TargetTxtDictionary[ DataType.TAB_TAT_DEFINES_TOOL_CHAIN_TAG] if ToolChainList is None or len(ToolChainList) == 0: EdkLogger.error( "GenFds", RESOURCE_NOT_AVAILABLE, ExtraData="No toolchain given. Don't know how to build." ) if len(ToolChainList) != 1: EdkLogger.error( "GenFds", OPTION_VALUE_INVALID, ExtraData="Only allows one instance for ToolChain.") GenFdsGlobalVariable.ToolChainTag = ToolChainList[0] else: EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=BuildConfigurationFile) #Set global flag for build mode GlobalData.gIgnoreSource = Options.IgnoreSources if Options.Macros: for Pair in Options.Macros: if Pair.startswith('"'): Pair = Pair[1:] if Pair.endswith('"'): Pair = Pair[:-1] List = Pair.split('=') if len(List) == 2: if not List[1].strip(): EdkLogger.error( "GenFds", OPTION_VALUE_INVALID, ExtraData="No Value given for Macro %s" % List[0]) if List[0].strip() == "EFI_SOURCE": GlobalData.gEfiSource = List[1].strip() GlobalData.gGlobalDefines[ "EFI_SOURCE"] = GlobalData.gEfiSource continue elif List[0].strip() == "EDK_SOURCE": GlobalData.gEdkSource = List[1].strip() GlobalData.gGlobalDefines[ "EDK_SOURCE"] = GlobalData.gEdkSource continue elif List[0].strip() in [ "WORKSPACE", "TARGET", "TOOLCHAIN" ]: GlobalData.gGlobalDefines[ List[0].strip()] = List[1].strip() else: GlobalData.gCommandLineDefines[ List[0].strip()] = List[1].strip() else: GlobalData.gCommandLineDefines[List[0].strip()] = "TRUE" os.environ["WORKSPACE"] = Workspace # Use the -t and -b option as gGlobalDefines's TOOLCHAIN and TARGET if they are not defined if "TARGET" not in GlobalData.gGlobalDefines: GlobalData.gGlobalDefines[ "TARGET"] = GenFdsGlobalVariable.TargetName if "TOOLCHAIN" not in GlobalData.gGlobalDefines: GlobalData.gGlobalDefines[ "TOOLCHAIN"] = GenFdsGlobalVariable.ToolChainTag if "TOOL_CHAIN_TAG" not in GlobalData.gGlobalDefines: GlobalData.gGlobalDefines[ 'TOOL_CHAIN_TAG'] = GenFdsGlobalVariable.ToolChainTag """call Workspace build create database""" GlobalData.gDatabasePath = os.path.normpath( os.path.join(ConfDirectoryPath, GlobalData.gDatabasePath)) BuildWorkSpace = WorkspaceDatabase(GlobalData.gDatabasePath) BuildWorkSpace.InitDatabase() # # Get files real name in workspace dir # GlobalData.gAllFiles = DirCache(Workspace) GlobalData.gWorkspace = Workspace if (Options.archList): ArchList = Options.archList.split(',') else: # EdkLogger.error("GenFds", OPTION_MISSING, "Missing build ARCH") ArchList = BuildWorkSpace.BuildObject[ GenFdsGlobalVariable.ActivePlatform, TAB_COMMON, Options.BuildTarget, Options.ToolChain].SupArchList TargetArchList = set(BuildWorkSpace.BuildObject[ GenFdsGlobalVariable.ActivePlatform, TAB_COMMON, Options.BuildTarget, Options.ToolChain].SupArchList) & set(ArchList) if len(TargetArchList) == 0: EdkLogger.error( "GenFds", GENFDS_ERROR, "Target ARCH %s not in platform supported ARCH %s" % (str(ArchList), str(BuildWorkSpace.BuildObject[ GenFdsGlobalVariable.ActivePlatform, TAB_COMMON].SupArchList))) for Arch in ArchList: GenFdsGlobalVariable.OutputDirFromDscDict[Arch] = NormPath( BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, Options.BuildTarget, Options.ToolChain].OutputDirectory) GenFdsGlobalVariable.PlatformName = BuildWorkSpace.BuildObject[ GenFdsGlobalVariable.ActivePlatform, Arch, Options.BuildTarget, Options.ToolChain].PlatformName if (Options.outputDir): OutputDirFromCommandLine = GenFdsGlobalVariable.ReplaceWorkspaceMacro( Options.outputDir) if not os.path.isabs(OutputDirFromCommandLine): OutputDirFromCommandLine = os.path.join( GenFdsGlobalVariable.WorkSpaceDir, OutputDirFromCommandLine) for Arch in ArchList: GenFdsGlobalVariable.OutputDirDict[ Arch] = OutputDirFromCommandLine else: for Arch in ArchList: GenFdsGlobalVariable.OutputDirDict[Arch] = os.path.join( GenFdsGlobalVariable.OutputDirFromDscDict[Arch], GenFdsGlobalVariable.TargetName + '_' + GenFdsGlobalVariable.ToolChainTag) for Key in GenFdsGlobalVariable.OutputDirDict: OutputDir = GenFdsGlobalVariable.OutputDirDict[Key] if OutputDir[0:2] == '..': OutputDir = os.path.realpath(OutputDir) if OutputDir[1] != ':': OutputDir = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, OutputDir) if not os.path.exists(OutputDir): EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=OutputDir) GenFdsGlobalVariable.OutputDirDict[Key] = OutputDir """ Parse Fdf file, has to place after build Workspace as FDF may contain macros from DSC file """ FdfParserObj = FdfParser.FdfParser(FdfFilename) FdfParserObj.ParseFile() if FdfParserObj.CycleReferenceCheck(): EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Cycle Reference Detected in FDF file") if (Options.uiFdName): if Options.uiFdName.upper() in FdfParserObj.Profile.FdDict: GenFds.OnlyGenerateThisFd = Options.uiFdName else: EdkLogger.error( "GenFds", OPTION_VALUE_INVALID, "No such an FD in FDF file: %s" % Options.uiFdName) if (Options.uiFvName): if Options.uiFvName.upper() in FdfParserObj.Profile.FvDict: GenFds.OnlyGenerateThisFv = Options.uiFvName else: EdkLogger.error( "GenFds", OPTION_VALUE_INVALID, "No such an FV in FDF file: %s" % Options.uiFvName) if (Options.uiCapName): if Options.uiCapName.upper() in FdfParserObj.Profile.CapsuleDict: GenFds.OnlyGenerateThisCap = Options.uiCapName else: EdkLogger.error( "GenFds", OPTION_VALUE_INVALID, "No such a Capsule in FDF file: %s" % Options.uiCapName) GenFdsGlobalVariable.WorkSpace = BuildWorkSpace if ArchList is not None: GenFdsGlobalVariable.ArchList = ArchList # Dsc Build Data will handle Pcd Settings from CommandLine. """Modify images from build output if the feature of loading driver at fixed address is on.""" if GenFdsGlobalVariable.FixedLoadAddress: GenFds.PreprocessImage(BuildWorkSpace, GenFdsGlobalVariable.ActivePlatform) # Record the FV Region info that may specific in the FD if FdfParserObj.Profile.FvDict and FdfParserObj.Profile.FdDict: for Fv in FdfParserObj.Profile.FvDict: FvObj = FdfParserObj.Profile.FvDict[Fv] for Fd in FdfParserObj.Profile.FdDict: FdObj = FdfParserObj.Profile.FdDict[Fd] for RegionObj in FdObj.RegionList: if RegionObj.RegionType != BINARY_FILE_TYPE_FV: continue for RegionData in RegionObj.RegionDataList: if FvObj.UiFvName.upper() == RegionData.upper(): if FvObj.FvRegionInFD: if FvObj.FvRegionInFD != RegionObj.Size: EdkLogger.error( "GenFds", FORMAT_INVALID, "The FV %s's region is specified in multiple FD with different value." % FvObj.UiFvName) else: FvObj.FvRegionInFD = RegionObj.Size RegionObj.BlockInfoOfRegion( FdObj.BlockSizeList, FvObj) """Call GenFds""" GenFds.GenFd('', FdfParserObj, BuildWorkSpace, ArchList) """Generate GUID cross reference file""" GenFds.GenerateGuidXRefFile(BuildWorkSpace, ArchList, FdfParserObj) """Display FV space info.""" GenFds.DisplayFvSpaceInfo(FdfParserObj) except FdfParser.Warning as X: EdkLogger.error(X.ToolName, FORMAT_INVALID, File=X.FileName, Line=X.LineNumber, ExtraData=X.Message, RaiseError=False) ReturnCode = FORMAT_INVALID except FatalError as X: if Options.debug is not None: import traceback EdkLogger.quiet(traceback.format_exc()) ReturnCode = X.args[0] except: import traceback EdkLogger.error( "\nPython", CODE_ERROR, "Tools code failure", ExtraData= "Please send email to [email protected] for help, attaching following call stack trace!\n", RaiseError=False) EdkLogger.quiet(traceback.format_exc()) ReturnCode = CODE_ERROR finally: ClearDuplicatedInf() return ReturnCode
def main(): global Options Options = myOptionParser() EdkLogger.Initialize() return GenFdsApi(OptionsToCommandDict(Options))
def main(): global Options Options = myOptionParser() global Workspace Workspace = "" ArchList = None ReturnCode = 0 EdkLogger.Initialize() try: if Options.verbose != None: EdkLogger.SetLevel(EdkLogger.VERBOSE) GenFdsGlobalVariable.VerboseMode = True if Options.FixedAddress != None: GenFdsGlobalVariable.FixedLoadAddress = True if Options.quiet != None: EdkLogger.SetLevel(EdkLogger.QUIET) if Options.debug != None: EdkLogger.SetLevel(Options.debug + 1) GenFdsGlobalVariable.DebugLevel = Options.debug else: EdkLogger.SetLevel(EdkLogger.INFO) if (Options.Workspace == None): EdkLogger.error( "GenFds", OPTION_MISSING, "WORKSPACE not defined", ExtraData= "Please use '-w' switch to pass it or set the WORKSPACE environment variable." ) elif not os.path.exists(Options.Workspace): EdkLogger.error( "GenFds", PARAMETER_INVALID, "WORKSPACE is invalid", ExtraData= "Please use '-w' switch to pass it or set the WORKSPACE environment variable." ) else: Workspace = os.path.normcase(Options.Workspace) GenFdsGlobalVariable.WorkSpaceDir = Workspace if 'EDK_SOURCE' in os.environ.keys(): GenFdsGlobalVariable.EdkSourceDir = os.path.normcase( os.environ['EDK_SOURCE']) if (Options.debug): GenFdsGlobalVariable.VerboseLogger("Using Workspace:" + Workspace) os.chdir(GenFdsGlobalVariable.WorkSpaceDir) if (Options.filename): FdfFilename = Options.filename FdfFilename = GenFdsGlobalVariable.ReplaceWorkspaceMacro( FdfFilename) if FdfFilename[0:2] == '..': FdfFilename = os.path.realpath(FdfFilename) if not os.path.isabs(FdfFilename): FdfFilename = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, FdfFilename) if not os.path.exists(FdfFilename): EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=FdfFilename) if os.path.normcase(FdfFilename).find(Workspace) != 0: EdkLogger.error("GenFds", FILE_NOT_FOUND, "FdfFile doesn't exist in Workspace!") GenFdsGlobalVariable.FdfFile = FdfFilename GenFdsGlobalVariable.FdfFileTimeStamp = os.path.getmtime( FdfFilename) else: EdkLogger.error("GenFds", OPTION_MISSING, "Missing FDF filename") if (Options.BuildTarget): GenFdsGlobalVariable.TargetName = Options.BuildTarget else: EdkLogger.error("GenFds", OPTION_MISSING, "Missing build target") if (Options.ToolChain): GenFdsGlobalVariable.ToolChainTag = Options.ToolChain else: EdkLogger.error("GenFds", OPTION_MISSING, "Missing tool chain tag") if (Options.activePlatform): ActivePlatform = Options.activePlatform ActivePlatform = GenFdsGlobalVariable.ReplaceWorkspaceMacro( ActivePlatform) if ActivePlatform[0:2] == '..': ActivePlatform = os.path.realpath(ActivePlatform) if not os.path.isabs(ActivePlatform): ActivePlatform = os.path.join( GenFdsGlobalVariable.WorkSpaceDir, ActivePlatform) if not os.path.exists(ActivePlatform): EdkLogger.error("GenFds", FILE_NOT_FOUND, "ActivePlatform doesn't exist!") if os.path.normcase(ActivePlatform).find(Workspace) != 0: EdkLogger.error("GenFds", FILE_NOT_FOUND, "ActivePlatform doesn't exist in Workspace!") ActivePlatform = ActivePlatform[len(Workspace):] if len(ActivePlatform) > 0: if ActivePlatform[0] == '\\' or ActivePlatform[0] == '/': ActivePlatform = ActivePlatform[1:] else: EdkLogger.error("GenFds", FILE_NOT_FOUND, "ActivePlatform doesn't exist!") else: EdkLogger.error("GenFds", OPTION_MISSING, "Missing active platform") GenFdsGlobalVariable.ActivePlatform = PathClass( NormPath(ActivePlatform), Workspace) if (Options.ConfDirectory): # Get alternate Conf location, if it is absolute, then just use the absolute directory name ConfDirectoryPath = os.path.normpath(Options.ConfDirectory) if ConfDirectoryPath.startswith('"'): ConfDirectoryPath = ConfDirectoryPath[1:] if ConfDirectoryPath.endswith('"'): ConfDirectoryPath = ConfDirectoryPath[:-1] if not os.path.isabs(ConfDirectoryPath): # Since alternate directory name is not absolute, the alternate directory is located within the WORKSPACE # This also handles someone specifying the Conf directory in the workspace. Using --conf=Conf ConfDirectoryPath = os.path.join( GenFdsGlobalVariable.WorkSpaceDir, ConfDirectoryPath) else: # Get standard WORKSPACE/Conf, use the absolute path to the WORKSPACE/Conf ConfDirectoryPath = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, 'Conf') GenFdsGlobalVariable.ConfDir = ConfDirectoryPath BuildConfigurationFile = os.path.normpath( os.path.join(ConfDirectoryPath, "target.txt")) if os.path.isfile(BuildConfigurationFile) == True: TargetTxtClassObject.TargetTxtClassObject(BuildConfigurationFile) else: EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=BuildConfigurationFile) #Set global flag for build mode GlobalData.gIgnoreSource = Options.IgnoreSources if Options.Macros: for Pair in Options.Macros: if Pair.startswith('"'): Pair = Pair[1:] if Pair.endswith('"'): Pair = Pair[:-1] List = Pair.split('=') if len(List) == 2: if List[0].strip() == "EFI_SOURCE": GlobalData.gEfiSource = List[1].strip() GlobalData.gGlobalDefines[ "EFI_SOURCE"] = GlobalData.gEfiSource continue elif List[0].strip() == "EDK_SOURCE": GlobalData.gEdkSource = List[1].strip() GlobalData.gGlobalDefines[ "EDK_SOURCE"] = GlobalData.gEdkSource continue elif List[0].strip() in [ "WORKSPACE", "TARGET", "TOOLCHAIN" ]: GlobalData.gGlobalDefines[ List[0].strip()] = List[1].strip() else: GlobalData.gCommandLineDefines[ List[0].strip()] = List[1].strip() else: GlobalData.gCommandLineDefines[List[0].strip()] = "TRUE" os.environ["WORKSPACE"] = Workspace """call Workspace build create database""" GlobalData.gDatabasePath = os.path.normpath( os.path.join(ConfDirectoryPath, GlobalData.gDatabasePath)) BuildWorkSpace = WorkspaceDatabase(GlobalData.gDatabasePath) BuildWorkSpace.InitDatabase() # # Get files real name in workspace dir # GlobalData.gAllFiles = DirCache(Workspace) GlobalData.gWorkspace = Workspace if (Options.archList): ArchList = Options.archList.split(',') else: # EdkLogger.error("GenFds", OPTION_MISSING, "Missing build ARCH") ArchList = BuildWorkSpace.BuildObject[ GenFdsGlobalVariable.ActivePlatform, 'COMMON', Options.BuildTarget, Options.ToolChain].SupArchList TargetArchList = set(BuildWorkSpace.BuildObject[ GenFdsGlobalVariable.ActivePlatform, 'COMMON', Options.BuildTarget, Options.ToolChain].SupArchList) & set(ArchList) if len(TargetArchList) == 0: EdkLogger.error( "GenFds", GENFDS_ERROR, "Target ARCH %s not in platform supported ARCH %s" % (str(ArchList), str(BuildWorkSpace.BuildObject[ GenFdsGlobalVariable.ActivePlatform, 'COMMON'].SupArchList))) for Arch in ArchList: GenFdsGlobalVariable.OutputDirFromDscDict[Arch] = NormPath( BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, Options.BuildTarget, Options.ToolChain].OutputDirectory) GenFdsGlobalVariable.PlatformName = BuildWorkSpace.BuildObject[ GenFdsGlobalVariable.ActivePlatform, Arch, Options.BuildTarget, Options.ToolChain].PlatformName if (Options.outputDir): OutputDirFromCommandLine = GenFdsGlobalVariable.ReplaceWorkspaceMacro( Options.outputDir) if not os.path.isabs(OutputDirFromCommandLine): OutputDirFromCommandLine = os.path.join( GenFdsGlobalVariable.WorkSpaceDir, OutputDirFromCommandLine) for Arch in ArchList: GenFdsGlobalVariable.OutputDirDict[ Arch] = OutputDirFromCommandLine else: for Arch in ArchList: GenFdsGlobalVariable.OutputDirDict[Arch] = os.path.join( GenFdsGlobalVariable.OutputDirFromDscDict[Arch], GenFdsGlobalVariable.TargetName + '_' + GenFdsGlobalVariable.ToolChainTag) for Key in GenFdsGlobalVariable.OutputDirDict: OutputDir = GenFdsGlobalVariable.OutputDirDict[Key] if OutputDir[0:2] == '..': OutputDir = os.path.realpath(OutputDir) if OutputDir[1] != ':': OutputDir = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, OutputDir) if not os.path.exists(OutputDir): EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=OutputDir) GenFdsGlobalVariable.OutputDirDict[Key] = OutputDir """ Parse Fdf file, has to place after build Workspace as FDF may contain macros from DSC file """ FdfParserObj = FdfParser.FdfParser(FdfFilename) FdfParserObj.ParseFile() if FdfParserObj.CycleReferenceCheck(): EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Cycle Reference Detected in FDF file") if (Options.uiFdName): if Options.uiFdName.upper() in FdfParserObj.Profile.FdDict.keys(): GenFds.OnlyGenerateThisFd = Options.uiFdName else: EdkLogger.error( "GenFds", OPTION_VALUE_INVALID, "No such an FD in FDF file: %s" % Options.uiFdName) if (Options.uiFvName): if Options.uiFvName.upper() in FdfParserObj.Profile.FvDict.keys(): GenFds.OnlyGenerateThisFv = Options.uiFvName else: EdkLogger.error( "GenFds", OPTION_VALUE_INVALID, "No such an FV in FDF file: %s" % Options.uiFvName) if (Options.uiCapName): if Options.uiCapName.upper( ) in FdfParserObj.Profile.CapsuleDict.keys(): GenFds.OnlyGenerateThisCap = Options.uiCapName else: EdkLogger.error( "GenFds", OPTION_VALUE_INVALID, "No such a Capsule in FDF file: %s" % Options.uiCapName) """Modify images from build output if the feature of loading driver at fixed address is on.""" if GenFdsGlobalVariable.FixedLoadAddress: GenFds.PreprocessImage(BuildWorkSpace, GenFdsGlobalVariable.ActivePlatform) """Call GenFds""" GenFds.GenFd('', FdfParserObj, BuildWorkSpace, ArchList) """Generate GUID cross reference file""" GenFds.GenerateGuidXRefFile(BuildWorkSpace, ArchList) """Display FV space info.""" GenFds.DisplayFvSpaceInfo(FdfParserObj) except FdfParser.Warning, X: EdkLogger.error(X.ToolName, FORMAT_INVALID, File=X.FileName, Line=X.LineNumber, ExtraData=X.Message, RaiseError=False) ReturnCode = FORMAT_INVALID
def Main(): EdkLogger.Initialize() Options = MyOptionParser() try: if not Options.PackageGuid and not Options.PackageVersion: EdkLogger.error( "RmPkg", OPTION_MISSING, ExtraData= "The GUID and Version of distribution package must be specified" ) if Options.LogLevel < EdkLogger.DEBUG_9: EdkLogger.SetLevel(Options.LogLevel + 1) else: EdkLogger.SetLevel(Options.LogLevel) CheckEnvVariable() WorkspaceDir = os.environ["WORKSPACE"] # Prepare check dependency Db = IpiDatabase( os.path.normpath( os.path.join(WorkspaceDir, "Conf/DistributionPackageDatabase.db"))) Db.InitDatabase() Dep = DependencyRules(Db) Guid = Options.PackageGuid Version = Options.PackageVersion # Check Dp existing if not Dep.CheckDpExists(Guid, Version): EdkLogger.error("RmPkg", UNKNOWN_ERROR, "This distribution package are not installed!") # Check Dp depex if not Dep.CheckDpDepexForRemove(Guid, Version): print "Some packages/modules are depending on this distribution package, do you really want to remove it?" print "Press Y to delete all files or press other keys to quit:" Input = Input = sys.stdin.readline() Input = Input.replace('\r', '').replace('\n', '') if Input.upper() != 'Y': EdkLogger.error("RmPkg", UNKNOWN_ERROR, "User interrupt") # Remove all files if not Options.Yes: print "All files of the distribution package will be removed, do you want to continue?" print "Press Y to remove all files or press other keys to quit:" Input = Input = sys.stdin.readline() Input = Input.replace('\r', '').replace('\n', '') if Input.upper() != 'Y': EdkLogger.error("RmPkg", UNKNOWN_ERROR, "User interrupt") # Remove all files MissingFileList = [] for Item in Db.GetDpFileList(Guid, Version): if os.path.isfile(Item): print "Removing file [%s] ..." % Item os.remove(Item) else: MissingFileList.append(Item) # Remove all empty dirs of package for Item in Db.GetPackageListFromDp(Guid, Version): Dir = os.path.dirname(Item[2]) RemoveEmptyDirs(Dir) # Remove all empty dirs of module for Item in Db.GetStandaloneModuleInstallPathListFromDp(Guid, Version): Dir = os.path.dirname(Item) RemoveEmptyDirs(Dir) # update database EdkLogger.quiet("Update Distribution Package Database ...") Db.RemoveDpObj(Guid, Version) EdkLogger.quiet("DONE") except FatalError, X: if Options and Options.LogLevel < EdkLogger.DEBUG_9: EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc()) ReturnCode = X.args[0]
def Main(): EdkLogger.Initialize() Options = None DistFileName = 'dist.pkg' ContentFileName = 'content.zip' DistFile, ContentZipFile, UnpackDir = None, None, None Options = MyOptionParser() try: if Options.LogLevel < EdkLogger.DEBUG_9: EdkLogger.SetLevel(Options.LogLevel + 1) else: EdkLogger.SetLevel(Options.LogLevel) CheckEnvVariable() WorkspaceDir = os.environ["WORKSPACE"] if not Options.PackageFile: EdkLogger.error("InstallPkg", OPTION_NOT_SUPPORTED, ExtraData="Must specify one distribution package") # unzip dist.pkg file EdkLogger.quiet("Unzipping and parsing distribution package XML file ... ") DistFile = PackageFile(Options.PackageFile) UnpackDir = os.path.normpath(os.path.join(WorkspaceDir, ".tmp")) DistPkgFile = DistFile.UnpackFile(DistFileName, os.path.normpath(os.path.join(UnpackDir, DistFileName))) if not DistPkgFile: EdkLogger.error("InstallPkg", FILE_NOT_FOUND, "File [%s] is broken in distribution package" %DistFileName) # Generate distpkg DistPkgObj = DistributionPackageXml() DistPkg = DistPkgObj.FromXml(DistPkgFile) # prepare check dependency Db = IpiDatabase(os.path.normpath(os.path.join(WorkspaceDir, "Conf/DistributionPackageDatabase.db"))) Db.InitDatabase() Dep = DependencyRules(Db) # Check distribution package exist if Dep.CheckDpExists(DistPkg.Header.Guid, DistPkg.Header.Version): EdkLogger.error("InstallPkg", UNKNOWN_ERROR, "This distribution package has been installed", ExtraData=DistPkg.Header.Name) # unzip contents.zip file ContentFile = DistFile.UnpackFile(ContentFileName, os.path.normpath(os.path.join(UnpackDir, ContentFileName))) ContentZipFile = PackageFile(ContentFile) if not ContentFile: EdkLogger.error("InstallPkg", FILE_NOT_FOUND, "File [%s] is broken in distribution package" %ContentFileName) # verify MD5 signature Md5Sigature = md5.new(open(ContentFile).read()) if DistPkg.Header.Signature != Md5Sigature.hexdigest(): EdkLogger.error("InstallPkg", FILE_CHECKSUM_FAILURE, ExtraData=ContentFile) # Check package exist and install for Guid,Version,Path in DistPkg.PackageSurfaceArea: PackagePath = os.path.dirname(Path) NewPackagePath = PackagePath Package = DistPkg.PackageSurfaceArea[Guid,Version,Path] EdkLogger.info("Installing package ... %s" % Package.PackageHeader.Name) if Dep.CheckPackageExists(Guid, Version): EdkLogger.quiet("Package [%s] has been installed" %Path) NewPackagePath = InstallNewPackage(WorkspaceDir, PackagePath) Package.FileList = [] for Item in Package.MiscFiles.Files: FromFile = os.path.join(PackagePath, Item.Filename) ToFile = os.path.normpath(os.path.join(WorkspaceDir, NewPackagePath, Item.Filename)) ContentZipFile.UnpackFile(FromFile, ToFile) Package.FileList.append(ToFile) # Update package Package.PackageHeader.CombinePath = Package.PackageHeader.CombinePath.replace(PackagePath, NewPackagePath, 1) # Update modules of package Module = None for ModuleGuid, ModuleVersion, ModulePath in Package.Modules: Module = Package.Modules[ModuleGuid, ModuleVersion, ModulePath] NewModulePath = ModulePath.replace(PackagePath, NewPackagePath, 1) del Package.Modules[ModuleGuid, ModuleVersion, ModulePath] Package.Modules[ModuleGuid, ModuleVersion, NewModulePath] = Module del DistPkg.PackageSurfaceArea[Guid,Version,Path] DistPkg.PackageSurfaceArea[Guid,Version,Package.PackageHeader.CombinePath] = Package # SaveFileOnChange(os.path.join(Options.InstallDir, ModulePath, Module.Header.Name, ".inf"), Inf.ModuleToInf(Module), False) # EdkLogger.info("Installing package ... %s" % Package.Header.Name) # shutil.copytree(os.path.join(ContentFileDir, Path), Options.InstallDir) # SaveFileOnChange(os.path.join(Options.InstallDir, Path, Package.Header.Name, ".dec"), Dec.PackageToDec(Package), False) # Check module exist and install Module = None for Guid,Version,Path in DistPkg.ModuleSurfaceArea: ModulePath = os.path.dirname(Path) NewModulePath = ModulePath Module = DistPkg.ModuleSurfaceArea[Guid,Version,Path] EdkLogger.info("Installing module ... %s" % Module.ModuleHeader.Name) if Dep.CheckModuleExists(Guid, Version): EdkLogger.quiet("Module [%s] has been installed" %Path) NewModulePath = InstallNewPackage(WorkspaceDir, ModulePath) Module.FileList = [] for Item in Module.MiscFiles.Files: ModulePath = ModulePath[os.path.normpath(ModulePath).rfind(os.path.normpath('/'))+1:] FromFile = os.path.join(ModulePath, Item.Filename) ToFile = os.path.normpath(os.path.join(WorkspaceDir, NewModulePath, Item.Filename)) ContentZipFile.UnpackFile(FromFile, ToFile) Module.FileList.append(ToFile) # EdkLogger.info("Installing module ... %s" % Module.Header.Name) # shutil.copytree(os.path.join(ContentFileDir, Path), Options.InstallDir) # SaveFileOnChange(os.path.join(Options.InstallDir, Path, Module.Header.Name, ".inf"), Inf.ModuleToInf(Module), False) # Update module Module.ModuleHeader.CombinePath = Module.ModuleHeader.CombinePath.replace(os.path.dirname(Path), NewModulePath, 1) del DistPkg.ModuleSurfaceArea[Guid,Version,Path] DistPkg.ModuleSurfaceArea[Guid,Version,Module.ModuleHeader.CombinePath] = Module # # # for Guid,Version,Path in DistPkg.PackageSurfaceArea: # print Guid,Version,Path # for item in DistPkg.PackageSurfaceArea[Guid,Version,Path].FileList: # print item # for Guid,Version,Path in DistPkg.ModuleSurfaceArea: # print Guid,Version,Path # for item in DistPkg.ModuleSurfaceArea[Guid,Version,Path].FileList: # print item if Options.Tools: EdkLogger.info("Installing tools ... ") for File in DistPkg.Tools.Files: FromFile = File.Filename ToFile = InstallNewFile(WorkspaceDir, FromFile) ContentZipFile.UnpackFile(FromFile, ToFile) if Options.MiscFiles: EdkLogger.info("Installing misc files ... ") for File in DistPkg.MiscellaneousFiles.Files: FromFile = File.Filename ToFile = InstallNewFile(WorkspaceDir, FromFile) ContentZipFile.UnpackFile(FromFile, ToFile) # update database EdkLogger.quiet("Update Distribution Package Database ...") Db.AddDPObject(DistPkg) except FatalError, X: if Options and Options.LogLevel < EdkLogger.DEBUG_9: EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc()) ReturnCode = X.args[0]
def Main(): EdkLogger.Initialize() Options = MyOptionParser() try: if Options.LogLevel < EdkLogger.DEBUG_9: EdkLogger.SetLevel(Options.LogLevel + 1) else: EdkLogger.SetLevel(Options.LogLevel) CheckEnvVariable() WorkspaceDir = os.environ["WORKSPACE"] # Init DistributionFile if not Options.DistributionFile: Options.DistributionFile = "DistributionPackage.zip" # Check Tools Dir if Options.ToolsDir: if not os.path.isdir( os.path.normpath( os.path.join(WorkspaceDir, Options.ToolsDir))): EdkLogger.error( "\nMkPkg", FILE_NOT_FOUND, "Tools directory [%s] not found" % Options.ToolsDir) # Check misc files if Options.MiscFiles: for Item in Options.MiscFiles: FullPath = os.path.normpath(os.path.join(WorkspaceDir, Item)) if not os.path.isfile(FullPath): EdkLogger.error("\nMkPkg", FILE_NOT_FOUND, "Misc file [%s] not found" % Item) #Check package file existing and valid if Options.PackageFileList: for Item in Options.PackageFileList: (Name, Ext) = os.path.splitext(Item) if Ext.upper() != '.DEC': EdkLogger.error("\nMkPkg", OPTION_VALUE_INVALID, "[%s] is not a valid package name" % Item) Path = os.path.normpath(os.path.join(WorkspaceDir, Item)) if not os.path.exists(Path): EdkLogger.error("\nMkPkg", FILE_NOT_FOUND, "[%s] not found" % Item) #Check module file existing and valid if Options.ModuleFileList: for Item in Options.ModuleFileList: (Name, Ext) = os.path.splitext(Item) if Ext.upper() != '.INF': EdkLogger.error("\nMkPkg", OPTION_VALUE_INVALID, "[%s] is not a valid module name" % Item) Path = os.path.normpath(os.path.join(WorkspaceDir, Item)) if not os.path.exists(Path): EdkLogger.error("\nMkPkg", FILE_NOT_FOUND, "[%s] not found" % Item) ContentFile = PackageFile("content.zip", "w") DistPkg = DistributionPackageClass() DistPkg.GetDistributionPackage(WorkspaceDir, Options.PackageFileList, Options.ModuleFileList) DistPkgXml = DistributionPackageXml() for Item in DistPkg.PackageSurfaceArea: ContentFile.Pack( os.path.dirname( os.path.normpath(os.path.join(WorkspaceDir, Item[2])))) for Item in DistPkg.ModuleSurfaceArea: ContentFile.Pack( os.path.dirname( os.path.normpath(os.path.join(WorkspaceDir, Item[2])))) # Add tools files and information if Options.ToolsDir: ToolsFiles = MiscFileClass() ToolsRoot = os.path.normpath( os.path.join(WorkspaceDir, Options.ToolsDir)) ContentFile.Pack(ToolsRoot) ToolsFileList = GetFiles(ToolsRoot, ['CVS', '.svn']) for Item in ToolsFileList: OriPath = Item[len(WorkspaceDir) + 1:] FileObj = FileClass() FileObj.Filename = OriPath (Name, Ext) = os.path.splitext(OriPath) if Ext.upper() in ['EXE', 'COM', 'EFI']: FileObj.Executable = 'True' ToolsFiles.Files.append(FileObj) DistPkg.Tools = ToolsFiles # Add misc files and information if Options.MiscFiles: MiscFiles = MiscFileClass() for Item in Options.MiscFiles: ContentFile.PackFile(Item) FileObj = FileClass() FileObj.Filename = Item (Name, Ext) = os.path.splitext(Item) if Ext.upper() in ['EXE', 'COM', 'EFI']: FileObj.Executable = 'True' MiscFiles.Files.append(FileObj) DistPkg.MiscellaneousFiles = MiscFiles print "Compressing Distribution Package File ..." ContentFile.Close() # Add temp distribution header if Options.TemplateFile: TempXML = DistributionPackageXml() DistPkg.Header = TempXML.FromXml(Options.TemplateFile).Header # Add init dp information else: DistPkg.Header.Name = 'Distribution Package' DistPkg.Header.Guid = str(uuid.uuid4()) DistPkg.Header.Version = '1.0' # Add Md5Sigature Md5Sigature = md5.new(open(str(ContentFile)).read()) DistPkg.Header.Signature = Md5Sigature.hexdigest() # Add current Date DistPkg.Header.Date = str( time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime())) # Finish final dp file DistPkgFile = PackageFile(Options.DistributionFile, "w") DistPkgFile.PackFile(str(ContentFile)) DistPkgFile.PackData(DistPkgXml.ToXml(DistPkg), "dist.pkg") DistPkgFile.Close() print "DONE" except FatalError, X: if Options and Options.LogLevel < EdkLogger.DEBUG_9: EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc()) ReturnCode = X.args[0]