Exemplo n.º 1
0
    def updateMsys(self):
        msysDir = CraftCore.settings.get(
            "Paths", "Msys", os.path.join(CraftStandardDirs.craftRoot(),
                                          "msys"))
        shell = shells.BashShell()
        useOverwrite = CraftCore.cache.checkCommandOutputFor(
            os.path.join(msysDir, "usr/bin", "pacman.exe"), "--overwrite",
            "-Sh")

        # force was replace by overwrite
        overwrite = "--overwrite='*'" if useOverwrite else "--force"

        def stopProcesses():
            return OsUtils.killProcess("*", msysDir)

        def queryForUpdate():
            out = io.BytesIO()
            if not shell.execute(".", "pacman",
                                 f"-Sy --noconfirm {overwrite}"):
                raise Exception()
            shell.execute(".",
                          "pacman",
                          "-Qu --noconfirm",
                          stdout=out,
                          stderr=subprocess.PIPE)
            out = out.getvalue()
            return out != b""

        # start and restart msys before first use
        if not (shell.execute(".", "echo", "Init update") and stopProcesses()
                and shell.execute(".", "pacman-key", "--init")
                and shell.execute(".", "pacman-key", "--populate")):
            return False

        try:
            # max 10 tries
            for _ in range(10):
                if not queryForUpdate():
                    break
                # might return 1 on core updates...
                shell.execute(".", "pacman",
                              f"-Su --noconfirm {overwrite} --ask 20")
                if not stopProcesses():
                    return False
        except Exception as e:
            CraftCore.log.error(e, exc_info=e)
            return False
        if not (shell.execute(
                ".", "pacman",
                f"-S base-devel msys/binutils --noconfirm {overwrite} --needed"
        ) and stopProcesses()):
            return False
        # rebase: Too many DLLs for available address space: Cannot allocate memory => ignore return code ATM
        utils.system("autorebase.bat", cwd=msysDir)
        return True
Exemplo n.º 2
0
 def __init__(self):
     BinaryPackageBase.__init__(self)
     self.shell = shells.BashShell()