Homebrew: programmatically replicate an installation?

I would like to copy my macos brew configuration to multiple machines.

Is there a way to programmatically check the status of brew or create a set of commands for it to synchronize the state with another machine?

update: there seems to be nothing, so I put together a quick package that does this. This has worked well for me so far.

https://github.com/marhar/brewmaster
+4
source share
3 answers

Here is a simple package that runs brew on multiple machines, synchronizing them so that they have the same installed packages. I also add support for font synchronization.

https://github.com/marhar/brewmaster
0
source

Good question!!!!

, "" , , , Homebrew . - export settings import settings Dropbox .

, , . JSON jq home- brew .

...

1) , , home- brew , , . - , .

2) - pinned, . , , .

FWIW, , , , - .

   first=1
   # Start output file with array so we can use map()
   echo "["                                                               >  "$f"
   # Iterate over all installed packages
   for pkg in $(brew list); do
      [ $first -ne 1 ] && echo ","                                        >> "$f"
      [ $verbose -gt 0 ] && echo Processing package: $pkg
      # Find options used for this package
      options=$(brew info --json=v1 $pkg | jq '.[].installed[0].used_options')
      echo "{\"name\":\"$pkg\",\"used_options\":$options}"                >> "$f"
      first=0
   done
   # Close array in output file
   echo "]"                                                               >> "$f"

, - "INSTALL_RECEIPT.json", ...

find /usr/local -name "INSTALL_RECEIPT*"

,

# List package names
#jq -r '.packages[] | .["package-name"]' < *json

# List options for package "imagemagick"
#jq -r '.packages[] | select(."package-name"=="imagemagick") | .options[]' < *json
+1

It's probably not quite what you are looking for in terms of synchronizing installations, but you should check out Brewfiles and Bundler: https://github.com/Homebrew/homebrew-bundle

+1
source

Source: https://habr.com/ru/post/1616425/


All Articles