2019年3月15日 星期五

【macOS】Homebrew macOS 缺少套件的管理工具

What Does Homebrew Do?

  1. 使用 Homebrew 安裝 Apple 沒有預裝但是你需要的東西。
    $ brew install wget
    
  2. Homebrew 會將 packages 安裝在他們自己的目錄,然後把檔案 symlink 到 /usr/local 下。
    $ cd /usr/local
    $ find Cellar
    Cellar/wget/1.16.1
    Cellar/wget/1.16.1/bin/wget
    Cellar/wget/1.16.1/share/man/man1/wget.1
    
    $ ls -l bin
    bin/wget -> ../Cellar/wget/1.16.1/bin/wget
    
  3. Homebrew 不會把檔案放在預設路徑之外的地方,因此可以在任何位置使用 Homebrew 安裝程式。
  4. 輕鬆建立你自己的 Homebrew packages。
    $ brew create https://foo.com/bar-1.0.tgz
    Created /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/bar.rb
    
  5. 完全以 Git 和 Ruby 為基底,所以你可以盡情地運用這些知識,輕鬆地復原你的修改以及合併上游的更新。
    $ brew edit wget # 使用 $EDITOR 編輯!
    
  6. Homebrew 的 formula 都是簡單的 Ruby 腳本:
    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
    
  7. Homebrew 互補了 macOS,你可以使用 gem 來安裝 Ruby 套件, 而它的依存軟體可以用 brew 安裝。
  8. "To install, drag this icon..." no more. brew cask installs macOS apps, fonts and plugins and other non-open source software.
    $ brew cask install firefox
    
  9. Making a cask is as simple as creating a formula.
    $ brew cask create foo
    Editing /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/Casks/foo.rb
    

安裝 Homebrew

在終端機命令列提示貼上這個。
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 


更多資訊

https://brew.sh/

沒有留言:

張貼留言