owickstrom / komposition

The video editor built for screencasters
https://owickstrom.github.io/komposition/
Mozilla Public License 2.0
429 stars 21 forks source link

MacOS brew formula #55

Closed wiradikusuma closed 4 years ago

wiradikusuma commented 5 years ago

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)

owickstrom commented 5 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.

2mol commented 5 years ago

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:

  1. From CI like you said won't work, since you point to a download URL in the homebrew formula. I see you don't have releases yet.
  2. I'd check how to get the dependencies defined properly, especially if passing the flag in 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.
owickstrom commented 5 years ago

@2mol Thank for the feedback!

  1. 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 .dylibs 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?

  2. 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.

athas commented 4 years ago

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:

  1. 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.

  2. 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.

  3. Some of the dependencies may in fact just be build dependencies.

athas commented 4 years ago

Note that if the formula gets put in Homebrew-core, they will take care of all the bottling and updates.

owickstrom commented 4 years ago

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.

athas commented 4 years ago

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.

owickstrom commented 4 years ago

Sounds OK, then. :+1:

athas commented 4 years ago

I'll still need you to tag a release before I can move this further.

owickstrom commented 4 years ago

Of course, here it is: https://github.com/owickstrom/komposition/releases/tag/v0.2.0

athas commented 4 years ago

Thanks! I'll submit a Homebrew formula soon-ish, and then we'll see what they say.

owickstrom commented 4 years ago

@athas Great, thanks!

athas commented 4 years ago

komposition is now in Homebrew

owickstrom commented 4 years ago

Awesome work, @athas !

owickstrom commented 4 years ago

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?

athas commented 4 years ago

@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.

owickstrom commented 4 years ago

Sounds good. And I suppose it's this file: https://github.com/Homebrew/homebrew-core/blob/7557e86f658cc3ae4abe627b92919538388c098d/Formula/komposition.rb ?

athas commented 4 years ago

Yes, that's the one.