From nobody Mon May 6 17:38:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+59152+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+59152+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1589217505; cv=none; d=zohomail.com; s=zohoarc; b=P0MVg8Tarl/ndix69ecKNdWgJaS4kvBnuMVfEQDC8dqfoFg+DofDqF0Yg/WtVmrEV7WpfEpSLORBEtRva7/C3WXt4tyQSpWsiVbITMSUKXm1XRyYRKFlCYYaYqwdbiV5xnFnD1wXEmKxPgTQTzm5PQKpxGqGNcEwFr13k3nz4Rs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589217505; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To; bh=ss8HcbB9SiJA7XVkjFrLn0JmMzsTPZdQnY2oIaZHDmU=; b=McVYriMRzTAev2wmTotNSFCCzQo7AjlWVJoVmijbb3jhdjzi8xAAqmF+mimKbyUOVgcH08PL4ZoX+FWd1ts0mZYBbd8XOdFSrFLTd8pn055iCnjcbePQhhrvG8uT0yILq5+mLazYxRhbmkYHR9/Gy9JcZtye05TugSN6eQxo5I0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+59152+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1589217505040548.7837055476836; Mon, 11 May 2020 10:18:25 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id I4E1YY1788612xH2IMsm3ekR; Mon, 11 May 2020 10:18:24 -0700 X-Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web11.1430.1589217503734754489 for ; Mon, 11 May 2020 10:18:24 -0700 IronPort-SDR: KvEChzfrz4bzxHMXJ+3JC1Bp8YjvVEfFsZtAm/PLR5Poezs7JCgi243kjXb3miPBe9LerxjSC/ 87ZOp3pdI1+w== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2020 10:18:23 -0700 IronPort-SDR: YOk9Rk+PoyKeafJGonpzAfkkst8DA18edIOS0LWqh+ydAZCQRNWKyjj4o+zYwWVD4ixOjfKiMQ C2pGGIw9jD6Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,380,1583222400"; d="scan'208";a="250615449" X-Received: from aedesimo-desk.amr.corp.intel.com ([10.212.18.220]) by orsmga007.jf.intel.com with ESMTP; 11 May 2020 10:18:22 -0700 From: "Ashley E Desimone" To: devel@edk2.groups.io Cc: Nate DeSimone , Puja Pandya , Erik Bjorge , Bret Barkelew , Prince Agyeman Subject: [edk2-devel] [edk2-staging/EdkRepo] [PATCH V2] EdkRepo: Add the manifest-repos command Date: Mon, 11 May 2020 10:18:20 -0700 Message-Id: <20200511171820.16088-1-ashley.e.desimone@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ashley.e.desimone@intel.com X-Gm-Message-State: VZyefhSUlEPfxkp8SGMhUVQyx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1589217504; bh=spu/vFoUkiISI3Tu4ecDsrFPOJ/OKJ+9oxjtwMl3w1I=; h=Cc:Date:From:Reply-To:Subject:To; b=A4K408OvWLg0CfgOjzC7Dst2WB2Xay7RmWqYh9malIJkoS7N5oapNNLK2RD5qLWCy8F ythCtgjSS2h0mUw7WdgARm/PVhgfenZuTxgFYHalfNmvwe4skzzmdllFGhbHAqfmafGv5 lthomdTWRnfoF27rtI907GZt2QlIDLJ4ol4= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add the manifest_repos_command to list, add, or remove manifest repositories in the ekdrepo_user.cfg Signed-off-by: Ashley E Desimone Cc: Nate DeSimone Cc: Puja Pandya Cc: Erik Bjorge Cc: Bret Barkelew Cc: Prince Agyeman Reviewed-by: Nate DeSimone --- edkrepo/commands/arguments/manifest_repo_args.py | 22 +++++ edkrepo/commands/humble/manifest_repos_humble.py | 20 +++++ edkrepo/commands/manifest_repos_command.py | 107 +++++++++++++++++++= ++++ 3 files changed, 149 insertions(+) create mode 100644 edkrepo/commands/arguments/manifest_repo_args.py create mode 100644 edkrepo/commands/humble/manifest_repos_humble.py create mode 100644 edkrepo/commands/manifest_repos_command.py diff --git a/edkrepo/commands/arguments/manifest_repo_args.py b/edkrepo/com= mands/arguments/manifest_repo_args.py new file mode 100644 index 0000000..5792a4d --- /dev/null +++ b/edkrepo/commands/arguments/manifest_repo_args.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# +## @file +# manifest_repo_args.py +# +# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +''' Contains the help and description strings for arguments in the +manifest_repo command meta data. +''' + +COMMAND_DESCRIPTION =3D 'Lists, adds or removes a manifest repository.' +LIST_HELP =3D 'List all available manifest repositories.' +ADD_HELP =3D 'Add a manifest repository.' +REMOVE_HELP =3D 'Remove a manifest repository.' +NAME_HELP =3D 'The name of a manifest repository to add/remove. Required w= ith Add or Remove flags.' +URL_HELP =3D 'The URL of a manifest repository to add. Required with Add f= lag.' +LOCAL_PATH_HELP =3D 'The local path that a manifest is stored at in the ed= krepo global data directory. Required with Add flag.' +BRANCH_HELP =3D 'The branch of a manifest repository to use. Required with= Add flag.' +ACTION_HELP =3D 'Which action "list", "add", "remove" to take' diff --git a/edkrepo/commands/humble/manifest_repos_humble.py b/edkrepo/com= mands/humble/manifest_repos_humble.py new file mode 100644 index 0000000..7dc8bfe --- /dev/null +++ b/edkrepo/commands/humble/manifest_repos_humble.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +# +## @file +# manifest_repos_humble.py +# +# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +''' +Contains user visible strings printed by the manifest_repos command. +''' + +CFG_LIST_ENTRY =3D 'Config File: edkrepo.cfg Manifest Repository Name: {}' +USER_CFG_LIST_ENTRY =3D 'Config File: edkrepo_user.cfg Manifest Repository= Name: {}' +NAME_REQUIRED =3D 'The "name" argument is required to add/remove a manifes= t repository' +ADD_REQUIRED =3D 'The "name", "url", "branch" and "local-path" arguments a= re required to add a manifest repository' +CANNOT_REMOVE_CFG =3D 'Manifest repositories cannot be removed from the ed= krepo.cfg file.' +REMOVE_NOT_EXIST =3D 'The selected manifest repository does note exist in = the edkrepo_user.cfg file.' +ALREADY_EXISTS =3D 'A manifest repository already exists with name: {}' diff --git a/edkrepo/commands/manifest_repos_command.py b/edkrepo/commands/= manifest_repos_command.py new file mode 100644 index 0000000..b817662 --- /dev/null +++ b/edkrepo/commands/manifest_repos_command.py @@ -0,0 +1,107 @@ +#!/usr/bin/env python3 +# +## @file +# manifest_repos_command.py +# +# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +import configparser + +from edkrepo.commands.edkrepo_command import EdkrepoCommand +import edkrepo.commands.arguments.manifest_repo_args as arguments +import edkrepo.commands.humble.manifest_repos_humble as humble +from edkrepo.common.edkrepo_exception import EdkrepoInvalidParametersExcep= tion +from edkrepo.common.workspace_maintenance.manifest_repos_maintenance impor= t list_available_manifest_repos + + + + +class ManifestRepos(EdkrepoCommand): + def __init__(self): + super().__init__() + + def get_metadata(self): + metadata =3D {} + metadata['name'] =3D 'manifest-repos' + metadata['help-text'] =3D arguments.COMMAND_DESCRIPTION + args =3D [] + metadata['arguments'] =3D args + args.append({'choice': 'list', + 'parent': 'action', + 'help-text': arguments.LIST_HELP}) + args.append({'choice': 'add', + 'parent': 'action', + 'help-text': arguments.ADD_HELP}) + args.append({'choice': 'remove', + 'parent': 'action', + 'help-text': arguments.REMOVE_HELP}) + args.append({'name': 'action', + 'positional': True, + 'position': 0, + 'required': True, + 'choices': True, + 'help-text': arguments.ACTION_HELP}) + args.append({'name': 'name', + 'positional': True, + 'required': False, + 'position': 1, + 'nargs' : 1, + 'help-text': arguments.NAME_HELP}) + args.append({'name': 'branch', + 'positional': True, + 'required': False, + 'position': 3, + 'nargs' : 1, + 'help-text': arguments.BRANCH_HELP}) + args.append({'name': 'url', + 'positional': True, + 'required': False, + 'position': 2, + 'nargs' : 1, + 'help-text': arguments.URL_HELP}) + args.append({'name': 'path', + 'positional': True, + 'required': False, + 'position': 4, + 'nargs' : 1, + 'help-text': arguments.LOCAL_PATH_HELP}) + return metadata + + def run_command(self, args, config): + cfg_repos, user_cfg_repos, conflicts =3D list_available_manifest_r= epos(config['cfg_file'], config['user_cfg_file']) + + if args.action =3D=3D 'list': + for repo in cfg_repos: + print(humble.CFG_LIST_ENTRY.format(repo)) + for repo in user_cfg_repos: + print(humble.USER_CFG_LIST_ENTRY.format(repo)) + + elif (args.action =3D=3D ('add' or 'remove')) and not args.name: + raise EdkrepoInvalidParametersException(humble.NAME_REQUIRED) + elif args.action =3D=3D 'add' and not (args.branch or args.url or = args.local_path): + raise EdkrepoInvalidParametersException(humble.ADD_REQUIRED) + elif args.action =3D=3D 'remove' and args.name and args.name in cf= g_repos: + raise EdkrepoInvalidParametersException(humble.CANNOT_REMOVE_C= FG) + elif args.action =3D=3D'remove' and args.name not in config['user_= cfg_file'].manifest_repo_list: + raise EdkrepoInvalidParametersException(humble.REMOVE_NOT_EXIS= T) + elif args.action =3D=3D 'add' and (args.name in cfg_repos or args.= name in user_cfg_repos): + raise EdkrepoInvalidParametersException(humble.ALREADY_EXISTS.= format(args.name)) + + user_cfg_file_path =3D config['user_cfg_file'].cfg_filename + + if args.action =3D=3D 'add' or 'remove': + user_cfg_file =3D configparser.ConfigParser(allow_no_value=3DT= rue) + user_cfg_file.read(user_cfg_file_path) + if args.action =3D=3D 'add': + user_cfg_file.set('manifest-repos', args.name, None) + user_cfg_file.add_section(args.name) + user_cfg_file.set(args.name, 'URL', args.url) + user_cfg_file.set(args.name, 'Branch', args.branch) + user_cfg_file.set(args.name, 'LocalPath', args.path) + if args.action =3D=3D 'remove': + user_cfg_file.remove_option('manifest-repos', args.name) + user_cfg_file.remove_section(args.name) + with open(user_cfg_file_path, 'w') as cfg_stream: + user_cfg_file.write(cfg_stream) --=20 2.16.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#59152): https://edk2.groups.io/g/devel/message/59152 Mute This Topic: https://groups.io/mt/74140887/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-