brew: comment supprimer une version obsolète du package


15

Homebrew se met à jour pour brasser . Et il semble que les mainteneurs n'aient pas implémenté certaines commandes utilisées quotidiennement brew cleanup.

Donc, n'importe qui sait comment supprimer automatiquement une version obsolète du logiciel?

$ brew
Example usage:
  brew search [TEXT|/REGEX/]
  brew (info|home|options) [FORMULA...]
  brew install FORMULA...
  brew update
  brew upgrade [FORMULA...]
  brew uninstall FORMULA...
  brew list [FORMULA...]

Troubleshooting:
  brew config
  brew doctor
  brew install -vd FORMULA

Brewing:
  brew create [URL [--no-fetch]]
  brew edit [FORMULA...]
  https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/Formula-Cookbook.md

Further help:
  man brew
  brew help [COMMAND]
  brew home

2
Je suis sûr que c'est juste brew clean.
At0mic

Réponses:


27

La commande que vous voulez est cleanup- l'exécution brew cleanupsupprimera les packages qui sont sur le disque, mais qui ne sont plus installés.

> brew help cleanup
brew cleanup [--prune=days] [--dry-run] [-s] [formulae]:
    For all installed or specific formulae, remove any older versions from the
    cellar. In addition, old downloads from the Homebrew download-cache are deleted.

    If --prune=days is specified, remove all cache files older than days.

    If --dry-run or -n is passed, show what would be removed, but do not
    actually remove anything.

    If -s is passed, scrubs the cache, removing downloads for even the latest
    versions of formulae. Note downloads for any installed formulae will still not be
    deleted. If you want to delete those too: rm -rf $(brew --cache)

Par exemple:

> brew cleanup
Removing: /usr/local/Cellar/awscli/1.10.19... (2,955 files, 22.3M)
Removing: /usr/local/Cellar/git/2.8.2... (1,418 files, 30.5M)
Removing: /usr/local/Cellar/imagemagick/6.9.3-7... (1,459 files, 17.9M)
Removing: /usr/local/Cellar/libgcrypt/1.7.0... (17 files, 1.5M)
Removing: /usr/local/Cellar/libgpg-error/1.21... (19 files, 419.4K)
Removing: /usr/local/Cellar/libksba/1.3.3... (13 files, 343K)
Removing: /usr/local/Cellar/mercurial/3.7.3... (386 files, 4.7M)
Removing: /usr/local/Cellar/node/6.0.0... (3,655 files, 38.8M)
Removing: /usr/local/Cellar/openssl/1.0.2g... (1,678 files, 12.0M)
Removing: /usr/local/Cellar/vim/7.4.1795... (1,687 files, 22.6M)
Removing: /Library/Caches/Homebrew/git-2.8.2.el_capitan.bottle.tar.gz... (11.2M)
Removing: /Library/Caches/Homebrew/imagemagick-6.9.3-7.el_capitan.bottle.tar.gz... (7M)
Removing: /Library/Caches/Homebrew/libgcrypt-1.7.0.el_capitan.bottle.tar.gz... (565.4K)
Removing: /Library/Caches/Homebrew/libgpg-error-1.21.el_capitan.bottle.tar.gz... (130.8K)
Removing: /Library/Caches/Homebrew/libksba-1.3.3.el_capitan.bottle.tar.gz... (126.6K)
Removing: /Library/Caches/Homebrew/node-6.0.0.el_capitan.bottle.tar.gz... (10.9M)
Removing: /Library/Caches/Homebrew/openssl-1.0.2g.el_capitan.bottle.tar.gz... (3.6M)
Removing: /Library/Caches/Homebrew/vim-7.4.1795.tar.gz... (12.0M)
==> This operation has freed approximately 196.4M of disk space.

J'ai un régime du lundi matin de:

brew update
brew upgrade
brew cleanup

Cela me met à jour sur Homebrew, puis sur tous mes brews installés et ensuite cela libère de l'espace disque en supprimant les anciens brews qui ne sont plus référencés. Pour les bières que je dois conserver dans une version spécifique, je les utilise brew pinpour les conserver afin que je puisse toujours exécuter cette chaîne simple à trois commandes pour mettre à jour tout le reste autour des packages épinglés.


1

Pas une réponse, mais trop long pour un commentaire, voici le code que j'utilise comme régime pour garder mon brassage à jour:

    fullBrewUpdate(){
            brew update
            brew cask update

            casks=( $(brew cask list) )

            for cask in ${casks[@]}
            do
                # in the first line there is version
                    current="$(brew cask info $cask | sed -n '1p' | sed -n 's/^.*: \(.*\)$/\1/p')"

                    installed=( $(ls /opt/homebrew-cask/Caskroom/$cask))
                    if (! [[ " ${installed[@]} " == *" $current "* ]]); then
                            (set -x; brew cask install $cask --force;)
                    fi
            done

            brew upgrade
            brew cleanup
    }

Je l'ai enregistré dans mon ~/.bash_profileafin que je puisse l'appeler à partir du terminal comme nom de fonction à la volée.


1
Au moins à partir de la version 1.5.12, brew cask updateest désactivé. Error: Calling 'brew cask update' is disabled! Use 'brew update' instead.
dotnetCarpenter
En utilisant notre site, vous reconnaissez avoir lu et compris notre politique liée aux cookies et notre politique de confidentialité.
Licensed under cc by-sa 3.0 with attribution required.