[edk2-devel] [edk2-staging/EdkRepo] [PATCH] EdkRepo: Make Python scripts in git_automation executable
Desimone, Ashley E
ashley.e.desimone at intel.com
Fri Dec 13 21:25:03 UTC 2019
Reviewed-by: Ashley DeSimone <ashley.e.desimone at intel.com>
-----Original Message-----
From: devel at edk2.groups.io [mailto:devel at edk2.groups.io] On Behalf Of Nate DeSimone
Sent: Thursday, December 12, 2019 4:30 PM
To: devel at edk2.groups.io
Cc: Desimone, Ashley E <ashley.e.desimone at intel.com>; Pandya, Puja <puja.pandya at intel.com>; Bjorge, Erik C <erik.c.bjorge at intel.com>; Bret Barkelew <Bret.Barkelew at microsoft.com>
Subject: [edk2-devel] [edk2-staging/EdkRepo] [PATCH] EdkRepo: Make Python scripts in git_automation executable
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 at intel.com>
Cc: Puja Pandya <puja.pandya at intel.com>
Cc: Erik Bjorge <erik.c.bjorge at intel.com>
Cc: Bret Barkelew <Bret.Barkelew at microsoft.com>
Signed-off-by: Nate DeSimone <nathaniel.l.desimone at 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
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#52214): https://edk2.groups.io/g/devel/message/52214
Mute This Topic: https://groups.io/mt/68357396/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list