DEV Community

Cover image for A Dead Simple Guide to Submitting Your First Package to the AUR
Samay Kumar
Samay Kumar

Posted on

A Dead Simple Guide to Submitting Your First Package to the AUR

So, you've been using Arch Linux for a while, and you've found some cool software that isn't available in the official repositories. Or maybe you've built something yourself and want other Arch users to install it without going through the hassle of manually compiling everything.

Well, that's what the AUR is for.

The Arch User Repository (AUR) is one of the best things about Arch Linux. It allows users to share package build instructions with everyone else. And the best part? You don't need to be some Arch Linux wizard to contribute to it.

In this guide, we'll go through the entire process of submitting your first package to the AUR. We'll start with a simple PKGBUILD, test it locally, and eventually push it to the AUR.

No unnecessary theory. Let's get started.

1. What exactly is the AUR?

Before we start, let's get one thing clear.

The AUR is not a repository that hosts precompiled binaries. Instead, it hosts PKGBUILD files and other supporting files required to build packages.

Think of a PKGBUILD as a recipe. It tells Arch Linux where to download the software from, what dependencies are required, how to build it, and where to install the resulting files.

When someone installs a package from the AUR, their AUR helper (like yay or paru) downloads these build instructions and uses makepkg to build the package locally.

That's pretty much it.

Also, the AUR is community-maintained. Packages are not officially reviewed or supported by Arch Linux.

IMPORTANT: AUR IS NOT SECURE BY DEFAULT

AUR packages are community-maintained and aren't officially reviewed by Arch Linux. With recent AI developments, creating malicious packages has become easier, and some packages may contain scripts that perform unwanted actions on your system.

Never blindly install random AUR packages. Always inspect the PKGBUILD before installing anything. Remember, yay and paru are package managers, not security scanners.

2. Before we begin

There are a few things you'll need:

  • An Arch Linux installation (or an Arch-based distribution).
  • Git.
  • base-devel installed.
  • An account on the AUR website.
  • An SSH key configured for your AUR account.

If you haven't installed the build tools yet, run:

sudo pacman -S --needed base-devel git
Enter fullscreen mode Exit fullscreen mode

Now, head over to aur.archlinux.org and create an account.

Once that's done, we'll configure SSH authentication.

3. Setting up SSH authentication

The AUR uses SSH for package submissions. You cannot simply upload a ZIP file through the website and call it a day.

First, generate a dedicated SSH key:

ssh-keygen -f ~/.ssh/aur
Enter fullscreen mode Exit fullscreen mode

You can set a passphrase if you want an additional layer of security.

Now, open your SSH configuration file:

nano ~/.ssh/config
Enter fullscreen mode Exit fullscreen mode

Add the following:

Host aur.archlinux.org
    IdentityFile ~/.ssh/aur
    User aur
Enter fullscreen mode Exit fullscreen mode

Save the file.

Next, copy your public key:

cat ~/.ssh/aur.pub
Enter fullscreen mode Exit fullscreen mode

Head over to your AUR account settings and add the public key under the SSH public key section.

That's it. Let's test the connection:

ssh aur@aur.archlinux.org
Enter fullscreen mode Exit fullscreen mode

If everything is configured correctly, you should receive a welcome message or information about available AUR commands.

If you get a permission denied error, check whether you've uploaded the correct public key and whether SSH is using the private key we just generated.

4. Creating your first PKGBUILD

Now comes the actual packaging part.

For this guide, let's assume we're packaging a small application called hello-aur, which provides a simple executable named hello-aur.

The application is hosted on GitHub and provides versioned source releases.

Create a working directory:

mkdir hello-aur
cd hello-aur
Enter fullscreen mode Exit fullscreen mode

Create a file named PKGBUILD:

nano PKGBUILD
Enter fullscreen mode Exit fullscreen mode

And put the following inside:

# Maintainer: Your Name <your.email at example dot com>

pkgname=hello-aur
pkgver=1.0.0
pkgrel=1
pkgdesc="A simple example application"
arch=('any')
url="https://github.com/example/hello-aur"
license=('MIT')
depends=('bash')
source=("$pkgname-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz")
sha256sums=('SKIP')

package() {
    install -Dm755 "$srcdir/$pkgname-$pkgver/hello-aur" \
        "$pkgdir/usr/bin/hello-aur"
}
Enter fullscreen mode Exit fullscreen mode

Hold on. What are all these variables?

Let's break them down.

  • pkgname: The name of your package. This is also the name you'll use when installing it.
  • pkgver: The upstream software version.
  • pkgrel: The release number of your PKGBUILD. Start with 1.
  • pkgdesc: A short description of your software.
  • arch: The architectures supported by your package. Use any for architecture-independent software.
  • url: The upstream project's website or source repository.
  • license: The software's license.
  • depends: Runtime dependencies required by your application.
  • source: Where makepkg should download the source files from.
  • sha256sums: Checksums used to verify downloaded source files.

And finally, the package() function.

This is where you tell makepkg which files should be installed and where they should go.

For example:

install -Dm755 hello-aur \
    "$pkgdir/usr/bin/hello-aur"
Enter fullscreen mode Exit fullscreen mode

This installs the executable into /usr/bin, making it accessible system-wide.

One important thing: the example above assumes that the downloaded archive extracts into a directory named hello-aur-1.0.0 and contains an executable called hello-aur. You'll need to adjust this according to the actual project structure.

Also, don't blindly use SKIP for checksums in a real package. Generate and verify the SHA-256 checksum of your source archive:

sha256sum hello-aur-1.0.0.tar.gz
Enter fullscreen mode Exit fullscreen mode

Replace SKIP with the resulting checksum.

For GitHub archives, make sure you're using the same archive URL when calculating the checksum as the one in your PKGBUILD.

5. Testing your package locally

Before uploading anything, we need to make sure the package actually works.

Run:

makepkg -si
Enter fullscreen mode Exit fullscreen mode

Here's what happens:

  • -s automatically installs missing dependencies.
  • -i installs the package after successfully building it.

If everything goes well, your package should be installed.

You can verify it using:

which hello-aur
Enter fullscreen mode Exit fullscreen mode

And check the installed package:

pacman -Qi hello-aur
Enter fullscreen mode Exit fullscreen mode

If the build fails, don't panic. Read the error message and fix your PKGBUILD accordingly.

You can also use namcap to check your package for common packaging mistakes:

sudo pacman -S namcap
namcap PKGBUILD
Enter fullscreen mode Exit fullscreen mode

For more serious validation, Arch also provides pkgctl build, which can build packages in a clean chroot.

Remember, just because a package builds successfully on your machine doesn't mean it'll work on every Arch installation.

6. Generating .SRCINFO

This is probably the step people forget when submitting their first AUR package.

The AUR requires a .SRCINFO file alongside your PKGBUILD.

It contains the package metadata in a format that the AUR website can read without executing your PKGBUILD.

Thankfully, you don't have to write it manually.

Run:

makepkg --printsrcinfo > .SRCINFO
Enter fullscreen mode Exit fullscreen mode

That's it.

Whenever you modify package metadata in your PKGBUILD, regenerate .SRCINFO before pushing your changes.

Your directory should now look something like this:

hello-aur/
├── PKGBUILD
└── .SRCINFO
Enter fullscreen mode Exit fullscreen mode

If you have additional files such as patches or install scripts, include those as well.

7. Finally, submitting your package to the AUR

We've reached the interesting part.

Go back to the AUR website and check whether your package already exists.

Please don't create duplicate packages. If someone has already packaged the same software, check whether it's maintained. If it's orphaned, you can request to adopt it instead.

Also, check whether the software is already available in the official Arch repositories. Packages already available there generally shouldn't be submitted to the AUR.

Assuming everything is clear, let's upload our package.

Clone the AUR repository for your package:

git clone ssh://aur@aur.archlinux.org/hello-aur.git
Enter fullscreen mode Exit fullscreen mode

If this is a completely new package, Git will show a warning that the repository is empty. That's expected.

Now enter the directory:

cd hello-aur
Enter fullscreen mode Exit fullscreen mode

Copy your PKGBUILD and .SRCINFO into this directory.

You can now commit your files:

git add PKGBUILD .SRCINFO
git commit -m "Initial commit"
Enter fullscreen mode Exit fullscreen mode

And finally, push:

git push
Enter fullscreen mode Exit fullscreen mode

That's it!

Your package should now be available on the AUR website.

You can visit:

https://aur.archlinux.org/packages/hello-aur

Obviously, replace hello-aur with your actual package name.

8. Updating your package

Submitting a package isn't the end of the story.

If you're maintaining a package, you'll need to keep it updated whenever the upstream software releases a new version.

Let's say the application releases version 1.1.0.

Update the following variables in your PKGBUILD:

pkgver=1.1.0
pkgrel=1
Enter fullscreen mode Exit fullscreen mode

Update the source checksum as well.

Then regenerate .SRCINFO:

makepkg --printsrcinfo > .SRCINFO
Enter fullscreen mode Exit fullscreen mode

Commit and push your changes:

git add PKGBUILD .SRCINFO
git commit -m "Update to v1.1.0"
git push
Enter fullscreen mode Exit fullscreen mode

One small thing to remember: increment pkgrel when you make packaging changes that require a rebuild without changing the upstream version. When the upstream version changes, reset pkgrel to 1.

And please don't submit a package and forget about it. Maintaining an AUR package means keeping an eye on upstream releases, dependencies, build changes, and user feedback.

That's pretty much it!

Submitting packages to the AUR isn't nearly as complicated as it might look initially.

You write a PKGBUILD, test it, generate .SRCINFO, and push it to the AUR using Git.

Of course, there's a lot more to Arch packaging than what we've covered here. Different applications have different build systems, dependencies, installation requirements, and packaging conventions.

But if you're just getting started, this should be enough to get your first package out there.

And one last thing: please read your PKGBUILD before submitting it. You're asking other people to execute that script on their machines. Make sure you know exactly what it does.

Anyways, here is my package which i created :)

Happy packaging!

Top comments (0)