📓
ainzzorl's wiki
  • Intro
  • Pet Projects
    • Good Code
    • LangFlipFlop
    • Soccer Adjectives
    • Word Highlighter
    • News Digest
    • Algorithms in Kotlin
    • rustorcli
  • Tech
    • Tech Articles
    • Algorithms
      • Distributed Hash Table (DHT)
      • RSA
      • Seam Carving
      • Fibonacci Heaps
      • Suffix trees, suffix arrays, etc.
    • Technologies
      • Threads vs Events
      • TLS
      • GPU
      • Web Sockets
      • OSI Model
    • Open Source
      • Homebrew
      • Standard Notes
      • LiChess
    • Bash
    • Raft
    • Quantum Computing
    • GFS
    • MapReduce
    • ZooKeeper
  • Courses
    • MIT 6.824: Distributed Systems
      • Primary-Backup Replication
      • Object Storage on CRAQ
      • Aurora
      • Cache Consistency: Frangipani
      • Takeways
      • Distributed Transactions
      • Midterm
      • Spanner
      • FaRM
      • Spark
      • Cache Consistency: Memcached at Facebook
    • Page 2
    • MIT 6.854/18.415: Advanced Algorithms + Stanford CS168: The Modern Algorithmic Toolbox
  • Math
    • Fourier Transform
    • Probabilities & Statistics
  • Places
    • Moscow
  • Books
    • Page 1
    • Page 1
    • Page 1
    • Page 1
    • Page 1
    • Tobol Mnogo Zvannyh - Ivanov
    • The Twelve Chairs/12 стульев - Ilf, Petrov
    • Beauty is a Wound - Eka Kurniawan
    • The Queen of Spades/Пиковая Дама - Pushkin
    • The Sirens of Titan - Kurt Vonnegut
    • Обитель - Захар Прилепин
    • The Faithful Executioner - Joel Harrington
    • City of Lies: Love, Sex, Death, and the Search for Truth in Tehran - Ramita Navai
    • June/Июль - Dmitry Bykov/Дмитрий Быков
    • East of Eden - John Steinbeck
    • Como Agua Para Chocolate/Like Water for Chocolate - Laura Esquivel Valdés
    • The Kukotski Enigma/Казус Кукоцкого - Lyudmila Ulitskaya/Людмила Улицкая
    • Ancillary Justice - Ann Leckie
    • Career of Evil - JK Rowling
    • The Signal and the Noise - Nate Silver
    • Don't Sleep, There are Snakes - Daniel Everett
    • Оправдание Острова - Eugene Vodolazkin
    • A Place Called Winter - Patrick Gale
    • 1491: New Revelations of the Americas Before Columbus - Charles C. Mann
    • Трудно Отпускает Антарктида - Vladimir Sanin
    • Klara and the Sun - Kazuo Ishiguro
    • The History of My Contemporary/История Моего Современника - Vladimir Korolenko
    • Life at the Speed of Light - Craig Venter
    • Misery - Stephen King
    • And Then There Were None - Agatha Christie
    • A Kim Jong-Il Production - Paul Fischer
  • Cooking
    • Marinated Mushrooms
    • Pea Soup
    • Fried Potato
    • Chimichurri
    • Komendantsky Sauce
    • Spicy mushroom marinara
    • Bruschetta
    • Solyanka with Mushrooms
    • Tofu Scramble
    • Bean Spaghetti
    • Salsa
    • Baked Mushrooms
    • Lentil Soup
    • Веганство в Москве
  • Misc Research
    • Recycling
    • Sailing Upwind
    • Viruses
  • Misc Reading
    • Harry Potter - Rowling Writing
  • Fitness
  • Languages
    • Spanish
    • Language Classification
  • Juggling
  • Life Advice
Powered by GitBook
On this page

Was this helpful?

  1. Tech
  2. Open Source

Homebrew

Summarizing my attempts to understand Homebrew codebase

PreviousOpen SourceNextStandard Notes

Last updated 3 years ago

Was this helpful?

:

  • Formula - package definition.

  • Keg - installation prefix of a formula.

  • Cellar - where all kegs are located.

  • Tap - git repo of formulae and/or commands.

  • Bottle - pre-built keg.

  • Cask - extension of Homebrew to install native MacOS apps.

General notes:

  • I like how formulae come with tests.

  • Formula dev guide is pretty great.

  • Ruby seems like a great choice for DLSs like this.

  • Overall code structure seems moderately simple, e.g. there are not too many layers of redirection for the most part.

  • Implementation details are often rather convoluted, with not too many comments.

  • A lot of long methods.

Tracing:

    • Setting env variables for OS, cache location, etc.

    • Checks that it's not sudo, not installing on temp, etc.

    • Check dependencies: curl, git, ...

      • Some are .sh, some are .rb

      • I expected a single ruby entry point, but there's none!

  • Install path:

      • Accepts formula and a ton of params.

      • I would probably extract the params into some class.

    • FormulaInstaller seems... rather convoluted.

Interesting:

    • Not too interesting. It just delegates.

Entry point shell script:

Then

Then route to one of

Test: Seems rather... superficial. But I kind of like their test DSL.

Command parser:

Check if to install:

Install:

Then it creates and calls its methods one by one: prelude, fetch, install, finish.

Did you mean?

Locking.

Github access With pagination and what not. Spec:

Search:

Download strategy switch:

Unpack strategy.

Cache store:

Curl & workarounds:

https://github.com/Homebrew
https://github.com/Homebrew/brew
https://github.com/Homebrew/homebrew-core
https://github.com/Homebrew/homebrew-cask
Terms
https://github.com/Homebrew/brew/blob/master/bin/brew
https://github.com/Homebrew/brew/blob/master/Library/Homebrew/brew.sh
https://github.com/Homebrew/brew/tree/master/Library/Homebrew/cmd
https://github.com/Homebrew/brew/blob/master/Library/Homebrew/cmd/install.rb
https://github.com/Homebrew/brew/blob/master/Library/Homebrew/test/cmd/install_spec.rb
https://github.com/Homebrew/brew/blob/master/Library/Homebrew/cli/parser.rb
https://github.com/Homebrew/brew/blob/aa14e48f4e73d2f4c7d178d7b8a2f528b74995d7/Library/Homebrew/install.rb#L95
https://github.com/Homebrew/brew/blob/aa14e48f4e73d2f4c7d178d7b8a2f528b74995d7/Library/Homebrew/install.rb#L232
FormulaInstaller
https://github.com/Homebrew/brew/pull/11565/files
https://github.com/Homebrew/brew/blob/master/Library/Homebrew/lock_file.rb
https://github.com/Homebrew/brew/blob/aa14e48f4e73d2f4c7d178d7b8a2f528b74995d7/Library/Homebrew/utils/github.rb
https://github.com/Homebrew/brew/blob/master/Library/Homebrew/test/utils/github_spec.rb
https://github.com/Homebrew/brew/blob/master/Library/Homebrew/search.rb
https://github.com/Homebrew/brew/blob/09f7bc27a99469cf947431df4754737dfbadb31d/Library/Homebrew/download_strategy.rb#L1323-L1356
https://github.com/Homebrew/brew/blob/master/Library/Homebrew/unpack_strategy.rb
https://github.com/Homebrew/brew/tree/master/Library/Homebrew/unpack_strategy
https://github.com/Homebrew/brew/blob/master/Library/Homebrew/cache_store.rb
https://github.com/Homebrew/brew/blob/04532cb6216b69a5b067aa7a4e22cff0944b257d/Library/Homebrew/utils/curl.rb#L64