Skip to content

Instantly share code, notes, and snippets.

@ss-o
Forked from keilmillerjr/Creating an AUR Package.md
Created December 13, 2021 00:07
Show Gist options
  • Save ss-o/91717bed12371fa7e9ff12921733f4e2 to your computer and use it in GitHub Desktop.
Save ss-o/91717bed12371fa7e9ff12921733f4e2 to your computer and use it in GitHub Desktop.
How to create and manage an AUR package. #AUR #ARCH #makepkg #PKGBUILD

Creating an AUR Package

Maintainer: Keil Miller Jr

How to create and manage an AUR package.

The following link should be read:

Prerequisites

$ pacman -S base-devel
$ nano ~/.ssh/config
--------------------
Host aur.archlinux.org
  IdentityFile ~/.ssh/aur
  User aur
--------------------
$ ssh-keygen -f ~/.ssh/aur

Contents of public key need to be copied to profile in My Account page accessible from aur.archlinux.org.

Clone Repo

If you are creating a new package from scratch, establish a local Git repository and an AUR remote by cloning the intended pkgbase. If the package does not yet exist, the following warning is expected:

$ mkdir ~/abs
$ cd ~/abs
$ git clone ssh://[email protected]/pkgbase.git

Cloning into 'pkgbase'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.

Add remote to existing package

$ cd ~/abs/[package]
$ git remote add label ssh://[email protected]/pkgbase.git

.gitignore

There are only 2 files required for an AUR package, unless you wish to add patches. This .gitignore file might help. Ignore everything, and call required files directly.

$ cd ~/abs/[package]
$ touch .gitignore
$ nano .gitignore
*
!.SRCINFO
!PKGBUILD

Create PKGBUILD

PKGBUILD is an "Arch Linux package build description file." It will include package related variables, most oif which are self explanitory.

$ cd ~/abs/[package]
$ cp /usr/share/pacman/PKGBUILD.proto PKGBUILD

Make appropriate changes to PKGBUILD.

Adding md5sums to PKGBUILD

updpkgsums will perform an in place update of the checksums in the path specified by [build file], defaulting to PKGBUILD in the current working directory.

This should be done every time the source changes. Your source should change with pkgver.

$ updpkgsums

Patching

$ cd ~/abs/[package]
$ rm -r src`
$ makepkg --nobuild` # Make package, but do not build source. Will run `prepare()` function, so do not include an unwanted patch.
$ cp -r src src.new`
$ code src.new # Make changes to new source directory
$ diff -Naur src src.new > package.diff

Testing

Terminal

$ cd ~/abs/[package]
$ makepkg
$ sudo pacman -U [package].pkg.tar.xz # Install
$ pacman -R [pkgname] # Uninstall

Pamac

  • Install: Three Vertical Dot Icon > Install Local Packages > [package] > Open
  • Uninstall: Search Icon > [package] > select package > remove

Generate .SRCINFO

.SRCINFO files contain package metadata in a simple, unambiguous format, so that tools such as the AUR's Web back-end or AUR helpers may retrieve a package's metadata without parsing the PKGBUILD directly.

$ cd ~/abs/[package]
$ makepkg --printsrcinfo > .SRCINFO

Pushing to AUR repository

Before pushing to AUR repository, make sure the following are updated:

  • PKGBUILD > pkgver
  • PKGBUILD > pkgrel
  • PKGBUILD > source
  • PKGBUILD > md5sums
  • Regenerate .SRCINFO
$ makepkg --printsrcinfo > .SRCINFO
$ git add PKGBUILD .SRCINFO
$ git commit -m "useful commit message"
$ git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment