[edk2-staging/EdkRepo] [PATCH V1 3/3] EdkRepo: Add command completion setup to Windows installer
Add configuration of command completion scripts
to the Windows installer. This enables edkrepo command completions to work "out of box" on Git for Windows by adding the edkrepo command completions scripts to the Git for Windows /etc/profile.d directory Cc: Ashley DeSimone <ashley.e.desimone@...> Cc: Puja Pandya <puja.pandya@...> Cc: Erik Bjorge <erik.c.bjorge@...> Cc: Prince Agyeman <prince.agyeman@...> Cc: Bret Barkelew <Bret.Barkelew@...> Cc: Philippe Mathieu-Daude <philmd@...> Signed-off-by: Nate DeSimone <nathaniel.l.desimone@...> --- .../EdkRepoInstaller/InstallWorker.cs | 212 ++++++++++++++++-- .../EdkRepoInstaller/InstallerStrings.cs | 44 +++- .../Vendor/win_edkrepo_prompt.sh | 60 +++++ 3 files changed, 296 insertions(+), 20 deletions(-) create mode 100644 edkrepo_installer/Vendor/win_edkrepo_prompt.sh diff --git a/edkrepo_installer/EdkRepoInstaller/InstallWorker.cs b/edkrepo_installer/EdkRepoInstaller/InstallWorker.cs index 472a6c8..679b4f4 100644 --- a/edkrepo_installer/EdkRepoInstaller/InstallWorker.cs +++ b/edkrepo_installer/EdkRepoInstaller/InstallWorker.cs @@ -19,6 +19,7 @@ using System.Security.AccessControl; using System.Security.Cryptography; using System.Security.Principal; using System.Text; +using System.Text.RegularExpressions; using System.Threading; namespace TianoCore.EdkRepoInstaller @@ -611,7 +612,7 @@ namespace TianoCore.EdkRepoInstaller SilentProcess process = SilentProcess.StartConsoleProcessSilently(GitPath, "--version", dataCapture.DataReceivedHandler); process.WaitForExit(); PythonVersion gitVersion = new PythonVersion(dataCapture.GetData().Trim()); - if (gitVersion < new PythonVersion(2,13,0)) + if (gitVersion < new PythonVersion(2, 13, 0)) { InstallLogger.Log(string.Format("Git Version 2.13 or later is required. You have version {0}, please upgrade to a newer version of Git.", gitVersion)); ReportComplete(false, false); @@ -624,7 +625,7 @@ namespace TianoCore.EdkRepoInstaller List<Tuple<string, PythonVersion>> ExclusivePackages = new List<Tuple<string, PythonVersion>>(); foreach (PythonInstance PyInstance in PythonWheelsToInstall) { - foreach(PythonWheel Wheel in PyInstance.Wheels) + foreach (PythonWheel Wheel in PyInstance.Wheels) { if (Wheel.UninstallAllOtherCopies) { @@ -668,13 +669,13 @@ namespace TianoCore.EdkRepoInstaller // foreach (PythonVersion Obsolete in ObsoletedPythonVersions) { - if(ExistingEdkRepoPaths.Select(p => p.Item2).Contains(Obsolete)) + if (ExistingEdkRepoPaths.Select(p => p.Item2).Contains(Obsolete)) { foreach (string ExistingEdkrepoPythonPath in ExistingEdkRepoPaths.Where(p => p.Item2 == Obsolete).Select(p => p.Item1)) { string UninstallerPath = Path.Combine(Path.GetDirectoryName(ExistingEdkrepoPythonPath), "Lib", "site-packages"); UninstallerPath = Path.Combine(UninstallerPath, Path.GetFileName(WindowsHelpers.GetApplicationPath())); - if(File.Exists(UninstallerPath)) + if (File.Exists(UninstallerPath)) { InstallLogger.Log(string.Format("Uninstalling {0}...", UninstallerPath)); string UninstallString = string.Format("\"{0}\" /Uninstall /Passive", UninstallerPath); @@ -788,14 +789,15 @@ namespace TianoCore.EdkRepoInstaller // // Step 10 - Setup symlink to edkrepo and bash script to launch edkrepo from git bash // + string EdkrepoSymlinkPath = null; if (!string.IsNullOrEmpty(EdkrepoPythonPath)) { string EdkrepoScriptPath = Path.Combine(Path.GetDirectoryName(EdkrepoPythonPath), "Scripts", InstallerStrings.EdkrepoCliExecutable); - string EdkrepoSymlinkPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), InstallerStrings.EdkrepoCliExecutable); + EdkrepoSymlinkPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), InstallerStrings.EdkrepoCliExecutable); if (File.Exists(EdkrepoScriptPath)) { bool CreateSymlink = true; - if(File.Exists(EdkrepoSymlinkPath)) + if (File.Exists(EdkrepoSymlinkPath)) { try { @@ -805,22 +807,22 @@ namespace TianoCore.EdkRepoInstaller } } catch (NotASymlinkException) { } - if(CreateSymlink) + if (CreateSymlink) { File.Delete(EdkrepoSymlinkPath); } } - if(CreateSymlink) + if (CreateSymlink) { InstallLogger.Log("Creating Symbolic Link for edkrepo.exe..."); WindowsHelpers.CreateSymbolicLink(EdkrepoSymlinkPath, EdkrepoScriptPath, WindowsHelpers.SYMBOLIC_LINK_FLAG.File); } string GitBashBinPath = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(GitPath)), "usr", "bin"); - if(Directory.Exists(GitBashBinPath)) + if (Directory.Exists(GitBashBinPath)) { InstallLogger.Log("Creating edkrepo launcher in Git Bash..."); string EdkrepoBashScriptPath = Path.Combine(GitBashBinPath, InstallerStrings.EdkrepoBashLauncherScript); - if(File.Exists(EdkrepoBashScriptPath)) + if (File.Exists(EdkrepoBashScriptPath)) { File.Delete(EdkrepoBashScriptPath); } @@ -838,7 +840,7 @@ namespace TianoCore.EdkRepoInstaller // Step 11 - Copy edkrepo config file to the edkrepo global data directory // string EdkrepoCfg = Path.Combine(Path.GetDirectoryName(WindowsHelpers.GetApplicationPath()), InstallerStrings.EdkrepoCfg); - if(File.Exists(EdkrepoCfg)) + if (File.Exists(EdkrepoCfg)) { CreateEdkrepoGlobalDataDirectory(); string EdkrepoCfgDir = Path.Combine(WindowsHelpers.GetAllUsersAppDataPath(), InstallerStrings.EdkrepoGlobalDirectoryName); @@ -853,7 +855,7 @@ namespace TianoCore.EdkRepoInstaller { string NewCfgHash = ComputeSha256(ReadFile(EdkrepoCfg)); string OldCfgHash = ComputeSha256(ReadFile(EdkrepoCfgTarget)); - if(NewCfgHash != OldCfgHash) + if (NewCfgHash != OldCfgHash) { if (GetPreviousEdkrepoCfgFileHashes().Contains(OldCfgHash)) { @@ -908,7 +910,119 @@ namespace TianoCore.EdkRepoInstaller } // - // Step 13 - Create Programs and Features uninstall links + // Step 13 - Copy win_edkrepo_prompt.sh and generate edkrepo_completions.sh + // + string edkrepoPromptSource = Path.Combine(Path.GetDirectoryName(WindowsHelpers.GetApplicationPath()), InstallerStrings.EdkrepoPrompt); + + if (File.Exists(edkrepoPromptSource) && !string.IsNullOrEmpty(EdkrepoSymlinkPath)) + { + string gitBashEtcPath = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(GitPath)), "etc"); + string gitBashEtcProfileDPath = Path.Combine(gitBashEtcPath, "profile.d"); + if (Directory.Exists(gitBashEtcPath) && Directory.Exists(gitBashEtcProfileDPath)) + { + InstallLogger.Log("Installing EdkRepo command completion..."); + + //Copy win_edkrepo_prompt.sh + string edkrepoPromptDest = Path.Combine(gitBashEtcProfileDPath, InstallerStrings.EdkrepoPrompt); + if (File.Exists(edkrepoPromptDest)) + { + File.Delete(edkrepoPromptDest); + } + File.Copy(edkrepoPromptSource, edkrepoPromptDest); + DirectoryInfo info = new DirectoryInfo(edkrepoPromptDest); + DirectorySecurity security = info.GetAccessControl(); + security.AddAccessRule(new FileSystemAccessRule( + new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null), + FileSystemRights.FullControl, + InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, + PropagationFlags.NoPropagateInherit, + AccessControlType.Allow + )); + info.SetAccessControl(security); + InstallLogger.Log(string.Format("Copied {0}", InstallerStrings.EdkrepoPrompt)); + + //Generate edkrepo_completions.sh + string edkrepoCompletionDest = Path.Combine(gitBashEtcProfileDPath, InstallerStrings.EdkrepoCompletion); + if (File.Exists(edkrepoCompletionDest)) + { + File.Delete(edkrepoCompletionDest); + } + dataCapture = new SilentProcess.StdoutDataCapture(); + process = SilentProcess.StartConsoleProcessSilently( + EdkrepoSymlinkPath, + string.Format( + "generate-command-completion-script \"{0}\"", + edkrepoCompletionDest), + dataCapture.DataReceivedHandler); + process.WaitForExit(); + InstallLogger.Log(EdkrepoSymlinkPath); + InstallLogger.Log(edkrepoCompletionDest); + InstallLogger.Log(dataCapture.GetData().Trim()); + if (process.ExitCode != 0) + { + throw new InvalidOperationException(string.Format("generate-command-completion-script failed with status {0}", process.ExitCode)); + } + if (!File.Exists(edkrepoCompletionDest)) + { + throw new InvalidOperationException(string.Format("generate-command-completion-script did not create {0}", InstallerStrings.EdkrepoCompletion)); + } + info = new DirectoryInfo(edkrepoCompletionDest); + security = info.GetAccessControl(); + security.AddAccessRule(new FileSystemAccessRule( + new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null), + FileSystemRights.FullControl, + InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, + PropagationFlags.NoPropagateInherit, + AccessControlType.Allow + )); + info.SetAccessControl(security); + InstallLogger.Log(string.Format("Generated {0}", InstallerStrings.EdkrepoCompletion)); + + //Call win_edkrepo_prompt.sh from bash.bashrc so edkrepo completions are available for "interactive non-login" bash shells + string bashrcPath = Path.Combine(gitBashEtcPath, "bash.bashrc"); + if (File.Exists(bashrcPath)) + { + string bashrc = Encoding.UTF8.GetString(ReadFile(bashrcPath)); + Match match = Regex.Match(bashrc, InstallerStrings.BashrcEdkrepoPromptCallPattern); + if (match.Success) + { + InstallLogger.Log("EdkRepo prompt is already in bash.bashrc"); + } + else + { + bashrc = string.Format("{0}{1}", bashrc, InstallerStrings.BashrcEdkRepoPromptCall); + using (BinaryWriter writer = new BinaryWriter(File.Open(bashrcPath, FileMode.Truncate, FileAccess.Write))) + { + string sanitized = bashrc.Replace("\r\n", "\n"); + writer.Write(Encoding.UTF8.GetBytes(sanitized)); + } + InstallLogger.Log("EdkRepo prompt added to bash.bashrc"); + } + } + else + { + InstallLogger.Log(string.Format("{0} not found", bashrcPath)); + } + } + else + { + InstallLogger.Log("Git for Windows /etc/profile.d not found"); + } + } + else + { + if (string.IsNullOrEmpty(EdkrepoSymlinkPath)) + { + InstallLogger.Log("EdkRepo symlink not found"); + } + if (!File.Exists(edkrepoPromptSource)) + { + InstallLogger.Log(string.Format("{0} not found", InstallerStrings.EdkrepoPrompt)); + } + } + + // + // Step 14 - Create Programs and Features uninstall links // if (!string.IsNullOrEmpty(EdkrepoPythonPath)) { @@ -977,7 +1091,7 @@ namespace TianoCore.EdkRepoInstaller string GitPath = PythonOperations.GetFullPath("git.exe"); // - // Step 2 - Delete symlink to edkrepo and bash script to launch it from git bash + // Step 2 - Delete symlink to edkrepo // string EdkrepoSymlinkPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), InstallerStrings.EdkrepoCliExecutable); if (File.Exists(EdkrepoSymlinkPath)) @@ -1003,7 +1117,11 @@ namespace TianoCore.EdkRepoInstaller File.Delete(EdkrepoSymlinkPath); } } - if (GitPath != null) + + // + // Step 3 - Delete scripts to launch edkrepo and Python from git bash, and edkrepo command completion scripts + // + if (!string.IsNullOrWhiteSpace(GitPath)) { string GitBashBinPath = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(GitPath)), "usr", "bin"); if (Directory.Exists(GitBashBinPath)) @@ -1057,10 +1175,68 @@ namespace TianoCore.EdkRepoInstaller File.Delete(EdkrepoPython2ScriptPath); } } + string gitBashEtcPath = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(GitPath)), "etc"); + string gitBashEtcProfileDPath = Path.Combine(gitBashEtcPath, "profile.d"); + if (Directory.Exists(gitBashEtcPath) && Directory.Exists(gitBashEtcProfileDPath)) + { + string edkrepoPromptDest = Path.Combine(gitBashEtcProfileDPath, InstallerStrings.EdkrepoPrompt); + if (File.Exists(edkrepoPromptDest)) + { + AllowCancel(false); + if (CancelPending()) + { + ReportComplete(true, true); + return; + } + InstallLogger.Log(string.Format("Deleting {0}...", InstallerStrings.EdkrepoPrompt)); + File.Delete(edkrepoPromptDest); + } + + string edkrepoCompletionDest = Path.Combine(gitBashEtcProfileDPath, InstallerStrings.EdkrepoCompletion); + if (File.Exists(edkrepoCompletionDest)) + { + AllowCancel(false); + if (CancelPending()) + { + ReportComplete(true, true); + return; + } + InstallLogger.Log(string.Format("Deleting {0}...", InstallerStrings.EdkrepoCompletion)); + File.Delete(edkrepoCompletionDest); + } + + //Remove call win_edkrepo_prompt.sh from bash.bashrc + string bashrcPath = Path.Combine(gitBashEtcPath, "bash.bashrc"); + if (File.Exists(bashrcPath)) + { + string original_bashrc = Encoding.UTF8.GetString(ReadFile(bashrcPath)); + + string new_bashrc = Regex.Replace(original_bashrc, InstallerStrings.BashrcEdkrepoPromptCommentPattern, ""); + new_bashrc = Regex.Replace(new_bashrc, InstallerStrings.BashrcEdkrepoPromptCallPattern, ""); + if (new_bashrc == original_bashrc) + { + InstallLogger.Log("EdkRepo not found in bash.bashrc"); + } + else + { + new_bashrc = new_bashrc.TrimEnd(); + using (BinaryWriter writer = new BinaryWriter(File.Open(bashrcPath, FileMode.Truncate, FileAccess.Write))) + { + string sanitized = new_bashrc.Replace("\r\n", "\n"); + writer.Write(Encoding.UTF8.GetBytes(sanitized)); + } + InstallLogger.Log("EdkRepo prompt removed from bash.bashrc"); + } + } + else + { + InstallLogger.Log(string.Format("{0} not found", bashrcPath)); + } + } } // - // Step 3 - Uninstall any instances of edkrepo + // Step 4 - Uninstall any instances of edkrepo // IEnumerable<string> PackagesToUninstall = GetPythonWheelsToUninstall(); InstallLogger.Log("Determining currently installed Python packages..."); @@ -1109,7 +1285,7 @@ namespace TianoCore.EdkRepoInstaller } // - // Step 4 - Invoke the Finish Uninstall Event + // Step 5 - Invoke the Finish Uninstall Event // if (VendorCustomizer.Instance != null) { @@ -1122,7 +1298,7 @@ namespace TianoCore.EdkRepoInstaller } // - // Step 5 - Delete Programs and Feature uninstall link + // Step 6 - Delete Programs and Feature uninstall link // RegistryKey hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64); RegistryKey winUninstallRegistryKey = hklm.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", true); diff --git a/edkrepo_installer/EdkRepoInstaller/InstallerStrings.cs b/edkrepo_installer/EdkRepoInstaller/InstallerStrings.cs index 6aa90ee..1542641 100644 --- a/edkrepo_installer/EdkRepoInstaller/InstallerStrings.cs +++ b/edkrepo_installer/EdkRepoInstaller/InstallerStrings.cs @@ -2,7 +2,7 @@ InstallerStrings.cs @copyright - Copyright 2016 - 2019 Intel Corporation. All rights reserved.<BR> + Copyright 2016 - 2020 Intel Corporation. All rights reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent @par Specification Reference: @@ -43,7 +43,7 @@ namespace TianoCore.EdkRepoInstaller } public static string EdkrepoPackageName - { + { get { return "edkrepo"; @@ -113,6 +113,46 @@ namespace TianoCore.EdkRepoInstaller } } + public static string EdkrepoPrompt + { + get + { + return "win_edkrepo_prompt.sh"; + } + } + + public static string EdkrepoCompletion + { + get + { + return "edkrepo_completions.sh"; + } + } + + public static string BashrcEdkrepoPromptCommentPattern + { + get + { + return @"#\s+Install\s+EdkRepo\s+command\s+completions"; + } + } + + public static string BashrcEdkrepoPromptCallPattern + { + get + { + return @"shopt\s+-q\s+login_shell\s+\|\|\s+\.\s+/etc/profile\.d/win_edkrepo_prompt\.sh"; + } + } + + public static string BashrcEdkRepoPromptCall + { + get + { + return "\n\n# Install EdkRepo command completions\nshopt -q login_shell || . /etc/profile.d/win_edkrepo_prompt.sh"; + } + } + public static string InstallerName { get diff --git a/edkrepo_installer/Vendor/win_edkrepo_prompt.sh b/edkrepo_installer/Vendor/win_edkrepo_prompt.sh new file mode 100644 index 0000000..5404175 --- /dev/null +++ b/edkrepo_installer/Vendor/win_edkrepo_prompt.sh @@ -0,0 +1,60 @@ +## @file win_edkrepo_prompt.sh +# Note: For use on Git for Windows/MSYS2 ONLY. +# UNIX version is in install.py +# +# Copyright (c) 2020, Intel Corporation. All rights reserved.<BR> +# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +# Add EdkRepo command completions +[[ -r "/etc/profile.d/edkrepo_completions.sh" ]] && . "/etc/profile.d/edkrepo_completions.sh" + +# Add EdkRepo to the prompt +ps1len="${#PS1}" +let "pos38 = ps1len - 38" +let "pos3 = ps1len - 3" +let "pos2 = ps1len - 2" +if [ "${PS1:pos38}" == '\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ ' ]; then + newps1="${PS1:0:pos38}" + prompt_suffix='\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ ' +elif [ "${PS1:pos3}" == "\\$ " ]; then + newps1="${PS1:0:pos3}" + prompt_suffix="\\$ " +elif [ "${PS1:pos3}" == " $ " ]; then + newps1="${PS1:0:pos3}" + prompt_suffix=" $ " +elif [ "${PS1:pos2}" == "$ " ]; then + newps1="${PS1:0:pos2}" + prompt_suffix="$ " +else + newps1="$PS1" + prompt_suffix="" +fi + +if [ -x "$(command -v edkrepo)" ] && [ -x "$(command -v $command_completion_edkrepo_file)" ]; then + newps1="$newps1\[\033[32m\]\$current_edkrepo_combo\[\033[00m\]" + current_edkrepo_combo=$(command_completion_edkrepo current-combo) + + # Determining the current Edkrepo combo requires invoking Python and parsing + # manifest XML, which is a relatively expensive operation to do every time + # the user presses <Enter>. + # As a performance optimization, only do this if the present working directory + # changed + if [[ ! -z ${PROMPT_COMMAND+x} ]] && [[ "$PROMPT_COMMAND" != "edkrepo_combo_chpwd" ]]; then + old_prompt_command=$PROMPT_COMMAND + fi + old_pwd=$(pwd) + edkrepo_combo_chpwd() { + if [[ "$(pwd)" != "$old_pwd" ]]; then + old_pwd=$(pwd) + current_edkrepo_combo=$(command_completion_edkrepo current-combo) + fi + if [[ ! -z ${PROMPT_COMMAND+x} ]]; then + eval $old_prompt_command + fi + } + PROMPT_COMMAND=edkrepo_combo_chpwd +fi + +PS1="$newps1$prompt_suffix" +MSYS2_PS1="$PS1" # for detection by MSYS2 SDK's bash.basrc -- 2.24.0.windows.2
|
|
[edk2-staging/EdkRepo] [PATCH V1 2/3] EdkRepo: Add command completion setup to install.py
Add configuration of command completion scripts
to install.py This enables edkrepo command completions to work "out of box" on most Linux systems by appending to the user's .bashrc and .zshrc startup scripts inclusion of the EdkRepo command completion scripts. Cc: Ashley DeSimone <ashley.e.desimone@...> Cc: Puja Pandya <puja.pandya@...> Cc: Erik Bjorge <erik.c.bjorge@...> Cc: Prince Agyeman <prince.agyeman@...> Cc: Bret Barkelew <Bret.Barkelew@...> Cc: Philippe Mathieu-Daude <philmd@...> Signed-off-by: Nate DeSimone <nathaniel.l.desimone@...> --- edkrepo_installer/linux-scripts/install.py | 285 ++++++++++++++++++++- 1 file changed, 283 insertions(+), 2 deletions(-) diff --git a/edkrepo_installer/linux-scripts/install.py b/edkrepo_installer/linux-scripts/install.py index b2cdfed..52f0c52 100755 --- a/edkrepo_installer/linux-scripts/install.py +++ b/edkrepo_installer/linux-scripts/install.py @@ -15,6 +15,7 @@ import importlib.util import logging import os import platform +import re import stat import shutil import subprocess @@ -22,7 +23,7 @@ import sys import traceback import xml.etree.ElementTree as et -tool_sign_on = 'Installer for edkrepo version {}\nCopyright(c) Intel Corporation, 2019' +tool_sign_on = 'Installer for edkrepo version {}\nCopyright(c) Intel Corporation, 2020' # Data here should be maintained in a configuration file cfg_dir = '.edkrepo' @@ -31,6 +32,21 @@ cfg_src_dir = os.path.abspath('config') whl_src_dir = os.path.abspath('wheels') def_python = 'python3' +# ZSH Configuration options +prompt_regex = re.compile(r"#\s+[Aa][Dd][Dd]\s+[Ee][Dd][Kk][Rr][Ee][Pp][Oo]\s+&\s+[Gg][Ii][Tt]\s+[Tt][Oo]\s+[Tt][Hh][Ee]\s+[Pp][Rr][Oo][Mm][Pp][Tt]") +zsh_autoload_compinit_regex = re.compile(r"autoload\s+-U\s+compinit") +zsh_autoload_bashcompinit_regex = re.compile(r"autoload\s+-U\s+bashcompinit") +zsh_autoload_colors_regex = re.compile(r"autoload\s+-U\s+colors") +zsh_colors_regex = re.compile(r"\n\s*colors\n") +zsh_compinit_regex = re.compile(r"compinit\s+-u") +zsh_bashcompinit_regex = re.compile(r"\n\s*bashcompinit\n") +zsh_autoload_compinit = 'autoload -U compinit' +zsh_autoload_bashcompinit = 'autoload -U bashcompinit' +zsh_autoload_colors = 'autoload -U colors' +zsh_colors = 'colors' +zsh_compinit = 'compinit -u' +zsh_bashcompinit = 'bashcompinit' + def default_run(cmd): return subprocess.run(cmd, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=True) @@ -51,8 +67,85 @@ def get_args(): parser.add_argument('-p', '--py', action='store', default=None, help='Specify the python command to use when installing') parser.add_argument('-u', '--user', action='store', default=None, help='Specify user account to install edkrepo support on') parser.add_argument('-v', '--verbose', action='store_true', default=False, help='Enables verbose output') + parser.add_argument('--no-prompt', action='store_true', default=False, help='Do NOT add EdkRepo combo and git branch to the shell prompt') + parser.add_argument('--prompt', action='store_true', default=False, help='Add EdkRepo combo and git branch to the shell prompt') return parser.parse_args() +def is_prompt_customization_installed(user_home_dir): + script_files = [os.path.join(user_home_dir, '.bashrc'), os.path.join(user_home_dir, '.zshrc')] + customization_installed = True + for script_file in script_files: + if os.path.isfile(script_file): + with open(script_file, 'r') as f: + script = f.read().strip() + data = prompt_regex.search(script) + if not data: + customization_installed = False + break + return customization_installed + +__add_prompt_customization = None +def get_add_prompt_customization(args, user_home_dir): + global __add_prompt_customization + if __add_prompt_customization is not None: + return __add_prompt_customization + if args.no_prompt: + __add_prompt_customization = False + return False + elif args.prompt: + __add_prompt_customization = True + return True + #Check if the prompt customization has already been installed + if is_prompt_customization_installed(user_home_dir): + __add_prompt_customization = False + return False + #If the prompt has not been installed and EdkRepo >= 2.0.0 is installed, then don't install the prompt customization + if shutil.which('edkrepo') is not None: + res = default_run(['edkrepo', '--version']) + if _check_version(res.stdout.replace('edkrepo ', '').strip(), '2.0.0') >= 0: + __add_prompt_customization = False + return False + #Show the user an advertisement to see if they want the prompt customization + from select import select + import termios + import tty + def get_key(timeout=-1): + key = None + old_settings = termios.tcgetattr(sys.stdin.fileno()) + try: + tty.setraw(sys.stdin.fileno()) + if timeout != -1: + rlist, _, _ = select([sys.stdin], [], [], timeout) + if rlist: + key = sys.stdin.read(1) + else: + key = sys.stdin.read(1) + finally: + termios.tcsetattr(sys.stdin.fileno(), termios.TCSADRAIN, old_settings) + return key + print('\nEdkRepo can show the checked out \033[32mcombo\033[00m and \033[36mbranch\033[00m as part of the command prompt') + print('For example, instead of:\n') + print('\033[01;32muser@machine\033[00m:\033[01;34mEdk2\033[00m$ ') + print('\nThe command prompt would look like:\n') + print('\033[01;32muser@machine\033[00m:\033[01;34mEdk2\033[00m \033[32m[Edk2Master]\033[36m (master)\033[00m$ ') + print('') + while True: + print('Would you like the combo and branch shown on the command prompt? [y/N] ') + key = get_key(120) + if key: + if key == 'y' or key == 'Y': + print('Y') + __add_prompt_customization = True + return True + if key == 'n' or key == 'N': + print('N') + __add_prompt_customization = False + return False + else: + print('No response after 2min... assuming no.') + __add_prompt_customization = False + return False + def get_installed_packages(python_command): pip_cmd = [def_python, '-m', 'pip', 'list', '--legacy'] try: @@ -146,6 +239,176 @@ def set_execute_permissions(): stat_data = os.stat(py_file) os.chmod(py_file, stat_data.st_mode | stat.S_IEXEC) +bash_prompt_customization = r''' +# Add EdkRepo & git to the prompt +ps1len="${#PS1}" +let "pos3 = ps1len - 3" +let "pos2 = ps1len - 2" +if [ "${PS1:pos3}" == "\\$ " ]; then + newps1="${PS1:0:pos3}" + prompt_suffix="\\$ " +elif [ "${PS1:pos3}" == " $ " ]; then + newps1="${PS1:0:pos3}" + prompt_suffix=" $ " +elif [ "${PS1:pos2}" == "$ " ]; then + newps1="${PS1:0:pos2}" + prompt_suffix="$ " +else + newps1="$PS1" + prompt_suffix="" +fi + +# EdkRepo combo in prompt. +if [ -x "$(command -v edkrepo)" ] && [ -x "$(command -v command_completion_edkrepo)" ]; then + newps1="$newps1\[\033[32m\]\$current_edkrepo_combo" + current_edkrepo_combo=$(command_completion_edkrepo current-combo) + + # Determining the current Edkrepo combo requires invoking Python and parsing + # manifest XML, which is a relatively expensive operation to do every time + # the user presses <Enter>. + # As a performance optimization, only do this if the present working directory + # changed + if [[ ! -z ${PROMPT_COMMAND+x} ]] && [[ "$PROMPT_COMMAND" != "edkrepo_combo_chpwd" ]]; then + old_prompt_command=$PROMPT_COMMAND + fi + old_pwd=$(pwd) + edkrepo_combo_chpwd() { + if [[ "$(pwd)" != "$old_pwd" ]]; then + old_pwd=$(pwd) + current_edkrepo_combo=$(command_completion_edkrepo current-combo) + fi + if [[ ! -z ${PROMPT_COMMAND+x} ]]; then + eval $old_prompt_command + fi + } + PROMPT_COMMAND=edkrepo_combo_chpwd +fi + +# Git branch in prompt. +parse_git_branch() { + git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' +} + +PS1="$newps1\[\033[36m\]\$(parse_git_branch)\[\033[00m\]$prompt_suffix" +''' + +zsh_prompt_customization = r''' +# Add EdkRepo & git to the prompt +prompt_length="${#PROMPT}" +let "pos4 = prompt_length - 3" +let "pos3 = prompt_length - 2" +if [ "${PROMPT[$pos4,$prompt_length]}" = ' %# ' ]; then + new_prompt="${PROMPT[1,$pos4-1]}" + prompt_suffix=" %# " +elif [ "${PROMPT[$pos3,$prompt_length]}" = "%# " ]; then + new_prompt="${PROMPT[1,$pos3-1]}" + prompt_suffix="%# " +else + new_prompt="$PROMPT" + prompt_suffix="" +fi + +# EdkRepo combo in prompt. +if [ -x "$(command -v edkrepo)" ] && [ -x "$(command -v command_completion_edkrepo)" ]; then + new_prompt="$new_prompt%{$fg[green]%}\$current_edkrepo_combo%{$reset_color%}" + current_edkrepo_combo=$(command_completion_edkrepo current-combo) + + # Determining the current Edkrepo combo requires invoking Python and parsing + # manifest XML, which is a relatively expensive operation to do every time + # the user presses <Enter>. + # As a performance optimization, only do this if the present working directory + # changed + function edkrepo_combo_chpwd() { + current_edkrepo_combo=$(command_completion_edkrepo current-combo) + } + chpwd_functions=(${chpwd_functions[@]} "edkrepo_combo_chpwd") +fi + +# Load version control information +autoload -Uz vcs_info +precmd() { vcs_info } + +# Format the vcs_info_msg_0_ variable +zstyle ':vcs_info:git:*' formats " %{$fg[cyan]%}(%b)%{$reset_color%}" + +# Set up the prompt (with git branch name) +setopt PROMPT_SUBST +eval "PROMPT='$new_prompt\${vcs_info_msg_0_}\$prompt_suffix'" +''' + +def add_command_to_startup_script(script_file, regex, command, username): + script = '' + if os.path.isfile(script_file): + with open(script_file, 'r') as f: + script = f.read().strip() + data = regex.search(script) + if not data: + if script == '': + script = command + else: + script = '{}\n{}'.format(script, command) + with open(script_file, 'w') as f: + f.write(script) + +def add_command_comment_to_startup_script(script_file, regex, command, comment, username): + script = '' + if os.path.isfile(script_file): + with open(script_file, 'r') as f: + script = f.read().strip() + (new_script, subs) = re.subn(regex, command, script) + if subs == 0: + command = '\n{1}\n{0}\n'.format(command, comment) + if script == '': + new_script = command + else: + new_script = '{}\n{}'.format(script, command) + if new_script != script: + with open(script_file, 'w') as f: + f.write(new_script) + shutil.chown(script_file, user=username) + os.chmod(script_file, 0o644) + +def add_command_completions_to_shell(command_completion_script, args, username, user_home_dir): + # Add "source ~/.bashrc" to ~/.bash_profile if it does not have it already + bash_profile_file = os.path.join(user_home_dir, '.bash_profile') + bash_profile = '' + if os.path.isfile(bash_profile_file): + with open(bash_profile_file, 'r') as f: + bash_profile = f.read().strip() + profile_source_regex = re.compile(r"source\s+~/\.bashrc") + profile_source_regex2 = re.compile(r".\s+~/\.bashrc") + data = profile_source_regex.search(bash_profile) + if not data: + data = profile_source_regex2.search(bash_profile) + if not data: + if bash_profile == '': + bash_profile = 'source ~/.bashrc\n' + else: + bash_profile = '{}\nsource ~/.bashrc\n'.format(bash_profile) + with open(bash_profile_file, 'w') as f: + f.write(bash_profile) + shutil.chown(bash_profile_file, user=username) + os.chmod(bash_profile_file, 0o644) + + # Add edkrepo command completion to ~/.bashrc if it does not have it already + regex = r"\[\[\s+-r\s+\"\S*edkrepo_completions.sh\"\s+\]\]\s+&&\s+.\s+\"\S*edkrepo_completions.sh\"" + new_source_line = '[[ -r "{0}" ]] && . "{0}"'.format(command_completion_script) + comment = '\n# Add EdkRepo command completions' + bash_rc_file = os.path.join(user_home_dir, '.bashrc') + add_command_comment_to_startup_script(bash_rc_file, regex, new_source_line, comment, username) + if get_add_prompt_customization(args, user_home_dir): + add_command_to_startup_script(bash_rc_file, prompt_regex, bash_prompt_customization, username) + zsh_rc_file = os.path.join(user_home_dir, '.zshrc') + add_command_to_startup_script(zsh_rc_file, zsh_autoload_compinit_regex, zsh_autoload_compinit, username) + add_command_to_startup_script(zsh_rc_file, zsh_autoload_bashcompinit_regex, zsh_autoload_bashcompinit, username) + add_command_to_startup_script(zsh_rc_file, zsh_autoload_colors_regex, zsh_autoload_colors, username) + add_command_to_startup_script(zsh_rc_file, zsh_colors_regex, zsh_colors, username) + add_command_to_startup_script(zsh_rc_file, zsh_compinit_regex, zsh_compinit, username) + add_command_to_startup_script(zsh_rc_file, zsh_bashcompinit_regex, zsh_bashcompinit, username) + add_command_comment_to_startup_script(zsh_rc_file, regex, new_source_line, comment, username) + if get_add_prompt_customization(args, user_home_dir): + add_command_to_startup_script(zsh_rc_file, prompt_regex, zsh_prompt_customization, username) + def do_install(): global def_python org_python = None @@ -209,6 +472,7 @@ def do_install(): log.info('- Unable to determine users home directory') return 1 default_cfg_dir = os.path.join(user_home_dir, cfg_dir) + get_add_prompt_customization(args, user_home_dir) log.info('+ System information collected') # Display current system information. @@ -348,7 +612,7 @@ def do_install(): #Delete obsolete dependencies if updating_edkrepo: installed_packages = get_installed_packages(def_python) - for whl_name in ['smmap2', 'gitdb2']: + for whl_name in ['smmap2', 'gitdb2', 'edkrepo-internal']: if whl_name in installed_packages: try: res = default_run([def_python, '-m', 'pip', 'uninstall', '--yes', whl_name]) @@ -375,6 +639,23 @@ def do_install(): set_execute_permissions() log.info('+ Marked scripts as executable') + + #Install the command completion script + if shutil.which('edkrepo') is not None: + if args.local: + command_completion_script = os.path.join(default_cfg_dir, 'edkrepo_completions.sh') + else: + command_completion_script = os.path.join('/', 'etc', 'profile.d', 'edkrepo_completions.sh') + try: + res = default_run(['edkrepo', 'generate-command-completion-script', command_completion_script]) + if args.local: + shutil.chown(command_completion_script, user=username) + os.chmod(command_completion_script, 0o644) + add_command_completions_to_shell(command_completion_script, args, username, user_home_dir) + except: + log.info('- Failed to configure edkrepo command completion') + if args.verbose: + traceback.print_exc() log.log(logging.PRINT, '\nInstallation complete\n') return 0 -- 2.24.0.windows.2
|
|
[edk2-staging/EdkRepo] [PATCH V1 1/3] EdkRepo: Generate command completion scripts
Adds code to edkrepo_cli.py to generate a bash/zsh
compatible command completion script. Add a new command_completion_edkrepo.py script which is callable by the shell when needed for dynamic completion data. For example, providing completion for "edkrepo checkout" requires the shell to know the list of possible branch combinations, this requires parsing the manifest XML. command_completion_edkrepo.py provides a means for the shell to get that type of data. Cc: Ashley DeSimone <ashley.e.desimone@...> Cc: Puja Pandya <puja.pandya@...> Cc: Erik Bjorge <erik.c.bjorge@...> Cc: Prince Agyeman <prince.agyeman@...> Cc: Bret Barkelew <Bret.Barkelew@...> Cc: Philippe Mathieu-Daude <philmd@...> Signed-off-by: Nate DeSimone <nathaniel.l.desimone@...> --- edkrepo/command_completion_edkrepo.py | 86 +++++++++++++++++++++++++++ edkrepo/edkrepo_cli.py | 61 ++++++++++++++++++- setup.py | 8 +-- 3 files changed, 150 insertions(+), 5 deletions(-) create mode 100644 edkrepo/command_completion_edkrepo.py diff --git a/edkrepo/command_completion_edkrepo.py b/edkrepo/command_completion_edkrepo.py new file mode 100644 index 0000000..05de9ca --- /dev/null +++ b/edkrepo/command_completion_edkrepo.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python3 +# +## @file +# command_completion_edkrepo.py +# +# Copyright (c) 2020, Intel Corporation. All rights reserved.<BR> +# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +import argparse +import io +import os +import sys +import traceback + +from edkrepo_manifest_parser.edk_manifest import ManifestXml +from edkrepo.config import config_factory +from edkrepo.config.config_factory import get_workspace_manifest + +def checkout(parsed_args, config): + manifest = get_workspace_manifest() + print(' '.join([c.name for c in manifest.combinations])) + +def current_combo(parsed_args, config): + manifest = get_workspace_manifest() + print(" [{}]".format(manifest.general_config.current_combo)) + +def checkout_pin(parsed_args, config): + pins = [] + manifest_directory = config['cfg_file'].manifest_repo_abs_local_path + manifest = get_workspace_manifest() + pin_folder = os.path.normpath(os.path.join(manifest_directory, manifest.general_config.pin_path)) + for dirpath, _, filenames in os.walk(pin_folder): + for file in filenames: + pin_file = os.path.join(dirpath, file) + # Capture error output from manifest parser stdout so it is hidden unless verbose is enabled + stdout = sys.stdout + sys.stdout = io.StringIO() + pin = ManifestXml(pin_file) + parse_output = sys.stdout.getvalue() + sys.stdout = stdout + if parsed_args.verbose and parse_output.strip() != '': + print('Pin {} Parsing Errors: {}\n'.format(file, parse_output.strip())) + if pin.project_info.codename == manifest.project_info.codename: + pins.append(file) + print(' '.join(pins)) + +# To add command completions for a new command, add an entry to this dictionary. +command_completions = { + 'current-combo': current_combo, + 'checkout': checkout, + 'checkout-pin': checkout_pin, + 'chp': checkout_pin +} + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("-v", "--verbose", action="store_true", help='Increases command verbosity') + subparsers = parser.add_subparsers(dest='subparser_name') + for command_completion in command_completions: + subparsers.add_parser(command_completion, formatter_class=argparse.RawTextHelpFormatter) + if len(sys.argv) <= 1: + return 0 + parsed_args = parser.parse_args() + try: + command_name = parsed_args.subparser_name + config = {} + config["cfg_file"] = config_factory.GlobalConfig() + config["user_cfg_file"] = config_factory.GlobalUserConfig() + if command_name not in command_completions: + return 1 + command_completions[command_name](parsed_args, config) + return 0 + except Exception as e: + if parsed_args.verbose: + traceback.print_exc() + print("Error: {}".format(str(e))) + return 1 + return 0 + +if __name__ == "__main__": + try: + sys.exit(main()) + except Exception as e: + traceback.print_exc() + sys.exit(1) diff --git a/edkrepo/edkrepo_cli.py b/edkrepo/edkrepo_cli.py index 0b69860..03061c9 100644 --- a/edkrepo/edkrepo_cli.py +++ b/edkrepo/edkrepo_cli.py @@ -3,7 +3,7 @@ ## @file # edkrepo_cli.py # -# Copyright (c) 2017- 2019, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.<BR> # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -29,6 +29,7 @@ from edkrepo.common.edkrepo_exception import EdkrepoException, EdkrepoGlobalConf from edkrepo.common.edkrepo_exception import EdkrepoWarningException from edkrepo.common.edkrepo_exception import EdkrepoConfigFileInvalidException from edkrepo.common.humble import KEYBOARD_INTERRUPT, GIT_CMD_ERROR +from edkrepo.common.pathfix import get_actual_path def generate_command_line(command): parser = argparse.ArgumentParser() @@ -100,6 +101,61 @@ def generate_command_line(command): subparser_name.add_argument(('--' + arg.get('name')), action=arg_action, help=arg.get('help-text')) return parser +command_completion_script_header='''#!/usr/bin/env bash +# +## @file edkrepo_completions.sh +# +# Automatically generated please DO NOT modify !!! +# + +''' +def generate_command_completion_script(script_filename, parser): + import edkrepo.command_completion_edkrepo as completion + commands = [] + for action in parser._positionals._group_actions: + if action.choices is not None: + commands = [c for c in action.choices] + break + commands = sorted(commands) + commands_with_3rd_param_completion = [c for c in completion.command_completions if c in commands] + commands_with_3rd_param_completion = sorted(commands_with_3rd_param_completion) + with open(script_filename, 'w') as f: + f.write(command_completion_script_header) + if sys.platform == "win32": + command_completion_path = os.path.dirname(sys.executable) + command_completion_path = os.path.join(command_completion_path, 'Scripts', "command_completion_edkrepo.exe") + if not os.path.isfile(command_completion_path): + print('command_completion_edkrepo.exe not found') + return + command_completion_path = get_actual_path(command_completion_path) + (drive, path) = os.path.splitdrive(command_completion_path) + command_completion_path = '/{}{}'.format(drive.replace(':','').lower(), path.replace('\\','/')) + f.write("export command_completion_edkrepo_file='{}'\n".format(command_completion_path)) + f.write('alias command_completion_edkrepo="$command_completion_edkrepo_file"\n') + f.write('_edkrepo_completions() {\n if [ "${#COMP_WORDS[@]}" -eq "2" ]; then\n') + f.write(' COMPREPLY=($(compgen -W "{}" -- "${{COMP_WORDS[1]}}"))\n'.format(' '.join(commands))) + if len(commands_with_3rd_param_completion) > 0: + f.write(' elif [ "${#COMP_WORDS[@]}" -eq "3" ]; then\n') + first_loop = True + for command in commands_with_3rd_param_completion: + if first_loop: + f.write(' if [ "${{COMP_WORDS[1]}}" == "{}" ]; then\n'.format(command)) + first_loop = False + else: + f.write(' elif [ "${{COMP_WORDS[1]}}" == "{}" ]; then\n'.format(command)) + f.write(' COMPREPLY=($(compgen -W "$(command_completion_edkrepo ${COMP_WORDS[1]})" -- "${COMP_WORDS[2]}"))\n') + if len(commands_with_3rd_param_completion) > 0: + f.write(' fi\n') + f.write(' fi\n}\n\n') + if len(commands_with_3rd_param_completion) > 0: + if sys.platform == "win32": + f.write('if [ -x "$(command -v edkrepo)" ] && [ -x "$(command -v $command_completion_edkrepo_file)" ]; then\n') + else: + f.write('if [ -x "$(command -v edkrepo)" ] && [ -x "$(command -v command_completion_edkrepo)" ]; then\n') + else: + f.write('if [ -x "$(command -v edkrepo)" ]; then\n') + f.write(' complete -F _edkrepo_completions edkrepo\nfi\n') + def main(): command = command_factory.create_composite_command() config = {} @@ -117,6 +173,9 @@ def main(): if len(sys.argv) <= 1: parser.print_help() return 1 + if sys.argv[1] == 'generate-command-completion-script' and len(sys.argv) >= 3: + generate_command_completion_script(sys.argv[2], parser) + return 0 parsed_args = parser.parse_args() command_name = parsed_args.subparser_name try: diff --git a/setup.py b/setup.py index e14aed1..e7e6ce8 100755 --- a/setup.py +++ b/setup.py @@ -1,9 +1,8 @@ #!/usr/bin/env python3 # -## @file -# setup.py +## @file setup.py # -# Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.<BR> # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -20,7 +19,8 @@ setup(name='edkrepo', include_package_data=True, entry_points={ 'console_scripts': [ - 'edkrepo = edkrepo.edkrepo_entry_point:main' + 'edkrepo = edkrepo.edkrepo_entry_point:main', + 'command_completion_edkrepo = edkrepo.command_completion_edkrepo:main' ] } ) -- 2.24.0.windows.2
|
|
[edk2-staging/EdkRepo] [PATCH V1 0/3] EdkRepo: Command completion in bash/zsh
This patch series adds command completions (also referred to as
[TAB] completions) to EdkRepo. It also adds the currently checked out branch combination to the command prompt. This is a significant quality of life improvement for EdkRepo's users. The bash and zsh shells are supported. The reason why bash and zsh were choosen is based on their popularity in the UNIX world. zsh is the default shell on macOS and most contemporary Linux distributions use bash as the default shell. Git for Windows also uses bash. Performance was a strong consideration in the design of this feature. Since EdkRepo has become a fairly large amount of Python code with lots of dependencies, the "boot time" for the Python interperter to load and execute the EdkRepo entrypoint is approximately 1-2 seconds. A 2 second delay on TAB completion would not be a good user experience. To mitigate this, instead of enumerating and instantiating all the command classes to generate the list of EdkRepo sub-commands every time the user presses the TAB key, this is done once and stored in a auto-generated shell script at installation time. This way, the shell has all the information needed for static completions without having to invoke the Python interperter at all. There are cases where TAB completions need some dynamic data. For example, completing the 3rd parameter after "edkrepo checkout " requires the shell to know the list of branch combinations, this requires parsing the manifest XML. command_completion_edkrepo.py provides a means for the shell to get that type of data. A new command_completion_edkrepo.py script has been added for this purpose. command_completion_edkrepo.py is callable by the shell when dynamic completion data is needed. command_completion_edkrepo.py has been tuned to limit imports as much as possible so that it executes quickly. command_completion_edkrepo.py is also used to retrieve the currently checked out branch combination so that it can be added to the prompt. For performance considerations, this operation is only done iff the present working directory was changed by the last command the shell executed. Cc: Ashley DeSimone <ashley.e.desimone@...> Cc: Puja Pandya <puja.pandya@...> Cc: Erik Bjorge <erik.c.bjorge@...> Cc: Prince Agyeman <prince.agyeman@...> Cc: Bret Barkelew <Bret.Barkelew@...> Cc: Philippe Mathieu-Daude <philmd@...> Signed-off-by: Nate DeSimone <nathaniel.l.desimone@...> Nate DeSimone (3): EdkRepo: Generate command completion scripts EdkRepo: Add command completion setup to install.py EdkRepo: Add command completion setup to Windows installer edkrepo/command_completion_edkrepo.py | 86 ++++++ edkrepo/edkrepo_cli.py | 61 +++- .../EdkRepoInstaller/InstallWorker.cs | 212 +++++++++++-- .../EdkRepoInstaller/InstallerStrings.cs | 44 ++- .../Vendor/win_edkrepo_prompt.sh | 60 ++++ edkrepo_installer/linux-scripts/install.py | 285 +++++++++++++++++- setup.py | 8 +- 7 files changed, 729 insertions(+), 27 deletions(-) create mode 100644 edkrepo/command_completion_edkrepo.py create mode 100644 edkrepo_installer/Vendor/win_edkrepo_prompt.sh -- 2.24.0.windows.2
|
|
Re: [edk2-staging/EdkRepo] [PATCH v1 7/7] EdkRepo: Update List Repos for archived combos
Ashley E Desimone
Reviewed-by: Ashley DeSimone <ashley.e.desimone@...>
toggle quoted messageShow quoted text
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Bjorge, Erik C Sent: Tuesday, March 31, 2020 3:42 PM To: devel@edk2.groups.io Cc: Desimone, Nathaniel L <nathaniel.l.desimone@...>; Pandya, Puja <puja.pandya@...>; Bret Barkelew <Bret.Barkelew@...>; Agyeman, Prince <prince.agyeman@...> Subject: [edk2-devel] [edk2-staging/EdkRepo] [PATCH v1 7/7] EdkRepo: Update List Repos for archived combos When running the List Repos command archived combos will not be listed unless the archived flag is provided. Signed-off-by: Erik Bjorge <erik.c.bjorge@...> Cc: Nate DeSimone <nathaniel.l.desimone@...> Cc: Puja Pandya <puja.pandya@...> Cc: Bret Barkelew <Bret.Barkelew@...> Cc: Prince Agyeman <prince.agyeman@...> --- edkrepo/commands/list_repos_command.py | 37 ++++++++++++++++++-------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/edkrepo/commands/list_repos_command.py b/edkrepo/commands/list_repos_command.py index caf0373..b06a493 100644 --- a/edkrepo/commands/list_repos_command.py +++ b/edkrepo/commands/list_repos_command.py @@ -3,7 +3,7 @@ ## @file # list_repos_command.py # -# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2019 - 2020, Intel Corporation. All rights +reserved.<BR> # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -74,7 +74,10 @@ class ListReposCommand(EdkrepoCommand): xml_file = ci_index_xml.get_project_xml(project) manifest = ManifestXml(os.path.normpath(os.path.join(global_manifest_directory, xml_file))) manifests[project] = manifest - for combo in [c.name for c in manifest.combinations]: + combo_list = [c.name for c in manifest.combinations] + if args.archived: + combo_list.extend([c.name for c in manifest.archived_combinations]) + for combo in combo_list: sources = manifest.get_repo_sources(combo) for source in sources: repo_urls.add(self.get_repo_url(source.remote_url)) @@ -84,7 +87,7 @@ class ListReposCommand(EdkrepoCommand): project_justify = len(max(manifests.keys(), key=len)) #Determine the names of the repositories - self.generate_repo_names(repo_urls, manifests) + self.generate_repo_names(repo_urls, manifests, args.archived) print(humble.REPOSITORIES) #If the user provided a list of repositories to view, check to make sure @@ -103,7 +106,10 @@ class ListReposCommand(EdkrepoCommand): #Determine the list of branches that used by any branch combination in any manifest branches = set() for project_name in manifests: - for combo in [c.name for c in manifests[project_name].combinations]: + combo_list = [c.name for c in manifests[project_name].combinations] + if args.archived: + combo_list.extend([c.name for c in manifests[project_name].archived_combinations]) + for combo in combo_list: sources = manifests[project_name].get_repo_sources(combo) for source in sources: if self.get_repo_url(source.remote_url) == repo: @@ -124,7 +130,10 @@ class ListReposCommand(EdkrepoCommand): #Determine the branch combinations that use that branch for project_name in manifests: combos = [] - for combo in [c.name for c in manifests[project_name].combinations]: + combo_list = [c.name for c in manifests[project_name].combinations] + if args.archived: + combo_list.extend([c.name for c in manifests[project_name].archived_combinations]) + for combo in combo_list: sources = manifests[project_name].get_repo_sources(combo) for source in sources: if self.get_repo_url(source.remote_url) == repo and source.branch == branch: @@ -165,11 +174,11 @@ class ListReposCommand(EdkrepoCommand): return name raise EdkrepoInvalidParametersException(humble.REPO_NAME_NOT_FOUND) - def generate_repo_names(self, repo_urls, manifests): + def generate_repo_names(self, repo_urls, manifests, archived=False): #Determine the names of the repositories self.repo_names = collections.OrderedDict() for repo_url in repo_urls: - self.__repo_name_worker(repo_url, manifests) + self.__repo_name_worker(repo_url, manifests, archived) #Sort the git repositories so they will be displayed alphabetically self.repo_names = collections.OrderedDict(sorted(self.repo_names.items())) @@ -188,12 +197,15 @@ class ListReposCommand(EdkrepoCommand): for name_to_move in names_to_move: self.repo_names.move_to_end(name_to_move, False) - def __repo_name_worker(self, repo_url, manifests): + def __repo_name_worker(self, repo_url, manifests, archived=False): #This is a heuristic that guesses the "name" of a repository by looking #at the name given to it by the most manifest files. names = collections.defaultdict(int) for project_name in manifests: - for combo in [c.name for c in manifests[project_name].combinations]: + combo_list = [c.name for c in manifests[project_name].combinations] + if archived: + combo_list.extend([c.name for c in manifests[project_name].archived_combinations]) + for combo in combo_list: sources = manifests[project_name].get_repo_sources(combo) for source in sources: if self.get_repo_url(source.remote_url) == repo_url: @@ -209,7 +221,10 @@ class ListReposCommand(EdkrepoCommand): #If only 1 project uses this name, then append the project #name to the directory name to create the repo name for project_name in manifests: - for combo in [c.name for c in manifests[project_name].combinations]: + combo_list = [c.name for c in manifests[project_name].combinations] + if archived: + combo_list.extend([c.name for c in manifests[project_name].archived_combinations]) + for combo in combo_list: sources = manifests[project_name].get_repo_sources(combo) for source in sources: if self.get_repo_url(source.remote_url) == repo_url and source.root == original_best_name: @@ -239,7 +254,7 @@ class ListReposCommand(EdkrepoCommand): del self.repo_names[best_name] found_unique_name = True self.repo_names[best_name] = (repo_url, best_name_frequency) - self.__repo_name_worker(old_repo_url, manifests) + self.__repo_name_worker(old_repo_url, + manifests, archived) else: #Use the name given by the second most manifest files del names[best_name] -- 2.21.0.windows.1
|
|
Re: [edk2-staging/EdkRepo] [PATCH v1 6/7] EdkRepo: Update clone for archived combos
Ashley E Desimone
Reviewed-by: Ashley DeSimone <ashley.e.desimone@...>
toggle quoted messageShow quoted text
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Bjorge, Erik C Sent: Tuesday, March 31, 2020 3:42 PM To: devel@edk2.groups.io Cc: Desimone, Nathaniel L <nathaniel.l.desimone@...>; Pandya, Puja <puja.pandya@...>; Bret Barkelew <Bret.Barkelew@...>; Agyeman, Prince <prince.agyeman@...> Subject: [edk2-devel] [edk2-staging/EdkRepo] [PATCH v1 6/7] EdkRepo: Update clone for archived combos Adding support for archived combos in the clone command. Signed-off-by: Erik Bjorge <erik.c.bjorge@...> Cc: Nate DeSimone <nathaniel.l.desimone@...> Cc: Puja Pandya <puja.pandya@...> Cc: Bret Barkelew <Bret.Barkelew@...> Cc: Prince Agyeman <prince.agyeman@...> --- edkrepo/commands/clone_command.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/edkrepo/commands/clone_command.py b/edkrepo/commands/clone_command.py index 2400272..701a853 100644 --- a/edkrepo/commands/clone_command.py +++ b/edkrepo/commands/clone_command.py @@ -3,7 +3,7 @@ ## @file # clone_command.py # -# Copyright (c) 2017- 2019, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2017- 2020, Intel Corporation. All rights reserved.<BR> # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -16,7 +16,7 @@ import edkrepo.commands.arguments.clone_args as arguments from edkrepo.common.common_repo_functions import pull_latest_manifest_repo, clone_repos, sparse_checkout, verify_manifest_data from edkrepo.common.common_repo_functions import case_insensitive_single_match, update_editor_config from edkrepo.common.common_repo_functions import write_included_config, write_conditional_include -from edkrepo.common.common_repo_functions import find_project_in_index +from edkrepo.common.common_repo_functions import find_project_in_index, +combinations_in_manifest from edkrepo.common.edkrepo_exception import EdkrepoInvalidParametersException, EdkrepoManifestInvalidException from edkrepo.common.humble import CLONE_INVALID_WORKSPACE, CLONE_INVALID_PROJECT_ARG, CLONE_INVALID_COMBO_ARG from edkrepo.common.humble import SPARSE_CHECKOUT, CLONE_INVALID_LOCAL_ROOTS @@ -99,7 +99,7 @@ class CloneCommand(EdkrepoCommand): combo_name = None if args.Combination is not None: try: - combo_name = case_insensitive_single_match(args.Combination, [x.name for x in manifest.combinations]) + combo_name = + case_insensitive_single_match(args.Combination, + combinations_in_manifest(manifest)) except: #remove the repo directory and Manifest.xml from the workspace so the next time the user trys to clone #they will have an empty workspace and then raise an exception -- 2.21.0.windows.1
|
|
Re: [edk2-staging/EdkRepo] [PATCH v1 5/7] EdkRepo: Update Checkout Pin for archived combos
Ashley E Desimone
Reviewed-by: Ashley DeSimone <ashley.e.desimone@...>
toggle quoted messageShow quoted text
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Bjorge, Erik C Sent: Tuesday, March 31, 2020 3:42 PM To: devel@edk2.groups.io Cc: Desimone, Nathaniel L <nathaniel.l.desimone@...>; Pandya, Puja <puja.pandya@...>; Bret Barkelew <Bret.Barkelew@...>; Agyeman, Prince <prince.agyeman@...> Subject: [edk2-devel] [edk2-staging/EdkRepo] [PATCH v1 5/7] EdkRepo: Update Checkout Pin for archived combos Added support for archived combos in the Checkout Pin command. Signed-off-by: Erik Bjorge <erik.c.bjorge@...> Cc: Nate DeSimone <nathaniel.l.desimone@...> Cc: Puja Pandya <puja.pandya@...> Cc: Bret Barkelew <Bret.Barkelew@...> Cc: Prince Agyeman <prince.agyeman@...> --- edkrepo/commands/checkout_pin_command.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/edkrepo/commands/checkout_pin_command.py b/edkrepo/commands/checkout_pin_command.py index a2afc41..858271a 100644 --- a/edkrepo/commands/checkout_pin_command.py +++ b/edkrepo/commands/checkout_pin_command.py @@ -15,7 +15,7 @@ from edkrepo.commands.edkrepo_command import EdkrepoCommand, OverrideArgument import edkrepo.commands.arguments.checkout_pin_args as arguments import edkrepo.commands.humble.checkout_pin_humble as humble from edkrepo.common.common_repo_functions import sparse_checkout_enabled, reset_sparse_checkout, sparse_checkout -from edkrepo.common.common_repo_functions import check_dirty_repos, checkout_repos +from edkrepo.common.common_repo_functions import check_dirty_repos, +checkout_repos, combinations_in_manifest from edkrepo.common.humble import SPARSE_CHECKOUT, SPARSE_RESET from edkrepo.common.edkrepo_exception import EdkrepoInvalidParametersException, EdkrepoProjectMismatchException from edkrepo.config.config_factory import get_workspace_path, get_workspace_manifest @@ -89,7 +89,7 @@ class CheckoutPinCommand(EdkrepoCommand): raise EdkrepoProjectMismatchException(humble.MANIFEST_MISMATCH) elif not set(pin.remotes).issubset(set(manifest.remotes)): raise EdkrepoProjectMismatchException(humble.MANIFEST_MISMATCH) - elif pin.general_config.current_combo not in [c.name for c in manifest.combinations]: + elif pin.general_config.current_combo not in combinations_in_manifest(manifest): raise EdkrepoProjectMismatchException(humble.MANIFEST_MISMATCH) combo_name = pin.general_config.current_combo pin_sources = pin.get_repo_sources(combo_name) -- 2.21.0.windows.1
|
|
Re: [edk2-staging/EdkRepo] [PATCH v1 4/7] EdkRepo: Update Sync for archived combos
Ashley E Desimone
Reviewed-by: Ashley DeSimone <ashley.e.desimone@...>
toggle quoted messageShow quoted text
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Bjorge, Erik C Sent: Tuesday, March 31, 2020 3:42 PM To: devel@edk2.groups.io Cc: Desimone, Nathaniel L <nathaniel.l.desimone@...>; Pandya, Puja <puja.pandya@...>; Bret Barkelew <Bret.Barkelew@...>; Agyeman, Prince <prince.agyeman@...> Subject: [edk2-devel] [edk2-staging/EdkRepo] [PATCH v1 4/7] EdkRepo: Update Sync for archived combos Added support for archived combos in Sync command. Signed-off-by: Erik Bjorge <erik.c.bjorge@...> Cc: Nate DeSimone <nathaniel.l.desimone@...> Cc: Puja Pandya <puja.pandya@...> Cc: Bret Barkelew <Bret.Barkelew@...> Cc: Prince Agyeman <prince.agyeman@...> --- edkrepo/commands/sync_command.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/edkrepo/commands/sync_command.py b/edkrepo/commands/sync_command.py index 71c600a..daa558f 100644 --- a/edkrepo/commands/sync_command.py +++ b/edkrepo/commands/sync_command.py @@ -3,7 +3,7 @@ ## @file # sync_command.py # -# Copyright (c) 2017- 2019, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2017- 2020, Intel Corporation. All rights reserved.<BR> # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -19,7 +19,7 @@ from git import Repo # Our modules from edkrepo.commands.edkrepo_command import EdkrepoCommand from edkrepo.commands.edkrepo_command import DryRunArgument, SubmoduleSkipArgument -import edkrepo.commands.arguments.sync_args as arguments +import edkrepo.commands.arguments.sync_args as arguments from edkrepo.common.progress_handler import GitProgressHandler from edkrepo.common.edkrepo_exception import EdkrepoUncommitedChangesException, EdkrepoManifestNotFoundException from edkrepo.common.edkrepo_exception import EdkrepoManifestChangedException @@ -38,7 +38,7 @@ from edkrepo.common.common_repo_functions import generate_name_for_obsolete_back from edkrepo.common.common_repo_functions import update_editor_config from edkrepo.common.common_repo_functions import update_repo_commit_template, get_latest_sha from edkrepo.common.common_repo_functions import has_primary_repo_remote, fetch_from_primary_repo, in_sync_with_primary -from edkrepo.common.common_repo_functions import update_hooks, maintain_submodules +from edkrepo.common.common_repo_functions import update_hooks, +maintain_submodules, combinations_in_manifest from edkrepo.common.common_repo_functions import write_included_config, remove_included_config from edkrepo.common.ui_functions import init_color_console from edkrepo.config.config_factory import get_workspace_path, get_workspace_manifest, get_edkrepo_global_data_directory @@ -53,22 +53,22 @@ class SyncCommand(EdkrepoCommand): def get_metadata(self): metadata = {} metadata['name'] = 'sync' - metadata['help-text'] = arguments.COMMAND_DESCRIPTION + metadata['help-text'] = arguments.COMMAND_DESCRIPTION args = [] metadata['arguments'] = args args.append({'name' : 'fetch', 'positional' : False, 'required' : False, - 'help-text': arguments.FETCH_HELP}) + 'help-text': arguments.FETCH_HELP}) args.append({'name' : 'update-local-manifest', 'short-name': 'u', 'required' : False, - 'help-text' : arguments.UPDATE_LOCAL_MANIFEST_HELP}) + 'help-text' : + arguments.UPDATE_LOCAL_MANIFEST_HELP}) args.append({'name' : 'override', 'short-name': 'o', 'positional' : False, 'required' : False, - 'help-text' : arguments.OVERRIDE_HELP}) + 'help-text' : arguments.OVERRIDE_HELP}) args.append(SubmoduleSkipArgument) return metadata @@ -222,7 +222,7 @@ class SyncCommand(EdkrepoCommand): if initial_manifest_remotes[remote_name] != new_manifest_remotes[remote_name]: raise EdkrepoManifestChangedException(SYNC_URL_CHANGE.format(remote_name)) #check to see if the currently checked out combo exists in the new manifest. - new_combos = [c.name for c in new_manifest_to_check.combinations] + new_combos = combinations_in_manifest(new_manifest_to_check) if current_combo not in new_combos: raise EdkrepoManifestChangedException(SYNC_COMBO_CHANGE.format(current_combo, initial_manifest.project_info.codename)) -- 2.21.0.windows.1
|
|
Re: [edk2-staging/EdkRepo] [PATCH v1 3/7] EdkRepo: Update Checkout for archived combos
Ashley E Desimone
Reviewed-by: Ashley DeSimone <ashley.e.desimone@...>
toggle quoted messageShow quoted text
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Bjorge, Erik C Sent: Tuesday, March 31, 2020 3:42 PM To: devel@edk2.groups.io Cc: Desimone, Nathaniel L <nathaniel.l.desimone@...>; Pandya, Puja <puja.pandya@...>; Bret Barkelew <Bret.Barkelew@...>; Agyeman, Prince <prince.agyeman@...> Subject: [edk2-devel] [edk2-staging/EdkRepo] [PATCH v1 3/7] EdkRepo: Update Checkout for archived combos Now either an active or archived branch combination can be checked out. Signed-off-by: Erik Bjorge <erik.c.bjorge@...> Cc: Nate DeSimone <nathaniel.l.desimone@...> Cc: Puja Pandya <puja.pandya@...> Cc: Bret Barkelew <Bret.Barkelew@...> Cc: Prince Agyeman <prince.agyeman@...> --- edkrepo/common/common_repo_functions.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/edkrepo/common/common_repo_functions.py b/edkrepo/common/common_repo_functions.py index 288dd27..160127b 100644 --- a/edkrepo/common/common_repo_functions.py +++ b/edkrepo/common/common_repo_functions.py @@ -494,8 +494,14 @@ def sort_commits(manifest, workspace_path, max_commits=None): return sorted_commit_list -def combination_is_in_manifest(combination, manifest): +def combinations_in_manifest(manifest): combination_names = [c.name for c in manifest.combinations] + combination_names.extend([c.name for c in manifest.archived_combinations]) + return combination_names + + +def combination_is_in_manifest(combination, manifest): + combination_names = combinations_in_manifest(manifest) return combination in combination_names @@ -557,7 +563,7 @@ def checkout(combination_or_sha, verbose=False, override=False, log=None): combo_or_sha = combination_or_sha try: # Try to handle normalize combo name to match the manifest file. - combo_or_sha = case_insensitive_single_match(combo_or_sha, [x.name for x in manifest.combinations]) + combo_or_sha = case_insensitive_single_match(combo_or_sha, combinations_in_manifest()) except: # No match so leave it alone. It must be a SHA1 or a bad combo name. pass -- 2.21.0.windows.1
|
|
Re: [edk2-staging/EdkRepo] [PATCH v1 2/7] EdkRepo: Added ability to display archived combinations
Ashley E Desimone
Reviewed-by: Ashley DeSimone <ashley.e.desimone@...>
toggle quoted messageShow quoted text
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Bjorge, Erik C Sent: Tuesday, March 31, 2020 3:42 PM To: devel@edk2.groups.io Cc: Desimone, Nathaniel L <nathaniel.l.desimone@...>; Pandya, Puja <puja.pandya@...>; Bret Barkelew <Bret.Barkelew@...>; Agyeman, Prince <prince.agyeman@...> Subject: [edk2-devel] [edk2-staging/EdkRepo] [PATCH v1 2/7] EdkRepo: Added ability to display archived combinations Added support for using the -a / --archived flags to include archived combinations. Signed-off-by: Erik Bjorge <erik.c.bjorge@...> Cc: Nate DeSimone <nathaniel.l.desimone@...> Cc: Puja Pandya <puja.pandya@...> Cc: Bret Barkelew <Bret.Barkelew@...> Cc: Prince Agyeman <prince.agyeman@...> --- edkrepo/commands/arguments/combo_args.py | 5 +++-- edkrepo/commands/combo_command.py | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/edkrepo/commands/arguments/combo_args.py b/edkrepo/commands/arguments/combo_args.py index af3ded9..dabb464 100644 --- a/edkrepo/commands/arguments/combo_args.py +++ b/edkrepo/commands/arguments/combo_args.py @@ -3,7 +3,7 @@ ## @file # combo_args.py # -# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2019 - 2020, Intel Corporation. All rights +reserved.<BR> # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -11,4 +11,5 @@ combo command meta data. ''' -COMMAND_DESCRIPTION = 'Displays the currently checked out combination and lists all available combinations.' \ No newline at end of file +COMMAND_DESCRIPTION = 'Displays the currently checked out combination and lists all available combinations.' +ARCHIVED_HELP = 'Include a listing of archived combinations.' diff --git a/edkrepo/commands/combo_command.py b/edkrepo/commands/combo_command.py index 68d6854..9e13f47 100644 --- a/edkrepo/commands/combo_command.py +++ b/edkrepo/commands/combo_command.py @@ -3,10 +3,11 @@ ## @file # combo_command.py # -# Copyright (c) 2017- 2019, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2017- 2020, Intel Corporation. All rights reserved.<BR> # SPDX-License-Identifier: BSD-2-Clause-Patent # from colorama import Fore +from colorama import Style from edkrepo.commands.edkrepo_command import EdkrepoCommand from edkrepo.commands.edkrepo_command import ColorArgument @@ -25,6 +26,11 @@ class ComboCommand(EdkrepoCommand): metadata['help-text'] = arguments.COMMAND_DESCRIPTION args = [] metadata['arguments'] = args + args.append({'name': 'archived', + 'short-name': 'a', + 'positional': False, + 'required': False, + 'help-text': arguments.ARCHIVED_HELP}) args.append(ColorArgument) return metadata @@ -32,9 +38,18 @@ class ComboCommand(EdkrepoCommand): init_color_console(args.color) manifest = get_workspace_manifest() - for combo in [c.name for c in manifest.combinations]: + combo_archive = [] + combo_list = [c.name for c in manifest.combinations] + if args.archived: + combo_archive = [c.name for c in manifest.archived_combinations] + combo_list.extend(combo_archive) + if manifest.general_config.current_combo not in combo_list: + combo_list.append(manifest.general_config.current_combo) + for combo in sorted(combo_list): if combo == manifest.general_config.current_combo: print("* {}{}{}".format(Fore.GREEN, combo, Fore.RESET)) + elif combo in combo_archive: + print(" {}{}{}{}".format(Fore.YELLOW, Style.BRIGHT, + combo, Style.RESET_ALL)) else: print(" {}".format(combo)) if args.verbose: -- 2.21.0.windows.1
|
|
Re: [edk2-staging/EdkRepo] [PATCH v1 1/7] EdkRepo: Adding support for archiving combos
Ashley E Desimone
Reviewed-by: Ashley DeSimone <ashley.e.desimone@...>
toggle quoted messageShow quoted text
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Bjorge, Erik C Sent: Tuesday, March 31, 2020 3:42 PM To: devel@edk2.groups.io Cc: Desimone, Nathaniel L <nathaniel.l.desimone@...>; Pandya, Puja <puja.pandya@...>; Bret Barkelew <Bret.Barkelew@...>; Agyeman, Prince <prince.agyeman@...> Subject: [edk2-devel] [edk2-staging/EdkRepo] [PATCH v1 1/7] EdkRepo: Adding support for archiving combos Adding support to check the archived attribute on branch combos. This allows a combo to be archived and available if required but not dirty up the combo list. Signed-off-by: Erik Bjorge <erik.c.bjorge@...> Cc: Nate DeSimone <nathaniel.l.desimone@...> Cc: Puja Pandya <puja.pandya@...> Cc: Bret Barkelew <Bret.Barkelew@...> Cc: Prince Agyeman <prince.agyeman@...> --- edkrepo_manifest_parser/edk_manifest.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/edkrepo_manifest_parser/edk_manifest.py b/edkrepo_manifest_parser/edk_manifest.py index dd3512b..7b513dc 100644 --- a/edkrepo_manifest_parser/edk_manifest.py +++ b/edkrepo_manifest_parser/edk_manifest.py @@ -306,7 +306,11 @@ class ManifestXml(BaseXmlHelper): @property def combinations(self): - return self._tuple_list(self.__combinations.values()) + return self._tuple_list([x for x in + self.__combinations.values() if not x.archived]) + + @property + def archived_combinations(self): + return self._tuple_list([x for x in + self.__combinations.values() if x.archived]) def get_repo_sources(self, combo_name): if combo_name in self.__combo_sources: @@ -645,6 +649,10 @@ class _Combination(): self.description = element.attrib['description'] except: self.description = None #description is optional attribute + try: + self.archived = (element.attrib['archived'].lower() == 'true') + except: + self.archived = False @property def tuple(self): -- 2.21.0.windows.1
|
|
Re: [PATCH v2 00/28] Add PEI phase to LS1043ARDB Platform
Leif Lindholm
Hi Pankaj,
toggle quoted messageShow quoted text
I have now finished my review of individual patches. Beyond that, the build fails at the patch 10/28 "Silicon/NXP: remove print information from Soc lib" with the error edk2-platforms/Silicon/NXP/Library/SocLib/Chassis.c:209:1: error: ‘CpuMaskNext’ defined but not used [-Werror=unused-function] The function is deleted in the subsequent patch, 11/28 "Silicon/NXP: remove not needed components". Please move that deletion to the now failing patch. Regards, Leif
On Fri, Mar 20, 2020 at 20:05:15 +0530, Pankaj Bansal wrote:
From: Pankaj Bansal <pankaj.bansal@...>
|
|
Re: [PATCH v6 00/42] SEV-ES guest support
Lendacky, Thomas
On 3/30/20 7:47 PM, Dong, Eric wrote:
Hi Tom,Ok, will do. 2.All functions need to have comments for them. Miss comments in patch 10/42 and others.Just external functions or both external and internal (STATIC) functions, too? Thanks, Tom Please update patches to fix above basic checks first.
|
|
Re: [PATCH v2 27/28] Silicon/NXP: move MemoryInitPeiLib as per PEIM structures
Leif Lindholm
On Fri, Mar 20, 2020 at 20:05:42 +0530, Pankaj Bansal wrote:
From: Pankaj Bansal <pankaj.bansal@...>Reviewed-by: Leif Lindholm <leif@...> ---
|
|
Re: [PATCH v2 26/28] Platform/NXP/LS1043aRdbPkg: Add VarStore
Leif Lindholm
On Fri, Mar 20, 2020 at 20:05:41 +0530, Pankaj Bansal wrote:
From: Pankaj Bansal <pankaj.bansal@...>Reviewed-by: Leif Lindholm <leif@...> ---
|
|
Re: [PATCH v2 25/28] Platform/NXP: Modify FV rules
Leif Lindholm
Please make the subject contain information.
toggle quoted messageShow quoted text
/ Leif
On Fri, Mar 20, 2020 at 20:05:40 +0530, Pankaj Bansal wrote:
From: Pankaj Bansal <pankaj.bansal@...>
|
|
Re: [PATCH v2 24/28] NXP/LS1043aRdbPkg/ArmPlatformLib: Remove extern SocInit
Leif Lindholm
On Fri, Mar 20, 2020 at 20:05:39 +0530, Pankaj Bansal wrote:
From: Pankaj Bansal <pankaj.bansal@...>Reviewed-by: Leif Lindholm <leif@...> But do please move it as early as possible in the series. ---
|
|
Re: [PATCH v2 23/28] NXP/LS1043aRdbPkg/ArmPlatformLib: Use Allocate pool
Leif Lindholm
On Fri, Mar 20, 2020 at 20:05:38 +0530, Pankaj Bansal wrote:
From: Pankaj Bansal <pankaj.bansal@...>I don't object to this as such (although one comment), but what is the purpose of this change? My comment is that most other platforms use AllocatePages for this. So this is diverging from the norm. Secondly, while I don't necessarily *like* the current design (copied across most ARM platforms), it's somewhat mitigated by the AllocatePages giving you a minimum of 128 entries before you start overwriting things. I don't know what you'll overwrite if you do go too far, but you will overwrite it *before* the ASSERT ever gets evaluated. / Leif ---
|
|
Re: [PATCH 0/4] remove generation of EFI properties table
Ard Biesheuvel
On Mon, 30 Mar 2020 at 19:57, Ard Biesheuvel <ard.biesheuvel@...> wrote:
Jian, Hao, Liming, Michael, It is not always clear to me how you at Intel divide up the maintainer duties between yourselves. Liming and Jiewen have acked this entire series, but they are not the MdeModulePkg maintainers, so I assume either Jian or Hao should approve it as well before i can proceed with it. If this is the case, could Jian and Hao please acknowledge that they read this email, and perhaps indicate a timeframe within which they will be able to give their verdict on these changes? Thanks, Ard.
|
|
Re: [PATCH] CryptoPkg/FltUsedLib: Add FltUsedLib for float.
Michael D Kinney
Hi Ard,
toggle quoted messageShow quoted text
I think adding a dependency in the module entry point libs is also good way to guarantee an intrinsic lib is available. I agree that it can provide module type and arch specific mappings. The NULL lib instance can do the same if the NULL instance is listed in the module/arch specific library classes sections. a few example section names. [LibraryClasses.ARM.PEIM, LibraryClasses.AARCH64.PEIM] [LibraryClasses.IA32.UEFI_DRIVER] [LibraryClasses.X64.DXE_DRIVER] So either way, the DSC files need to provide the library mapping. The only difference between these 2 approaches is that adding a dependency to the module entry point libs uses a formally defined library class name for the intrinsic functions vs. the un-named NULL library instance. A formally defined library class name is better supported for things like unit tests from the UnitTestFrameworkPkg. The fltused issue would not go away of we removed the float usage for OpenSSL. One or more other libs or the module could use float/double types and this issue would pop up again. I do agree it would be cleaner if we could use OpenSSL without floating point. I think adding an intrinsic lib for IA32/X64 for VS20xx generation of intrinsic functions would address fltused and other common C implementation styles that generate intrinsic functions (e.g. 64-bit int math on 32-bit, structure variable assignments, and loops that fill a buffer with a const value) by VS20xx compilers. An intrinsic lib for GCC would also help with these same common C implementation styles that generate intrinsic functions. Mike
-----Original Message-----
|
|