Skip to content

Commit

Permalink
Remove DFCI Python Scripts (#397)
Browse files Browse the repository at this point in the history
## Description

The SettingSupport directory in SetupDataPkg was brought over from
mu_feature_dfci to allow reusing the UEFI variable support access from
Python. However, this was moved into edk2-pytool-library and none of the
other scripts are needed here. Any users of them should use the updated
scripts in mu_feature_dfci.

- [ ] Impacts functionality?
- [ ] Impacts security?
- [x] Breaking change?
- [ ] Includes tests?
- [ ] Includes documentation?

## How This Was Tested

N/A.

## Integration Instructions

Any users of the SettingSupport scripts should consume them from
mu_feature_dfci.
  • Loading branch information
os-d committed Sep 4, 2024
1 parent 845fae5 commit b0593c6
Show file tree
Hide file tree
Showing 18 changed files with 80 additions and 4,477 deletions.
43 changes: 40 additions & 3 deletions SetupDataPkg/Tools/ConfigEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os
import sys
import base64
import datetime
from pathlib import Path

sys.dont_write_bytecode = True
Expand All @@ -16,7 +17,6 @@
import tkinter.ttk as ttk # noqa: E402
import tkinter.messagebox as messagebox # noqa: E402
import tkinter.filedialog as filedialog # noqa: E402
from SettingSupport.SettingsXMLLib import SettingsXMLLib # noqa: E402
from GenNCCfgData import CGenNCCfgData # noqa: E402
from CommonUtility import ( # noqa: E402
bytes_to_value,
Expand Down Expand Up @@ -917,6 +917,44 @@ def save_delta_file(self, full=False):
csv_path, self.cfg_data_list[file_id].org_cfg_data_bin, new_data, full
)

def create_settings_xml(self, filename, version, lsv, settingslist):

with open(filename, "w") as f:
f.write('<?xml version="1.0" encoding="utf-8"?>\n')
f.write('<SettingsPacket xmlns="urn:UefiSettings-Schema">\n')
f.write(' <CreatedBy>Dfci Testcase Libraries</CreatedBy>\n')
f.write(' <CreatedOn>')

print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M"), end='', file=f)

f.write('</CreatedOn>\n')
f.write(' <Version>')
print(version, end='', file=f)
f.write('</Version>\n')
f.write(' <LowestSupportedVersion>')
print(lsv, end='', file=f)
f.write('</LowestSupportedVersion>\n')
f.write(' <Settings>\n')

#
# The settings list is a list of a list. The lowest level list is really a tuple of
# setting id and value
#
for setting in settingslist:
f.write(' <Setting>\n')
f.write(' <Id>')
print(setting[0], end='', file=f)
f.write('</Id>\n')
f.write(' <Value>')
print(setting[1], end='', file=f)
f.write('</Value>\n')
f.write(' </Setting>\n')

f.write(' </Settings>\n')
f.write('</SettingsPacket>\n')

return True

def save_to_svd(self, full):
path = self.get_save_file_name("svd")
if not path:
Expand Down Expand Up @@ -951,8 +989,7 @@ def save_to_svd(self, full):
(name_array[index], b64data.decode("utf-8"))
)

set_lib = SettingsXMLLib()
set_lib.create_settings_xml(
self.create_settings_xml(
filename=temp_file, version=1, lsv=1, settingslist=settings
)

Expand Down
44 changes: 40 additions & 4 deletions SetupDataPkg/Tools/GenNCCfgData.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from collections import OrderedDict
import base64

from SettingSupport.DFCI_SupportLib import DFCI_SupportLib # noqa: E402
import xml.etree.ElementTree as ET

from CommonUtility import bytes_to_value
from VariableList import (
Schema,
Expand Down Expand Up @@ -228,6 +229,43 @@ def get_var_list_for_instance(self, var_list):
break
return actual_var_list

def iterate_each_setting(self, resultfile, handler):
xmlstring = ""
found = False
a = open(resultfile, "r")

# find the start of the xml string and then copy all lines to xmlstring variable
for line in a.readlines():
if found:
xmlstring += line
else:
if line.lstrip().startswith("<?xml"):
xmlstring = line
found = True
a.close()

if (len(xmlstring) == 0) or (not found):
print("Result XML not found")
return None

# make an element tree from xml string
r = None
root = ET.fromstring(xmlstring)

# Process Settings produced by SettingsXMLLib.py
for e in root.findall(
"./{urn:UefiSettings-Schema}Settings/{urn:UefiSettings-Schema}Setting"
):
i = e.find("{urn:UefiSettings-Schema}Id")
r = e.find("{urn:UefiSettings-Schema}Value")
handler(i.text, r.text)

# Process SettingsCurrent from ConfApp output (from DFCI Libs)
for e in root.findall("./Settings/SettingCurrent"):
i = e.find("Id")
r = e.find("Value")
handler(i.text, r.text)

def load_from_svd(self, path):
def handler(id, value):
# ignore YAML entries
Expand All @@ -240,9 +278,7 @@ def handler(id, value):
uefi_variables_to_knobs(self.schema, actual_var_list)
self.sync_shim_and_schema()

a = DFCI_SupportLib()

a.iterate_each_setting(path, handler)
self.iterate_each_setting(path, handler)

def load_default_from_bin(self, bin_data, is_variable_list_format):
var_list = read_vlist_from_buffer(bin_data)
Expand Down
95 changes: 0 additions & 95 deletions SetupDataPkg/Tools/SettingSupport/BldDskPkt.py

This file was deleted.

76 changes: 0 additions & 76 deletions SetupDataPkg/Tools/SettingSupport/CertSupportLib.py

This file was deleted.

Loading

0 comments on commit b0593c6

Please sign in to comment.