mirror of
https://github.com/miurahr/aqtinstall.git
synced 2025-12-17 04:34:37 +03:00
Set executable file permissions for qmake
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
import logging
|
||||
import os
|
||||
import stat
|
||||
import subprocess
|
||||
from logging import getLogger
|
||||
from pathlib import Path
|
||||
@@ -69,8 +70,9 @@ class Updater:
|
||||
file.write_text(data, "UTF-8")
|
||||
os.chmod(str(file), st.st_mode)
|
||||
|
||||
def _patch_textfile(self, file: Path, old: Union[str, List[str]], new: str):
|
||||
def _patch_textfile(self, file: Path, old: Union[str, List[str]], new: str, *, is_executable: bool = False):
|
||||
st = file.stat()
|
||||
file_mode = st.st_mode | (stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH if is_executable else 0)
|
||||
data = file.read_text("UTF-8")
|
||||
if isinstance(old, str):
|
||||
data = data.replace(old, new)
|
||||
@@ -78,7 +80,7 @@ class Updater:
|
||||
for old_str in old:
|
||||
data = data.replace(old_str, new)
|
||||
file.write_text(data, "UTF-8")
|
||||
os.chmod(str(file), st.st_mode)
|
||||
os.chmod(str(file), file_mode)
|
||||
|
||||
def _detect_qmake(self) -> bool:
|
||||
"""detect Qt configurations from qmake."""
|
||||
@@ -178,7 +180,7 @@ class Updater:
|
||||
unpatched = [f"{p}/bin" for p in unpatched_paths()]
|
||||
qmake_path = self.prefix / "bin" / ("qmake.bat" if os_name == "windows" else "qmake")
|
||||
self.logger.info(f"Patching {qmake_path}")
|
||||
self._patch_textfile(qmake_path, unpatched, patched)
|
||||
self._patch_textfile(qmake_path, unpatched, patched, is_executable=True)
|
||||
|
||||
def patch_qtcore(self, target):
|
||||
"""patch to QtCore"""
|
||||
|
||||
@@ -1001,6 +1001,8 @@ def test_install(
|
||||
for patched_file in archive.contents:
|
||||
file_path = installed_path / patched_file.filename
|
||||
assert file_path.is_file()
|
||||
if file_path.name == "qmake":
|
||||
assert os.access(file_path, os.X_OK), "qmake file must be executable"
|
||||
|
||||
expect_content = patched_file.expected_content(base_dir=output_dir, sep=os.sep)
|
||||
actual_content = file_path.read_text(encoding="utf_8")
|
||||
|
||||
Reference in New Issue
Block a user