From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web10.4858.1576197005334223712 for ; Thu, 12 Dec 2019 16:30:05 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: nathaniel.l.desimone@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Dec 2019 16:30:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,307,1571727600"; d="scan'208";a="414117660" Received: from nldesimo-mac02.jf.intel.com ([10.24.15.97]) by fmsmga005.fm.intel.com with ESMTP; 12 Dec 2019 16:30:03 -0800 From: "Nate DeSimone" To: devel@edk2.groups.io Cc: Ashley DeSimone , Puja Pandya , Erik Bjorge , Bret Barkelew Subject: [edk2-staging/EdkRepo] [PATCH] EdkRepo: Make Python scripts in git_automation executable Date: Thu, 12 Dec 2019 16:29:53 -0800 Message-Id: <20191213002953.19726-1-nathaniel.l.desimone@intel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Scripts in the git_automation folder need to be executable so that git can invoke them as editor commands. Cc: Ashley DeSimone Cc: Puja Pandya Cc: Erik Bjorge Cc: Bret Barkelew Signed-off-by: Nate DeSimone --- 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