From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web10.3756.1586207989919310753 for ; Mon, 06 Apr 2020 14:19:50 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=q5Aril/A; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: erik.c.bjorge@intel.com) IronPort-SDR: 6B4My6aaq4m6Dk2UOQEFiu/pYgByZtCF2zFF36Ai21jv5ZYcOkXera+lpfioSyQkgGuL1Lcd/0 M8YOM6Acg10g== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2020 14:19:49 -0700 IronPort-SDR: 3gIkYDPOf3Mysbv9Iw+Vl9nuD4/5vM4IEJ7ZoM0d49q4/6iHIywvjzbffIgkakXccnzi4CGAC7 8IUIx+He/FqQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,352,1580803200"; d="scan'208";a="247149105" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga008.jf.intel.com with ESMTP; 06 Apr 2020 14:19:48 -0700 Received: from fmsmsx123.amr.corp.intel.com (10.18.125.38) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 6 Apr 2020 14:19:48 -0700 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by fmsmsx123.amr.corp.intel.com (10.18.125.38) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 6 Apr 2020 14:19:48 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.176) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 6 Apr 2020 14:19:48 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XGW7OxftGAuo+5Fx6J4K7NYjSP08rfR1DEUPnZbSG4P9/jpbUFE7ql22mmuHihMc7Aw23PlSfdFLQn6CFtN25BZovWRYkhRxJV34pUCtldLdMASn8bGFnMxEwJVjKcsCqsFatKzp0Vl6/hR18+wAf85kERSLmi9fpL3YMdjLn3e4+NWpi4boVGjmXF/4Kgi4bQRhy1W/VvNn5wg5oujAj+bMkMSXP8Y3vTjcQuzSQ4zWHaent12/SHKC/WK/FIlp9iFa+Jnv9Fi1DphxdMLxqXYO2IbNoSltKXG9o2OXHV7E9HYYVobONLnmSpyGs5YUssHeuvucOuUrDBOkp15SNQ== 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=rX3Kzn68pF7beJpeFJAds4wWUxCOosCb75LkV5S0CnQ=; b=jiVyIjC7VFh4YkuSFMCMIP40a/fS4rchzhnX7R2qYpP/DyLeew02zcSOAekxKDGOtMpLHH7KXkKWLywIpiom4D58QHIv9tyem41LMv7jv04RR7QS+V8uxuDFdhxewTZFGGmT8jtrIsXkOV4ELLDQ4xr6XNHSmz0mClGWFyDNUo55WGbzjckRsb/ffsX/0R+qo+WROEa/3JcnoKMAX9GS3rP/xVaQX4FhyQFwSXgLdDxu86toXlghBMYMaIsGzVOXOFKLG+5FBxU6SqygTsvPp7OpBMJio48KGgpbmqKKPZMh3bqwlFHO8rKVi7hhQfkapaRvl7Ws9JiydfCRblMCXA== 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=rX3Kzn68pF7beJpeFJAds4wWUxCOosCb75LkV5S0CnQ=; b=q5Aril/AN5HOCngdMMUtr4MKMCudesSskw/W54qeR98l9W2O9RT9qh3DUdjmgxjO7zJO/x6vzWZ3QYO8AyG8yEbICQ3IPMO5P+EXg5521Cxet+jwY05u37u4+KGyIF6SEyHV72J4IbM4aIQ4B69YKcaErXRdqv4nRjkgC1GLbiM= Received: from MW3PR11MB4554.namprd11.prod.outlook.com (2603:10b6:303:5d::7) by MW3PR11MB4556.namprd11.prod.outlook.com (2603:10b6:303:5b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.17; Mon, 6 Apr 2020 21:19:45 +0000 Received: from MW3PR11MB4554.namprd11.prod.outlook.com ([fe80::ed52:bf5d:a3dc:7252]) by MW3PR11MB4554.namprd11.prod.outlook.com ([fe80::ed52:bf5d:a3dc:7252%7]) with mapi id 15.20.2878.018; Mon, 6 Apr 2020 21:19:45 +0000 From: "Bjorge, Erik C" To: "devel@edk2.groups.io" , "Desimone, Nathaniel L" CC: "Desimone, Ashley E" , "Pandya, Puja" , "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: AQHWDFZZx9LzJWjPyEe8i69/OukIAKhsmGSQ Date: Mon, 6 Apr 2020 21:19:45 +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-reaction: no-action dlp-version: 11.2.0.6 dlp-product: dlpe-windows authentication-results: spf=none (sender IP is ) smtp.mailfrom=erik.c.bjorge@intel.com; x-originating-ip: [134.134.136.221] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 329ef49b-fa7c-454f-6645-08d7da703af6 x-ms-traffictypediagnostic: MW3PR11MB4556: 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:3631; x-forefront-prvs: 0365C0E14B x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4554.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(10019020)(346002)(396003)(376002)(136003)(39850400004)(366004)(8936002)(55016002)(81156014)(8676002)(30864003)(81166006)(4326008)(6506007)(966005)(71200400001)(478600001)(2906002)(33656002)(6636002)(52536014)(66446008)(9686003)(53546011)(26005)(86362001)(54906003)(64756008)(66476007)(76116006)(66946007)(5660300002)(7696005)(66556008)(186003)(316002)(110136005)(460985005);DIR:OUT;SFP:1102; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: XQd6AgsBd2zKVd/vXXoL0zfb8NJsd4UI7kRZu8452f21FfNyySdhb3WsL5t/qc3G+OBPjVyi+cqbjpx/Glzd9aA1q87AZ8/QYXm9D18w39iDh91GlCOiK+TRmaj5XXT47H/xetbesvWMeN8Na8ivmi45qsjZCrLjusBTOcUiVMVJ4YcOvVI4hOF+3JGl0A0jXY+FR1W9Bo6+55X1ptX7JNpQ6bjrgxYnCsGwP2fKfAlz32pq1dXBN78Xe80Ge5LTsAOq4WcMhN0nTteb6ThYtc5+soEHGKz/KLoynQ64YLH89O41IAC6BtXQ7dWZFCSzjdZ/GSeWAz4SIwn2S/G2o70HcJgU1EFvXB3XYMwLq/0Kzk/h9VGY31ILWRdqbjcD37sYgZUJDvRwBTZIVR7/47rVmPT51+CMQ6HaVI4h06LIW7jw29xbS/T06Kl2PDdV2PyWFxXs/jTZPLLvnGNRCMsVyuYwquEogsP2cSKw+HrT4mTZUJid9TyHr+btf8y5YdeRiD8yjsapatsL2sY7UsXq1bQKbMj62FfKAWktVhLe/NAIDr7LJewAAm0VErQ9 x-ms-exchange-antispam-messagedata: 7uEvZ7iJL5r99MaCsSMlKKpwdSbUoJEylrgHvp5rQcycaf4aPpzk6r1Wioa5UrrYvVMqJfmr5bjBfQrPE3OVk4yBiVJVeNr9Z9Qc9Gqw4jPT2IID/C1aDoOefE5R5JetTj9zt6JnlHia4au2Xf3iDw== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 329ef49b-fa7c-454f-6645-08d7da703af6 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Apr 2020 21:19:45.5478 (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: iKEGbXWx3xS2IIRFdokD6DpPe/NCD1ZjMwVu0qW93dbDY1BGDY7XOJuo92pI/nZIxpRFu9O1EcDjBi/cG03Xmg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4556 Return-Path: erik.c.bjorge@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Nate, To simplify some of the installer code should we just switch to local (use= r) installs in for Linux and Mac? I would like to move to this for Linux a= nyway. I can also submit a patch for this at some other time. The rest of the code looks good. Thanks, -Erik -----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