Homebrew intro

Published by onesixx on

https://formulae.brew.sh/

 

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๋ฅผ ์„ค์น˜ํ•˜๋Š” ๋ฐฉ๋ฒ•
(์˜ˆ๋ฅผ ๋“ค์–ด ๋‹ค์šด๋กœ๋“คํ•  tar.gzipํŒŒ์ผ ์œ„์น˜ ๊ฐ™์€ ์ •๋ณด๊ฐ€ ๋“ค์–ด์žˆ๋‹ค.)

Caskroom

cask

brew-cask

extend Homebrew
ํŒฉํ‚ค์ง€ ์‹ค์ œ๊ฒฝ๋กœ

/usr/local/Caskroom
 
Celler ์™€์ธ์ด๋‚˜ ๋งฅ์ฃผ ๋“ฑ์˜ ์ €์žฅ๊ณ 
ํ”„๋กœ๊ทธ๋žจ ์„ค์น˜์žฅ์†Œ

Package๋ฅผ ์ž์‹ ์˜ Cellar(/usr/local/Cellar/ํŒฉํ‚ค์ง€๋ช…)์— ์„ค์น˜ํ•˜๊ณ , 
/usr/local/bin ์— symlinks๋ฅผ ๋งŒ๋“ ๋‹ค.

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 ํŒŒ์ผ

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 ์‹คํ–‰

๋“œ๋””์–ด,  ์„ค์น˜

https://brew.sh/index_ko.html

์Šคํฌ๋ฆฝํŠธ ์‹คํ–‰

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

https://www.xquartz.org

$ 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

 

Categories: Ubuntu

onesixx

Blog Owner

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x