def _install()

in microsoft/testsuites/xdp/xdptools.py [0:0]


    def _install(self) -> bool:
        # install dependencies

        config_envs: Dict[str, str] = {}
        if isinstance(self.node.os, Debian):
            if self.node.os.information.version < "18.4.0":
                raise UnsupportedDistroException(self.node.os)
            elif self.node.os.information.version == "18.4.0":
                self.node.os.add_repository("ppa:ubuntu-toolchain-r/test")
            else:
                toolchain = f"llvm-toolchain-{self.node.os.information.codename}"
                self.node.os.add_repository(
                    repo=(
                        f"deb http://apt.llvm.org/{self.node.os.information.codename}/ "
                        f"{toolchain} main"
                    ),
                    key_location="https://apt.llvm.org/llvm-snapshot.gpg.key",
                )

            self.node.os.install_packages(
                "clang-10 llvm libelf-dev libpcap-dev gcc-multilib build-essential "
                "pkg-config m4 tshark"
            )

            config_envs.update({"CLANG": "clang-10", "LLC": "llc-10"})

        elif isinstance(self.node.os, Fedora):
            self.node.os.install_packages(
                "llvm-toolset elfutils-devel m4 wireshark perf make gcc tc "
                # pcaplib
                "http://rpmfind.net/linux/centos/8.5.2111/PowerTools/"
                "x86_64/os/Packages/libpcap-devel-1.9.1-5.el8.x86_64.rpm"
            )
        else:
            raise UnsupportedDistroException(self.node.os)

        git = self.node.tools[Git]
        # use super() to prevent duplicate build.
        code_root_path = git.clone(
            self._xdp_tools_repo, cwd=super().get_tool_path(), ref=self._xdp_tools_tag
        )
        self._code_path = code_root_path
        # use xdpdump to detect if the tool is installed or not.
        self._command = self._code_path / "xdp-dump" / "xdpdump"

        # create a default version for exists checking.
        self.node.execute(
            "./configure",
            cwd=code_root_path,
            update_envs=config_envs,
            expected_exit_code=0,
            expected_exit_code_failure_message="failed on configure xdp "
            "tools before make.",
        )
        make = self.node.tools[Make]
        # Errors happen if built with multi-threads. The program may not be
        # ready for concurrent build, but our make tool use multi-thread by
        # default. So set thread count to 1.
        make.make(
            arguments="",
            cwd=self._code_path,
            update_envs={"ARCH": "x86_64"},
            thread_count=1,
        )

        return self._check_exists()