From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web12.619.1589306648411974121 for ; Tue, 12 May 2020 11:04:08 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: erik.c.bjorge@intel.com) IronPort-SDR: 7QFeZupj32VFXyeCout1yWkpS1LkwM5D5qmcQGy37kViPeHNhPP4TtePx5Rk8Fm4TZrI1jebKz gbNFr9VEE6qQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2020 11:04:07 -0700 IronPort-SDR: OBL2DwSD/0yIjABsq9GEZI3XKq0Al7w9ot5bqGchf/Lti4coz+IPQYodtmZQORLxIdH9N3aSsi 0Q5DmmvG4TEA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,384,1583222400"; d="scan'208";a="306548714" Received: from ecbjorge-mobl1.amr.corp.intel.com ([10.254.2.156]) by FMSMGA003.fm.intel.com with ESMTP; 12 May 2020 11:04:06 -0700 From: "Bjorge, Erik C" To: devel@edk2.groups.io Cc: Ashley E Desimone , Nate DeSimone , Puja Pandya , Bret Barkelew , Prince Agyeman Subject: [edk2-staging/EdkRepo] [PATCH v1] EdkRepo: Adding manifest support for submodule init Date: Tue, 12 May 2020 11:04:00 -0700 Message-Id: <643f03028f1dd1cfc8b51dcbb024b851b9414900.1589306304.git.erik.c.bjorge@intel.com> X-Mailer: git-send-email 2.21.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Enabling support for selective submodule initialization in the manifest file. This will allow for more control over the submodules that are initialized. If this section is not present the existing functionality will be used. Signed-off-by: Erik Bjorge Cc: Ashley E Desimone Cc: Nate DeSimone Cc: Puja Pandya Cc: Bret Barkelew Cc: Prince Agyeman --- edkrepo_manifest_parser/edk_manifest.py | 78 +++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/edkrepo_manifest_parser/edk_manifest.py b/edkrepo_manifest_parser/edk_manifest.py index 1e2b111..45be2fe 100644 --- a/edkrepo_manifest_parser/edk_manifest.py +++ b/edkrepo_manifest_parser/edk_manifest.py @@ -37,6 +37,7 @@ FolderToFolderMappingFolder = namedtuple('FolderToFolderMappingFolder', ['projec FolderToFolderMappingFolderExclude = namedtuple('FolderToFolderMappingFolderExclude', ['path']) SubmoduleAlternateRemote = namedtuple('SubmoduleAlternateRemote', ['remote_name', 'original_url', 'alternate_url']) +SubmoduleInitPath = namedtuple('SubmoduleInitPath', ['remote_name', 'combo', 'recursive', 'path']) REQUIRED_ATTRIB_ERROR_MSG = "Required attribute malformed in <{}>: {}" NO_ASSOCIATED_REMOTE = 'There are no remotes associated with the ClientGitHook entry:\nsource:{} destination:{}' \ @@ -138,6 +139,7 @@ class ManifestXml(BaseXmlHelper): self._commit_templates = {} # dict of commit message templates with the remote name as the key self._folder_to_folder_mappings = [] # List of FolderToFolderMapping objects self._submodule_alternate_remotes = [] + self._submodule_init_list = [] # # Append include XML's to the Manifest etree before parsing @@ -191,6 +193,13 @@ class ManifestXml(BaseXmlHelper): for element in subroot.iter(tag='SubmoduleAlternateRemote'): self._submodule_alternate_remotes.append(_SubmoduleAlternateRemote(element, self._remotes)) + # + # Determine submodule initialization paths + # + for subroot in self._tree.iter(tag='SelectiveSubmoduleInitList'): + for element in subroot.iter(tag='Submodule'): + self._submodule_init_list.append(_SubmoduleInitEntry(element)) + # # parse tags # requires RemoteList to be parsed first @@ -386,6 +395,22 @@ class ManifestXml(BaseXmlHelper): alternates.append(alternate.tuple) return alternates + def get_submodule_init_paths(self, remote_name=None, combo=None): + submodule_list = [] + if remote_name is None and combo is None: + submodule_list = self._tuple_list(self._submodule_init_list) + elif remote_name is not None and combo is None: + submodule_list = self._tuple_list( + [x for x in self._submodule_init_list if x.remote_name == remote_name]) + elif remote_name is None and combo is not None: + submodule_list = self._tuple_list( + [x for x in self._submodule_init_list if x.combo == combo or x.combo is None]) + else: + submodule_list = self._tuple_list( + [x for x in self._submodule_init_list + if x.remote_name == remote_name and (x.combo == combo or x.combo is None)]) + return submodule_list + def write_current_combo(self, combo_name, filename=None): # # Updates the CurrentClonedCombo tag of _tree attribute and writes the entire tree out to the @@ -460,6 +485,10 @@ class ManifestXml(BaseXmlHelper): if self._tree.find('SubmoduleAlternateRemotes'): submodule_alt_url_root = ET.SubElement(pin_root, 'SubmoduleAlternateRemotes') + selective_submodules_root = None + if self._tree.find('SelectiveSubmoduleInitList'): + selective_submodules_root = ET.SubElement(pin_root, 'SelectiveSubmoduleInitList') + remote_root = ET.SubElement(pin_root, 'RemoteList') source_root = ET.SubElement(pin_root, 'Combination') source_root.attrib['name'] = self._combinations[combo_name].name @@ -487,6 +516,13 @@ class ManifestXml(BaseXmlHelper): if alt_url_element.attrib['remote'] == src_tuple.remote_name: submodule_alt_url_root.append(alt_url_element) + for subroot_selective_subs in self._tree.iter('SelectiveSubmoduleInitList'): + for selective_sub in subroot_selective_subs.iter('Submodule'): + if selective_sub.attrib['remote'] == src_tuple.remote_name: + if 'combo' in selective_sub.attrib and selective_sub.attrib['combo'] != combo_name: + continue + selective_submodules_root.append(selective_sub) + sparse = 'true' if src_tuple.sparse else 'false' sub = 'true' if src_tuple.enable_submodule else 'false' # Write the source element based on what value branch or commit is available. @@ -535,6 +571,10 @@ class ManifestXml(BaseXmlHelper): submodule_alt_url_root.text = '\n ' submodule_alt_url_root.tail = '\n\n ' list(submodule_alt_url_root)[-1].tail = '\n ' + if selective_submodules_root: + selective_submodules_root.text = '\n ' + selective_submodules_root.tail = '\n\n ' + list(selective_submodules_root)[-1].tail = '\n ' remote_root.text = '\n ' remote_root.tail = '\n\n ' list(remote_root)[-1].tail = '\n ' @@ -882,6 +922,27 @@ class _SubmoduleAlternateRemote(): return SubmoduleAlternateRemote(self.remote_name, self.originalUrl, self.altUrl) +class _SubmoduleInitEntry(): + def __init__(self, element): + try: + self.remote_name = element.attrib['remote'] + self.path = element.text + except KeyError as k: + raise KeyError(REQUIRED_ATTRIB_ERROR_MSG.format(k, element.tag)) + try: + self.combo = element.attrib['combo'] + except Exception: + self.combo = None + try: + self.recursive = element.attrib['recursive'].lower() == 'true' + except Exception: + self.recursive = False + + @property + def tuple(self): + return SubmoduleInitPath(self.remote_name, self.combo, self.recursive, self.path) + + # # Optional entry point for debug and validation of the CiIndexXml & ManifestXml classes # @@ -956,6 +1017,23 @@ def main(): for alt in alts: print(alt) + print('\nGet Submodule Init Objects') + print('\nAll:') + for entry in test_manifest.get_submodule_init_paths(): + print('+ {}'.format(entry)) + print('\nPer Remote:') + for remote in test_manifest.remotes: + for entry in test_manifest.get_submodule_init_paths(remote.name): + print('+ {}'.format(entry)) + print('\nCurrent Combo:') + current_combo = test_manifest.general_config.current_combo + for entry in test_manifest.get_submodule_init_paths(combo=current_combo): + print('+ {}'.format(entry)) + print('\nCurrent Combo Per Remote:') + for remote in test_manifest.remotes: + for entry in test_manifest.get_submodule_init_paths(remote.name, current_combo): + print('+ {}'.format(entry)) + if not test_manifest.is_pin_file(): print('\nSparse settings:') print(test_manifest.sparse_settings) -- 2.21.0.windows.1