From 66b9db21e50886a65776edead78e2dcb9c63290b Mon Sep 17 00:00:00 2001 From: ngosang Date: Sun, 21 May 2023 21:09:06 +0200 Subject: [PATCH] Fix Chromium exec permissions in Linux package --- src/build_package.py | 15 ++++++++++++++- src/utils.py | 7 +++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/build_package.py b/src/build_package.py index 6d51b6e..3ceda2d 100644 --- a/src/build_package.py +++ b/src/build_package.py @@ -50,7 +50,20 @@ def download_chromium(): with zipfile.ZipFile(dl_path_zip, 'r') as zip_ref: zip_ref.extractall(dl_path) os.remove(dl_path_zip) - shutil.move(dl_path_folder, os.path.join(dl_path, "chrome")) + + chrome_path = os.path.join(dl_path, "chrome") + shutil.move(dl_path_folder, chrome_path) + print("Extracted in: " + chrome_path) + + if os.name != 'nt': + # Give executable permissions for *nix + # file * | grep executable | cut -d: -f1 + print("Giving executable permissions...") + execs = ['chrome', 'chrome_crashpad_handler', 'chrome_sandbox', 'chrome-wrapper', 'nacl_helper', + 'nacl_helper_bootstrap', 'nacl_irt_x86_64.nexe', 'xdg-mime', 'xdg-settings'] + for exec_file in execs: + exec_path = os.path.join(chrome_path, exec_file) + os.chmod(exec_path, 0o755) def run_pyinstaller(): diff --git a/src/utils.py b/src/utils.py index eee8868..8f42b5f 100644 --- a/src/utils.py +++ b/src/utils.py @@ -106,12 +106,15 @@ def get_chrome_exe_path() -> str: return CHROME_EXE_PATH # linux pyinstaller bundle chrome_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'chrome', "chrome") - if os.path.exists(chrome_path) and os.access(chrome_path, os.X_OK): + if os.path.exists(chrome_path): + if not os.access(chrome_path, os.X_OK): + raise Exception(f'Chrome binary "{chrome_path}" is not executable. ' + f'Please, extract the archive with "tar xzf ".') CHROME_EXE_PATH = chrome_path return CHROME_EXE_PATH # windows pyinstaller bundle chrome_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'chrome', "chrome.exe") - if os.path.exists(chrome_path) and os.access(chrome_path, os.X_OK): + if os.path.exists(chrome_path): CHROME_EXE_PATH = chrome_path return CHROME_EXE_PATH # system