You've already forked slimbootloader
mirror of
https://github.com/Dasharo/slimbootloader.git
synced 2026-03-06 15:26:20 -08:00
Convert the line endings stored for all text files in the repository to LF. The majority previously used DOS-style CRLF line endings. Add a .gitattributes file to enforce this and treat certain extensions as never being text files. Update PatchCheck.py to insist on LF line endings rather than CRLF. However, its other checks fail on this commit due to lots of pre-existing complaints that it only notices because the line endings have changed. Silicon/QemuSocPkg/FspBin/Patches/0001-Build-QEMU-FSP-2.0-binaries.patch needs to be treated as binary since it contains a mixture of line endings. This change has implications depending on the client platform you are using the repository from: * Windows The usual configuration for Git on Windows means that text files will be checked out to the work tree with DOS-style CRLF line endings. If that's not the case then you can configure Git to do so for the entire machine with: git config --global core.autocrlf true or for just the repository with: git config core.autocrlf true Line endings will be normalised to LF when they are committed to the repository. If you commit a text file with only LF line endings then it will be converted to CRLF line endings in your work tree. * Linux, MacOS and other Unices The usual configuration for Git on such platforms is to check files out of the repository with LF line endings. This is probably the right thing for you. In the unlikely even that you are using Git on Unix but editing or compiling on Windows for some reason then you may need to tweak your configuration to force the use of CRLF line endings as described above. * General For more information see https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings . Fixes: https://github.com/slimbootloader/slimbootloader/issues/1400 Signed-off-by: Mike Crowe <mac@mcrowe.com>
128 lines
5.3 KiB
Python
128 lines
5.3 KiB
Python
## @file
|
|
# This file is used to create/update/query/erase table for ECC reports
|
|
#
|
|
# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
#
|
|
|
|
##
|
|
# Import Modules
|
|
#
|
|
from __future__ import absolute_import
|
|
import Common.EdkLogger as EdkLogger
|
|
import Common.LongFilePathOs as os, time
|
|
from Table.Table import Table
|
|
from Common.StringUtils import ConvertToSqlString2
|
|
import Ecc.EccToolError as EccToolError
|
|
import Ecc.EccGlobalData as EccGlobalData
|
|
from Common.LongFilePathSupport import OpenLongFilePath as open
|
|
|
|
## TableReport
|
|
#
|
|
# This class defined a table used for data model
|
|
#
|
|
# @param object: Inherited from object class
|
|
#
|
|
#
|
|
class TableReport(Table):
|
|
def __init__(self, Cursor):
|
|
Table.__init__(self, Cursor)
|
|
self.Table = 'Report'
|
|
|
|
## Create table
|
|
#
|
|
# Create table report
|
|
#
|
|
# @param ID: ID of an Error
|
|
# @param ErrorID: ID of an Error TypeModel of a Report item
|
|
# @param OtherMsg: Other error message besides the standard error message
|
|
# @param BelongsToItem: The error belongs to which item
|
|
# @param Enabled: If this error enabled
|
|
# @param Corrected: if this error corrected
|
|
#
|
|
def Create(self):
|
|
SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
|
|
ErrorID INTEGER NOT NULL,
|
|
OtherMsg TEXT,
|
|
BelongsToTable TEXT NOT NULL,
|
|
BelongsToItem SINGLE NOT NULL,
|
|
Enabled INTEGER DEFAULT 0,
|
|
Corrected INTEGER DEFAULT -1
|
|
)""" % self.Table
|
|
Table.Create(self, SqlCommand)
|
|
|
|
## Insert table
|
|
#
|
|
# Insert a record into table report
|
|
#
|
|
# @param ID: ID of an Error
|
|
# @param ErrorID: ID of an Error TypeModel of a report item
|
|
# @param OtherMsg: Other error message besides the standard error message
|
|
# @param BelongsToTable: The error item belongs to which table
|
|
# @param BelongsToItem: The error belongs to which item
|
|
# @param Enabled: If this error enabled
|
|
# @param Corrected: if this error corrected
|
|
#
|
|
def Insert(self, ErrorID, OtherMsg='', BelongsToTable='', BelongsToItem= -1, Enabled=0, Corrected= -1):
|
|
self.ID = self.ID + 1
|
|
SqlCommand = """insert into %s values(%s, %s, '%s', '%s', %s, %s, %s)""" \
|
|
% (self.Table, self.ID, ErrorID, ConvertToSqlString2(OtherMsg), BelongsToTable, BelongsToItem, Enabled, Corrected)
|
|
Table.Insert(self, SqlCommand)
|
|
|
|
return self.ID
|
|
|
|
## Query table
|
|
#
|
|
# @retval: A recordSet of all found records
|
|
#
|
|
def Query(self):
|
|
SqlCommand = """select ID, ErrorID, OtherMsg, BelongsToTable, BelongsToItem, Corrected from %s
|
|
where Enabled > -1 order by ErrorID, BelongsToItem""" % (self.Table)
|
|
return self.Exec(SqlCommand)
|
|
|
|
## Update table
|
|
#
|
|
def UpdateBelongsToItemByFile(self, ItemID=-1, File=""):
|
|
SqlCommand = """update Report set BelongsToItem=%s where BelongsToTable='File' and BelongsToItem=-2
|
|
and OtherMsg like '%%%s%%'""" % (ItemID, File)
|
|
return self.Exec(SqlCommand)
|
|
|
|
## Convert to CSV
|
|
#
|
|
# Get all enabled records from table report and save them to a .csv file
|
|
#
|
|
# @param Filename: To filename to save the report content
|
|
#
|
|
def ToCSV(self, Filename='Report.csv'):
|
|
try:
|
|
File = open(Filename, 'w+')
|
|
File.write("""No, Error Code, Error Message, File, LineNo, Other Error Message\n""")
|
|
RecordSet = self.Query()
|
|
Index = 0
|
|
for Record in RecordSet:
|
|
Index = Index + 1
|
|
ErrorID = Record[1]
|
|
OtherMsg = Record[2]
|
|
BelongsToTable = Record[3]
|
|
BelongsToItem = Record[4]
|
|
IsCorrected = Record[5]
|
|
SqlCommand = ''
|
|
if BelongsToTable == 'File':
|
|
SqlCommand = """select 1, FullPath from %s where ID = %s
|
|
""" % (BelongsToTable, BelongsToItem)
|
|
else:
|
|
SqlCommand = """select A.StartLine, B.FullPath from %s as A, File as B
|
|
where A.ID = %s and B.ID = A.BelongsToFile
|
|
""" % (BelongsToTable, BelongsToItem)
|
|
NewRecord = self.Exec(SqlCommand)
|
|
if NewRecord != []:
|
|
File.write("""%s,%s,"%s",%s,%s,"%s"\n""" % (Index, ErrorID, EccToolError.gEccErrorMessage[ErrorID], NewRecord[0][1], NewRecord[0][0], OtherMsg))
|
|
EdkLogger.quiet("%s(%s): [%s]%s %s" % (NewRecord[0][1], NewRecord[0][0], ErrorID, EccToolError.gEccErrorMessage[ErrorID], OtherMsg))
|
|
|
|
File.close()
|
|
except IOError:
|
|
NewFilename = 'Report_' + time.strftime("%Y%m%d_%H%M%S.csv", time.localtime())
|
|
EdkLogger.warn("ECC", "The report file %s is locked by other progress, use %s instead!" % (Filename, NewFilename))
|
|
self.ToCSV(NewFilename)
|
|
|