diff --git a/.github/workflows/brew.yml b/.github/workflows/brew.yml new file mode 100644 index 00000000..70e44c47 --- /dev/null +++ b/.github/workflows/brew.yml @@ -0,0 +1,43 @@ +name: Update Homebrew formula + +on: + push: + tags: + - 'v[0-9]*.[0-9]*' + +jobs: + update-formula: + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Checkout master + uses: actions/checkout@v4 + with: + ref: master + fetch-depth: 0 + + - name: Compute SHA256 + id: vars + run: | + TAG="${{ github.ref_name }}" + VERSION="${TAG#v}" + TARBALL_URL="https://github.com/${{ github.repository }}/archive/refs/tags/${TAG}.tar.gz" + SHA256=$(curl -fsSL "${TARBALL_URL}" | sha256sum | cut -d ' ' -f1) + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" + echo "sha256=${SHA256}" >> "$GITHUB_OUTPUT" + echo "url=${TARBALL_URL}" >> "$GITHUB_OUTPUT" + + - name: Update formula + run: | + sed -i 's| url ".*"| url "${{ steps.vars.outputs.url }}"|' Formula/qdl.rb + sed -i 's| sha256 ".*"| sha256 "${{ steps.vars.outputs.sha256 }}"|' Formula/qdl.rb + + - name: Commit and push + run: | + git config user.name "GitHub Actions" + git config user.email "actions@github.com" + git add Formula/qdl.rb + git commit -m "brew: update formula to ${{ steps.vars.outputs.version }}" + git push origin HEAD:master diff --git a/Formula/qdl.rb b/Formula/qdl.rb new file mode 100644 index 00000000..8851b6d9 --- /dev/null +++ b/Formula/qdl.rb @@ -0,0 +1,30 @@ +class Qdl < Formula + desc "Flash images to Qualcomm EDL devices" + homepage "https://github.com/linux-msm/qdl" + url "https://github.com/linux-msm/qdl/archive/refs/tags/v2.7.1.tar.gz" + sha256 "93cd1475d4cdfed31bca2aed9279c3e4cf829e5d65921762734dc0c6d26f0221" + license "BSD-3-Clause" + + head "https://github.com/linux-msm/qdl.git" + + depends_on "help2man" => :build + depends_on "meson" => :build + depends_on "ninja" => :build + depends_on "pkgconf" => :build + depends_on "libusb" + depends_on "libxml2" + depends_on "libzip" + + def install + system "meson", "setup", "build", + "-DVERSION=#{version}", + *std_meson_args + system "meson", "compile", "-C", "build" + system "meson", "compile", "manpages", "-C", "build" + system "meson", "install", "-C", "build" + end + + test do + system bin/"qdl", "--version" + end +end diff --git a/README.md b/README.md index 53c5f58f..d804043b 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,31 @@ meson compile -C build ### MacOS -For Homebrew users: +For Homebrew users, a formula is maintained in [`Formula/qdl.rb`](Formula/qdl.rb). +Tap this repository and install the latest release or the development +`HEAD`: + +```bash +brew tap linux-msm/qdl https://github.com/linux-msm/qdl +brew install linux-msm/qdl/qdl # latest tagged release +brew install --HEAD linux-msm/qdl/qdl # build from the tip of master +``` + +To build and install from a local checkout instead of the tap - for +example, to test a change to `Formula/qdl.rb` before it is merged - tap +the working tree directly and install from it: + +```bash +brew tap linux-msm/qdl /path/to/qdl.git +brew install --build-from-source linux-msm/qdl/qdl +``` + +Re-run `brew install --build-from-source linux-msm/qdl/qdl` after editing +the formula to rebuild with the changes; `brew untap linux-msm/qdl` removes +the local tap when done. + +To build without Homebrew packaging, install the dependencies and drive +Meson directly: ```bash brew install libxml2 libusb libzip meson ninja help2man