Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildconfig/download_msys2_prebuilt: Add --overwrite option #4238

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions buildconfig/download_msys2_prebuilt.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 11,16 @@
import sys


def install_pacman_package(pkg_name):
def install_pacman_package(pkg_name, overwrite):
"""This installs a package in the current MSYS2 environment

Does not download again if the package is already installed
and if the version is the latest available in MSYS2
"""
cmd = ["pacman", "-S", "--noconfirm", pkg_name] if not overwrite else ["pacman", "-S", "--noconfirm", "--overwrite", "'*'", pkg_name]

output = subprocess.run(
["pacman", "-S", "--noconfirm", pkg_name], capture_output=True, text=True
cmd, capture_output=True, text=True
)
if output.returncode != 0:
logging.error(
Expand Down Expand Up @@ -90,13 92,13 @@ def get_packages(arch: str) -> list:
return [x.format(full_arch_names[arch]) for x in deps]


def install_prebuilts(arch):
def install_prebuilts(arch, overwrite):
"""For installing prebuilt dependencies."""
errors = False
print("Installing pre-built dependencies")
for pkg in get_packages(arch):
print(f"Installing {pkg}")
error = install_pacman_package(pkg)
error = install_pacman_package(pkg, overwrite)
errors = errors or error
if errors:
raise Exception("Some dependencies could not be installed")
Expand Down Expand Up @@ -127,7 129,10 @@ def detect_arch():


def update(arch=None):
install_prebuilts(arch if arch else detect_arch())
overwrite = "--overwrite" in sys.argv
if overwrite:
print ("Running pacman with --overwrite '*'")
install_prebuilts(arch if arch else detect_arch(), overwrite)


if __name__ == "__main__":
Expand Down
Loading