Skip to main content

Updating Blowfish

··1118 words·6 mins
Author
Moulting Penguin
Table of Contents

Updating Blowfish … and Hugo
#

So after switching to Blowfish, I learned the hard way that updating Hugo itself is a nightmare. This post isn’t about that1, but about the way I am making it easier to update.

So the basic problem here is that I still can’t figure out how to pin Hugo to a specific version that’s not the current version. But that’s OK, pinning brew seems. . . ad hoc.

Instead, I created a brew ‘Tap’. This consists primarily of a ruby file in a specific file hierarchy in a git repository. :-) Like so many things I do, like we all do, I bashed about a little bit and stopped when I got it to work. Then I incrementally refined it. This post is from the perspective of if I was to do it over again, or how I wished I’d done it.

You have two options:

  • Don’t bother with a remote repository
  • Set up a remote repository

Clearly, I started with “don’t bother with a remote repository”, and am now wishing I had started with “set up a remote repository”.

No remote repository
#

If you don’t want to have a remote repository you can do something like:

brew tap-new user/your-tap-name-here
cd $(brew --repo users/your-tap-name-here)

Note: brew tap-new makes a git repository.

Of course, this is what I did originally. So you can do this if you want to avoid setting up the hierarchy (though it’s like a single mkdir command). Of course, you get a .github directory with hooks in it. Useful (maybe) if you use github. I don’t.

Setting up a remote Tap repository
#

While the first time around I used brew tap-new to make the repository, the instruction here don’t do that, because you don’t need to, because I’m used to setting up git repositories in my repo server by hand.

So, the first thing to do is create a git repository:

mkdir homebrew-versioned-hugo
cd homebrew-versioned-hugo
git init
touch readme.md
git add .
git commit -m 'First Commit!'

Yeah, nothin’ new there. Next up is to make a Tap!

This is where I really have no idea what I’m doing. But it worked2.

So we need to actually populate the tap, using the homebrew-core repository as a model. Moreover, it has the actual file we want.

The layout of the repository would appear to be to have a Formula directory, and then sub-directories based on the first letter of formulae (this is what git tap-new does for you). The formula we want is hugo, so:

mkdir -p Formula/h
touch Formula/h/hugo.rb
git add .
git commit -m "Adding a stub for the hugo formula"

What do we put in the hugo.rb file? Yeah, that’s another step. It’s actually the same step as updating. For now, we just use a stub file.

You don’t have to push this repository somewhere, but if you don’t, you are at the vagaries of your equipment3. Further, you have to go into the homebrew directories to muck about4. Since I have a private Gitea instance, it’s easy for me to make a repo there, but you could use github/gitlab/bitbucket or whatever. I’m not giving instructions on how to push to a repository, since if you know how to do it, you know how to do it, and if you don’t. . . maybe mucking around in the homebrew directories isn’t the right way to go for you. :-)

Regardless, before you go any further, you should be able to git push if you’re using a repository.

Updating the Tap
#

When it’s time to update the tap (or when you first create the tap) for the most current version of Hugo that Blowfish supports, we need to do two things:

  • Find the version of Hugo that Blowfish supports
  • Download the formula for that version of Hugo

Finding the latest version of Hugo that Blowfish supports
#

This is actually fairly easy. When you update blowfish in your blog directory5 you just look at themes/blowfish/release-versions/hugo-latest.txt, which will tell you the maximum version of Hugo that this version of Blowfish supports.

Downloading/Updating the Formula
#

This is a little more involved. Start with the Hugo commits. From there, find the version you want. Look for the bottle commit, since that will have the correct versions for download – if you pick the other one, the version will be updated, but not the downloaded bits, and you’ll get an error about how the directory doesn’t exist when updating (and will show the prior version directory if you go look).

So, from the commits, click on the Bottle commit to see the diff, then click the three dot menu to “View file”, and then download the file (or view raw and get the URL to download the file). For example, I just updated to v139.3. So:

cd Formula/h
curl -O https://github.com/Homebrew/homebrew-core/raw/6bc2dd864201e766b9c6ae44cbf23625dc50dad5/Formula/h/hugo.rb
git commit -a -m "Updating Hugo to v0.139.3"
git push

Add/Update the Tap
#

If you haven’t already, you must add your repository as a tap. If you’ve been doing all this in the homebrew tap area, you’re done adding it.

Otherwise, this is how you add the tap:

brew tap user/repo <URL _to your repo>

Once the tap exists, you can use brew upgrade to update.

At least I think so. Once I updated the repo and ran brew upgrade, it pulled down the updated Tap repo, and then updated Hugo.

Closing Thoughts
#

So this post is about keeping Blowfish and Hugo “in sync”, as it were. I put a lot of “I dunno” type stuff here, and that might seem to go against my “Learn how it works!” ethos. But it doesn’t, because a) this isn’t really a “How-To”, b) I am digging into how it works, and c) I’ll update this if I need to know or learn more.


  1. Much. :-) I mean, you gotta know by know there’ll be digressions. ↩︎

  2. But of course, I’m trying to write this as I wished I’d done it, not as I actually did. This is in line with my rant about Using Your Brain, and going back to understand what you’ve done. ↩︎

  3. I just had to replace my (somewhat) aging Intel MacBook Pro with an Apple Silicon one, and, well, chose not to pull everything over. The location of homebrew changed (intel vs. arm) as well. So I had to start over. Of course, that’s why I’m writing this up. ↩︎

  4. In researching this post, I found out you can do cd $(brew --repo tap/path), so there you go. ↩︎

  5. You are keeping your blog directory in a repository of some sort, right? Right? If you’re using git, you can update blowfish with git submodule update --recursive --remote↩︎