From 6f628b6e5a893325556bb28c938aa8f0f22fd3cc Mon Sep 17 00:00:00 2001 From: "U-IDSI0\\nghodban" Date: Mon, 28 Oct 2024 11:16:22 +0100 Subject: [PATCH] support msys2 --- commands/config.py | 3 ++ src/architecture.py | 18 ++++++++- src/compilation.py | 7 +++- src/internal_config/distrib.pyconf | 1 + src/internal_config/salomeTools_msys.pyconf | 26 ++++++++++++ src/product.py | 4 ++ src/system.py | 44 +++++++++++---------- 7 files changed, 80 insertions(+), 23 deletions(-) create mode 100644 src/internal_config/salomeTools_msys.pyconf diff --git a/commands/config.py b/commands/config.py index 3b9fb9c..bd6759c 100644 --- a/commands/config.py +++ b/commands/config.py @@ -267,6 +267,9 @@ class ConfigManager: if src.architecture.is_windows(): # special internal config for windows internal_cfg = src.pyconf.Config(open( osJoin(cfg.VARS.srcDir, 'internal_config', 'salomeTools_win.pyconf'))) + elif src.architecture.is_msys2(): + internal_cfg = src.pyconf.Config(open( osJoin(cfg.VARS.srcDir, + 'internal_config', 'salomeTools_msys.pyconf'))) else: internal_cfg = src.pyconf.Config(open( osJoin(cfg.VARS.srcDir, 'internal_config', 'salomeTools.pyconf'))) diff --git a/src/architecture.py b/src/architecture.py index ad06c80..bc35478 100644 --- a/src/architecture.py +++ b/src/architecture.py @@ -45,8 +45,19 @@ def is_windows(): :rtype: boolean ''' - return system() == 'Windows' + return system() == 'Windows' and not is_msys2() +def is_msys2(): + '''method that checks MSYS2 + + :rtype: boolean + ''' + try: + import distro + return distro.id().startswith("mingw64_nt") + except Exception: + sys.exit(-1) + def get_user(): '''method that gets the username that launched sat @@ -74,6 +85,8 @@ def get_distribution(codes): ''' if is_windows(): return "W" + elif is_msys2(): + return "mingw" # else get linux distribution description from platform, and encode it with code lin_distrib = linux_distribution()[0].lower() @@ -117,7 +130,8 @@ def get_distrib_version(distrib): if is_windows(): return release() - + elif is_msys2(): + return '-w64-x86_64' # get version from platform dist_version=linux_distribution()[1].split('.') diff --git a/src/compilation.py b/src/compilation.py index ac2a556..59821dc 100644 --- a/src/compilation.py +++ b/src/compilation.py @@ -507,6 +507,10 @@ CC=\\"hack_libtool\\"%g" libtool''' self.build_environ.set("SAT_VERBOSE", "1") + def list2cmdline(self, args): return ' '.join(map( + lambda a: a if a.lstrip().startswith('"') or '"' not in a else '"' + a + '"', + map(lambda a: subprocess.list2cmdline([a]), args))) + def do_batch_script_build(self, script, nb_proc): if src.architecture.is_windows(): @@ -517,12 +521,13 @@ CC=\\"hack_libtool\\"%g" libtool''' self.log_command(" " + _("Run build script %s\n") % script) self.complete_environment(make_options) - res = subprocess.call(script, + res = subprocess.call(self.list2cmdline([script]), shell=True, stdout=self.logger.logTxtFile, stderr=subprocess.STDOUT, cwd=str(self.build_dir), env=self.build_environ.environ.environ) + print("==",res) res_check=self.check_install() if res_check > 0 : diff --git a/src/internal_config/distrib.pyconf b/src/internal_config/distrib.pyconf index 9476840..371be59 100644 --- a/src/internal_config/distrib.pyconf +++ b/src/internal_config/distrib.pyconf @@ -21,4 +21,5 @@ DISTRIBUTIONS : "linux mint": "UB" "opensuse":"OS" "Windows" : "W" + "msys2" : "mingw-w64-x86_64" } diff --git a/src/internal_config/salomeTools_msys.pyconf b/src/internal_config/salomeTools_msys.pyconf new file mode 100644 index 0000000..5642acb --- /dev/null +++ b/src/internal_config/salomeTools_msys.pyconf @@ -0,0 +1,26 @@ +#!/usr/bin/env python +#-*- coding:utf-8 -*- + +INTERNAL : +{ + sat_version : "5.3.0" + config : + { + copy_prefix : "LOCAL_" + install_dir : "w64-x86-64" + binary_dir : "w64-x86-64" + single_install_dir : "PRODUCTS" + } + log : + { + not_shown_commands : ["log"] + } + command : + { + pip_download : "python3 -m pip download --disable-pip-version-check" + pip_install : "python3 -m pip install --disable-pip-version-check --no-index" + } +} +PRODUCTS : +{ +} diff --git a/src/product.py b/src/product.py index 8f49eb1..b60edc5 100644 --- a/src/product.py +++ b/src/product.py @@ -1353,6 +1353,10 @@ def check_system_dep(distrib, check_cmd, product_info): if "apt_dev" in additional_sysinfo: for pkg in additional_sysinfo.apt_dev: build_dep[pkg]=src.system.check_system_pkg(check_cmd,pkg) + if check_cmd[0]=="pacman": + if "pacman" in sysinfo: + for pkg in sysinfo.pacman: + runtime_dep[pkg]=src.system.check_system_pkg(check_cmd,pkg) return runtime_dep,build_dep diff --git a/src/system.py b/src/system.py index 7dbd2d3..2dfee2d 100644 --- a/src/system.py +++ b/src/system.py @@ -425,33 +425,37 @@ def get_pkg_check_cmd(dist_name): if dist_name in ["CO","FD","MG","MD","CO","OS"]: # linux using rpm linux="RH" - manager_msg_err="Error : command failed because sat was not able to find apt command" + manager_msg_err="Error : command failed because sat was not able to find rpm command" else: linux="DB" - manager_msg_err="Error : command failed because sat was not able to find rpm command" + manager_msg_err="Error : command failed because sat was not able to find apt command" # 1- search for an installed package manager (rpm on rh, apt or dpkg-query on db) cmd_which_rpm = ["which", "rpm"] cmd_which_apt = ["which", "apt"] cmd_which_dpkg = ["which", "dpkg-query"] - with open(os.devnull, 'w') as devnull: - # 1) we search for apt (debian based systems) - completed=SP.call(cmd_which_dpkg,stdout=devnull, stderr=SP.STDOUT) - if completed==0 and linux=="DB": - cmd_is_package_installed = ["dpkg-query", "-l"] - else: - # 2) if dpkg not found search for apt - completed = SP.call(cmd_which_apt, stdout=devnull, stderr=SP.STDOUT) - if completed == 0 and linux == "DB": - cmd_is_package_installed = ["apt", "list", "--installed"] - else: - # 3) if apt not found search for rpm (redhat) - completed=SP.call(cmd_which_rpm,stdout=devnull, stderr=SP.STDOUT) # only 3.8! ,capture_output=True) - if completed==0 and linux=="RH": - cmd_is_package_installed=["rpm", "-q"] - else: - # no package manager was found corresponding to dist_name - raise src.SatException(manager_msg_err) + cmd_which_pacman = ["which", "pacman"] + if src.architecture.is_msys2(): + cmd_is_package_installed = ["pacman", "-Q"] + else: + with open(os.devnull, 'w') as devnull: + # 1) we search for apt (debian based systems) + completed=SP.call(cmd_which_dpkg,stdout=devnull, stderr=SP.STDOUT) + if completed==0 and linux=="DB": + cmd_is_package_installed = ["dpkg-query", "-l"] + else: + # 2) if dpkg not found search for apt + completed = SP.call(cmd_which_apt, stdout=devnull, stderr=SP.STDOUT) + if completed == 0 and linux == "DB": + cmd_is_package_installed = ["apt", "list", "--installed"] + else: + # 3) if apt not found search for rpm (redhat) + completed=SP.call(cmd_which_rpm,stdout=devnull, stderr=SP.STDOUT) # only 3.8! ,capture_output=True) + if completed==0 and linux=="RH": + cmd_is_package_installed=["rpm", "-q"] + else: + # no package manager was found corresponding to dist_name + raise src.SatException(manager_msg_err) return cmd_is_package_installed def check_system_pkg(check_cmd,pkg): -- 2.39.2