From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web11.1084.1574669118037490098 for ; Mon, 25 Nov 2019 00:05:18 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: bob.c.feng@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Nov 2019 00:05:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,241,1571727600"; d="scan'208";a="198377747" Received: from shwdepsi1121.ccr.corp.intel.com ([10.239.158.47]) by orsmga007.jf.intel.com with ESMTP; 25 Nov 2019 00:05:10 -0800 From: "Bob Feng" To: devel@edk2.groups.io Cc: Liming Gao , Steven Shi Subject: [Patch] GenBiosId: Enable GenBiosId to set timestamp as zero Date: Mon, 25 Nov 2019 16:05:06 +0800 Message-Id: <20191125080506.37368-1-bob.c.feng@intel.com> X-Mailer: git-send-email 2.20.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2384 We need eliminate the effect of timestamp to verify the reproducible build. This patch is to add the support for GenBiosId to set timestamp as zero. Cc: Liming Gao Cc: Steven Shi Signed-off-by: Bob Feng --- Platform/Intel/Tools/GenBiosId/GenBiosId.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Platform/Intel/Tools/GenBiosId/GenBiosId.py b/Platform/Intel/Tools/GenBiosId/GenBiosId.py index 31abb24d31..1b25621104 100644 --- a/Platform/Intel/Tools/GenBiosId/GenBiosId.py +++ b/Platform/Intel/Tools/GenBiosId/GenBiosId.py @@ -100,26 +100,28 @@ def MyOptionParser(): parser.add_argument('-v', '--version', action='version', version=__version__, help="show program's version number and exit") parser.add_argument('-i', '--int', metavar='FILENAME', dest='InputFile', help="Input Config file") parser.add_argument('-o', '--out', metavar='FILENAME', dest='OutputFile', help="Output file") parser.add_argument('-ot', '--text', metavar='FILENAME', dest='OutputTextFile', help="Output Text file") + parser.add_argument('-NT', '--NoTimeStamp', dest='NoTimestamp', action='store_true', default=False, help="Set timestamp to zero") Options = parser.parse_args() return Options # Check the Tool for missing variables def CheckOptions(Options): - if len(sys.argv) != 5 and not (len(sys.argv) == 7 and Options.OutputTextFile): + if len(sys.argv) not in [5,6] and not (len(sys.argv) not in [7,8] and Options.OutputTextFile): EdkLogger("GenBiosId", OPTION_MISSING, ExtraData=_Usage) elif not Options.InputFile or not Options.OutputFile: EdkLogger("GenBiosId", OPTION_MISSING, ExtraData=_Usage) InputFile = Options.InputFile OutputFile = Options.OutputFile OutputTextFile = Options.OutputTextFile + NoTimestamp = Options.NoTimestamp if not os.path.exists(InputFile): EdkLogger("GenBiosId", FILE_NOT_FOUND, ExtraData="Input file not found") - return InputFile, OutputFile, OutputTextFile + return InputFile, OutputFile, OutputTextFile,NoTimestamp # Read input file and get config def ReadInputFile(InputFile): InputDict = OrderedDict() with open(InputFile) as File: @@ -132,23 +134,25 @@ def ReadInputFile(InputFile): InputDict[Key.strip()] = Value.strip() return InputDict # Parse the input file and extract the information -def ParserInputFile(InputDict): +def ParserInputFile(InputDict,NoTimestamp): for Item in InputDict: if Item not in _ConfigItem: EdkLogger("GenBiosId", FORMAT_INVALID, ExtraData=_ConfigItemInvalid % Item) _ConfigItem[Item]['Value'] = InputDict[Item] if len(_ConfigItem[Item]['Value']) != _ConfigItem[Item]['Length']: EdkLogger("GenBiosId", FORMAT_INVALID, ExtraData=_ConfigLenInvalid % Item) for Item in _ConfigItem: if not _ConfigItem[Item]['Value']: EdkLogger("GenBiosId", FORMAT_UNKNOWN_ERROR, ExtraData="Item %s is missing" % Item) utcnow = datetime.datetime.utcnow() - TimeStamp = time.strftime("%y%m%d%H%M", utcnow.timetuple()) - + if NoTimestamp: + TimeStamp = "\0\0\0\0\0\0\0\0\0\0" + else: + TimeStamp = time.strftime("%y%m%d%H%M", utcnow.timetuple()) Id_Str = _ConfigItem['BOARD_ID']['Value'] + _ConfigItem['BOARD_REV']['Value'] + '.' + _ConfigItem['BOARD_EXT'][ 'Value'] + '.' + _ConfigItem['VERSION_MAJOR']['Value'] + \ '.' + _ConfigItem["BUILD_TYPE"]['Value'] + _ConfigItem['VERSION_MINOR']['Value'] + '.' + TimeStamp return Id_Str @@ -169,13 +173,13 @@ def PrintOutputFile(OutputFile, OutputTextFile, Id_Str): # Tool entrance method def Main(): Options = MyOptionParser() - InputFile, OutputFile, OutputTextFile = CheckOptions(Options) + InputFile, OutputFile, OutputTextFile,NoTimestamp = CheckOptions(Options) InputDict = ReadInputFile(InputFile) - Id_Str = ParserInputFile(InputDict) + Id_Str = ParserInputFile(InputDict,NoTimestamp) PrintOutputFile(OutputFile, OutputTextFile, Id_Str) return 0 if __name__ == '__main__': -- 2.20.1.windows.1