sandreas / m4b-tool

m4b-tool is a command line utility to merge, split and chapterize audiobook files such as mp3, ogg, flac, m4a or m4b
MIT License
1.15k stars 76 forks source link

Installing latest master using `brew install sandreas/tap/m4b-tool --HEAD` #213

Open kallegrens opened 1 year ago

kallegrens commented 1 year ago

Hello!

I would like to install the latest master using Homebrew on MacOS. How do I do this?

Following the guide in the README with brew install sandreas/tap/m4b-tool, it simply installs the release version 0.4.2, which is really old.

Usually I can do brew install <package name> --HEAD to pull the master. However, when doing this I get Error: No head is defined for sandreas/tap/m4b-tool.

Any ideas?

kallegrens commented 1 year ago

I figured out how to specify the head in the Ruby formula. The reference was found here: https://github.com/Homebrew/brew/blob/master/docs/Formula-Cookbook.md#unstable-versions-head

Using brew edit m4b-tool I edited the formula manually and added the line

head "https://github.com/sandreas/m4b-tool.git", using: :git

The full formula can be seen below.

# brew tap sandreas/tap
# brew install m4b-tool
class M4bTool < Formula
  version "0.4.2"
  desc "m4b-tool is a command line utility to merge, split and chapterize audiobook files such as mp3, ogg, flac, m4a or m4b"
  homepage "https://github.com/sandreas/m4b-tool"
  url "https://github.com/sandreas/m4b-tool/releases/download/v.#{version}/m4b-tool.tar.gz"
  sha256 "0ec79733770379dbd11ea9d76fd03d62d8aacca8e66730779f7caaa92f577ba7"
  head "https://github.com/sandreas/m4b-tool.git", using: :git

  depends_on "php"
  depends_on "sandreas/tap/mp4v2"
  depends_on "fdk-aac-encoder"
  # depends_on "homebrew-ffmpeg/ffmpeg/ffmpeg" => 'with-fdk-aac'

  def install
    bin.install "m4b-tool.phar" => "m4b-tool"
  end

  test do
    assert_equal "m4b-tool v.#{version}", shell_output("#{bin}/m4b-tool --version").chomp
  end

end

When calling brew install sandreas/tap/m4b-tool --HEAD I now get the error:

Error: An exception occurred within a child process:
  Errno::ENOENT: No such file or directory - m4b-tool.phar

So it seems we have to change the install-function? Any thoughts?

sandreas commented 1 year ago

Did you see the install instructions for the latest pre-release?

Just replace the m4b-tool.phar file with the latest one:

# show m4b-tool install path, e.g. /usr/local/bin/m4b-tool
which m4b-tool

# download latest pre-release
cd /tmp
wget https://github.com/sandreas/m4b-tool/files/9721007/m4b-tool.tar.gz
tar xzf m4b-tool.tar.gz

# backup old version
sudo mv /usr/local/bin/m4b-tool /usr/local/bin/m4b-tool.2020-02-29.phar

# install new version
sudo mv m4b-tool.phar /usr/local/bin/m4b-tool && sudo chmod +x /usr/local/bin/m4b-tool

# check version
m4b-tool version
kallegrens commented 1 year ago

Hello!

I'm aware I can just build from source or just use the latest pre-release. However, what I was after was doing this using Homebrew. The reasons are several. Two of them are:

I managed to install the latest pre-release using Homebrew by editing the formula and instead of pointing the head to the latest master I pointed it to the latest pre-release as such:

head "https://github.com/sandreas/m4b-tool/files/9721007/m4b-tool.tar.gz"

This installs nicely using brew install sandreas/tap/m4b-tool --HEAD. However, this still doesn't allow brew upgrade m4b-tool --fetch-HEAD, because it's not really cloning the master and building.

Unfortunately I'm not experienced in Ruby, nor with Homebrew. But, as mentioned before, probably we need to make the --HEAD-option use it's own way of installing.

sandreas commented 1 year ago

I managed to install the latest pre-release using Homebrew by editing the formula and instead of pointing the head to the latest master I pointed it to the latest pre-release as such:

Cool, I did not understand that at first. This is really helpful, thank you very much.

Unfortunately I'm not experienced in Ruby, nor with Homebrew. But, as mentioned before, probably we need to make the --HEAD-option use it's own way of installing.

Currently, I'm absolutely busy with other things. But I'll keep that in mind for the future and will definitely take a look at this.

BTW: @kallegrens the tap is open souce, too: https://github.com/sandreas/homebrew-tap/blob/master/Formula/m4b-tool.rb

sandreas commented 1 year ago

Related to #217

The plan is to rework brew that a newer pre-release known as stable is the default install... as well as getting rid of some useless dependencies (sandreas/mp4v2 is deprecated in favour of enzo1982/mp4v2). I think integrating tone would also be a good idea.

sandreas commented 1 year ago

Got a PR, switched to a pretty new preview-release since 0.4.2 is unusable right now. Integration of tone has to be done, but this is something for later.

kallegrens commented 1 year ago

Nice to see some progress here! Keep up the good work :)