Programming

Homebrew Cask를 통해 설치된 모든 통을 업그레이드하십시오.

procodes 2020. 6. 30. 21:29
반응형

Homebrew Cask를 통해 설치된 모든 통을 업그레이드하십시오.


내가 사용 브루 술통 ' 나는 모든 설치된 통을 업그레이드하려면 OS X의 방법에 응용 프로그램을 설치?


2017 년 12 월 업데이트

나는 그것이 결코 일어나지 않을 것이라고 생각했지만, 마침내 Homebrew Cask에 대한 공식적인 업그레이드 메커니즘이 있습니다 ( 구현 이슈 3396 참조 )! 사용하려면 다음 명령을 실행하십시오.

brew cask upgrade

그러나 버전 정보가없는 캐스 크 ( version :latest) 또는 내장 된 업그레이드 메커니즘이있는 응용 프로그램 ( ) 은 업데이트하지 않습니다 auto_updates true. 이러한 통을 다시 설치하고 업그레이드가 가능한 경우 업그레이드하려면 다음과 같이 --greedy플래그를 사용 하여 upgrade 명령을 실행하십시오 .

brew cask upgrade --greedy

2017 년 3 월 업데이트 (말씀) (@ polo)

이것이 원래 답변 된 이후로 일부 업데이트를 발견했습니다. 해결 방법으로 이제 다음을 사용할 수 있습니다 brew cask reinstall.

brew cask reinstall <cask_name>
brew cask list | xargs brew cask reinstall

원래의 대답에 언급 된 문제 4678 닫혔다하고 업그레이드 기능은 현재 논의되는 문제 # 29301 도있다 부오 / 사제-통 업그레이드 , 통 맥주를 양조하는 업그레이드 명령을 추가 외부 패키지. 몇 가지 패키지에서 성공적으로 테스트했습니다.

원래 답변

사제 통을 업그레이드하는 공식적인 방법은 없습니다. 현재 진행 중이지만 아직 완료되지 않은 상태입니다. 자세한 내용은 문제 # 4678 을 참조하십시오. 이 문제에는 사용자가 모든 통을 업그레이드하는 데 사용하는 스크립트 예제도 있습니다. 단일 캐스 크를 업그레이드하는 가장 간단한 방법은을 실행하는 것입니다 brew cask install --force <cask_name>. 그러나 앱이 먼저 제대로 제거되지 않기 때문에 앱에 문제가 발생할 가능성이 있음을 알고 있습니다. 일반적으로 문제는 아닙니다.

다음 쉘 명령을 사용하여 설치된 모든 통을 업그레이드 할 수 있습니다.

brew cask list | xargs brew cask install --force

나중에 참조 할 수 있도록 자세한 내용은 github중복 문제 에서 확인할 수 있습니다 .


자가 맥주 통 업그레이드

나는 이것이 통을 업그레이드하는 가장 좋은 해결책이라고 생각합니다.
출처 : https://github.com/buo/homebrew-cask-upgrade

설치 및 사용법

brew tap buo/cask-upgrade
brew update
brew cu

(선택 사항) 최신으로 표시된 앱을 포함하여 오래된 앱을 강제로 업그레이드합니다.

brew cu --all

설치된 통을 다음과 같이 나열 할 수 있습니다.

brew cask list

그리고 다음을 사용하여 통을 다시 설치하십시오.

brew cask install --force CASK_NAME

따라서 첫 번째 명령의 출력을 두 번째 명령으로 파이핑하여 모든 통을 업데이트합니다.

brew cask list | xargs brew cask install --force

패키지를 업그레이드하기위한 Bash 스크립트

파스칼 답변에서 영감을

#!/usr/bin/env bash

(set -x; brew update;)

(set -x; brew cleanup;)
(set -x; brew cask cleanup;)

red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`

casks=( $(brew cask list) )

for cask in ${casks[@]}
do
    version=$(brew cask info $cask | sed -n "s/$cask:\ \(.*\)/\1/p")
    installed=$(find "/usr/local/Caskroom/$cask" -type d -maxdepth 1 -maxdepth 1 -name "$version")

    if [[ -z $installed ]]; then
        echo "${red}${cask}${reset} requires ${red}update${reset}."
        (set -x; brew cask uninstall $cask --force;)
        (set -x; brew cask install $cask --force;)
    else
        echo "${red}${cask}${reset} is ${green}up-to-date${reset}."
    fi
done

그것이하는 일

  • 추출 / 양조 통 업데이트, 청소
  • 통 목록을 읽으십시오
  • brew cask info최신 버전을 확인하십시오
  • 가능한 경우 새 버전을 설치하십시오 (모든 이전 버전을 제거하십시오!).

출처 : https://gist.github.com/atais/9c72e469b1cbec35c7c430ce03de2a6b

참을성이없는 라이너 :

curl -s https://gist.githubusercontent.com/atais/9c72e469b1cbec35c7c430ce03de2a6b/raw/36808a0544628398f26b48f7a3c7b309872ca2c6/cask_upgrade.sh | bash /dev/stdin

다른 이름으로 저장하여 나중에 /usr/local/bin/cask-upgrade로컬에서 실행할 수 있습니다.cask-upgrade


2017 년 12 월 현재 사용 : 맥주 통 업그레이드

[Homebrew가 cask에 대한 업그레이드 명령을 도입 한 2017 년 12 월 이후로 더 이상 사용되지 않음] 간단히 다음을 사용합니다.

brew cask outdated | xargs brew cask reinstall


이것을 처리하기 위해 작성한 함수는 다음과 같습니다. 개인적으로 설치하는 데 약간의 시간이 걸리거나 추가 메시지가 필요하기 때문에 모든 것을 맹목적으로 다시 설치하기를 원하지 않았습니다.

brew-cask-upgrade() { 
  if [ "$1" != '--continue' ]; then 
    echo "Removing brew cache" 
    rm -rf "$(brew --cache)" 
    echo "Running brew update" 
    brew update 
  fi 
  for c in $(brew cask list); do 
    echo -e "\n\nInstalled versions of $c: " 
    ls /opt/homebrew-cask/Caskroom/$c 
    echo "Cask info for $c" 
    brew cask info $c 
    select ynx in "Yes" "No" "Exit"; do  
      case $ynx in 
        "Yes") echo "Uninstalling $c"; brew cask uninstall --force "$c"; echo "Re-installing $c"; brew cask install "$c"; break;; 
        "No") echo "Skipping $c"; break;; 
        "Exit") echo "Exiting brew-cask-upgrade"; return;; 
      esac 
    done 
  done 
} 

brew cask upgrade

upgrade명령은 최근 Homebrew Cask에 도입되었으며 다른 답변에 설명 된 다른 모든 수동 방법을 사용하지 않아야합니다.


@Atais의 답변을 바탕으로 그의 논리를 더 멋진 것으로 향상 시켰습니다. 실제로 업그레이드를 강제하기 전에 패키지를 먼저 업그레이드했는지 검사하는 방법이 필요했습니다.

  • $ brew-cask.shHomebrew 's와 유사한 출력 만 나열합니다 brew update.
  • 위 목록에는 설치된 모든 패키지가 표시 되며 녹색 은 보류중인 업데이트를 나타냅니다.
  • $ brew-cask.sh upgrade 해당 패키지를 강제로 업그레이드합니다.

암호:

# Usage:
#
#  $ brew update
#    You should execute this first to update everything locally.
#
#  $ brew-cask.sh [update]
#    This will list all of your cask packages and rather there is an upgrade
#    pending with a ✔ checkmark, just like Homebrew does with "brew update".
#    The update command is optional, as it doesn't actually do any tracking, there's
#    not really anything to "update" with cask.  But it keeps with the pattern of
#    of Homebrew's "brew update" pattern for those with memory muscle fingers (like me).
#
#  $ brew-cask.sh upgrade
#    This performs a "brew cask install <cask> --force" of all cask packages that have
#    an update pending.
#
# This code was inspired by http://stackoverflow.com/a/36000907/56693

# get the list of installed casks
casks=( $(brew cask list) )

if [[ "$1" == "upgrade" ]]; then
  for cask in ${casks[@]}; do
    current="$(brew cask info $cask | sed -n '1p' | sed -n 's/^.*: \(.*\)$/\1/p')"
    installed=( $(ls /opt/homebrew-cask/Caskroom/$cask))
    if (! [[ " ${installed[@]} " == *" $current "* ]]); then
      echo "Upgrading $cask to v$current."
      (set -x; brew cask install $cask --force;)
    else
      echo "$cask v$current is up-to-date, skipping."
    fi
  done
else
  echo "Inspecting ${#casks[@]} casks. Use 'brew-cask.sh upgrade' to perform any updates."
  for (( i = i ; i < ${#casks[@]} ; i++ )); do
    current="$(brew cask info ${casks[$i]} | sed -n '1p' | sed -n 's/^.*: \(.*\)$/\1/p')"
    installed=( $(ls /opt/homebrew-cask/Caskroom/${casks[$i]}))
    if (! [[ " ${installed[@]} " == *" $current "* ]]); then
      casks[$i]="${casks[$i]}$(tput sgr0)$(tput setaf 2) ✔$(tput sgr0)"
    fi
  done
  echo " ${casks[@]/%/$'\n'}" | column
fi

설치 만하면됩니다 (일명 "지금 필요합니다!").

.dotfiles저장소에 체크인되었습니다 . 따라서 다음을 통해 신속하게 설치할 수 있습니다 ~/bin.

$ curl -L https://raw.githubusercontent.com/eduncan911/dotfiles/master/bin/brew-cask.sh --create-dirs -o ~/bin/brew-cask.sh
$ chmod 755 ~/bin/brew-cask.sh

그런 다음 다음과 같이 사용하십시오.

$ brew-cask.sh
$ brew-cask.sh upgrade

당신이 ~/bin당신의 경로 ~/bin/에없는 경우 위의 진술 접두사 .


내가 사용하는 것 같아

brew cask reinstall `brew cask outdated`

트릭을 할 것입니다. 또한 응용 프로그램의 이전 버전을 제거하고 최신 버전을 설치하는 데 도움이됩니다.


improving on the provided code from deinspanjer, I tried to imitate a noop command, much like the one from chocolatey (choco update --noop / choco outdated).

https://git.io/vgjiL

#!/bin/sh

fetch(){
    echo "Removing brew cache" 
    rm -rf "$(brew --cache)" 
    echo "Running brew update" 
    brew update 
}

lookup() { 
  for c in $(brew cask list); do 
    brew cask info $c 
  done 
} 

update(){
  var=$( lookup  | grep -B 3 'Not installed' | sed -e '/^http/d;/^Not/d;/:/!d'  | cut -d ":" -f1)
  if [ -n "$var" ]; then
  echo "The following installed casks have updates avilable:"
  echo "$var"
  echo "Install updates now?"
  select yn in "Yes" "No"; do
    case $yn in
      "Yes") echo "updating outdated casks"; break;;
      "No") echo "brew cask upgrade cancelled" ;return;;
      *) echo "Please choose 1 or 2";;
    esac
    done
  for i in $var; do
    echo "Uninstalling $c"; brew cask uninstall --force "$i"; echo "Re-installing $i"; brew cask install "$i"
  done
else
  echo "all casks are up to date"
fi
}

fetch
update

As one can see, I am using a modular approach since my use case differs a little. I do not want to sit in front of my computer and type yes/no for every app I have installed. While there is no real way of upgrading casks (just the reinstall the newest version), I first do brew update to have the information that there are actually updates available.

Next, I cycle through all the casks to display their information. Because I did brew update before, one is now provided with the information that some cask's latest version is not installed.

Inside my update method, I actually parse the info command for that specific line:

lookup  | grep -B 3 'Not installed' | sed -e '/^http/d;/^Not/d;/:/!d'  | cut -d ":" -f1

Which translates to: "Give the 3 lines above of info provided whenever you read the line "not installed". Then delete any line that has a link in it, also delete a line that has a ':' in it."

Given the structure of the brew cask info command, we end up with one line (no version info, no app URL), which reflects the cask's actual name that it also was installed with.

brew cask info output

In my version, this info is now printed out so one can easily see what casks are out of date and could be updated.

At this point I do a switch case, because maybe right now is not enough time to update things. It depends on your use-case. For me, I sometimes just want to see what's new (waiting for a new version, a bugfix) but don't actually have time to update things because right now I do not want to close my browser etc.

So if one opts for "yes", the list of cleaned names of casks is given to the update function where for each cask that was determined to be out of date the reinstall is issued.

Thanks again to deinspanjer, while trying to solve this issue for myself, I always forgot to issue brew update beforehand so there was no "not installed" line there to actually parse (the foundation of my whole approach).

I hope this was helpful.


I made such script by myself. Please look at the github https://github.com/pesh1983/brew_cask_upgrade. It has pretty good description, but if you have any additional question, feel free to ask me. It does fair upgrade: uninstall and install, so any necessary cleanup will be performed by 'brew' itself.


brew cask outdated | xargs brew cask reinstall --force

get outdated casks:

brew cask outdated

upgrade cask:

brew cask reinstall outdated-cask

demo script:

$ cat ~/bin/brew_cask_upgrade.sh
#!/bin/bash
red=$(tput setaf 1)
# green=$(tput setaf 2)
reset=$(tput sgr0)

(set -x; brew update;)

for cask in $(brew cask outdated | awk '{print $1}')
do
    echo "${red}update ${cask} ...${reset}."
    (set -x; brew cask install --force "$cask";)
done

echo "${red}brew clean up ...${reset}"
(set -x; brew cask cleanup;)
echo "${red}brew clean up done.${reset}"

Based on what i have read i have created a script that will create a file that lists the files to be updated including apps that are defined as latest. You can then modify the file to suit your requirements and install updates using my olinst script.

For more information visit my github.

https://github.com/pacav69/caskroom-offline-install


This has really irked me so I created this script to update all Brew apps and allow the user to choose which Cask apps to update. You can exclude apps from consideration too.

https://github.com/derrekyoung/ScriptsAndUtils/blob/master/brew-cask-upgrade.sh


I use

brew cask install --force `brew cask list`

Check outdated casks:

brew cask outdated

Upgrading all outdated cask:

brew cask upgrade

If you want upgrade specific cask, just adding cask-name after upgrade (ex: 4k-video-downloader):

brew cask upgrade 4k-video-downloader

참고URL : https://stackoverflow.com/questions/31968664/upgrade-all-the-casks-installed-via-homebrew-cask

반응형