예제 #1
0
 def system_requirements(self):
     if self.settings.os == 'Linux':
         installer = SystemPackageTool()
         installer.update()
         installer.install("libxaw7-dev")
         installer.install("libxt-dev")
         installer.install("libxrandr-dev")
예제 #2
0
 def system_requirements(self):
     pack_name = None
     if os_info.linux_distro == "ubuntu":
         pack_name = "libbsd-dev"
     if pack_name:
         installer = SystemPackageTool()
         installer.install(pack_name)
예제 #3
0
    def system_package_tool_fail_when_not_0_returned_test(self):
        def get_linux_error_message():
            """
            Get error message for Linux platform if distro is supported, None otherwise
            """
            os_info = OSInfo()
            update_command = None
            if os_info.with_apt:
                update_command = "sudo apt-get update"
            elif os_info.with_yum:
                update_command = "sudo yum check-update"
            elif os_info.with_zypper:
                update_command = "sudo zypper --non-interactive ref"
            elif os_info.with_pacman:
                update_command = "sudo pacman -Syyu --noconfirm"

            return "Command '{0}' failed".format(update_command) if update_command is not None else None

        platform_update_error_msg = {
            "Linux": get_linux_error_message(),
            "Darwin": "Command 'brew update' failed",
            "Windows": "Command 'choco outdated' failed" if which("choco.exe") else None,
        }

        runner = RunnerMock(return_ok=False)
        pkg_tool = ChocolateyTool() if which("choco.exe") else None
        spt = SystemPackageTool(runner=runner, tool=pkg_tool)

        msg = platform_update_error_msg.get(platform.system(), None)
        if msg is not None:
            with self.assertRaisesRegexp(ConanException, msg):
                spt.update()
        else:
            spt.update()  # Won't raise anything because won't do anything
예제 #4
0
 def system_requirements(self):
     pack_list = None
     if os_info.linux_distro == "ubuntu":
         pack_list = []
     if pack_list:
         for p in pack_list:
             installer = SystemPackageTool()
             installer.install(p)
예제 #5
0
 def system_requirements(self):
     if os_info.is_linux:
         installer = SystemPackageTool()
         for pkg in [
                 "autoconf", "automake", "libtool", "curl", "make", "g++",
                 "unzip"
         ]:
             installer.install(pkg)
예제 #6
0
	def system_requirements(self):
		pack_name = None
		if os_info.linux_distro == "ubuntu":
			pack_name = ["libopenal-dev", "libvorbis-dev", "libflac-dev"]

		if pack_name:
			installer = SystemPackageTool()
			installer.install(pack_name)  # Install the package, will update the package database if pack_name isn't already installed
예제 #7
0
파일: tools_test.py 프로젝트: nesono/conan
 def system_package_tool_fail_when_not_0_returned_test(self):
     runner = RunnerMock(return_ok=False)
     spt = SystemPackageTool(runner=runner)
     if platform.system() == "Linux" or platform.system() == "Darwin":
         msg = "Command 'sudo apt-get update' failed" if platform.system() == "Linux" \
             else "Command 'brew update' failed"
         with self.assertRaisesRegexp(ConanException, msg):
             spt.update()
     else:
         spt.update()  # Won't raise anything because won't do anything
예제 #8
0
    def system_package_tool_try_multiple_test(self):
        class RunnerMultipleMock(object):
            def __init__(self, expected=None):
                self.calls = 0
                self.expected = expected

            def __call__(self, command, output):  # @UnusedVariable
                self.calls += 1
                return 0 if command in self.expected else 1

        packages = ["a_package", "another_package", "yet_another_package"]
        with tools.environment_append({"CONAN_SYSREQUIRES_SUDO": "True"}):
            runner = RunnerMultipleMock(["dpkg -s another_package"])
            spt = SystemPackageTool(runner=runner, tool=AptTool())
            spt.install(packages)
            self.assertEquals(2, runner.calls)
            runner = RunnerMultipleMock(["sudo apt-get update",
                                         "sudo apt-get install -y --no-install-recommends yet_another_package"])
            spt = SystemPackageTool(runner=runner, tool=AptTool())
            spt.install(packages)
            self.assertEquals(7, runner.calls)

            runner = RunnerMultipleMock(["sudo apt-get update"])
            spt = SystemPackageTool(runner=runner, tool=AptTool())
            with self.assertRaises(ConanException):
                spt.install(packages)
            self.assertEquals(7, runner.calls)
예제 #9
0
 def system_requirements(self):
     if self.settings.os == 'Linux' and tools.os_info.is_linux:
         if tools.os_info.with_apt:
             installer = SystemPackageTool()
             arch_suffix = ''
             if self.settings.arch == 'x86':
                 arch_suffix = ':i386'
             elif self.settings.arch == 'x86_64':
                 arch_suffix = ":amd64"
             packages = ["libgtk2.0-dev%s" % arch_suffix]
             for package in packages:
                 installer.install(package)
예제 #10
0
    def source(self):
        if os_info.is_linux:
            installer = SystemPackageTool()
            installer.install("subversion")

        self.run('svn checkout -r ' + self.revision +
                 " http://svn.apache.org/repos/asf/incubator/log4cxx/trunk " +
                 self.lib_name)
        if not self.settings.os == "Windows":
            with tools.chdir(self.lib_name):
                self.run("./autogen.sh")
        tools.patch(base_path=self.lib_name, patch_file="char_widening.patch")
예제 #11
0
    def system_requirements(self):
        if os_info.is_linux:
            installer = SystemPackageTool()
            if os_info.linux_distro == 'arch':
                package_names = ["freeglut", "libxt"]
            else:
                package_names = [
                    "freeglut3-dev", "mesa-common-dev", "mesa-utils-extra",
                    "libgl1-mesa-dev", "libglapi-mesa"
                ]

            for name in package_names:
                installer.install(name)
예제 #12
0
 def system_requirements(self):
     # https://mxe.cc/#requirements-debian
     pkgs = [
         "autoconf", "automake", "autopoint", "bash", "bison", "bzip2",
         "flex", "g++", "g++-multilib", "gettext", "git", "gperf",
         "intltool", "libc6-dev-i386", "libgdk-pixbuf2.0-dev",
         "libltdl-dev", "libssl-dev", "libtool-bin", "libxml-parser-perl",
         "make", "openssl", "p7zip-full", "patch", "perl", "pkg-config",
         "python", "ruby", "sed", "unzip", "wget", "xz-utils"
     ]
     installer = SystemPackageTool()
     for pkg in pkgs:
         installer.install(pkg)
예제 #13
0
 def system_requirements(self):
     if os_info.is_linux:
         installer = SystemPackageTool()
         installer.install("gfortran")
     if os_info.is_macos:
         installer = SystemPackageTool()
         installer.install("gcc", update=True, force=True)
예제 #14
0
    def system_requirements(self):
        spt = SystemPackageTool()
        pack_names = []

        if not os_info.is_linux:
            return
        if os_info.linux_distro == "ubuntu":
            suffix_32 = ":i386"
        elif "opensuse" in os_info.linux_distro:
            suffix_32 = "-32bit"
        else:
            suffix_32 = ""
        
        if os_info.linux_distro == "ubuntu":
            if self.options.openGL:
                pack_names.extend(["libgl1-mesa-dev", "libglu1-mesa-dev", "freeglut3-dev", "libgl1-mesa-glx"])
            pack_names.append("libxmu-dev")
        elif "opensuse" in os_info.linux_distro:
            if self.options.openGL:
                pack_names.extend(["Mesa-libGL-devel"])
            pack_names.append("libXmu-devel")
        else:
            self.output.error("distro: %s" % os_info.linux_distro)
            pack_names = []

        spt.update()

        for pack in pack_names:
            if self.settings.arch == "x86":
                spt.install(pack + suffix_32)
            else:
                spt.install(pack)
예제 #15
0
 def system_package_tool_fail_when_not_0_returned_test(self):
     runner = RunnerMock(return_ok=False)
     spt = SystemPackageTool(runner=runner)
     platforms = {"Linux": "sudo apt-get update", "Darwin": "brew update"}
     if platform.system() in platforms:
         msg = "Command '%s' failed" % platforms[platform.system()]
         with self.assertRaisesRegexp(ConanException, msg):
             spt.update()
     elif platform.system() == "Windows" and which("choco.exe"):
         spt = SystemPackageTool(runner=runner, tool=ChocolateyTool())
         with self.assertRaisesRegexp(ConanException, "Command 'choco outdated' failed"):
             spt.update()
     else:
         spt.update()  # Won't raise anything because won't do anything
예제 #16
0
    def requirements(self):

        ncurses_pkg = None

        if os_info.is_linux:

            if os_info.linux_distro == "ubuntu":
                ncurses_pkg = "libncurses-dev"
            elif os_info.linux_distro in ("fedora", "centos"):
                ncurses_pkg = "ncurses-devel"

        if ncurses_pkg:
            installer = SystemPackageTool()
            installer.install(ncurses_pkg)
예제 #17
0
 def system_package_tool_installed_test(self):
     if platform.system() != "Linux" and platform.system() != "Macos" and platform.system() != "Windows":
         return
     if platform.system() == "Windows" and not which("choco.exe"):
         return
     spt = SystemPackageTool()
     expected_package = "git"
     if platform.system() == "Windows" and which("choco.exe"):
         spt = SystemPackageTool(tool=ChocolateyTool())
         # Git is not installed by default on Chocolatey
         expected_package = "chocolatey"
     # The expected should be installed on development/testing machines
     self.assertTrue(spt._tool.installed(expected_package))
     # This package hopefully doesn't exist
     self.assertFalse(spt._tool.installed("oidfjgesiouhrgioeurhgielurhgaeiorhgioearhgoaeirhg"))
예제 #18
0
 def system_requirements(self):
     try:
         if (self._is_msvc):
             return
         if (os_info.detect_windows_subsystem() != None and os_info.detect_windows_subsystem() != 'WSL'):
             os.environ["CONAN_SYSREQUIRES_SUDO"] = "False"
         installer = SystemPackageTool()
         #installer.update()
         installer.install('autoconf')
         installer.install('automake')
         installer.install('libtool')
         installer.install('make')
         installer.install('pkg-config')
     except:
         self.output.warn('Unable to bootstrap required build tools.  If they are already installed, you can ignore this warning.')
         self.output.warn(traceback.print_exc())
예제 #19
0
 def system_requirements(self):
     installer = SystemPackageTool()
     if os_info.is_linux:
         if tools.os_info.linux_distro == "arch":
             installer.install("gcc-fortran")
         else:
             installer.install("gfortran")
     if os_info.is_macos:
         installer.install("gcc", update=True, force=True)
예제 #20
0
 def system_package_tool_installed_test(self):
     if platform.system() != "Linux" and platform.system() != "Macos":
         return
     spt = SystemPackageTool()
     # Git should be installed on development/testing machines
     self.assertTrue(spt._tool.installed("git"))
     # This package hopefully doesn't exist
     self.assertFalse(spt._tool.installed("oidfjgesiouhrgioeurhgielurhgaeiorhgioearhgoaeirhg"))
예제 #21
0
 def system_requirements(self):
     if tools.os_info.with_apt:
         packages = [
             "libgtk-3-dev",
             "libatk1.0-dev",
             "libglib2.0-dev",
             "libpango1.0-dev",
             "libgdk-pixbuf2.0-dev",
             "libcairo2-dev",
             "libpango1.0-dev",
             "libcairo2-dev"
         ]
         if tools.cross_building(self.settings):
             target_arch = {"x86": "i386", "armv7": "arm", "armv7hf": "armhf"}
             conan_arch = str(self.settings.arch)
             packages = ["%s:%s" % (package, target_arch[conan_arch]) for package in packages]
         installer = SystemPackageTool()
         installer.install(" ".join(packages))
예제 #22
0
    def system_requirements(self):
        pack_name = None
        if os_info.linux_distro == "ubuntu":
            if os_info.os_version > "12":
                pack_name = "lua5.3 liblua5.3-dev"
            else:
                pack_name = "lua5.3 liblua5.3-dev"
        # elif os_info.linux_distro == "fedora" or os_info.linux_distro == "centos":
        #    pack_name = "package_name_in_fedora_and_centos"
        elif os_info.is_macos:
            pack_name = ["lua"]
        # elif os_info.is_freebsd:
        #    pack_name = "package_name_in_freebsd"
        # elif os_info.is_solaris:
        #    pack_name = "package_name_in_solaris"

        if pack_name:
            installer = SystemPackageTool()
            installer.install(pack_name)
예제 #23
0
    def system_requirements(self):
        self.output.warn("system_requirements: ")
        pack_name = None
        if os_info.linux_distro == "ubuntu":
            self.run('sudo apt-get build-dep openscenegraph', True)
            #gstreamer seams missing after build-dep
            pack_name="libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libasio-dev libcollada-dom2.4-dp-dev libdcmtk-dev libfltk1.3-dev libnvtt-dev libboost-filesystem-dev"
        elif os_info.linux_distro == "fedora" or os_info.linux_distro == "centos":
            pack_name = "TODOpackage_names_in_fedora_and_centos"
        elif os_info.is_macos:
            pack_name = "TODOpackage_names_in_macos"
        elif os_info.is_freebsd:
            pack_name = "TODOpackage_names_in_freebsd"
        elif os_info.is_solaris:
            pack_name = "TODOpackage_names_in_solaris"

        if pack_name:
            installer = SystemPackageTool()
            installer.install(pack_name) # Install the package, will update the package database if pack_name isn't already installed
예제 #24
0
        def system_requirements(self):
            self.output.warn("system_requirements: ")
            pack_name = None
            if os_info.linux_distro == "ubuntu":
                #gstreamer seams missing after build-dep
                pack_name = "libgstreamer1.0-dev libgstreamer1.0-dev"
            elif os_info.linux_distro == "fedora" or os_info.linux_distro == "centos":
                pack_name = "TODOpackage_names_in_fedora_and_centos"
            elif os_info.is_macos:
                pack_name = "TODOpackage_names_in_macos"
            elif os_info.is_freebsd:
                pack_name = "TODOpackage_names_in_freebsd"
            elif os_info.is_solaris:
                pack_name = "TODOpackage_names_in_solaris"

            if pack_name:
                installer = SystemPackageTool()
                installer.install(
                    pack_name
                )  # Install the package, will update the package database if pack_name isn't already installed
예제 #25
0
    def build_requirements(self):
        if self.options.build_testing:
            self.build_requires("doctest/2.3.4@bincrafters/stable")

        installer = SystemPackageTool()
        if self.options.build_docs:
            os_info = tools.OSInfo()
            if os_info.with_pacman:
                installer.install("ruby-ronn")
            if os_info.with_yum:
                installer.install("rubygem-ronn")
            if os_info.with_apt:
                installer.install("ruby-ronn")
예제 #26
0
 def system_requirements(self):
     if self.settings.os == "Linux":
         installer = SystemPackageTool()
         if self.settings.arch == 'x86':
             installer.install("libx11-dev:i386")
         elif self.settings.arch == 'x86_64':
             installer.install("libx11-dev:amd64")
예제 #27
0
 def system_requirements(self):
     if not self.options.without_python:
         if os_info.is_linux:
             if os_info.with_apt:
                 # @Todo This should not be done here !!! conan should not install system packages ..
                 installer = SystemPackageTool()
                 if self.settings.arch == "x86" and tools.detected_architecture(
                 ) == "x86_64":
                     arch_suffix = ':i386'
                     installer.install("g++-multilib")
                 else:
                     arch_suffix = ''
                 installer.install(
                     "%s%s" % ("%s-dev" % self.options.python, arch_suffix))
             # elif os_info.with_yum:
             #     installer = SystemPackageTool()
             #     if self.settings.arch == "x86" and tools.detected_architecture() == "x86_64":
             #         arch_suffix = '.i686'
             #         installer.install("glibc-devel.i686")
             #     else:
             #         arch_suffix = ''
             #     installer.install("%s%s" % ("lttng-tools", arch_suffix))
             #     installer.install("%s%s" % ("lttng-ust", arch_suffix))
             else:
                 self.output.warn(
                     "Could not determine package manager, skipping Linux system requirements installation."
                 )
예제 #28
0
파일: tools_test.py 프로젝트: mathieu/conan
    def system_package_tool_fail_when_not_0_returned_test(self):
        def get_linux_error_message():
            """
            Get error message for Linux platform if distro is supported, None otherwise
            """
            os_info = OSInfo()
            update_command = None
            if os_info.with_apt:
                update_command = "sudo apt-get update"
            elif os_info.with_yum:
                update_command = "sudo yum check-update"
            elif os_info.with_zypper:
                update_command = "sudo zypper --non-interactive ref"
            elif os_info.with_pacman:
                update_command = "sudo pacman -Syyu --noconfirm"

            return "Command '{0}' failed".format(update_command) if update_command is not None else None

        platform_update_error_msg = {
            "Linux": get_linux_error_message(),
            "Darwin": "Command 'brew update' failed",
            "Windows": "Command 'choco outdated' failed" if which("choco.exe") else None,
        }

        runner = RunnerMock(return_ok=False)
        pkg_tool = ChocolateyTool() if which("choco.exe") else None
        spt = SystemPackageTool(runner=runner, tool=pkg_tool)

        msg = platform_update_error_msg.get(platform.system(), None)
        if msg is not None:
            with self.assertRaisesRegexp(ConanException, msg):
                spt.update()
        else:
            spt.update()  # Won't raise anything because won't do anything
예제 #29
0
    def system_requirements(self):
        pack_names = None
        if os_info.linux_distro == "ubuntu":
            pack_names = ["libgl1-mesa-dev", "libxcb1", "libxcb1-dev",
                          "libx11-xcb1", "libx11-xcb-dev", "libxcb-keysyms1",
                          "libxcb-keysyms1-dev", "libxcb-image0", "libxcb-image0-dev",
                          "libxcb-shm0", "libxcb-shm0-dev", "libxcb-icccm4",
                          "libxcb-icccm4-dev", "libxcb-sync1", "libxcb-sync-dev",
                          "libxcb-xfixes0-dev", "libxrender-dev", "libxcb-shape0-dev",
                          "libxcb-randr0-dev", "libxcb-render-util0", "libxcb-render-util0-dev",
                          "libxcb-glx0-dev", "libxcb-xinerama0", "libxcb-xinerama0-dev"]

            if self.settings.arch == "x86":
                full_pack_names = []
                for pack_name in pack_names:
                    full_pack_names += [pack_name + ":i386"]
                pack_names = full_pack_names

        if pack_names:
            installer = SystemPackageTool()
            installer.update() # Update the package database
            installer.install(" ".join(pack_names)) # Install the package
예제 #30
0
    def system_requirements(self):
        pack_names = None
        if tools.os_info.linux_distro == "ubuntu":
            pack_names = [
                "freeglut3-dev", "mesa-common-dev", "mesa-utils-extra",
                "libgl1-mesa-dev", "libglapi-mesa"
            ]
            # print("names: " + str(pack_names))

            if self.settings.arch == "x86":
                full_pack_names = []
                for pack_name in pack_names:
                    full_pack_names += [pack_name + ":i386"]
                pack_names = full_pack_names

        installer = SystemPackageTool()
        # installer.update() # Update the package database
        to_be_installed = ""
        for pkg in pack_names:
            if not installer.installed(pkg):
                to_be_installed += " " + pkg
        if to_be_installed:
            # print("pkg will be installed: " + to_be_installed)
            installer.install(to_be_installed)
예제 #31
0
 def system_package_tool_fail_when_not_0_returned_test(self):
     runner = RunnerMock(return_ok=False)
     spt = SystemPackageTool(runner=runner)
     if platform.system() == "Linux" or platform.system() == "Darwin":
         msg = "Command 'sudo apt-get update' failed" if platform.system() == "Linux" \
                                                      else "Command 'brew update' failed"
         with self.assertRaisesRegexp(ConanException, msg):
             spt.update()
     else:
         spt.update()  # Won't raise anything because won't do anything
예제 #32
0
    def system_requirements(self):
        pack_names = None
        if os_info.linux_distro == "ubuntu":
            pack_names = "libgtk2.0-dev", "pkg-config"

        if pack_names:
            installer = SystemPackageTool()
            installer.update()  # Update the package database
            for pack_name in pack_names:
                installer.install(pack_name)  # Install the package
예제 #33
0
    def system_requirements(self):
        pack_names = None
        if os_info.linux_distro == "ubuntu":
            pack_names = [
                "freeglut3-dev", "mesa-common-dev", "mesa-utils-extra",
                "libgl1-mesa-dev", "libglapi-mesa"
            ]

            if self.settings.arch == "x86":
                full_pack_names = []
                for pack_name in pack_names:
                    full_pack_names += [pack_name + ":i386"]
                pack_names = full_pack_names

        if pack_names:
            installer = SystemPackageTool()
            installer.update()  # Update the package database
            installer.install(" ".join(pack_names))  # Install the package
예제 #34
0
    def system_requirements(self):
        pack_names = None
        if os_info.linux_distro == "ubuntu":
            pack_names = [
                "libgl1-mesa-dev", "libxcb1", "libxcb1-dev", "libx11-xcb1",
                "libx11-xcb-dev", "libxcb-keysyms1", "libxcb-keysyms1-dev",
                "libxcb-image0", "libxcb-image0-dev", "libxcb-shm0",
                "libxcb-shm0-dev", "libxcb-icccm4", "libxcb-icccm4-dev",
                "libxcb-sync1", "libxcb-sync-dev", "libxcb-xfixes0-dev",
                "libxrender-dev", "libxcb-shape0-dev", "libxcb-randr0-dev",
                "libxcb-render-util0", "libxcb-render-util0-dev",
                "libxcb-glx0-dev", "libxcb-xinerama0", "libxcb-xinerama0-dev"
            ]

            if self.settings.arch == "x86":
                full_pack_names = []
                for pack_name in pack_names:
                    full_pack_names += [pack_name + ":i386"]
                pack_names = full_pack_names

        if pack_names:
            installer = SystemPackageTool()
            installer.update()  # Update the package database
            installer.install(" ".join(pack_names))  # Install the package
예제 #35
0
 def system_requirements(self):
     if os_info.is_linux:
         if os_info.with_apt:
             installer = SystemPackageTool()
             if self.version == "master":
                 installer.install("build-essential")
                 installer.install("libxmu-dev")
                 installer.install("libxi-dev")
                 installer.install("libgl-dev")
                 installer.install("libosmesa-dev")
             installer.install("libglu1-mesa-dev")
         elif os_info.with_yum:
             installer = SystemPackageTool()
             if self.version == "master":
                 installer.install("libXmu-devel")
                 installer.install("libXi-devel")
                 installer.install("libGL-devel")
             installer.install("mesa-libGLU-devel")
         else:
             self.output.warn("Could not determine Linux package manager, skipping system requirements installation.")
예제 #36
0
    def system_package_tool_test(self):

        with tools.environment_append({"CONAN_SYSREQUIRES_SUDO": "True"}):
            runner = RunnerMock()
            # fake os info to linux debian, default sudo
            os_info = OSInfo()
            os_info.is_macos = False
            os_info.is_linux = True
            os_info.is_windows = False
            os_info.linux_distro = "debian"
            spt = SystemPackageTool(runner=runner, os_info=os_info)
            spt.update()
            self.assertEquals(runner.command_called, "sudo apt-get update")

            os_info.linux_distro = "ubuntu"
            spt = SystemPackageTool(runner=runner, os_info=os_info)
            spt.update()
            self.assertEquals(runner.command_called, "sudo apt-get update")

            os_info.linux_distro = "knoppix"
            spt = SystemPackageTool(runner=runner, os_info=os_info)
            spt.update()
            self.assertEquals(runner.command_called, "sudo apt-get update")

            os_info.linux_distro = "fedora"
            spt = SystemPackageTool(runner=runner, os_info=os_info)
            spt.update()
            self.assertEquals(runner.command_called, "sudo yum check-update")

            os_info.linux_distro = "opensuse"
            spt = SystemPackageTool(runner=runner, os_info=os_info)
            spt.update()
            self.assertEquals(runner.command_called, "sudo zypper --non-interactive ref")

            os_info.linux_distro = "redhat"
            spt = SystemPackageTool(runner=runner, os_info=os_info)
            spt.install("a_package", force=False)
            self.assertEquals(runner.command_called, "rpm -q a_package")
            spt.install("a_package", force=True)
            self.assertEquals(runner.command_called, "sudo yum install -y a_package")

            os_info.linux_distro = "debian"
            spt = SystemPackageTool(runner=runner, os_info=os_info)
            with self.assertRaises(ConanException):
                runner.return_ok = False
                spt.install("a_package")
                self.assertEquals(runner.command_called, "sudo apt-get install -y --no-install-recommends a_package")

            runner.return_ok = True
            spt.install("a_package", force=False)
            self.assertEquals(runner.command_called, "dpkg -s a_package")

            os_info.is_macos = True
            os_info.is_linux = False
            os_info.is_windows = False

            spt = SystemPackageTool(runner=runner, os_info=os_info)
            spt.update()
            self.assertEquals(runner.command_called, "brew update")
            spt.install("a_package", force=True)
            self.assertEquals(runner.command_called, "brew install a_package")

            os_info.is_freebsd = True
            os_info.is_macos = False

            spt = SystemPackageTool(runner=runner, os_info=os_info)
            spt.update()
            self.assertEquals(runner.command_called, "sudo pkg update")
            spt.install("a_package", force=True)
            self.assertEquals(runner.command_called, "sudo pkg install -y a_package")
            spt.install("a_package", force=False)
            self.assertEquals(runner.command_called, "pkg info a_package")

            # Chocolatey is an optional package manager on Windows
            if platform.system() == "Windows" and which("choco.exe"):
                os_info.is_freebsd = False
                os_info.is_windows = True
                spt = SystemPackageTool(runner=runner, os_info=os_info, tool=ChocolateyTool())
                spt.update()
                self.assertEquals(runner.command_called, "choco outdated")
                spt.install("a_package", force=True)
                self.assertEquals(runner.command_called, "choco install --yes a_package")
                spt.install("a_package", force=False)
                self.assertEquals(runner.command_called,
                                  'choco search --local-only --exact a_package | findstr /c:"1 packages installed."')

        with tools.environment_append({"CONAN_SYSREQUIRES_SUDO": "False"}):

            os_info = OSInfo()
            os_info.is_linux = True
            os_info.linux_distro = "redhat"
            spt = SystemPackageTool(runner=runner, os_info=os_info)
            spt.install("a_package", force=True)
            self.assertEquals(runner.command_called, "yum install -y a_package")
            spt.update()
            self.assertEquals(runner.command_called, "yum check-update")

            os_info.linux_distro = "ubuntu"
            spt = SystemPackageTool(runner=runner, os_info=os_info)
            spt.install("a_package", force=True)
            self.assertEquals(runner.command_called, "apt-get install -y --no-install-recommends a_package")

            spt.update()
            self.assertEquals(runner.command_called, "apt-get update")

            os_info.is_macos = True
            os_info.is_linux = False
            os_info.is_windows = False
            spt = SystemPackageTool(runner=runner, os_info=os_info)

            spt.update()
            self.assertEquals(runner.command_called, "brew update")
            spt.install("a_package", force=True)
            self.assertEquals(runner.command_called, "brew install a_package")

            os_info.is_freebsd = True
            os_info.is_macos = False
            os_info.is_windows = False

            spt = SystemPackageTool(runner=runner, os_info=os_info)
            spt.update()
            self.assertEquals(runner.command_called, "pkg update")
            spt.install("a_package", force=True)
            self.assertEquals(runner.command_called, "pkg install -y a_package")
            spt.install("a_package", force=False)
            self.assertEquals(runner.command_called, "pkg info a_package")

            os_info.is_solaris = True
            os_info.is_freebsd = False
            os_info.is_windows = False

            spt = SystemPackageTool(runner=runner, os_info=os_info)
            spt.update()
            self.assertEquals(runner.command_called, "pkgutil --catalog")
            spt.install("a_package", force=True)
            self.assertEquals(runner.command_called, "pkgutil --install --yes a_package")

        with tools.environment_append({"CONAN_SYSREQUIRES_SUDO": "True"}):

            # Chocolatey is an optional package manager on Windows
            if platform.system() == "Windows" and which("choco.exe"):
                os_info.is_solaris = False
                os_info.is_windows = True

                spt = SystemPackageTool(runner=runner, os_info=os_info, tool=ChocolateyTool())
                spt.update()
                self.assertEquals(runner.command_called, "choco outdated")
                spt.install("a_package", force=True)
                self.assertEquals(runner.command_called, "choco install --yes a_package")
                spt.install("a_package", force=False)
                self.assertEquals(runner.command_called,
                                  'choco search --local-only --exact a_package | findstr /c:"1 packages installed."')
예제 #37
0
    def system_package_tool_mode_test(self):
        """
        System Package Tool mode is defined by CONAN_SYSREQUIRES_MODE env variable.
        Allowed values: (enabled, verify, disabled). Parser accepts it in lower/upper case or any combination.
        """

        class RunnerMultipleMock(object):
            def __init__(self, expected=None):
                self.calls = 0
                self.expected = expected

            def __call__(self, command, *args, **kwargs):  # @UnusedVariable
                self.calls += 1
                return 0 if command in self.expected else 1

        packages = ["a_package", "another_package", "yet_another_package"]

        # Check invalid mode raises ConanException
        with tools.environment_append({
            "CONAN_SYSREQUIRES_MODE": "test_not_valid_mode",
            "CONAN_SYSREQUIRES_SUDO": "True"
        }):
            runner = RunnerMultipleMock([])
            spt = SystemPackageTool(runner=runner, tool=AptTool())
            with self.assertRaises(ConanException) as exc:
                spt.install(packages)
            self.assertIn("CONAN_SYSREQUIRES_MODE=test_not_valid_mode is not allowed", str(exc.exception))
            self.assertEquals(0, runner.calls)

        # Check verify mode, a package report should be displayed in output and ConanException raised.
        # No system packages are installed
        with tools.environment_append({
            "CONAN_SYSREQUIRES_MODE": "VeRiFy",
            "CONAN_SYSREQUIRES_SUDO": "True"
        }):
            packages = ["verify_package", "verify_another_package", "verify_yet_another_package"]
            runner = RunnerMultipleMock(["sudo apt-get update"])
            spt = SystemPackageTool(runner=runner, tool=AptTool())
            with self.assertRaises(ConanException) as exc:
                spt.install(packages)
            self.assertIn("Aborted due to CONAN_SYSREQUIRES_MODE=", str(exc.exception))
            self.assertIn('\n'.join(packages), tools.system_pm._global_output)
            self.assertEquals(3, runner.calls)

        # Check disabled mode, a package report should be displayed in output.
        # No system packages are installed
        with tools.environment_append({
            "CONAN_SYSREQUIRES_MODE": "DiSaBlEd",
            "CONAN_SYSREQUIRES_SUDO": "True"
        }):
            packages = ["disabled_package", "disabled_another_package", "disabled_yet_another_package"]
            runner = RunnerMultipleMock(["sudo apt-get update"])
            spt = SystemPackageTool(runner=runner, tool=AptTool())
            spt.install(packages)
            self.assertIn('\n'.join(packages), tools.system_pm._global_output)
            self.assertEquals(0, runner.calls)

        # Check enabled, default mode, system packages must be installed.
        with tools.environment_append({
            "CONAN_SYSREQUIRES_MODE": "EnAbLeD",
            "CONAN_SYSREQUIRES_SUDO": "True"
        }):
            runner = RunnerMultipleMock(["sudo apt-get update"])
            spt = SystemPackageTool(runner=runner, tool=AptTool())
            with self.assertRaises(ConanException) as exc:
                spt.install(packages)
            self.assertNotIn("CONAN_SYSREQUIRES_MODE", str(exc.exception))
            self.assertEquals(7, runner.calls)
예제 #38
0
파일: tools_test.py 프로젝트: nesono/conan
    def system_package_tool_test(self):

        runner = RunnerMock()

        # fake os info to linux debian, default sudo
        os_info = OSInfo()
        os_info.is_linux = True
        os_info.linux_distro = "debian"
        spt = SystemPackageTool(runner=runner, os_info=os_info)
        spt.update()
        self.assertEquals(runner.command_called, "sudo apt-get update")

        os_info.linux_distro = "ubuntu"
        spt = SystemPackageTool(runner=runner, os_info=os_info)
        spt.update()
        self.assertEquals(runner.command_called, "sudo apt-get update")

        os_info.linux_distro = "knoppix"
        spt = SystemPackageTool(runner=runner, os_info=os_info)
        spt.update()
        self.assertEquals(runner.command_called, "sudo apt-get update")

        os_info.linux_distro = "fedora"
        spt = SystemPackageTool(runner=runner, os_info=os_info)
        spt.update()
        self.assertEquals(runner.command_called, "sudo yum check-update")

        os_info.linux_distro = "redhat"
        spt = SystemPackageTool(runner=runner, os_info=os_info)
        spt.install("a_package", force=False)
        self.assertEquals(runner.command_called, "rpm -q a_package")
        spt.install("a_package", force=True)
        self.assertEquals(runner.command_called, "sudo yum install -y a_package")

        os_info.linux_distro = "debian"
        spt = SystemPackageTool(runner=runner, os_info=os_info)
        with self.assertRaises(ConanException):
            runner.return_ok = False
            spt.install("a_package")
            self.assertEquals(runner.command_called, "sudo apt-get install -y a_package")

        runner.return_ok = True
        spt.install("a_package", force=False)
        self.assertEquals(runner.command_called, "dpkg -s a_package")

        os_info.is_macos = True
        os_info.is_linux = False

        spt = SystemPackageTool(runner=runner, os_info=os_info)
        spt.update()
        self.assertEquals(runner.command_called, "brew update")
        spt.install("a_package", force=True)
        self.assertEquals(runner.command_called, "brew install a_package")

        os.environ["CONAN_SYSREQUIRES_SUDO"] = "False"

        os_info = OSInfo()
        os_info.is_linux = True
        os_info.linux_distro = "redhat"
        spt = SystemPackageTool(runner=runner, os_info=os_info)
        spt.install("a_package", force=True)
        self.assertEquals(runner.command_called, "yum install -y a_package")
        spt.update()
        self.assertEquals(runner.command_called, "yum check-update")

        os_info.linux_distro = "ubuntu"
        spt = SystemPackageTool(runner=runner, os_info=os_info)
        spt.install("a_package", force=True)
        self.assertEquals(runner.command_called, "apt-get install -y a_package")

        spt.update()
        self.assertEquals(runner.command_called, "apt-get update")

        os_info.is_macos = True
        os_info.is_linux = False
        spt = SystemPackageTool(runner=runner, os_info=os_info)

        spt.update()
        self.assertEquals(runner.command_called, "brew update")
        spt.install("a_package", force=True)
        self.assertEquals(runner.command_called, "brew install a_package")

        del os.environ["CONAN_SYSREQUIRES_SUDO"]
예제 #39
0
    def system_package_tool_test(self):

        runner = RunnerMock()
        spt = SystemPackageTool(runner=runner)

        # fake os info to linux debian, default sudo
        spt._os_info.is_linux = True
        spt._os_info.linux_distro = "debian"
        spt.update()
        self.assertEquals(runner.command_called, "sudo apt-get update")

        spt._os_info.linux_distro = "ubuntu"
        spt.update()
        self.assertEquals(runner.command_called, "sudo apt-get update")

        spt._os_info.linux_distro = "knoppix"
        spt.update()
        self.assertEquals(runner.command_called, "sudo apt-get update")

        spt._os_info.linux_distro = "fedora"
        spt.update()
        self.assertEquals(runner.command_called, "sudo yum check-update")

        spt._os_info.linux_distro = "redhat"
        spt.install("a_package")
        self.assertEquals(runner.command_called, "sudo yum install -y a_package")

        spt._os_info.linux_distro = "debian"
        spt.install("a_package")
        self.assertEquals(runner.command_called, "sudo apt-get install -y a_package")

        spt._os_info.is_macos = True
        spt._os_info.is_linux = False

        spt.update()
        self.assertEquals(runner.command_called, "brew update")
        spt.install("a_package")
        self.assertEquals(runner.command_called, "brew install a_package")

        os.environ["CONAN_SYSREQUIRES_SUDO"] = "False"

        spt = SystemPackageTool(runner=runner)
        spt._os_info.is_linux = True

        spt._os_info.linux_distro = "redhat"
        spt.install("a_package")
        self.assertEquals(runner.command_called, "yum install -y a_package")
        spt.update()
        self.assertEquals(runner.command_called, "yum check-update")

        spt._os_info.linux_distro = "ubuntu"
        spt.install("a_package")
        self.assertEquals(runner.command_called, "apt-get install -y a_package")

        spt.update()
        self.assertEquals(runner.command_called, "apt-get update")

        spt._os_info.is_macos = True
        spt._os_info.is_linux = False

        spt.update()
        self.assertEquals(runner.command_called, "brew update")
        spt.install("a_package")
        self.assertEquals(runner.command_called, "brew install a_package")

        del os.environ["CONAN_SYSREQUIRES_SUDO"]