Static binaries and Homebrew as a channel for internal tools

7 hours ago 1

The Homebrew package manager is nice. It's not perfect, it's not performant, but in my opinion, for developer machines, it's by far the easiest and most flexible package manager, especially for quickly distributing internal tools. The flexibility comes from two main points:

  1. Homebrew is thought of as the missing package manager for macOS, but it also works extremely well on Linux! It installs everything under /opt so it can coexist with other package managers, like aptitude.

  2. It's trivial to write and host third-party package feeds, also called taps. Get it? Because it's homebrew.

Let's look at examples of how I used this daily. First, I have two internal tools that I wrote, Decompose, which takes in a YAML Docker compose file and transforms it into its docker run ... form and xray-junit-uploader, which takes a junit test results file and uploads it to the XRay test management software.

This is important: both tools are written in Rust and compile statically (with a dependency on glibc) for Linux x86. This is done by GitLab which automatically creates a release for me making the static binary for download. You don't need to compile tools statically, but I noticed it makes all the difference when working with engineers that use several dozens of different systems.

Then, I write a Homebrew formula in Ruby that instructs Homebrew to download and install that binary into the host system. This formula lives in a git repository (also known as a tap) aptly named homebrew-toradex.

class Decompose < Formula desc "Takes a docker-compose.yml and makes it into a docker run command" homepage "https://gitlab.com/toradex/rd/torizon-core/decompose" url "https://gitlab.com/toradex/rd/torizon-core/decompose/-/jobs/artifacts/0.0.1/raw/target/x86_64-unknown-linux-gnu/release/decompose?job=build-x86_64" sha256 "51a53458b895f67cb6ec16735e96f0ec2eec3799a097ba4ca3d81790d03e5b81" license "MIT" version "0.0.1" def install bin.install "decompose" end test do system "#{bin}/decompose", "--version" end end

The last step is easy: I just tap into homebrew-toradex and install the tool:

# brew tap homebrew-toradex/xray-junit-uploader https://gitlab.int.toradex.com/rd/torizon-core-containers/homebrew-toradex.git # brew install xray-junit-uploader

It's particularly helpful on CI, and the Homebrew project provides a homebrew/brew Docker image which is handy. Here's a example of this strategy in production use.

No servers, no complex metadata, just easy tooling distribution.

Read Entire Article