xmake.lua 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package("msys2-base")
  2. set_kind("toolchain")
  3. set_homepage("https://www.msys2.org/")
  4. set_description("Software Distribution and Building Platform for Windows")
  5. add_urls("https://github.com/msys2/msys2-installer/releases/download/$(version).tar.xz", {version = function (version)
  6. return version:gsub("%.", "-") .. "/msys2-base-x86_64-" .. version:gsub("%.", "")
  7. end})
  8. add_versions("2024.01.13", "04456a44a956d3c0b5f9b6c754918bf3a8c3d87c858be7a0c94c9171ab13c58c")
  9. set_policy("package.precompiled", false)
  10. on_install("@windows|x64", function (package)
  11. -- reduce time required to install packages by disabling pacman's disk space checking
  12. io.gsub("etc/pacman.conf", "^CheckSpace", "#CheckSpace")
  13. -- disable key refresh
  14. io.replace("etc/post-install/07-pacman-key.post", "--refresh-keys", "--version", {plain = true})
  15. -- install files
  16. os.cp("*", package:installdir())
  17. package:addenv("PATH", "usr/bin")
  18. -- starting MSYS2 for the first time
  19. local bash = path.join(package:installdir("usr/bin"), "bash.exe")
  20. os.vrunv(bash, {"-leo", "pipefail", "-c", "uname -a"})
  21. -- updating packages
  22. try { function () os.vrunv(bash, {"-leo", "pipefail", "-c", "pacman --noconfirm -Syuu --overwrite *"}) end}
  23. -- killing remaining tasks
  24. os.vrunv("taskkill", {"/F", "/FI", "MODULES eq msys-2.0.dll"})
  25. -- final system upgrade
  26. os.vrunv(bash, {"-leo", "pipefail", "-c", "pacman --noconfirm -Syuu --overwrite *"})
  27. end)
  28. on_test(function (package)
  29. os.vrun("sh --version")
  30. os.vrun("perl --version")
  31. os.vrun("ls -l")
  32. os.vrun("grep --version")
  33. os.vrun("uname -a")
  34. end)