From nobody Mon Feb 9 07:55:38 2026 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+57003+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+57003+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1586220000; cv=none; d=zohomail.com; s=zohoarc; b=V5xuLsW8GSHJ4nodZ639lZ+NiRJFNcdQw4j/yC5r+aL9+ZzJNJjD+/tIPvzvznBdH6mRdrEORti+QuTQE7q4QBkmqX79ktoBELjrWiCHRCknR5JP6VcRpNu8xD2vBghVmkZHK2ssPxeFmTxDQLJ4phNDZkbF7l3BifAfA0rGdB8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586220000; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=ciL2bJQbZ7GeK7KFASJirOu37edt3N1fcfNJ191iT/E=; b=hDwOvcsI96c+tZl+Bb0BOjhFaRef/NOt395Rmk4ceeqMCCTBfdA2ehUVALWjjUt/CQA/RCV+dws7YbOlfJ+OPpGvFRCh9TjYPKUNrrnnUEU5xhx7mMAgh99q7gddsLhQYv9q7gj2tLkTE91ZjZL/JSvSPiT+6w1OJ9o2nWm5poc= 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+57003+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 1586220000114569.4343362430095; Mon, 6 Apr 2020 17:40:00 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id SVquYY1788612xDJVHTXOwnD; Mon, 06 Apr 2020 17:39:59 -0700 X-Received: from mga02.intel.com (mga02.intel.com []) by mx.groups.io with SMTP id smtpd.web12.583.1586219997646584672 for ; Mon, 06 Apr 2020 17:39:58 -0700 IronPort-SDR: gsf0b39bWigaK69DYz8EBFZvbnZioO6es93YsitZabzrtZLVOiDSiaI18znjLVju2QktluaoKa kCf6+zKmIiXg== 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 orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2020 17:39:57 -0700 IronPort-SDR: QmjdnjkFDYWY3ucophOaVaA+/IX4OC5ZgG9w5Qtmy3x+TR90hSDF2lOo0BC0Yte7M1HMx+Wyuu ea9rrLjjFb8Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,352,1580803200"; d="scan'208";a="251059374" X-Received: from vbuzyanx-mobl.amr.corp.intel.com ([10.254.111.95]) by orsmga003.jf.intel.com with ESMTP; 06 Apr 2020 17:39:56 -0700 From: "Nate DeSimone" To: devel@edk2.groups.io Cc: Puja Pandya , Erik Bjorge , Prince Agyeman , Bret Barkelew , Philippe Mathieu-Daude Subject: [edk2-devel] [edk2-staging/EdkRepo] [PATCH 1/2] EdkRepo: Add setup_git_pyenv_mac.sh Date: Mon, 6 Apr 2020 17:39:49 -0700 Message-Id: <20200407003950.33249-2-nathaniel.l.desimone@intel.com> In-Reply-To: <20200407003950.33249-1-nathaniel.l.desimone@intel.com> References: <20200407003950.33249-1-nathaniel.l.desimone@intel.com> MIME-Version: 1.0 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,nathaniel.l.desimone@intel.com X-Gm-Message-State: BFaSe6MvRDYJRKc8UxxCR7SFx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1586219999; bh=fycwsy8S3SLkpy0X7wNpACi9inNorOvww6q6lcmCNo4=; h=Cc:Date:From:Reply-To:Subject:To; b=rll0EsVpkgHXiaGXDoaWGaLy+lfdm4AAhRf3EYZH4DTkmUNB6R2uRhivti9nx+Hv+zN 6pvLLBe6IaCTU9JEoL2YfwYsbnffhIe8u2ZO5GWCiLi/MH6zmTEnwxTtmTXUbf64Ell3C 0Xi50wA/GbkxoH5QMXP0B7wq2ysD0qlwaQU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Ashley DeSimone --- .../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/edkrepo= _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.
+# 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 re.compile(r"\[\[\s+-r\s+\"/usr/local/etc/profil= e.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 re.compile(r"autoload\s+-U\s+bashcompi= nit") +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 re.compile(r"compinit\s+-u") +zsh_bashcompinit_regex =3D 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 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 alr= eady + 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_prof= ile) + 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, bas= h_completion) + add_command_to_startup_script(bash_rc_file, pyenv_init_regex, pyenv_in= it) + 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_regex= , zsh_autoload_compinit) + add_command_to_startup_script(zsh_rc_file, zsh_autoload_bashcompinit_r= egex, 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_color= s) + add_command_to_startup_script(zsh_rc_file, zsh_compinit_regex, zsh_com= pinit) + add_command_to_startup_script(zsh_rc_file, zsh_bashcompinit_regex, zsh= _bashcompinit) + add_command_to_startup_script(zsh_rc_file, bash_completion_regex, bash= _completion) + add_command_to_startup_script(zsh_rc_file, pyenv_init_regex, pyenv_ini= t) + + 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 packaged by Apple on earlier OSes +if [ -x "$(command -v python3)" ]; then + python3 -c "$python_script" + exit $? +else + python -c "$python_script" + exit $? +fi -- 2.25.2 -=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 (#57003): https://edk2.groups.io/g/devel/message/57003 Mute This Topic: https://groups.io/mt/72840961/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-