Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,45 @@
name: brew pr-pull

on:
pull_request_target:
types:
- labeled

jobs:
pr-pull:
if: contains(github.event.pull_request.labels.*.name, 'pr-pull')
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
permissions:
actions: read
checks: read
contents: write
issues: read
packages: write
pull-requests: write
steps:
- name: Set up Homebrew
uses: Homebrew/actions/setup-homebrew@master
with:
token: ${{ github.token }}

- name: Set up git
uses: Homebrew/actions/git-user-config@master

- name: Pull bottles
env:
HOMEBREW_GITHUB_API_TOKEN: ${{ github.token }}
HOMEBREW_GITHUB_PACKAGES_TOKEN: ${{ github.token }}
HOMEBREW_GITHUB_PACKAGES_USER: ${{ github.repository_owner }}
PULL_REQUEST: ${{ github.event.pull_request.number }}
run: brew pr-pull --debug --tap=$GITHUB_REPOSITORY $PULL_REQUEST
run: brew pr-pull --debug --tap="$GITHUB_REPOSITORY" "$PULL_REQUEST"

- name: Push commits
uses: Homebrew/actions/git-try-push@master
with:
token: ${{ github.token }}
branch: main

- name: Delete branch
if: github.event.pull_request.head.repo.fork == false
env:
BRANCH: ${{ github.event.pull_request.head.ref }}
run: git push --delete origin $BRANCH
run: git push --delete origin "$BRANCH"
56 changes: 31 additions & 25 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,63 @@
name: brew test-bot

on:
push:
branches:
- main
pull_request:

jobs:
test-bot:
strategy:
matrix:
# I gave up on Linux Bottles because it was taking over 2 hours to build
# a bottle on Ubuntu 24.04.
os:
# auto-multiple-choice: Re-enable Linux as soon as the qt@5 formula
# gets a bootle: https://github.com/Homebrew/linuxbrew-core/pull/23174
#
# amc-pango: installation fails on linux with the error:
# /usr/bin/ld: cannot find -lintl
# collect2: error: ld returned 1 exit status
# Remember to re-enable it one day.
#
# - ubuntu-latest

# https://github.com/actions/virtual-environments/#available-environments
- macos-11
- macos-10.15
- macos-14
- macos-15
runs-on: ${{ matrix.os }}
permissions:
actions: read
checks: read
contents: read
packages: read
pull-requests: read
steps:
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
with:
token: ${{ github.token }}

- name: Cache Homebrew Bundler RubyGems
id: cache
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ${{ steps.set-up-homebrew.outputs.gems-path }}
key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }}
restore-keys: ${{ runner.os }}-rubygems-

- name: Install Homebrew Bundler RubyGems
if: steps.cache.outputs.cache-hit != 'true'
run: brew install-bundler-gems
key: ${{ matrix.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }}
restore-keys: ${{ matrix.os }}-rubygems-

- run: brew test-bot --only-cleanup-before

- run: brew test-bot --only-setup

- run: brew test-bot --only-tap-syntax

- run: brew test-bot --only-formulae
- name: Base64-encode GITHUB_TOKEN for HOMEBREW_DOCKER_REGISTRY_TOKEN
id: base64-encode
if: github.event_name == 'pull_request'
env:
TOKEN: ${{ github.token }}
run: |
base64_token=$(echo -n "${TOKEN}" | base64 | tr -d "\n")
echo "::add-mask::${base64_token}"
echo "token=${base64_token}" >> "${GITHUB_OUTPUT}"
- run: brew test-bot --only-formulae --root-url='https://ghcr.io/v2/${{ github.repository }}'
if: github.event_name == 'pull_request'
env:
HOMEBREW_DOCKER_REGISTRY_TOKEN: ${{ steps.base64-encode.outputs.token }}

- name: Upload bottles as artifact
if: always() && github.event_name == 'pull_request'
uses: actions/upload-artifact@main
uses: actions/upload-artifact@v4
with:
name: bottles
name: bottles_${{ matrix.os }}
path: "*.bottle.*"
63 changes: 36 additions & 27 deletions auto-multiple-choice.rb → Formula/auto-multiple-choice.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
class AutoMultipleChoice < Formula
desc "Printable tests for students with OCR marking"
homepage "https://www.auto-multiple-choice.net"
url "https://gitlab.com/jojo_boulix/auto-multiple-choice/uploads/3262cbab3161e5e63239a281e9a2ce23/auto-multiple-choice_1.5.0_dist.tar.gz"
sha256 "2e48ebb11a215c7882212c46f31d9013bb488c32899104008b0840e67f716948"
revision 0
url "https://download.auto-multiple-choice.net/amc_1.7.0_dist.tar.gz"
sha256 "dfb916aa076f668a6f35253a2c0fc5998db07d2273deb45295a405d8749b7660"

bottle do
root_url "https://github.com/maelvls/homebrew-amc/releases/download/auto-multiple-choice-1.5.0"
Expand All @@ -22,9 +21,10 @@
# to remove the original PATH of the user so that the latex binaries can be
# found.

depends_on "libpthread-stubs" => :build
depends_on "librsvg" => :build
depends_on "make" => :build # macOS system make (3.81) breaks vars-subs.pl

# Although libpthread-stubs isn't actually needed on macOS, libxcb
# used to require lib libpthread-stubs. Because Homebrew doesn't
# systematically upgrade dependencies anymore, users may hit the
Expand All @@ -38,22 +38,23 @@
# to install auto-multiple-choice. We can remove this hack in
# a few months.
# See: https://github.com/maelvls/homebrew-amc/issues/82#issuecomment-1383690536
depends_on "libpthread-stubs" => :build


depends_on "adwaita-icon-theme"
depends_on "amc-pango"
depends_on "cairo"
depends_on "expat"
depends_on "freetype"
depends_on "gettext"
depends_on "glib"
depends_on "gobject-introspection"
depends_on "gtk+3"
depends_on "harfbuzz"
depends_on "imagemagick@6"
depends_on "libffi"
depends_on "libx11"
depends_on "netpbm"
depends_on "opencv" # vendored Pango, stuck at v1.42.4
depends_on "opencv"
depends_on "openssl@3" # required by Net::SSLeay
depends_on "pango"
depends_on "perl"
depends_on "poppler"
depends_on "qpdf"
Expand Down Expand Up @@ -420,14 +421,8 @@
sha256 "40da40948ecc9c787ed39c95715872679eebfd54243721174993a2003e32ab0a"
end
resource "Net::SSLeay" do
url "https://cpan.metacpan.org/authors/id/C/CH/CHRISN/Net-SSLeay-1.90.tar.gz"
sha256 "f8696cfaca98234679efeedc288a9398fcf77176f1f515dbc589ada7c650dc93"
patch do
# To be removed as soon as Net::SSLeay is patched with a fix. See:
# https://trac.macports.org/ticket/63415
url "https://gist.githubusercontent.com/maelvls/9a4890e7c5adf2309a453d0cdbffaa19/raw/e32a76eb40321de66bc40d5adff491267a907a0a/net-ssleay-1.90.diff"
sha256 "d4db9007ac4551a9f618e42e86d4b3484f8eca871bbf803668eb99a7ac0c1cdb"
end
url "https://cpan.metacpan.org/authors/id/C/CH/CHRISN/Net-SSLeay-1.94.tar.gz"
sha256 "9d7be8a56d1bedda05c425306cc504ba134307e0c09bda4a788c98744ebcd95d"
end
resource "Mozilla::CA" do
url "https://cpan.metacpan.org/authors/id/A/AB/ABH/Mozilla-CA-20200520.tar.gz"
Expand Down Expand Up @@ -457,6 +452,14 @@
url "https://cpan.metacpan.org/authors/id/E/ET/ETHER/YAML-Tiny-1.73.tar.gz"
sha256 "bc315fa12e8f1e3ee5e2f430d90b708a5dc7e47c867dba8dce3a6b8fbe257744"
end
resource "Hash::Merge" do
url "https://cpan.metacpan.org/authors/id/H/HE/HERMES/Hash-Merge-0.302.tar.gz"
sha256 "ae0522f76539608b61dde14670e79677e0f391036832f70a21f31adde2538644"
end
resource "Clone::Choose" do
url "https://cpan.metacpan.org/authors/id/H/HE/HERMES/Clone-Choose-0.010.tar.gz"
sha256 "5623481f58cee8edb96cd202aad0df5622d427e5f748b253851dfd62e5123632"
end

def install
installed = {} # helps me avoid installing the same perl package twice
Expand All @@ -467,15 +470,15 @@
ENV.prepend_path "PATH", Formula["gobject-introspection"].bin
ENV.prepend_path "PKG_CONFIG_PATH", "#{Formula["libffi"].lib}/pkgconfig" # for Glib::Object::Introspection
ENV.prepend_path "PKG_CONFIG_PATH", "#{Formula["gobject-introspection"].lib}/pkgconfig" # Same
ENV.prepend_path "PKG_CONFIG_PATH", "#{Formula["amc-pango"].lib}/pkgconfig" # for Pango & AMC-buildpdf
ENV.prepend_path "PKG_CONFIG_PATH", "#{Formula["pango"].lib}/pkgconfig" # for Pango & AMC-buildpdf

ENV["OPENSSL_PREFIX"] = Formula["openssl@1.1"].prefix.to_s
ENV["OPENSSL_PREFIX"] = Formula["openssl@3"].prefix.to_s
ENV["PERL_MM_OPT"] = "INSTALL_BASE=#{libexec}" # for cpan (Makefile.PL)
ENV["PERL_MB_OPT"] = "--install_base '#{libexec}'" # for cpan (Build.PL)
ENV["PERL_MM_USE_DEFAULT"] = "1" # for always saying "yes" in Makefile.PL

# The Libertine font provided by 'brew cask' is 'Linux Libertine' (no O)
inreplace ["AMC-annotate.pl", "AMC-perl/AMC/Annotate.pm", "AMC-perl/AMC/Config.pm",
inreplace ["AMC-annotate.pl.in", "AMC-perl/AMC/Annotate.pm", "AMC-perl/AMC/Config.pm",
"AMC-perl/AMC/Filter/plain.pm", "buildpdf.cc"], "Linux Libertine O", "Linux Libertine"

# When using 'sudo auto-multiple-choice latex-link', make sure that the
Expand All @@ -488,15 +491,18 @@
# broke things. Now c++11 is needed and I use pkg-config for conveniency.
# And since pkg-config is used, CFLAGS, CXXFLAGS and LDFLAGS aren't needed
# anymore.
inreplace "Makefile", "opencv\)", "opencv4)"
inreplace "Makefile", "opencv)", "opencv4)"
inreplace "Makefile", "$(GCC_OPENCV) $(GCC_OPENCV_LIBS)", "$(GCC_OPENCV) $(GCC_OPENCV_LIBS) -std=c++11"
inreplace "Makefile-brew.conf", /^GCC_.*/, ""
inreplace "Makefile-brew.conf", /^CFLAGS.*/, ""
inreplace "Makefile-brew.conf", /^CXXFLAGS.*/, ""
inreplace "Makefile-brew.conf", /^LDFLAGS.*/, ""

# Override three variables that cannot be passed as make variables
# because they are reset in Makefile.conf.
# Override three variables that cannot be passed as make variables because
# they are reset in Makefile.conf.
#
# The CSSDIR should have been added directly to Makefile-brew.conf upstream
# before the 1.7.0 release. But since it wasn't, let's just set it here.
(buildpath/"Makefile-brew.conf").append_lines <<~EOS
DOCBOOK_MAN_XSL = #{Formula["docbook-xsl"].prefix}/docbook-xsl/manpages/docbook.xsl
DOCBOOK_XHTML_XSL = #{Formula["docbook-xsl"].prefix}/docbook-xsl/xhtml/docbook.xsl
Expand All @@ -505,6 +511,7 @@
PERLDIR=#{libexec}/lib/perl5
DESKTOPDIR=
METAINFODIR=
CSSDIR=#{prefix}/share/auto-multiple-choice/gtk
EOS

# The actual build
Expand All @@ -518,8 +525,8 @@
(bin/"auto-multiple-choice").write_env_script libexec/"bin/auto-multiple-choice",
PERL5LIB: ENV["PERL5LIB"],
# netpbm, poppler and imagemagick@6 must be in the PATH
PATH: "#{libexec}/bin:#{Formula["qpdf"].bin}:#{Formula["netpbm"].bin}"\
":#{Formula["poppler"].bin}:#{Formula["imagemagick@6"].bin}"\
PATH: "#{libexec}/bin:#{Formula["qpdf"].bin}:#{Formula["netpbm"].bin}" \
":#{Formula["poppler"].bin}:#{Formula["imagemagick@6"].bin}" \
":#{Formula["gobject-introspection"].bin}:$PATH",
AMCBASEDIR: prefix

Expand Down Expand Up @@ -625,6 +632,8 @@
Glib
ExtUtils::PkgConfig
ExtUtils::Depends
Hash::Merge
Clone::Choose
Locale::gettext
Module::Load::Conditional
OpenOffice::OODoc
Expand Down Expand Up @@ -762,12 +771,12 @@
<<~EOS
If you don't have Mactex installed, you will need it:

brew install homebrew/cask/mactex
brew install mactex

Where is automultiplechoice.sty? After installing, run:

sudo auto-multiple-choice latex-link remove
sudo auto-multiple-choice latex-link
sudo env PATH="$PATH" auto-multiple-choice latex-link remove
sudo env PATH="$PATH" auto-multiple-choice latex-link

If you have any problem/remark regarding this formula, you can submit
an issue to https://github.com/maelvls/homebrew-amc.
Expand Down
44 changes: 32 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@

| Install | Version |
| ----------------------------------------------- | :-----: |
| `brew install maelvls/amc/auto-multiple-choice` | 1.5.0 |
| `brew install maelvls/amc/auto-multiple-choice` | 1.7.0 |

| macOS version | Support | Prebuilt binaries (bottles) |
|-----------------------------------|:-------:|:---------------------------:|
| macOS 12 Monterey (Intel) | ✔️ | ❌ |
| macOS 12 Monterey (Apple Silicon) | ✔️ | ❌ |
| macOS 11 Big Sur (Intel) | ✔️ | ✔️ |
| macOS 11 Big Sur (Apple Silicon) | ✔️ | ❌ |
| macOS 10 catalina (Intel) | ✔️ | ✔️ |
| linux (x86_64) | ❌ | ❌ |
| macOS version | Build from source | Bottle (Intel)\* | Bottle (Apple Silicon)\* |
|-------------------|:-----------------:|:----------------:|:------------------------:|
| macOS 15 Sequoia | ✔️ | ❌ | ❌ |
| macOS 14 Sonoma | ✔️ | ❌ | ✔️ |
| macOS 13 Ventura | ✔️ | ❌ | ❌ |
| macOS 12 Monterey | ✔️ | ❌ | ❌ |
| macOS 11 Big Sur | ✔️ | ❌ | ❌ |
| macOS 10 catalina | ✔️ | ❌ | ❌ |

Regarding Linux, bottles are built for x86_64, but not for arm64.

> \*Bottles are precompiled binaries that are faster to install.

- **To run it**: open [terminal](https://www.iterm2.com) and run
`auto-multiple-choice`.
Expand All @@ -35,6 +39,17 @@ using GitHub Actions. The bottles are uploaded to GitHub Packages.

## News

### May 9, 2025: 1.7.0 released!

The new version of `auto-multiple-choice` is out! Bottles are now available for
macOS 14 Sonoma (Apple Silicon only). Bottles for macOS 15 Sequoia will come
soon ([as soon as opencv gets a bottle for
Sequoia](https://github.com/maelvls/homebrew-amc/pull/96)).

Looking at the analytics, the number of installations went down to 570 for the
past year, which makes sense since I haven't been keeping up with issues and
releases.

### Dec 4, 2021: M1 support, 1083 installations in 2021!

The formula finally supports M1 macs! Note that prebuilt bottles (= faster install time) are not available since it would require renting an M1 mac. I have enable GitHub sponsoring for that reason.
Expand Down Expand Up @@ -390,7 +405,7 @@ think the whole idea of a formula that vendors everything is insane.
I went to <http://deps.cpantesters.org> and I copy-pasted the tree of dependencies
(except for 'Core modules') into a Ruby array. For example:

```ruby
```text
"XML::Simple",
"XML::SAX",
"XML::NamespaceSupport",
Expand All @@ -400,9 +415,14 @@ I went to <http://deps.cpantesters.org> and I copy-pasted the tree of dependenci
I then gather all the ruby array with all dependencies (for example the
previous example) into a file `list_of_deps`.

Then I run
Then I run:

./list_to_resources.pl < list_of_deps > resources
```bash
# Without tests
brew install cpanm
cpanm --notest MetaCPAN::Client
./list_to_resources.pl < list_of_deps > resources
```

and I copy everything in `resources` to the formula.

Expand Down
Loading
Loading