public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-staging/EdkRepo] [PATCH] EdkRepo: Make Python scripts in git_automation executable
@ 2019-12-13  0:29 Nate DeSimone
  2019-12-13 21:25 ` [edk2-devel] " Desimone, Ashley E
  0 siblings, 1 reply; 2+ messages in thread
From: Nate DeSimone @ 2019-12-13  0:29 UTC (permalink / raw)
  To: devel; +Cc: Ashley DeSimone, Puja Pandya, Erik Bjorge, Bret Barkelew

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-12-13 21:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-13  0:29 [edk2-staging/EdkRepo] [PATCH] EdkRepo: Make Python scripts in git_automation executable Nate DeSimone
2019-12-13 21:25 ` [edk2-devel] " Desimone, Ashley E

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox