Пример #1
0
 def install_osx():
     if not host.Which('brew'):
         io.Print("Installing Homebrew")
         url = 'https://raw.githubusercontent.com/Homebrew/install/master/install'
         host.ShellCommand(
             'yes | /usr/bin/ruby -e "$(curl -fsSL {url})"'.format(
                 **vars()))
         host.ShellCommand('brew doctor')
Пример #2
0
    def install_ubuntu(cls):
        # Install build dependencies:
        apt.Apt().install_package("build-essential")
        apt.Apt().install_package("curl")
        apt.Apt().install_package("file")
        apt.Apt().install_package("git")
        apt.Apt().install_package("python-setuptools")

        if not os.path.exists('/home/linuxbrew/.linuxbrew/bin/brew'):
            url = ("https://raw.githubusercontent.com/"
                   "Linuxbrew/install/master/install.sh")
            host.ShellCommand(
                'yes | sh -c "$(curl -fsSL {url})"'.format(url=url))
            host.ShellCommand('{brew} update'.format(brew=cls.BREW_BINARY))
Пример #3
0
 def upgrade_package(self, package):
     """ upgrade package, return True if upgraded """
     if self.package_is_outdated(package):
         io.Print("brew upgrade {package}".format(**vars()))
         host.ShellCommand(
             "{self.BREW_BINARY} upgrade {package}".format(**vars()))
         return True
Пример #4
0
 def install_package(self, package):
     """ install a package using homebrew, return True if installed """
     if not self.package_is_installed(package):
         io.Print("brew install " + package)
         host.ShellCommand(
             "{self.BREW_BINARY} install {package}".format(**vars()))
         return True
Пример #5
0
 def package_is_installed(self, package):
     """ return True if package is installed """
     if not os.path.isfile(self.PKG_LIST):
         host.ShellCommand(
             "{self.BREW_BINARY} list > {self.PKG_LIST}".format(**vars()))
     return host.CheckShellCommand(
         "grep '^{package}$' <{self.PKG_LIST}".format(**vars()))
Пример #6
0
 def upgrade_cask(self, cask):
     """ upgrade a homebrew cask. does nothing if cask not installed """
     if self.cask_is_outdated(cask):
         io.Print("brew cask upgrade {cask}".format(**vars()))
         host.ShellCommand(
             "{self.BREW_BINARY} cask upgrade {cask}".format(**vars()))
         return True
Пример #7
0
 def install_cask(self, cask):
     """ install a homebrew cask, return True if installed """
     if not self.cask_is_installed(cask):
         io.Print("brew cask install " + cask)
         host.ShellCommand(
             "{self.BREW_BINARY} cask install {cask}".format(**vars()))
         return True
Пример #8
0
 def __call__(self, ctx):
     package = self.package
     brew = Homebrew()
     brew.install()
     if brew.install_package(package):
         host.ShellCommand(
             "{brew.BREW_BINARY} link {package} --force".format(
                 brew=brew, package=package))
Пример #9
0
    def cask_is_installed(self, cask):
        """ return True if cask is installed """
        if not os.path.isfile(self.CASK_LIST):
            host.ShellCommand(
                "{self.BREW_BINARY} cask list > {self.CASK_LIST}".format(
                    **vars()))

        cask_stump = cask.split('/')[-1]
        return host.CheckShellCommand(
            "grep '^{cask_stump}$' <{self.CASK_LIST}".format(**vars()))
Пример #10
0
    def package_is_outdated(self, package):
        """ returns True if package is outdated """
        if not self.package_is_installed(package):
            raise task.InvalidTaskError(
                "homebrew package '{package}' cannot be upgraded "
                "as it is not installed".format(**vars()))

        if not os.path.isfile(self.OUTDATED_PKG_LIST):
            host.ShellCommand(
                "{self.BREW_BINARY} outdated | awk '{{print $1}}' >{self.OUTDATED_PKG_LIST}"
                .format(**vars()))

        package_stump = package.split('/')[-1]
        return host.CheckShellCommand(
            "grep '^{package_stump}$' <{self.OUTDATED_PKG_LIST}".format(
                **vars()))
Пример #11
0
    def cask_is_outdated(self, cask):
        """ returns True if cask is outdated """
        if not self.cask_is_installed(cask):
            raise task.InvalidTaskError(
                "homebrew cask '{package}' cannot be upgraded as it is not installed"
                .format(**vars()))

        if not os.path.isfile(self.OUTDATED_CASK_LIST):
            host.ShellCommand(
                "{self.BREW_BINARY} cask outdated ".format(**vars()) +
                "| awk '{{print $1}}' >{self.OUTDATED_CASK_LIST}".format(
                    **vars()))

        cask_stump = cask.split('/')[-1]
        return host.CheckShellCommand(
            "grep '^{cask_stump}$' <{self.OUTDATED_CASK_LIST}".format(
                **vars()))
Пример #12
0
 def uninstall_cask(self, cask):
     """ remove a homebrew cask, return True if uninstalled """
     if self.cask_is_installed(cask):
         io.Print("brew cask remove " + cask)
         host.ShellCommand("{self.BREW_BINARY} cask remove " + cask)
         return True