* [Patch V2] GenBiosId: Enable GenBiosId to set timestamp as zero
@ 2019-11-26 10:00 Bob Feng
2019-11-26 10:46 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 3+ messages in thread
From: Bob Feng @ 2019-11-26 10:00 UTC (permalink / raw)
To: devel; +Cc: Liming Gao, Steven Shi, Philippe Mathieu-Daude
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 <liming.gao@intel.com>
Cc: Steven Shi <steven.shi@intel.com>
Cc: Philippe Mathieu-Daude <philmd@redhat.com>
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
---
V2:
1. Change command line argument to lowercase.
2. Add white space before NoTimestamp
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..8cecb1c76f 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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Patch V2] GenBiosId: Enable GenBiosId to set timestamp as zero
2019-11-26 10:00 [Patch V2] GenBiosId: Enable GenBiosId to set timestamp as zero Bob Feng
@ 2019-11-26 10:46 ` Philippe Mathieu-Daudé
2019-12-03 7:58 ` Liming Gao
0 siblings, 1 reply; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-11-26 10:46 UTC (permalink / raw)
To: Bob Feng, devel; +Cc: Liming Gao, Steven Shi
On 11/26/19 11:00 AM, Bob Feng wrote:
> 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 <liming.gao@intel.com>
> Cc: Steven Shi <steven.shi@intel.com>
> Cc: Philippe Mathieu-Daude <philmd@redhat.com>
> Signed-off-by: Bob Feng <bob.c.feng@intel.com>
> ---
> V2:
> 1. Change command line argument to lowercase.
> 2. Add white space before NoTimestamp
Thanks for the cleanup.
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
> 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..8cecb1c76f 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__':
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch V2] GenBiosId: Enable GenBiosId to set timestamp as zero
2019-11-26 10:46 ` Philippe Mathieu-Daudé
@ 2019-12-03 7:58 ` Liming Gao
0 siblings, 0 replies; 3+ messages in thread
From: Liming Gao @ 2019-12-03 7:58 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, Feng, Bob C, devel@edk2.groups.io
Cc: Shi, Steven
Reviewed-by: Liming Gao <liming.gao@intel.com>
>-----Original Message-----
>From: Philippe Mathieu-Daudé [mailto:philmd@redhat.com]
>Sent: Tuesday, November 26, 2019 6:47 PM
>To: Feng, Bob C <bob.c.feng@intel.com>; devel@edk2.groups.io
>Cc: Gao, Liming <liming.gao@intel.com>; Shi, Steven <steven.shi@intel.com>
>Subject: Re: [Patch V2] GenBiosId: Enable GenBiosId to set timestamp as zero
>
>On 11/26/19 11:00 AM, Bob Feng wrote:
>> 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 <liming.gao@intel.com>
>> Cc: Steven Shi <steven.shi@intel.com>
>> Cc: Philippe Mathieu-Daude <philmd@redhat.com>
>> Signed-off-by: Bob Feng <bob.c.feng@intel.com>
>> ---
>> V2:
>> 1. Change command line argument to lowercase.
>> 2. Add white space before NoTimestamp
>
>Thanks for the cleanup.
>
>Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
>
>> 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..8cecb1c76f 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__':
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-12-03 7:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-26 10:00 [Patch V2] GenBiosId: Enable GenBiosId to set timestamp as zero Bob Feng
2019-11-26 10:46 ` Philippe Mathieu-Daudé
2019-12-03 7:58 ` Liming Gao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox