From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web11.816.1586377799863175856 for ; Wed, 08 Apr 2020 13:29:59 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=mmzIgh2K; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: ashley.e.desimone@intel.com) IronPort-SDR: skYVC1IGCkrh4VrdpuFH+ozn1xIH+PsOYOytluQgRHWDI3HeiuCmh/VI3/2gbDTG+yYV4edJry 3EdZ8PLXNegQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2020 13:29:59 -0700 IronPort-SDR: PrZpF21WOS+GqBu4C1gPS/l3t/1ai2UjW4rQ3gdshtmZ3ZcK/e8M6rCePAoAqhncKSgfVpBY5B mw32wuW+D7RQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,359,1580803200"; d="scan'208";a="251674977" Received: from orsmsx106.amr.corp.intel.com ([10.22.225.133]) by orsmga003.jf.intel.com with ESMTP; 08 Apr 2020 13:29:59 -0700 Received: from orsmsx115.amr.corp.intel.com (10.22.240.11) by ORSMSX106.amr.corp.intel.com (10.22.225.133) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 8 Apr 2020 13:29:58 -0700 Received: from ORSEDG002.ED.cps.intel.com (10.7.248.5) by ORSMSX115.amr.corp.intel.com (10.22.240.11) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 8 Apr 2020 13:29:58 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.41) by edgegateway.intel.com (134.134.137.101) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 8 Apr 2020 13:29:58 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bE8bWngyreAOEGrxomp1G3nA7g82UQHf0bV52HIG2rf9XY7McKK9V7Fpm7O3spy4oPAo0cD4ztzpvxhETvoYW+YEzFn94SWmDlr08AnQrVf7GikN3RAekxUnLIFAfTbQgldmgG38ruGxOIX0A8pkBynfIjoM7P8H3d+qtFEhBB85UitftgO6QH8sR5EkHSA6KRjJBeQyCneDtcsyed7B7sKVvzjeYJLEhonlcBQ8+rVKZa0/lUtASzHShZvKMqSxkhnv7BMq32gZerXcF6ap98aU+25R84HpJQ5AGgDcw31MbeXDIjechkHTEj3JkkDKu+WBl62eFqj3Llr4gyTNqA== 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=CP/xlkFkfE6XjiN0joaKmu7PIckt6PnV0CPVnucmU4U=; b=IXltUTSp71GcwH4DUdVuiY3f4d+jEV+F+A1VLvMwaOumIqGPIsonmVS7JX5Y31J+lPNBAKPJ5ldn4rPk3aA8a5qQT7fM8JeoIviq55WqOLWEhF5cRD+JwdXgTQGoAWX1VX7MW/Eus9oX2HhMEZ6v15fhB1C1n0xzIDtzsrjMT9/5/U1Fd+aVZtC5KcWX8btB+4e0721JxidLYsfgFMbB7K1Z+G/Hd0QXzV4SY7AL0JSQI+PHEuZ8HScDpOw4Dn2LSQkLGBt9I7enIRUj40qxzRpXYIjbxqmBPYiOh0tJ4faM1c5vkC4drg1ZDaqdu0aa0944rLsXNlM+aiuqcZnr7A== 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=CP/xlkFkfE6XjiN0joaKmu7PIckt6PnV0CPVnucmU4U=; b=mmzIgh2KmjUZpJUhOWkVovlPALOnFibPm2wGW8pvnR0KWAnZKUp+aNgbM6L7lHFI7AEl9hRVxyca83YuIFPkPRdTH5r5P+7L63TtkD8URHGxCi1A9YwexnzvHF9Mreti+RcXQ4T8AGY5m6IDNWzvd9MjidoCL3l9uZO5QfommPE= Received: from DM6PR11MB3628.namprd11.prod.outlook.com (2603:10b6:5:144::25) by DM6PR11MB3596.namprd11.prod.outlook.com (2603:10b6:5:13a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.16; Wed, 8 Apr 2020 20:29:57 +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 20:29:57 +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 1/2] EdkRepo: Add setup_git_pyenv_mac.sh Thread-Topic: [edk2-devel] [edk2-staging/EdkRepo] [PATCH 1/2] EdkRepo: Add setup_git_pyenv_mac.sh Thread-Index: AQHWDHUjZua60YS0Iku0SzCCTMnw+6hvr/zg Date: Wed, 8 Apr 2020 20:29:57 +0000 Message-ID: References: <20200407003950.33249-1-nathaniel.l.desimone@intel.com> <20200407003950.33249-2-nathaniel.l.desimone@intel.com> In-Reply-To: <20200407003950.33249-2-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: c2f28b68-ac51-4658-3013-08d7dbfb9a87 x-ms-traffictypediagnostic: DM6PR11MB3596: 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:257; 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)(136003)(366004)(346002)(39850400004)(396003)(26005)(7696005)(54906003)(71200400001)(6636002)(76116006)(53546011)(8676002)(4326008)(110136005)(81156014)(33656002)(52536014)(86362001)(316002)(5660300002)(2906002)(66946007)(81166007)(6506007)(55016002)(66476007)(9686003)(478600001)(966005)(8936002)(186003)(66556008)(64756008)(66446008);DIR:OUT;SFP:1102; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: L8au4oqk/HLcr3fQrOOm6FWyUkjlT0h5GqwpxIgOmTdVR3Lfz6Ud8MILNL1GDCmXwGq9xnnbxD6xGtpg4CKRqaQh3m0qvJdUK4tQJx8pLIDLXOrsgWjTquwoPIFI1pobcI0jrQCt3VNjRits9XBP9h+gwBhJfRTQbMFN8mO4Ii6EkrOIEo6vPjubVYiNk8In8hibdZRe61+NWH2Ra5RrHk0fJE+WjPryQZ90rl+16+tof7zP6t87qsoQGdE4tnYlDZhtAkK4iMlmXxYFaq07hQ55DVBnA8Fuj5DT7IpLFQGEYxeXbgFBP6j1TVLQUiVSVguLtBB/IacOqTByyqEx43QagGjXgNcC/GEtBbBPfdNDhyUQxYGGrUpj0PKokUtfanyd+aWw7ZWFwTO15+HN+Llp0S7DxlkQiwMCubJ3hJDpGL7QgesJ+bPkaYX8hJhr47UHwVDXcy27LqnqtOmzqsrAEAv3/Srdz/bFm4QxzbnKTzyxxHh6w412djITZOvXSlJ5vJ6OqVNfYP9gr3FCfg== x-ms-exchange-antispam-messagedata: LjAug+RIY6CZLp+vDg6CSZfgxcC/oWO95F+BU/7+Gl8LgJzEQeey6Gc822vWRf43wXcKyIJRa0x3ihJdB7NgnrqzxoPXNBDJOLUVEyIprBOXs5JziXSLcl4fHiA8N2bNsbf9Z4w3XUA1XX6BehmTOQ== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: c2f28b68-ac51-4658-3013-08d7dbfb9a87 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Apr 2020 20:29:57.0710 (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: 11EVyWGhM8ifSxx2P0h5PPKD4kZ6raPv/hpjgjjjKjQsz4cY6Vv9El4RTIU06RVOW3bTmPxJyKy46X58g5htHi1HultfUZc6cFE0hKX5ZjA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB3596 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 5:40 PM To: devel@edk2.groups.io Cc: Pandya, Puja ; Bjorge, Erik C ; Agyeman, Prince ; Bret Barkelew ; Philippe Mathieu-Daude Subject: [edk2-devel] [edk2-staging/EdkRepo] [PATCH 1/2] EdkRepo: Add setu= p_git_pyenv_mac.sh Script to configure pyenv and git for use on macOS. Signed-off-by: Nate DeSimone Cc: Puja Pandya Cc: Erik Bjorge Cc: Prince Agyeman Cc: Bret Barkelew Cc: Philippe Mathieu-Daude --- .../mac-scripts/setup_git_pyenv_mac.sh | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100755 edkrepo_installer/mac-scripts/setup_git_pyenv_mac.sh diff --git a/edkrepo_installer/mac-scripts/setup_git_pyenv_mac.sh b/edkrep= o_installer/mac-scripts/setup_git_pyenv_mac.sh new file mode 100755 index 0000000..34083d1 --- /dev/null +++ b/edkrepo_installer/mac-scripts/setup_git_pyenv_mac.sh @@ -0,0 +1,118 @@ +#!/usr/bin/env bash +# +## @file setup_git_pyenv_mac.sh +# +# Copyright (c) 2020, Intel Corporation. All rights reserved.
#=20 +SPDX-License-Identifier: BSD-2-Clause-Patent # + +IFS=3D'' read -r -d '' python_script <<"EOF" +import os +import re +import subprocess +import sys +import traceback + +profile_source_regex =3D re.compile(r"source\s+~/\.bashrc") +profile_source_regex2 =3D re.compile(r".\s+~/\.bashrc") + +ls_alias_regex =3D re.compile(r"alias\s+ls=3D'ls\s+-G'") +bash_completion_regex =3D=20 +re.compile(r"\[\[\s+-r\s+\"/usr/local/etc/profile.d/bash_completion.sh\ +"\s+\]\]\s+&&\s+.\s+\"/usr/local/etc/profile.d/bash_completion.sh\"") +zsh_autoload_compinit_regex =3D re.compile(r"autoload\s+-U\s+compinit") +zsh_autoload_bashcompinit_regex =3D=20 +re.compile(r"autoload\s+-U\s+bashcompinit") +zsh_autoload_colors_regex =3D re.compile(r"autoload\s+-U\s+colors") +zsh_colors_regex =3D re.compile(r"\n\s*colors\n") zsh_compinit_regex =3D= =20 +re.compile(r"compinit\s+-u") zsh_bashcompinit_regex =3D=20 +re.compile(r"\n\s*bashcompinit\n") +pyenv_init_regex =3D re.compile(r"eval\s+\"\$\(pyenv\s+init\s+-\)\"") + +ls_alias =3D "alias ls=3D'ls -G'" +bash_completion =3D '[[ -r "/usr/local/etc/profile.d/bash_completion.sh" = ]] && . "/usr/local/etc/profile.d/bash_completion.sh"' + +zsh_autoload_compinit =3D 'autoload -U compinit' +zsh_autoload_bashcompinit =3D 'autoload -U bashcompinit' +zsh_autoload_colors =3D 'autoload -U colors' +zsh_colors =3D 'colors' +zsh_compinit =3D 'compinit -u' +zsh_bashcompinit =3D 'bashcompinit' + +pyenv_init =3D ''' +# Use the pyenv intalled Python interperter if command -v pyenv=20 +1>/dev/null 2>&1; then + eval "$(pyenv init -)" +fi +''' + +def add_command_to_startup_script(script_file, regex, command): + script =3D '' + if os.path.isfile(script_file): + with open(script_file, 'r') as f: + script =3D f.read().strip() + data =3D regex.search(script) + if not data: + if script =3D=3D '': + script =3D command + else: + script =3D '{}\n{}'.format(script, command) + with open(script_file, 'w') as f: + f.write(script) + +def main(): + home_dir =3D os.path.expanduser('~') + + # Add "source ~/.bashrc" to ~/.bash_profile if it does not have it al= ready + bash_profile_file =3D os.path.join(home_dir, '.bash_profile') + bash_profile =3D '' + if os.path.isfile(bash_profile_file): + with open(bash_profile_file, 'r') as f: + bash_profile =3D f.read().strip() + data =3D profile_source_regex.search(bash_profile) + if not data: + data =3D profile_source_regex2.search(bash_profile) + if not data: + if bash_profile =3D=3D '': + bash_profile =3D 'source ~/.bashrc\n' + else: + bash_profile =3D '{}\nsource ~/.bashrc\n'.format(bash_pro= file) + with open(bash_profile_file, 'w') as f: + f.write(bash_profile) + + # Add pyenv configuration to ~/.bashrc if it does not have it already + bash_rc_file =3D os.path.join(home_dir, '.bashrc') + add_command_to_startup_script(bash_rc_file, ls_alias_regex, ls_alias) + add_command_to_startup_script(bash_rc_file, bash_completion_regex, ba= sh_completion) + add_command_to_startup_script(bash_rc_file, pyenv_init_regex, pyenv_i= nit) + zsh_rc_file =3D os.path.join(home_dir, '.zshrc') + add_command_to_startup_script(zsh_rc_file, ls_alias_regex, ls_alias) + add_command_to_startup_script(zsh_rc_file, zsh_autoload_compinit_rege= x, zsh_autoload_compinit) + add_command_to_startup_script(zsh_rc_file, zsh_autoload_bashcompinit_= regex, zsh_autoload_bashcompinit) + add_command_to_startup_script(zsh_rc_file, zsh_autoload_colors_regex,= zsh_autoload_colors) + add_command_to_startup_script(zsh_rc_file, zsh_colors_regex, zsh_colo= rs) + add_command_to_startup_script(zsh_rc_file, zsh_compinit_regex, zsh_co= mpinit) + add_command_to_startup_script(zsh_rc_file, zsh_bashcompinit_regex, zs= h_bashcompinit) + add_command_to_startup_script(zsh_rc_file, bash_completion_regex, bas= h_completion) + add_command_to_startup_script(zsh_rc_file, pyenv_init_regex,=20 + pyenv_init) + + print('Pyenv configured successfully') + return 0 + +if __name__ =3D=3D '__main__': + ret_val =3D 255 + try: + ret_val =3D main() + except Exception: + print('Unhandled Exception...') + traceback.print_exc() + + sys.exit(ret_val) +EOF + +# On Catalina and later python3 is preferred, # however it is not=20 +packaged by Apple on earlier OSes if [ -x "$(command -v python3)" ];=20 +then + python3 -c "$python_script" + exit $? +else + python -c "$python_script" + exit $? +fi -- 2.25.2