Streamline Package Distribution with AUR and Brew: Leveraging the Power of GitHub
It’s crucial to have a repository on GitHub for seamless development and collaboration. In the case of Arch Linux’s AUR, creating an account on aur.archlinux.org is essential. Additionally, generating and configuring an SSH key pair linked to the AUR account is crucial. Here’s how you can set it up:
Create the ~/.ssh/config
file with the following content:
Host aur.archlinux.org
IdentityFile ~/.ssh/aur
User aur
Generate the SSH keys:
ssh-keygen -f ~/.ssh/aur
ssh-keygen -b 4096 (RSA) This command will create a public key in the specified folder. Next, let's create the AUR repository (which is separate from the GitHub repository for our project):
git -c init.defaultbranch=master clone ssh://aur@aur.archlinux.org/pkgbase.git
You may receive a warning about cloning an empty repository, but don’t worry. Now, you can place the binaries, tarball, or any files related to the installation of the project inside this folder.
To proceed, add a remote label to your repository (Inside of it):
git remote add label ssh://aur@aur.archlinux.org/pkgbase.git
Replace pkgbase
with the name of the package you wish to publish on AUR.
Finally, follow these steps to complete the AUR package creation:
$ makepkg --printsrcinfo > .SRCINFO
$ git add PKGBUILD .SRCINFO
$ git commit -m "Updates"
$ git push origin master
Example of a PKGBUILD:
# Maintainer: Tu nombre <usuario@mail.ch>
pkgname=nombre-del-proyecto
pkgver=v.1.0.2
pkgrel=1
pkgdesc="DescripciĆ³n de la aplicaciĆ³n o software"
arch=('x86_64')
url="https://github.com/usuario/proyecto"
license=('MIT')
depends=('gcc' 'vim' 'nano')
source=("https://github.com/usuario/repo-proyecto/archive/refs/tags/$pkgver.tar.gz")
build() {
cd "$srcdir/proyecto-$pkgver"
#make
./setup
}
package() {
cd "$srcdir/proyecto-$pkgver"
install -Dm755 term_notes "$pkgdir/usr/bin/proyecto"
}
sha256sums=('e1ae65286b64c3466d5749524c79df1063ec9db35b265f0359d24cc76397d88c')
Make sure to review the PKGBUILD file, ensuring it matches the provided template and contains the correct sha256sums
. You can generate the sha256sums
by running sha256sum -b * > SHA256SUMS
. Open the resulting SHA256SUMS
file with a text editor to verify the sha256sums for the tarball versions in the GitHub repository.
In Mac OS is:
shasum -a 256 src/file-project.c
Moving on to Brew:
Inside the root folder of your GitHub project, create a folder called Formula
. Within this folder, create a file named project.rb
, where project
represents the name of your project in Brew.
Here’s an example of a formula in Ruby:
class TermNotes < Formula
desc "Description of the application"
homepage "https://github.com/user/repoproject"
url "https://github.com/user/repoproject/archive/refs/tags/v.1.0.2.tar.gz"
sha256 "e1ae65286b64c3466d5346346345634634634563464536d24cc76397d88c"
license "MIT"
depends_on "gcc"
depends_on "vim"
depends_on "nano"
def install
if OS.mac?
bin.install "named-project" => "renamed-project"
else
bin.install "project"
end
end
def caveats
<<~EOS
'Term Notes' has been installed!
On macOS, you can run the program using 'term-notes'.
On Linux, you may need to create a symbolic link to make it accessible globally.
Run the following command:
sudo ln -s #{opt_bin}/project-name /usr/local/bin/renamed-project
Enjoy taking notes with 'Term Notes'!
EOS
end
test do
# Add your test logic here
end
end
To utilize the tap functionality, ensure you have Homebrew installed on your Mac or Linux system. Visit brew.sh for installation instructions. Once installed, use tap
as follows:
brew tap <username>/<repository> <full-github-url-repoproject>
To install the project using brew, run:
brew install name-project
Replace name-project
with the same name used for the file inside the Formula
folder in your GitHub project’s root directory.
Once your tap is installed, Homebrew will automatically update it whenever a user runs brew update
. Outdated formulas will be upgraded when a user runs brew upgrade
along with core formulas.
Remember to update the AUR repository by replacing the sha256sum and adjusting the tag’s version to reflect the changes in the GitHub repository inside the .rb
formula file in the Formula
folder.
For more information about maintaining a tap, refer to the official Homebrew documentation. To learn about the AUR submission guidelines and sha256sums, visit the Arch Linux wiki and this Super User post.