From nobody Fri May 17 20:53:14 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+55904+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+55904+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1584382634; cv=none; d=zohomail.com; s=zohoarc; b=aIy1ybk17XH7AF5QJBMwUdHqA/R0rhVl0BbWOZ34PfGbQ1lidDW/eLCKeu7qH8dfwCnocpSH6JElFa0eYcvpvoLWRXPmnZESk8Q/Guzvwo2VUGOnou8IaK2DDx8z9SHTmI5phTHOkZaJ1fZQbDEyRmF2lZbtLTnihGhEgZ1P4Ts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584382634; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To; bh=SXjLlpdTfcyuVAEhOtL/dBvy+8alB2y7wa6lOYHhbuc=; b=g9F7M7V3s6QbH+GITIUM08IObW5yV40CKUyi1yzmpSigXdgX/CjdN6rhEznf248z0W8xzB9quEM4dsIQd44Y1Tgh+CGcMdu08/E2r4duyOhMYWWwF5u8Bycb38uCadw6YxIVWA1XFOtt0T80gSh7wywjorcspbHbkcmvb6bQuP4= 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+55904+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 158438263495118.67894526421219; Mon, 16 Mar 2020 11:17:14 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id kQjgYY1788612xZoBFzlEfnC; Mon, 16 Mar 2020 11:17:14 -0700 X-Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web12.75421.1584382630853583772 for ; Mon, 16 Mar 2020 11:17:11 -0700 IronPort-SDR: D2NUAGyyHvRntbKdY+u3dk0duKC2bA7lz0JPh/xMu0Z9YPyWe+UtVeD+adw6MxyA59fiIHQQsl DZpA/ZribJMQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2020 11:17:06 -0700 IronPort-SDR: +ZomO6+GwpnUkUboQbUhB7b4Pfe71KJ3XJQ3lRCufAPDWKaw7IvN9hcTEPLoPwp72e4YubwLDv mysEvSiXoT2Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,561,1574150400"; d="scan'208";a="244223117" X-Received: from aedesimo-desk.amr.corp.intel.com ([10.7.159.171]) by orsmga003.jf.intel.com with ESMTP; 16 Mar 2020 11:17:06 -0700 From: "Desimone, Ashley E" To: devel@edk2.groups.io Cc: Nate DeSimone , Puja Pandya , Erik Bjorge Subject: [edk2-devel] [edk2-staging/EdkRepo] [PATCH] EdkRepo: Initial commit of checkout pin Date: Mon, 16 Mar 2020 11:16:52 -0700 Message-Id: <20200316181652.29664-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: krPaF55q33MSCBvwxXbEKoYYx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1584382634; bh=qLbZezoQ28+FZAgFM+7RmuHbwI0qam+hLB8BIHhwLxw=; h=Cc:Date:From:Reply-To:Subject:To; b=HE6aFv138VF5uLMtIwWNltqBXIsvIWv2V3kqWOhWVG01dGQnCzytl7yUVmeSAdMrjf4 tIBq0w5z/o0rqAOwnpBcpnoJ75R/kMIcR9AJl5JWdlj9ZAGt2uuCLsPfsXQEGdjC/vZp1 hEfYHaKDgp9LPlU/Gov3d20FZLq94s8Q9Fo= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Command to allow a user to checkout the contents of a previously commited PIN file. Signed-off-by: Ashley E Desimone Cc: Nate DeSimone Cc: Puja Pandya Cc: Erik Bjorge Reviewed-by: Nate DeSimone --- edkrepo/commands/arguments/checkout_pin_args.py | 11 +++ edkrepo/commands/checkout_pin_command.py | 106 ++++++++++++++++++++= ++++ edkrepo/commands/humble/checkout_pin_humble.py | 14 ++++ edkrepo/common/edkrepo_exception.py | 4 + 4 files changed, 135 insertions(+) create mode 100644 edkrepo/commands/arguments/checkout_pin_args.py create mode 100644 edkrepo/commands/checkout_pin_command.py create mode 100644 edkrepo/commands/humble/checkout_pin_humble.py diff --git a/edkrepo/commands/arguments/checkout_pin_args.py b/edkrepo/comm= ands/arguments/checkout_pin_args.py new file mode 100644 index 0000000..abd01b3 --- /dev/null +++ b/edkrepo/commands/arguments/checkout_pin_args.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 +# +## @file +# checkout_pin_args.py +# +# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +COMMAND_DESCRIPTION =3D ('Checks out the revisions described in a PIN file= in ' + 'an existing workpace of the same project') diff --git a/edkrepo/commands/checkout_pin_command.py b/edkrepo/commands/ch= eckout_pin_command.py new file mode 100644 index 0000000..a2afc41 --- /dev/null +++ b/edkrepo/commands/checkout_pin_command.py @@ -0,0 +1,106 @@ +#!/usr/bin/env python3 +# +## @file +# checkout_pin_command.py +# +# Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +import os + +from git import Repo + +from edkrepo.commands.edkrepo_command import EdkrepoCommand, OverrideArgum= ent +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, checko= ut_repos +from edkrepo.common.humble import SPARSE_CHECKOUT, SPARSE_RESET +from edkrepo.common.edkrepo_exception import EdkrepoInvalidParametersExcep= tion, EdkrepoProjectMismatchException +from edkrepo.config.config_factory import get_workspace_path, get_workspac= e_manifest +from edkrepo_manifest_parser.edk_manifest import ManifestXml + +class CheckoutPinCommand(EdkrepoCommand): + def __init__(self): + super().__init__() + + def get_metadata(self): + metadata =3D {} + metadata['name'] =3D 'checkout-pin' + metadata['help-text'] =3D arguments.COMMAND_DESCRIPTION + metadata['alias'] =3D 'chp' + args =3D [] + metadata['arguments'] =3D args + args.append({'name' : 'pinfile', + 'positional' : True, + 'position' : 0, + 'required' : True, + 'help-text' : arguments.PIN_FILE_HELP}) + args.append(OverrideArgument) + return metadata + + def run_command(self, args, config): + workspace_path =3D get_workspace_path() + manifest =3D get_workspace_manifest() + pin_path =3D self.__get_pin_path(args, workspace_path, config['cfg= _file'].manifest_repo_abs_local_path, manifest) + pin =3D ManifestXml(pin_path) + manifest_sources =3D manifest.get_repo_sources(manifest.general_co= nfig.current_combo) + check_dirty_repos(manifest, workspace_path) + for source in manifest_sources: + local_path =3D os.path.join(workspace_path, source.root) + repo =3D Repo(local_path) + origin =3D repo.remotes.origin + origin.fetch() + self.__pin_matches_project(pin, manifest, workspace_path) + manifest.write_current_combo(pin.general_config.current_combo) + sparse_enabled =3D sparse_checkout_enabled(workspace_path, manifes= t_sources) + if sparse_enabled: + print(SPARSE_RESET) + reset_sparse_checkout(workspace_path, manifest_sources) + pin_repo_sources =3D pin.get_repo_sources(pin.general_config.curre= nt_combo) + try: + checkout_repos(args.verbose, args.override, pin_repo_sources, = workspace_path, manifest) + finally: + if sparse_enabled: + print(SPARSE_CHECKOUT) + sparse_checkout(workspace_path, pin_repo_sources, manifest) + + def __get_pin_path(self, args, workspace_path, manifest_repo_path, man= ifest): + if os.path.isabs(args.pinfile) and os.path.isfile(args.pinfile): + return os.path.normpath(args.pinfile) + elif os.path.isfile(os.path.join(manifest_repo_path, os.path.normp= ath(manifest.general_config.pin_path), args.pinfile)): + return os.path.join(manifest_repo_path, os.path.normpath(manif= est.general_config.pin_path), args.pinfile) + elif os.path.isfile(os.path.join(manifest_repo_path, args.pinfile)= ): + return os.path.join(manifest_repo_path, args.pinfile) + elif os.path.isfile(os.path.join(workspace_path, args.pinfile)): + return os.path.join(workspace_path, args.pinfile) + elif os.path.isfile(os.path.join(workspace_path, 'repo', args.pinf= ile)): + return os.path.join(workspace_path, 'repo', args.pinfile) + elif not os.path.isfile(os.path.join(workspace_path, args.pinfile)= ) and os.path.dirname(args.pinfile) is None: + for dirpath, dirnames, filenames in os.walk(workspace_path): + if args.pinfile in filenames: + return os.path.join(dirpath, args.pinfile) + else: + raise EdkrepoInvalidParametersException(humble.NOT_FOUND) + + def __pin_matches_project(self, pin, manifest, workspace_path): + if pin.project_info.codename !=3D manifest.project_info.codename: + 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 mani= fest.combinations]: + raise EdkrepoProjectMismatchException(humble.MANIFEST_MISMATCH) + combo_name =3D pin.general_config.current_combo + pin_sources =3D pin.get_repo_sources(combo_name) + pin_root_remote =3D {source.root:source.remote_name for source in = pin_sources} + manifest_sources =3D manifest.get_repo_sources(combo_name) + manifest_root_remote =3D {source.root:source.remote_name for sourc= e in manifest_sources} + if set(pin_root_remote.items()).isdisjoint(set(manifest_root_remot= e.items())): + raise EdkrepoProjectMismatchException(humble.MANIFEST_MISMATCH) + pin_root_commit =3D {source.root:source.commit for source in pin_s= ources} + for source in pin_sources: + source_repo_path =3D os.path.join(workspace_path, source.root) + repo =3D Repo(source_repo_path) + if repo.commit(pin_root_commit[source.root]) is None: + raise EdkrepoProjectMismatchException(humble.NOT_FOUND) diff --git a/edkrepo/commands/humble/checkout_pin_humble.py b/edkrepo/comma= nds/humble/checkout_pin_humble.py new file mode 100644 index 0000000..b5a9cfb --- /dev/null +++ b/edkrepo/commands/humble/checkout_pin_humble.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +# +## @file +# checkout_pin_humble.py +# +# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +CHP_EXIT =3D 'Exiting without checkout out PIN data.' +NOT_FOUND =3D 'The selected PIN file was not found.' +MANIFEST_MISMATCH =3D ('The selected PIN file does not refer to the same p= roject ' + 'as the local manifest file. {}'.format(CHP_EXIT)) +COMMIT_NOT_FOUND =3D 'The commit referenced by the PIN file does not exist= . {}'.format(CHP_EXIT)=20 \ No newline at end of file diff --git a/edkrepo/common/edkrepo_exception.py b/edkrepo/common/edkrepo_e= xception.py index b6ea3dd..a56e709 100644 --- a/edkrepo/common/edkrepo_exception.py +++ b/edkrepo/common/edkrepo_exception.py @@ -58,6 +58,10 @@ class EdkrepoConfigFileReadOnlyException(EdkrepoExceptio= n): def __init__(self, message): super().__init__(message, 112) =20 +class EdkrepoProjectMismatchException(EdkrepoException): + def __init__(self, message): + super().__init__(message, 113) + class EdkrepoVerificationException(EdkrepoException): def __init__(self, message): super().__init__(message, 114) --=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 (#55904): https://edk2.groups.io/g/devel/message/55904 Mute This Topic: https://groups.io/mt/72005418/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-