public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Nate DeSimone" <nathaniel.l.desimone@intel.com>
To: devel@edk2.groups.io
Cc: Ashley DeSimone <ashley.e.desimone@intel.com>,
	Puja Pandya <puja.pandya@intel.com>,
	Erik Bjorge <erik.c.bjorge@intel.com>,
	Bret Barkelew <Bret.Barkelew@microsoft.com>
Subject: [edk2-staging/EdkRepo] [PATCH] EdkRepo: Make Python scripts in git_automation executable
Date: Thu, 12 Dec 2019 16:29:53 -0800	[thread overview]
Message-ID: <20191213002953.19726-1-nathaniel.l.desimone@intel.com> (raw)

Scripts in the git_automation folder need to be executable so that git
can invoke them as editor commands.

Cc: Ashley DeSimone <ashley.e.desimone@intel.com>
Cc: Puja Pandya <puja.pandya@intel.com>
Cc: Erik Bjorge <erik.c.bjorge@intel.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
---
 edkrepo_installer/linux-scripts/install.py | 27 ++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/edkrepo_installer/linux-scripts/install.py b/edkrepo_installer/linux-scripts/install.py
index a05ce6a..e0f57b2 100755
--- a/edkrepo_installer/linux-scripts/install.py
+++ b/edkrepo_installer/linux-scripts/install.py
@@ -15,6 +15,7 @@ import importlib.util
 import logging
 import os
 import platform
+import stat
 import shutil
 import subprocess
 import sys
@@ -25,6 +26,7 @@ tool_sign_on = 'Installer for edkrepo version {}\nCopyright(c) Intel Corporation

 # Data here should be maintained in a configuration file
 cfg_dir = '.edkrepo'
+directories_with_executables = ['git_automation']
 cfg_src_dir = os.path.abspath('config')
 whl_src_dir = os.path.abspath('wheels')

@@ -116,6 +118,27 @@ def _check_version(current, expected):
             return 1
     return 0

+def get_site_packages_directory():
+    res = default_run([def_python, '-c', 'import site; print(site.getsitepackages()[0])'])
+    return res.stdout.strip()
+
+def set_execute_permissions():
+    site_packages = get_site_packages_directory()
+    config = configparser.ConfigParser(allow_no_value=True, delimiters='=')
+    config.read(os.path.join(cfg_src_dir, 'edkrepo.cfg'))
+    command_packages = [x.strip() for x in config['command-packages']['packages'].split('|')]
+    for command_package in command_packages:
+        package_dir = os.path.join(site_packages, command_package.split('.')[0])
+        for directory in directories_with_executables:
+            full_path = os.path.join(package_dir, directory)
+            if os.path.isdir(full_path):
+                for py_file in os.listdir(full_path):
+                    if py_file == '__init__.py' or os.path.splitext(py_file)[1] != '.py':
+                        continue
+                    py_file = os.path.join(full_path, py_file)
+                    stat_data = os.stat(py_file)
+                    os.chmod(py_file, stat_data.st_mode | stat.S_IEXEC)
+
 def do_install():
     # Parse command line
     args = get_args()
@@ -316,6 +339,10 @@ def do_install():
                     return 1
                 log.info('+ Installed {}'.format(whl_name))

+    #Mark scripts as executable
+    set_execute_permissions()
+    log.info('+ Marked scripts as executable')
+
     log.log(logging.PRINT, '\nInstallation complete\n')

     return 0
--
2.20.1


             reply	other threads:[~2019-12-13  0:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-13  0:29 Nate DeSimone [this message]
2019-12-13 21:25 ` [edk2-devel] [edk2-staging/EdkRepo] [PATCH] EdkRepo: Make Python scripts in git_automation executable Desimone, Ashley E

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191213002953.19726-1-nathaniel.l.desimone@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox