From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web12.176.1586375950603593498 for ; Wed, 08 Apr 2020 12:59:10 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=TeWkGlKa; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: ashley.e.desimone@intel.com) IronPort-SDR: HhTprqg676/YPk3qC2D3Dkoer7XFVoFgK+JL9v18fufbWmTb7avYpYGE7F0W2DlDJjW5cARCMX xH4EZX9tDzTg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2020 12:59:10 -0700 IronPort-SDR: nLx+ZNmb3ifKaCQhZBNvSc8nKoM9jVPFJfAOzcRGzx88xI3LlH5n+ny971pV8fvSk0I0TFrkli H5Q5vlq6Cx9g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,359,1580803200"; d="scan'208";a="398307094" Received: from orsmsx110.amr.corp.intel.com ([10.22.240.8]) by orsmga004.jf.intel.com with ESMTP; 08 Apr 2020 12:59:10 -0700 Received: from orsmsx158.amr.corp.intel.com (10.22.240.20) by ORSMSX110.amr.corp.intel.com (10.22.240.8) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 8 Apr 2020 12:59:10 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by ORSMSX158.amr.corp.intel.com (10.22.240.20) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 8 Apr 2020 12:59:09 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.175) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 8 Apr 2020 12:59:09 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TYKDuI0fscmLsTAMeTqULVLbH7R6/mzK+rbj45cKTklyqhi8MJy0gtcTd2Y65Cq4dQBexPs3a3MsvC1sKGDtQNz0+m4Op8JWoRqxzNzUxlJCdsiPJxzsXPQtB3Cd3Bo8mvSxlroKL8ZwBDimkkx7bK/vD//5FSKXv27PdABKqsogD9amJTurMXdJZmmbrFKTFPULas7Eby3CkgmS46t4Kyytg58Hl9u1RpPoKN1n7gSI4HIMAppLTC31cO9L6IrVrGPVG0Pswd09JJeC2mNOFcFvryY7p+DB+xogzuKgg1Ig98Gwd7WzgIo8AmDGAMktVBTgHgp8cIbp+gr6z9/mlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Di1u0Pecy6l1684iZQtzCrYbhmu9tQdG91h6xNfb7cY=; b=EkphOPjNfSRUnuxpe3pOIkwpFkx60Byi7g05jzps99J+73PHojv3cqLnSFNYNzrKpcwoS9HwjZ4j1sD9eBj9sNYmNR6+UVG/oIx6jl0Y1K1eXk1Ffz3ZxDEYkCtCZNPoiy/B3aiUKY8jjgVrrcUYxw18SC5K6uS7rDdHTf56xZ0Rw9nQiBi4ZCF/dy7QF29cZBwfHmjopGRdcqo48JTLt6ud7YAh7wkONvGN/cBowbc7ULWZDG1EFuKBkdsZiEPD+5C0pMNc/eUYOMKM2e2mEO0/g50VshuGc/bB4NzzmGvhPNth7Db1mchcp14K+NpICpy+EZ45MtUyVBNacPznEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Di1u0Pecy6l1684iZQtzCrYbhmu9tQdG91h6xNfb7cY=; b=TeWkGlKa9bu9+MDAW5A3lU5XgRQA6PvBBCsiv5UmrkDRkh/fqALg8RLkb3IaUXqN5TlHQc37lg1KRBPD5MkQnVUMr46PvQq7cj5/cNX49GPz/tNXyx1IMrmo0TyXt33mMTJR7kfBts84g4VaYc6x4Wtd+aNMwJduUq7LsiEZzyU= Received: from DM6PR11MB3628.namprd11.prod.outlook.com (2603:10b6:5:144::25) by DM6PR11MB4347.namprd11.prod.outlook.com (2603:10b6:5:200::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.15; Wed, 8 Apr 2020 19:59:07 +0000 Received: from DM6PR11MB3628.namprd11.prod.outlook.com ([fe80::5904:e7d9:f64d:9a7e]) by DM6PR11MB3628.namprd11.prod.outlook.com ([fe80::5904:e7d9:f64d:9a7e%3]) with mapi id 15.20.2878.021; Wed, 8 Apr 2020 19:59:07 +0000 From: "Ashley E Desimone" To: "devel@edk2.groups.io" , "Desimone, Nathaniel L" CC: "Pandya, Puja" , "Bjorge, Erik C" , "Agyeman, Prince" , "Bret Barkelew" , Philippe Mathieu-Daude Subject: Re: [edk2-devel] [edk2-staging/EdkRepo] [PATCH] EdkRepo: Add Support for macOS Thread-Topic: [edk2-devel] [edk2-staging/EdkRepo] [PATCH] EdkRepo: Add Support for macOS Thread-Index: AQHWDFZVZ13I3KGz00WYeN3O6zJaGahvp44A Date: Wed, 8 Apr 2020 19:59:07 +0000 Message-ID: References: <20200406205904.27226-1-nathaniel.l.desimone@intel.com> In-Reply-To: <20200406205904.27226-1-nathaniel.l.desimone@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.2.0.6 dlp-reaction: no-action dlp-product: dlpe-windows authentication-results: spf=none (sender IP is ) smtp.mailfrom=ashley.e.desimone@intel.com; x-originating-ip: [134.134.136.213] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6bdc56e1-67ba-41c4-d0f3-08d7dbf74c3c x-ms-traffictypediagnostic: DM6PR11MB4347: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:843; x-forefront-prvs: 0367A50BB1 x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR11MB3628.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(10019020)(376002)(396003)(346002)(366004)(136003)(39850400004)(4326008)(478600001)(6636002)(186003)(64756008)(66556008)(55016002)(9686003)(66476007)(66446008)(66946007)(6506007)(52536014)(5660300002)(86362001)(71200400001)(2906002)(26005)(33656002)(76116006)(81166007)(54906003)(8936002)(53546011)(7696005)(81156014)(8676002)(30864003)(316002)(110136005)(966005)(460985005);DIR:OUT;SFP:1102; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: mAGYTRILDuW+bKH0NaTJMEOVT1sqNF+vkXDfk+vlw7Z3rM6fUok7xJj0IVZUQpAIBg4Q1jfxi/9Nj/v+UHwj74MfVevqaMYeNI1YYBybGdqi9L8zzrMh/jPU71Bk04XP9kipj30aVnGgmJ3FsMeDnTn9WJODciXaz4rzWK9kTb06qp61meHQUVcXo23f4/tez0a6VpJa5eeNFVpuDu4m2BWMoQO4uuTtuIQ/5Xw2QeDe3Pi9oj2+BaMyB7eCaxYmvpzVyinQcm3tDmAOrCM5SrXPCK5xK4hn/SuXvxBihTyEh8i8GhvrNZ7Crkw6gOxvozfX4/ykMA+raDU1H1+3HGB9Chx0MsckW6hGxERg9H6Tvta6mtf7Qv6IWqDUeeSVsz+78Kwy/N+ZdArubsivDByGJdU5fO/5yQffHqqU6s+hkYthqjaDW3pprDrLn4aSZIIHHtcPpUFxLV1jaz2gXz6KYJ/LBwE0H4wo5kpX4gROoVnUELs/bhrhNEYfFl7xuwICjDna+0YKwkty3QrW+SlTH7huju7OkR5P7oz1VZVyS2Ntp7OBv1QmFCj1xW0q x-ms-exchange-antispam-messagedata: DgOQEe630n7r2zo9J9L//CLIzAuaNn3UtzWxykldBb0ju+dJpw6JZw++t7vF6U8mO34zKCz1m7VP2Tdx+h6JCDSLZsDQRhzO/QMAJWqEpkvjCvICQF17ZGHp4E6+FkftjK/LjdxRNJGcfMesLDNDvQ== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 6bdc56e1-67ba-41c4-d0f3-08d7dbf74c3c X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Apr 2020 19:59:07.6924 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: KAJcolrKjKuupNOm8bhUyRAZyr0CTjvu4qC245fHivG2f1/qtcTeXj0PryXZYF9RDoE00W85R3L08BtsfG3N/bqqpLmcC0X3T9d6kI8oSuM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4347 Return-Path: ashley.e.desimone@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ashley DeSimone -----Original Message----- From: devel@edk2.groups.io On Behalf Of Nate DeSimo= ne Sent: Monday, April 6, 2020 1:59 PM To: devel@edk2.groups.io Cc: Desimone, Ashley E ; Pandya, Puja ; Bjorge, Erik C ; Agyeman, Prince= ; Bret Barkelew ; P= hilippe Mathieu-Daude Subject: [edk2-devel] [edk2-staging/EdkRepo] [PATCH] EdkRepo: Add Support = for macOS Signed-off-by: Nate DeSimone Cc: Ashley DeSimone Cc: Puja Pandya Cc: Erik Bjorge Cc: Prince Agyeman Cc: Bret Barkelew Cc: Philippe Mathieu-Daude --- build-scripts/build_linux_installer.py | 2 + build-scripts/set_version_and_build_wheels.py | 10 +-- edkrepo/config/config_factory.py | 6 +- edkrepo_installer/linux-scripts/install.py | 65 +++++++++++++++++-- 4 files changed, 67 insertions(+), 16 deletions(-) diff --git a/build-scripts/build_linux_installer.py b/build-scripts/build_= linux_installer.py index 0130552..11dd8d7 100755 --- a/build-scripts/build_linux_installer.py +++ b/build-scripts/build_linux_installer.py @@ -10,6 +10,7 @@ from argparse import ArgumentParser import fnmatch, os, shutil, subprocess, sys import set_version_and_build= _wheels as build_edkrepo +import traceback def main(): parser =3D ArgumentParser() @@ -31,6 +32,7 @@ def main(): try: build_edkrepo.main() except: + traceback.print_exc() print('Failed to build edkrepo wheel') return 1 diff --git a/build-scripts/set_version_and_build_wheels.py b/build-scripts= /set_version_and_build_wheels.py index 42e58cc..7df0c84 100755 --- a/build-scripts/set_version_and_build_wheels.py +++ b/build-scripts/set_version_and_build_wheels.py @@ -3,7 +3,7 @@ ## @file # set_version_and_build_wheels.py # -# Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2017 - 2020, Intel Corporation. All rights=20 +reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -214,7 +214,7 @@ def build_wheels(extension_pkgs): def copy_wheels_and_set_xml(package_version, extension_pkgs): dir_path =3D os.path.join(os.path.dirname(os.path.abspath(os.path.dir= name(__file__))), "dist") dest_path =3D os.path.join(dir_path, "self_extract") - if ostype =3D=3D LINUX: + if ostype !=3D WIN: dest_path =3D os.path.join(dest_path, 'wheels') if not os.path.isdir(dest_path): os.makedirs(dest_path) @@ -241,9 +241,9 @@ def create_final_copy_script(version): f.write("pushd ..\\dist\n") f.write("ren \"setup.exe\" \"EdkRepoSetup-{}.exe\"\n".format(= version)) f.write("popd\n") - elif ostype =3D=3D LINUX: + else: with open('final_copy.py', 'w') as f: - f.write('#!/usr/bin/python3\n') + f.write('#!/usr/bin/env python3\n') f.write('import os, shutil, sys\n') f.write('dist_name =3D "edkrepo-{{}}".format("{}")\n'.format(= version)) f.write('installer_dir =3D "../dist/self_extract"\n') @@ -257= ,7 +257,7 @@ def _copy_file(source, destination): check_call("cp -f {} {}".format(source, destination), shell=3DTru= e) def make_version_cfg_file(version): - if ostype =3D=3D LINUX: + if ostype !=3D WIN: cfg_src =3D os.path.join(os.path.dirname(os.path.abspath(os.path.= dirname(__file__))), 'edkrepo_installer', 'linux-scripts') install_cfg =3D configparser.ConfigParser(allow_no_value=3DTrue) install_cfg.read(os.path.join(cfg_src, 'install.cfg')) diff --git= a/edkrepo/config/config_factory.py b/edkrepo/config/config_factory.py index e3a437f..b86e0b8 100644 --- a/edkrepo/config/config_factory.py +++ b/edkrepo/config/config_factory.py @@ -3,7 +3,7 @@ ## @file # config_factory.py # -# Copyright (c) 2017- 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2017 - 2020, Intel Corporation. All rights=20 +reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -30,9 +30,7 @@ def get_edkrepo_global_data_directory(): common_appdata =3D create_unicode_buffer(MAX_PATH) SHGetFolderPath(None, CSIDL_COMMON_APPDATA, None, SHGFP_TYPE_CURR= ENT, common_appdata) global_data_dir =3D os.path.join(common_appdata.value, "edkrepo") - elif sys.platform =3D=3D "darwin": - raise OSError("macOS support is in progress") - elif sys.platform.startswith("linux") or os.name =3D=3D "posix": + elif sys.platform =3D=3D "darwin" or sys.platform.startswith("linux")= or os.name =3D=3D "posix": global_data_dir =3D os.path.expanduser("~/.edkrepo") if not os.path.isdir(global_data_dir): if not os.path.exists(os.path.dirname(global_data_dir)): diff --git a/edkrepo_installer/linux-scripts/install.py b/edkrepo_installe= r/linux-scripts/install.py index 52f0c52..099954d 100755 --- a/edkrepo_installer/linux-scripts/install.py +++ b/edkrepo_installer/linux-scripts/install.py @@ -23,6 +23,21 @@ import sys import traceback import xml.etree.ElementTree as et +# +# Environment detection +# +MAC =3D "mac" +LINUX =3D "linux" +if sys.platform =3D=3D "darwin": + ostype =3D MAC +elif sys.platform.startswith("linux"): + ostype =3D LINUX +elif os.name =3D=3D "posix": + print("Warning: Unrecognized UNIX OS... treating as Linux") + ostype =3D LINUX +else: + raise EnvironmentError("Unsupported OS") + tool_sign_on =3D 'Installer for edkrepo version {}\nCopyright(c) Intel Co= rporation, 2020' # Data here should be maintained in a configuration file @@ -31,6 +46,7 @= @ directories_with_executables =3D ['git_automation'] cfg_src_dir =3D os.p= ath.abspath('config') whl_src_dir =3D os.path.abspath('wheels') def_pytho= n =3D 'python3' +nfs_home_directory_data =3D re.compile(r"NFSHomeDirectory:\s*(\S+)") # ZSH Configuration options prompt_regex =3D 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= ]") @@ -63,7 +79,8 @@ def init_logger(verbose): def get_args(): parser =3D ArgumentParser() - parser.add_argument('-l', '--local', action=3D'store_true', default= =3DFalse, help=3D'Install edkrepo to the user directory instead of system = wide') + if ostype !=3D MAC: + parser.add_argument('-l', '--local', action=3D'store_true',=20 + default=3DFalse, help=3D'Install edkrepo to the user directory instead o= f=20 + system wide') parser.add_argument('-p', '--py', action=3D'store', default=3DNone, h= elp=3D'Specify the python command to use when installing') parser.add_argument('-u', '--user', action=3D'store', default=3DNone,= help=3D'Specify user account to install edkrepo support on') parser.add_argument('-v', '--verbose', action=3D'store_true', default= = =3DFalse, help=3D'Enables verbose output') @@ -218,6 +235,18 @@ def _check= _version(current, expected): return 1 return 0 +def get_user_home_directory(username): + if ostype =3D=3D MAC: + res =3D default_run(['dscl', '.', '-read', '/Users/{}'.format(use= rname), 'NFSHomeDirectory']) + data =3D nfs_home_directory_data.match(res.stdout.strip()) + if data: + return data.group(1) + else: + raise ValueError("home directory not found") + else: + res =3D default_run(['getent', 'passwd', username]) + return res.stdout.strip().split(':')[5] + def get_site_packages_directory(): res =3D default_run([def_python, '-c', 'import site; print(site.getsi= tepackages()[0])']) return res.stdout.strip() @@ -424,6 +453,9 @@ def do_install(): # Initialize information based on command line input username =3D args.user + install_to_local =3D False + if ostype !=3D MAC and args.local: + install_to_local =3D True try: cfg =3D configparser.ConfigParser(allow_no_value=3DTrue) @@ -449,7 +481,7 @@ def do_install(): # Determine the user running sudo log.info('\nCollecting system information:') - if not args.local: + if not install_to_local and ostype !=3D MAC: try: res =3D default_run(['id', '-u']) except: @@ -466,11 +498,21 @@ def do_install(): log.info('- Unable to determine current user. Run installer = using the --user flag and specify the correct user name.') return 1 try: - res =3D default_run(['getent', 'passwd', username]) - user_home_dir =3D res.stdout.strip().split(':')[5] + user_home_dir =3D get_user_home_directory(username) except: log.info('- Unable to determine users home directory') return 1 + if ostype =3D=3D MAC: + try: + res =3D default_run(['id', '-u']) + except: + log.info('- Failed to determine user ID') + return 1 + if res.stdout.strip() =3D=3D '0': + log.info('- Installer must NOT be run as root') + return 1 + if os.path.commonprefix([user_home_dir, sys.executable]) !=3D use= r_home_dir: + install_to_local =3D True default_cfg_dir =3D os.path.join(user_home_dir, cfg_dir) get_add_prompt_customization(args, user_home_dir) log.info('+ System information collected') @@ -625,7 +667,7 @@ def do= _install(): install_whl =3D wheels_to_install[whl_name]['install'] if install_whl: install_cmd =3D [def_python, '-m', 'pip', 'install'] - if args.local: + if install_to_local: install_cmd.append('--user') install_cmd.append(os.path.join(whl_src_dir, whl)) try: @@ -639,23 +681,32 @@ def do_install(): set_execute_permissions() log.info('+ Marked scripts as executable') + #If pyenv is being used, regenerate the pyenv shims + if shutil.which('pyenv') is not None: + try: + res =3D default_run(['pyenv', 'rehash']) + log.info('+ Generated pyenv shims') + except: + log.info('- Failed to generate pyenv shim') #Install the command completion script if shutil.which('edkrepo') is not None: - if args.local: + if install_to_local or ostype =3D=3D MAC: command_completion_script =3D os.path.join(default_cfg_dir, '= edkrepo_completions.sh') else: command_completion_script =3D os.path.join('/', 'etc', 'profi= le.d', 'edkrepo_completions.sh') try: res =3D default_run(['edkrepo', 'generate-command-completion-= script', command_completion_script]) - if args.local: + if install_to_local or ostype =3D=3D MAC: shutil.chown(command_completion_script, user=3Dusername) os.chmod(command_completion_script, 0o644) add_command_completions_to_shell(command_completion_script, a= rgs, username, user_home_dir) + log.info('+ Configured edkrepo command completion') 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.25.2