Closed wiradikusuma closed 4 years ago
Indeed, it would be awesome! I haven't written such formulas before, but maybe someone with experience would like to help. Could be done from precompiled binaries from CI.
I've done it before, the base case is very easy. You basically create a generic repo that contains homebrew formulas that look like this: https://github.com/2mol/homebrew-tools/blob/master/pboy.rb.
In your case installation would then be brew install owickstrom/tools/komposition
("tools" can also be something else of your choosing).
Two things for your case that I see as potential roadblocks:
gst-plugins-good --with-gtk+3
works out of the box. Similar with exporting PKG_CONFIG_PATH
from within the formula. The stack install happy
might be even a bigger problem.@2mol Thank for the feedback!
I was thinking of setting up releases, or maybe an S3 bucket for those binaries, that the Homebrew script could download. Having the Homebrew formula compile from source seems like a bigger rabbit hole. With Homebrew, I suppose the executable would be dynamically linked, and not be a package including any other libraries, because Homebrew would supply the .dylib
s through depends_on
rules. Do you know if Homebrew sets up something like DYLD_LIBRARY_PATH
such that libraries are found automatically, or do we need to mess around with rpaths?
If we don't compile from source in the formula, as mentioned above, those things shouldn't be problems. Only the runtime libraries will be needed (GTK, Gstreamer + plugins, FFmpeg, and maybe something else). But as you say, somehow passing the --with-gtk+3
would still be needed.
I have written a Homebrew formula that seems to work fine:
require "language/haskell"
class Komposition < Formula
include Language::Haskell::Cabal
desc "Video editor built for screencasters"
homepage "https://github.com/owickstrom/komposition"
# url "https://github.com/owickstrom/komposition/archive/.tar.gz"
# sha256 ""
head "https://github.com/owickstrom/komposition.git"
depends_on "cabal-install" => :build
depends_on "ffmpeg"
depends_on "ghc" => :build
depends_on "gobject-introspection"
depends_on "gst-libav"
depends_on "gst-plugins-base"
depends_on "gst-plugins-good"
depends_on "gstreamer"
depends_on "gtk+3"
depends_on "gstreamer"
depends_on "libffi"
depends_on "pkg-config" => :build
depends_on "sox"
def install
# The --allow-newer-base may be removed if the ffmpeg-light bound
# is relaxed, or when Homebrew moves to Cabal 3 builds.
install_cabal_package "--allow-newer=base", :using => ["alex", "happy"]
end
test do
end
end
The missing points are:
Komposition must have a release tagged before this formula will be accepted in Homebrew-core. This is just a matter of tagging some commit vX.Y.Z
and doesn't have to imply anything about stability or release announcements or whatnot. GitHub will generate the tarball and such. The nice thing is that as subsequent tags are made, there's tooling to update the formula as well.
I'm not sure what the test
block should contain. Homebrew insists on something more than running --version
, but can komposition do anything interesting on the command line? Maybe I should read up on how Homebrew normally handles GUI applications.
Some of the dependencies may in fact just be build dependencies.
Note that if the formula gets put in Homebrew-core, they will take care of all the bottling and updates.
Regarding (2), I previously had a command line tool for splitting up videos, but it's no longer part of the codebase, IIRC. If you find some guidelines for GUI apps, that would be nice.
All I can find is this:
If the formula is for a GUI program, try to find some function that runs as command-line only, like a format conversion, reading or displaying a config file, etc.
However, I also find:
foo --version and foo --help are bad tests. However, a bad test is better than no test at all.
So I don't think it's a deal-breaker.
Sounds OK, then. :+1:
I'll still need you to tag a release before I can move this further.
Of course, here it is: https://github.com/owickstrom/komposition/releases/tag/v0.2.0
Thanks! I'll submit a Homebrew formula soon-ish, and then we'll see what they say.
@athas Great, thanks!
Awesome work, @athas !
The nice thing is that as subsequent tags are made, there's tooling to update the formula as well.
@athas how do we publish new versions in the future?
@owickstrom you just tag another release on GitHub. The formula must be updated, which you or I or someone else can submit a pull request for, but there are a bunch of people running scripts that look for new versions, so it usually happens automatically within a day or so. Those scripts just bump the tarball and hash though, so manual modification may be necessary if more non-Haskell dependencies are added.
Sounds good. And I suppose it's this file: https://github.com/Homebrew/homebrew-core/blob/7557e86f658cc3ae4abe627b92919538388c098d/Formula/komposition.rb ?
Yes, that's the one.
Just a placeholder. I think a lot of macOS users would benefit from komposition being available as a brew formula.
(If it's not appropriate, feel free to close)