Homebrew intro
Homebrew
Homebrew은 수제 맥주, 패키지 관리시스템(Chocolatey for Windows, apt-get for dpkg, or yum for RPM.)
사용자가 패키지를 빌드하고 버전별 관리하게 해준다는 의미
- 3th-party Package Manager (for missing package of OS X)
OS X에 설치되어 있지 않은 Unix팩키지를 설치/사용/업그레이드/삭제 - 관리자 권한이 필요없다 (sudo)
- 설치한 팩키지를 버전별로 사용
- 각각의 팩키지별로 설치되는 실행파일과 라이브러리, 헤더파일은 개발할때 팩키지를 찾는데 효과적이다.
용어 정의
HomeBrew | 자가 양조 | 소프트웨어 자가 구축 |
---|---|---|
Formula | 단계별 요리법 | 빌드 방법/절차가 작성된 스크립트(.rb)
팩키지와 관련 dependency를 설치하는 방법 |
Caskroom
cask brew-cask |
extend Homebrew |
팩키지 실제경로 /usr/local/Caskroom |
Celler | 와인이나 맥주 등의 저장고 |
프로그램 설치장소
Package를 자신의 Cellar(/usr/local/Cellar/팩키지명)에 설치하고, |
Keg | 저장용 작은 통 |
Build 자료
A “Keg” is the installation prefix of a formula, such as: openssl-1.0.2h_1.el_capitan.bottle.tar.gz |
bottle | pre-built binary Keg used for installation instead of building from source. It can be unpacked |
|
Cask | ||
tap | /usr/local/Homebrew/Library/Taps/ | |
Brew | 양조 | 소프트웨어 Build |
Package 설치
우선 해당 Package를 검색해 본다. 이때 설치된 Package는 체크표시가 되어 있다.
(예를들어 굳이 brew list | grep -i NginX
로 설치여부를 확인할 필요없음)
brew search vim
설치후, 삭제하고 싶을때는 brew uninstall 사용.
brew install vim
Documentation
brew
brew help
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 Developers: brew create [URL [--no-fetch]] brew edit [FORMULA...] https://docs.brew.sh/Formula-Cookbook Further help: man brew brew help [COMMAND] brew home
메뉴얼
man brew
Homebrew 관리
팩키지 리스트 업데이트
새 버전으로 업데이트할 대상 소프트웨어가 무엇인지 확인
brew update
설치한 팩키지 업그레이드
전체 팩키지(인수 없이) 또는 특정 팩키지 팩키지 최신설치, brew upgrade <팩키지명>
brew upgrade
Caches
다운로드한 bottles 목록 (~/Library/Caches/Homebrew)
brew –cache
Tap (= get Cask, repository)
Homebrew의 master repository에 포함되지 않는 repository를 참조할때
brew tap # list tapped repositories brew tap <tapname> # add tap brew untap <tapname> # remove a tap
homebrew-core : default로 설치된 tap (/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core)
homebrew-science
homebrew-php
homebrew-nginx
……..
Formulas
Homebrew에 설치할 수 있는 팩키지들, 일종의 팩키지 설명 (이 목록은 /usr/local/Library/Formulas 안에 있음)
해당 팩키지를 다운을 받아 설치하는 .rb 파일
-
http://braumeister.org provides recent activity. => http://braumeister.org/formula/wget
brew install <formula>
brew install Repository/<formula> => brew tap <Repository> + brew install <formula>
예> wget 프로그램의 formula
Formula는 간단한 Ruby 스크립트입니다 (package .rb )
class Wget < Formula homepage "https://www.gnu.org/software/wget/" url "https://ftp.gnu.org/gnu/wget/wget-1.15.tar.gz" sha256 "52126be8cf1bddd7536886e74c053ad7d0ed2aa89b4b630f76785bac21695fcd" def install system "./configure", "--prefix=#{prefix}" system "make", "install" end end
Fomular를 통한 설치는 /usr/local/bin폴더에 wget 을 설치한다.
팩키지 설치 | brew install Formulas |
팩키지 삭제 | brew remove Formulas |
팩키지 정보 | brew info Formulas |
(설치한) 팩키지 목록 | brew list 또는 brew ls => ls /usr/local/Cellar |
(설치한) 팩키지 최신버전 확인 | brew outdated |
(설치한) 팩키지의 최신버전으로 설치 | brew upgrade [Formulas] |
팩키지 과거버전 제거 | brew cleanup |
팩키지 버전 전환 | brew switch [Formulas 버전] |
팩키지 과거 버전 확인 | brew versions |
패키지 비활성화 및 활성화
$ brew unlink wget # 일시적으로 비활성화 $ brew link wget # 활성화 $ brew remove wget # 패키지 제거
Homebrew 설치
Preparations , 준비
App store에서 Xcode 설치 후, Xcode Command Line Tool 설치
xcode-select --install
Xcode license 동의
sudo xcodebuild -license
Xcode 실행
드디어, 설치
스크립트 실행
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" ==> This script will install: /usr/local/bin/brew /usr/local/share/doc/homebrew /usr/local/share/man/man1/brew.1 /usr/local/share/zsh/site-functions/_brew /usr/local/etc/bash_completion.d/brew /usr/local/Homebrew Press RETURN to continue or any other key to abort ==> Downloading and installing Homebrew... remote: Counting objects: 5732, done. remote: Compressing objects: 100% (3562/3562), done. remote: Total 5732 (delta 3182), reused 3797 (delta 1990), pack-reused 0 Receiving objects: 100% (5732/5732), 3.37 MiB | 284.00 KiB/s, done. Resolving deltas: 100% (3182/3182), done. From https://github.com/Homebrew/brew * [new branch] master -> origin/master * [new tag] 0.1 -> 0.1 * [new tag] 0.2 -> 0.2 ... * [new tag] 1.1.8 -> 1.1.8 * [new tag] 1.1.9 -> 1.1.9 HEAD is now at 30582a5 Merge pull request #2486 from reitermarkus/fix-audit ==> Tapping homebrew/core Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'... remote: Counting objects: 4347, done. remote: Compressing objects: 100% (4154/4154), done. remote: Total 4347 (delta 37), reused 449 (delta 18), pack-reused 0 Receiving objects: 100% (4347/4347), 3.47 MiB | 163.00 KiB/s, done. Resolving deltas: 100% (37/37), done. Tapped 4158 formulae (4,387 files, 10.9MB) ==> Cleaning up /Library/Caches/Homebrew... ==> Migrating /Library/Caches/Homebrew to /Users/onesixx/Library/Caches/Homebrew ==> Deleting /Library/Caches/Homebrew... Already up-to-date. ==> Installation successful! ==> Homebrew has enabled anonymous aggregate user behaviour analytics. Read the analytics documentation (and how to opt-out) here: http://docs.brew.sh/Analytics.html ==> Next steps: - Run `brew help` to get started - Further documentation: http://docs.brew.sh
설치 후, profile에 심볼릭 링크가 있는 /usr/local/bin/ 을 추가
echo export PATH="/usr/local/bin:$PATH" >> ~/.bash_profile
#~/.bash_profile export CLICOLOR=1 export PATH="/usr/local/sbin:$PATH"
zsh 을 사용하는 경우에는 .bash_profie 대신에 .zshrc 에 ~
탭 자동완성 활성화하기
아래의 명령을 ~/.bash_profile (~/.profile, ~/.bashrc)실행스크립트에 넣어두면,
brew 명령을 tab 자동완성으로 사용할 수 있다.
source `brew --repository`/Library/Contributions/brew_bash_completion.sh source `brew --prefix`/Library/Contributions/brew_bash_completion.sh
설치 후 확인
$ brew doctor
Your system is ready to brew.
설치된 팩키지 목록
$ brew list
필수 설치
Java
$ brew cask install java
XQuartz
$ brew install Caskroom/cask/xquartz
추가작업
OS X 에 Brew설정
El capitan OS 의 ‘시스템 무결성 보호(System Integrity Protection)’인 “rootless”는 Homebrew 설치 폴더인 /usr/local 폴더에는
영향을 주지 않는다.
/usr/local이 존재하는 경우, 폴더의 퍼미션이 변경함
sudo chown $(whoami):admin /usr/local && sudo chown -R $(whoami):admin /usr/local
계속 “already up-to-date”로 표시 되는 경우
16.10.11 업데이트 에러 처리
cd "$(brew --repo) " && git fetch && git reset --hard origin/master && brew update
Homebrew 정보 확인
버전 확인
brew -v
Homebrew 1.1.12 Homebrew/homebrew-core (git revision 6f2e; last commit 2017-04-13)
설치위치
which brew
/usr/local/bin/brew
설정
brew config
HOMEBREW_VERSION: 1.1.12 ORIGIN: https://github.com/Homebrew/brew HEAD: 8ea778f7c7ea790694485030d105a92a9416ef33 Last commit: 11 days ago Core tap ORIGIN: https://github.com/Homebrew/homebrew-core Core tap HEAD: 6f2e60d8a664a024d77bc4875cfffbf7b75452f6 Core tap last commit: 38 minutes ago HOMEBREW_PREFIX: /usr/local HOMEBREW_REPOSITORY: /usr/local/Homebrew HOMEBREW_CELLAR: /usr/local/Cellar HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com CPU: octa-core 64-bit ivybridge Homebrew Ruby: 2.0.0-p648 Clang: 8.1 build 802 Git: 2.11.0 => /Applications/Xcode.app/Contents/Developer/usr/bin/git Perl: /usr/bin/perl Python: /usr/bin/python Ruby: /usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby Java: N/A macOS: 10.12.4-x86_64 Xcode: 8.3.1 CLT: 8.3.0.0.1.1490382677 X11: N/A
정보확인
kegs (Files) 숫자 와 차지하는 disk space
brew info -all
15 kegs, 18,528 files, 540.6M
Homebrew 제거
$ cd `brew --prefix` $ rm -rf Cellar $ brew prune $ rm `git ls-files` $ rmdir Library/Homebrew Library/Aliases Library/Formula Library/Contributions $ rm -rf .git $ rm -rf ~/Library/Caches/Homebrew
$ rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
https://github.com/Homebrew/brew/blob/master/docs/Tips-N’-Tricks.md
https://wilsonmar.github.io/macos-homebrew/
http://tristanpenman.com/blog/posts/2015/10/20/installing-r-and-rstudio-on-mac-os-x/
https://github.com/mimul/dev-environment/blob/master/mac-homebrew.md
https://andromedarabbit.net/wp/homebrew-%EC%82%AC%EC%9A%A9%EB%B2%95/
https://github.com/Homebrew/brew
http://blog.saltfactory.net/mac/install-unix-packages-on-macosx-via-homebrew.html
https://rud.is/b/2015/10/22/installing-r-on-os-x-100-homebrew-edition/
https://raw.githubusercontent.com/Homebrew/install/master/install
http://brew.sh/index_ko.html
http://python-guide-kr.readthedocs.io/ko/latest/starting/install/osx.html