Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add homebrew as macOS install option #506

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

estromlund
Copy link

@estromlund estromlund commented Dec 9, 2023

(Please note: this is a PR against the master branch as it is project documentation)

I spent a bit of time over the last day getting direwolf to build using homebrew on macOS. I submitted the formula and it was approved, so direwolf is now available for all to install on macOS with

brew install direwolf

Homebrew is a modern and widely used package manager on macOS and has largely replaced MacPorts. It works by defining some project metadata as well as some build steps. Here is the direwolf formula reproduced for reference:

class Direwolf < Formula
  desc "Software \"soundcard\" AX.25 packet modem/TNC and APRS encoder/decoder"
  homepage "https://github.com/wb2osz/direwolf"
  url "https://github.com/wb2osz/direwolf/archive/refs/tags/1.7.tar.gz"
  sha256 "6301f6a43e5db9ef754765875592a58933f6b78585e9272afc850acf7c5914be"
  license "GPL-2.0-only"
  head "https://github.com/wb2osz/direwolf.git", branch: "master"

  bottle do
    sha256 arm64_sonoma:   "f15cf78ea350bac7d0daf8663e54242eed663f577400de7630f8225c4e08e340"
    sha256 arm64_ventura:  "494d3a0854c7d919fa8446915bec34806b387c138fd23210c05ab3677c701faf"
    sha256 arm64_monterey: "1c437d0c62b29032faf6eb115caef44b62bc7ef7525d5a137c09eec5015a0f49"
    sha256 sonoma:         "5ad4a23ede0053b7c587b99514c48982378ad7f5e4ae4871e8b8eea6dccb6249"
    sha256 ventura:        "e3064f51ee693453adc1e25a4dc7e7f1617f51d070dc209c847a7459968de0dc"
    sha256 monterey:       "16947ff3e289c953ddb75acb44215ab7f74a5128a20464cfb7f6332b4438f25d"
  end

  depends_on "cmake" => :build
  depends_on "gpsd"
  depends_on "hamlib"
  # Further investigation and work on this
  # formulae is needed to support linux builds. The upstream project
  # provides their own mechanism for linux distribution. Brew is most
  # valuable on macOS, where there is no other suitable package manager,
  # so for now, restrict this formulae to macOS.
  depends_on :macos
  depends_on "portaudio"

  def install
    inreplace "src/decode_aprs.c", "/opt/local/share", share
    inreplace "src/symbols.c", "/opt/local/share", share

    system "cmake", "-S", ".", "-B", "build", *std_cmake_args
    system "cmake", "--build", "build"
    system "cmake", "--install", "build"
    system "cmake", "--build", "build", "--target", "install-conf"
  end

  test do
    assert_match version.to_s, shell_output("#{bin}/direwolf -u")

    touch testpath/"direwolf.conf"
    assert_match "Pointless to continue without audio device.", shell_output("#{bin}/direwolf brew", 1)
  end
end

The formula will need to be bumped by someone for each new release, but as long as the build system doesn't change, you will always be able to pull the latest build from master using

brew install --HEAD direwolf

Note that there are a few changes to the standard build process:

  1. Some hardcoded paths are replaced in the source since homebrew installs packages under a special prefix (normally /opt/homebrew)
  2. The homebrew reviewers asked for changes to the make/cmake syntax. Their version seems to do the same as in the readme but with more modern cmake features. I have to admit I'm not a pro here but it all checks out and build perfectly.

@estromlund estromlund changed the title Readme: Add homebrew as macOS install option. Add homebrew as macOS install option Dec 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant