如何从自制啤酒中删除过时的酒桶?


9

我正在使用自制酒桶来保持我的应用程序生态系统最新。当在家中,旅行中或旅途中维护多台计算机时,这非常好。

但是,当更新某些软件包时(例如Google Chrome),我最终安装了不同的并发版本(操作系统可以看到这些版本):

$ ls / opt / homebrew-cask / Caskroom / google-chrome /最新的稳定频道

升级酒桶时会发生这种情况:

$ ls -l /opt/homebrew-cask/Caskroom/tunnelblick
total 0
drwxr-xr-x 5 foo staff 238 Mar 11 07:42 3.3.0
drwxr-xr-x 5 foo staff 238 May 13 13:53 3.3.2
[13:00:40] foo at bar in ~
$ brew cask install --force tunnelblick
==> Caveats
For security reasons, Tunnelblick must be installed to /Applications and will request to be moved at launch.

==> Downloading https://downloads.sourceforge.net/project/tunnelblick/All%20files/Tunnelblick_3.3.4.dmg
######################################################################## 100.0%
==> It seems there is already an App at '/Applications/Tunnelblick.app'; not linking.
🍺  tunnelblick installed to '/opt/homebrew-cask/Caskroom/tunnelblick/3.3.4' (236 files, 20M)

$ ls -l /opt/homebrew-cask/Caskroom/tunnelblick
total 0
drwxr-xr-x 5 foo staff 238 Mar 11 07:42 3.3.0
drwxr-xr-x 5 foo staff 238 May 13 13:53 3.3.2
drwxr-xr-x 5 foo staff 238 Jun 26 13:01 3.3.4
[13:01:26] foo at bar in ~

我如何只保留最新的?


你尝试过brew cleanupbrew prune
dwightk 2014年

是的,我尝试过,但不适用于酒桶...
meduz 2014年

1
这显然在@ github.com
caskroom

还在寻找答案。我最近的尝试涉及删除所有应用程序并重新安装,这不是很生态。
meduz '16

Answers:


1

在终端中,键入:

for app in $(brew cask list); do cver="$(brew cask info "${app}" | head -n 1 | cut -d " " -f 2)"; ivers=$(ls -1 "/opt/homebrew-cask/Caskroom/${app}/.metadata/" | tr '\n' ' ' | sed -e 's/ $//'); aivers=(${ivers}); nvers=$(echo ${#aivers[@]}); echo "[*] Found ${app} in cask list. Latest available version is ${cver}. You have installed version(s): ${overs}"; if [[ ${nvers} -eq 1 ]]; then echo "${ivers}" | grep -q "^${cver}$" && { echo "[*] Latest version already installed :) Skipping changes ..."; continue; }; fi; echo "[+] Fixing from ${ivers} to ${cver} ..."; brew cask uninstall "${app}" --force; brew cask install "${app}"; done

提示:将以上命令行复制并粘贴到Terminal中。


并且不要对一个以上的问题给出相同的答案。如果对问题的回答相同,则应将问题标记/关闭为重复
user151019 '16

嗨,@ name,您能编辑答案以了解它的作用吗,似乎很晦涩(我今天的名言:“ stackoverflow与解决方案无关,但与答案有关” :
meduz 2016年

对于一直尝试编辑此帖子的人员,将给定的复杂命令行更改为脚本,请停止!作者将其编写为复杂的命令行,而不是脚本。请尊重作者决定将其发布为复杂的命令行而不是脚本的决定!
user3439894's

请记住,使用新的Homebrew酒窖位置,您需要更改/opt/homebrew-cask/Caskroom//usr/local/Caskroom/
Spotlight'7

仅供将来运行此程序的用户参考,似乎正在卸载/重新安装我的所有容器。似乎无法正确检测到我的安装版本?“ [*]在酒桶列表中找到了原子。最新的可用版本是1.11.2。您已安装版本:”
Glenn'devalias'16
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.