Cooking with Azure
Published in

Cooking with Azure

Gofish’ing for packages

I discovered a nifty little tool to install tools I use often into my WSL2/linux boxes. Here’s how to contribute to the project.

Gofish (https://gofi.sh/) is an opensource cross-platform package manager, alternative to the likes of Homebrew but based on simple LUA scheme definitions to declare what should be installed. It’s geared (at least for me!) towards binaries distributed out of Github; imagine getting away with all those wget's and curl ‘s from github.com piped into a |tar -zxvf — and so on, and just run gofish install awesometool to have all your beloved cli tools ready to go.

There’s a bunch of tools already available (get a list with gofish search ), and it’s easy to add a package of your choice. Here’s a guide on how to contribute a package to the project (the gofish cli is at https://github.com/fishworks/gofish, while the actual packages are at https://github.com/fishworks/fish-food).

First of all, create a definition for your package :

$ vim $(gofish create foo)

This creates a file in /usr/local/gofish/Rigs/github.com/fishworks/fish-food/Food called package.lua . You should fill the version, the name and the description of the package, and then make sure that the URL from the github releases matches the url field. This is the part I find quite tricky and where packages vary wildly from each other: the best approach is to go to your package’ releases page on github, look at the URL of one package and match character by character the url (using the convention .. name .. as placeholder for the name or version of the package.

Make sure the path matches the archive structure of the extracted package; sometimes packages are extracted as /bin/package, sometimes directly on the root of the package as /package and other times into more complex folder structure. More info here.

For the sha field, I find it easier to save the file at this point (make sure all architectures have the right URL, and run a gofish lint command:

gofish lint /usr/local/gofish/Rigs/github.com/fishworks/fish-food/Food/package.lua

which it’s going to return the sha256 checksums for all the archives you specified.

Note: if you see the sha starting with 0019dfc4b32 it means that the package has not been downloaded correctly and probably the url is wrong. Remove the cached archives from ~/.gofish/ , fix the url and retry.

Now it’s time to test your package install with:

gofish install package

If the binary of your package is working and it’s correctly symlinked in /usr/local/bin, then it’s time to contribute your package to the fish-food repository.

Go to https://github.com/fishworks/fish-food and fork it into your account.

Note: if you already have a fork of the fish-food repo, make sure it’s up to date by rebasing it:

cd repos/github/user/fish-food
git remote add upstream https://github.com/fishworks/fish-food
git fetch upstream
git rebase upstream/main

Then back in the terminal, go into the local Rigs folder (this contains a checkout of the github repo of fish-food) and add your fork as remote:

cd /usr/local/gofish/Rigs/github.com/fishworks/fish-food/ 
git remote add upstream https://github.com/user/fish-food

Create a new branch and push it to your fork

git checkout package
git add Food/package.lua
git commit -a -m "added package"
git push upstream package

Now the only remaining step is to go to your https://github.com/user/fish-food fork and open a pull request against https://github.com/fishworks/fish-food. Congratulations! You contributed to make Gofish great :)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store