WHAT, WHY and HOW π€π¦π.
Hello everyone! ππ,
In this article, we will try to understand what is AUR, what are the benefits of publishing packages on AUR and how you can publish your package on AUR. but before diving deep into AUR let's be familiar with some terms that we will be using frequently. πππ§
Repository ποΈπ:
A repository contains all of your project's files and each file's revision history. You can discuss and manage your project's work within the repository.
Package π¦π§:
In Linux, a package is a group of computer programs, documents, licences, etc which can be downloaded as a bundle related to a product. These packages usually contain source code to be compiled and PKGBUILD file telling how to build the package using makepkg.
Package Manager π¦π§:
A package management system or package manager is a group of software tools. It automates the installation process, upgrading process, configuration process, and removal process of the computer programs for an operating system of the computer in an efficient manner.
One big advantage that it has over other distributions, apart from being able to say "BTW I use Arch." is Arch User Repository commonly known as AUR. It has over 80,000 packages ready to be installed and maintained by various volunteer developers. AUR contains a Package description name PKGBUILD which is a script that helps to compile a package, download source code and build with the help of makepkg, then it can be installed via pacman.
Packages available on the official repository can be installed direct be installed using Pacman which is a package for Arch Linux. Command : sudo pacman -S <package_name>
The packages that are published on AUR cannot be installed using the same package manager so we have various AUR helpers like yay
. yay is one of the most popular AUR helpers which can install packages from official as well as AUR. Command : yay -S <package_name>
Why to publish on AUR βπ€:
Publishing packages is an important aspect of being a good developer for several reasons:
Contributing to the Community π: Community-driven projects as AUR with more than 80,000 packages and Contributing to such open-source projects as a developer fosters collaboration, skill enhancement, community engagement, and knowledge sharing, and empowers the growth of innovative, accessible, and reliable software solutions.
Review and Feedback π: For a developer feedback and reviews are very valuable resources for learning and improving knowledge and techniques.
Establishing Expertise π: Publishing packages showcase your skills and expertise in a particular domain or programming language. It serves as evidence of your capabilities, demonstrating your ability to create robust and reliable solutions.
Personal Growth and Learning π : Publishing packages encourages continuous learning and improvement. It pushes you to write cleaner, more modular, and more reusable code.
Now let's Publish our package π.
Overview:
The Arch User Repository (AUR) is a community-driven repository for Arch users. It contains package descriptions (PKGBUILDs) that allow you to compile a package from source with makepkg and then install it via pacman. The AUR was created to organize and share new packages from the community and to help expedite popular packages' inclusion into the extra repository. This document explains how users can access and utilize the AUR. π»π
A PKGBUILD is a shell script containing the build information required by Arch Linux packages. PKGBUILD does not contain any binary packages but allows users to upload PKGBUILDs that can be downloaded by others. β οΈ These PKGBUILDs are completely unofficial and have not been thoroughly vetted, so they should be used at your own risk ππ».
Prerequisites:
You donβt need much for this, you need to have base-devel, make, git
installed and you are good to go.
STEP 1: setting up an account and SSH keys π€ π:
Go through the AUR submission Guideline [here](https://wiki.archlinux.org/title/AUR_submission_guidelines#:~:text=When submitting a package to, do not submit the package.)
Create an account on aur.archlinux.org. Public SSH keys are required if you want to submit packages to the Arch User Repository. If you donβt have a key pair you can generate it using this command ssh-keygen -f ~/.ssh/aur
IF YOU ALREADY HAVE AN KEY PAIR FOR AUR DO NOT RUN THIS COMMAND.
At ~/.ssh/
you can see two files aur containing your private key which is as name suggests should not be shared with anyone and aur.pub containing your public key to be copied to your AUR account for authentication.
STEP 2: Creating an AUR repository ποΈ π:
Now after setting up your account, create a repository on aur and clone it to the local system using the command:
git clone ssh://
aur@aur.archlinux.org
/< package name >
If a repository exists it will clone the repository else create a repository with packagename and clone and empty the repository. You may see an error telling you that you have cloned an empty repository if you create a new package repository but it's A good sign that you are doing it correctly. One thing that should be kept in mind is that "< package-name >" cannot contain capital letters.
STEP 3: Creating PKGBUILD file π:
You are all set with the repository, now it's time to push your PKGBUILD into the AUR but before that let's create our PKGBUILD. Now cd to your repository you just cloned and copy the example PKGBUILD you already have as the best starting point.
cd < packagename >
cp /usr/share/pacman/PKGBUILD.proto ./PKGBUILD
No need to worry if you are seeing these variables for the first time, below table will give you a brief introduction to these variables. You don't need all these but it's good to know them as they are not that complicated.
Field | Description |
pkgname | name of the package |
pkgver | A version of the package to keep track of updates. whenever it changes you get an update. |
pkgrel | The release number. This is usually a positive integer number. |
epoch | Used to force the package to be seen as newer than any previous version with a lower epoch. |
pkgdesc | Small description of the package. Stander = 80 character max. |
arch | the architecture of the system package is designed for. The default is 'any'. |
url | url of the source code or official site. |
licence | the licence under which software is distributed. |
groups | Group the package belongs to, For instance, when installing plasma, it installs all packages belonging to that group. |
depends | An array of packages must be installed for the software to build and run. |
makedepends | An array of packages that are only required to build the package |
checkdepends | An array of packages that the software depends on to run its test suite, but are not needed at runtime. |
optdepends | An array of packages that are not needed for the software to function, but provide additional features. |
provides | what tools your package provides. |
conflicts | An array of packages that conflict with, or cause problems with the package, if installed. we will write whatever you are providing i.e, if you already have something with that name both cant be installed. |
replaces | Packages that are replaced by the package. |
backup | An array of files that can contain user-made changes and should be preserved during the upgrade or removal of a package, primarily intended for configuration files in /etc. |
options | Overriding some of the default behaviour of makepkg. |
install | The name of the .install script to be included in the package. |
changelog | The name of the package changelog. To view changelogs for installed packages. |
source | It must contain the location of the software source, which in most cases is a full HTTP or FTP URL. |
noestract | An array of files that should not be extracted from their archive format by makepkg. |
md5sum | 128-bit MD5 checksums of the files listed in the source array. |
validpgpkeys | An array of PGP fingerprints. If used, makepkg will only accept signatures from the keys listed here and will ignore the trust values from the keyring. |
This is all you need, but if you feel to know more about these feel free to check the arch wiki at PKGBUILD. there are a few functions that you should know. Edit these example functions in needed π.
prepare() {
action that should be taken before the instalation processes.
like patch files, unarchive files etc.
}
build() {
command to compile build the tool example:
cd <pkgname>
./configure
make
}
pkgver(){
The pkgver autobump is now achieved via a dedicated pkgver() function.
This allows for better control over the pkgver, and maintainers should favor
a pkgver that makes sense.
This id useful when source is at git and every push will be considered as update.
}
check() {
used to run the test suite for dependencies.
cd <pkgname>
make -k check
}
package() {
This function is actually thich install the package into the system.
If you have a MAKE file in your source code following command will be enough.
cd "$pkgname-$pkgver"
make DESTDIR="$pkgdir/" install
Incase you dont have a make file then we use "install" command,
this command will simpally copy and change the permission.
cd <packagename>
install -Dm755 ./$pkgname "$pkgdir/usr/bin/$pkgname"
install -Dm644 ./README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
install -Dm644 ./LICENSE $pkgdir/usr/share/licenses/$pkgname/LICENSE
}
Edit this file according to your need and your PKGBUILD is ready.
STEP 4: Validating PKGBUILD β :
To check we have edited the PKGBUILD properly. install namecap
.
Now pass the PKGBUILD to namecap to check it.
namecap ./PKGBUILD
If no result it's a good sign.
Another thing that should be checked before pushing it to the AUR is that, weather PKGBUILD is building correctly. Now we will run the following command in the repository containing PKGBUILD.
makepkg
This will clone the repository source code and all and build a package, this package is a tarball.
You can check various properties about the tarball via pacman as this is now our package ready to be installed.
Check these commands to know more about your package.
pacman -Qlp <pkg.tar.xz>
pacman -Qip <pkg.tar.xz>
These commands will help you to analyze whether your PKGBUILD is written correctly.
Creating a source-info file .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.
makepkg --printsrcinfo > .SRCINFO
Now install the package locally with makepkg.
makepkg -si
Assuming we have done everything correctly, this should install the package.
STEP 5: Pushing on AUR π.
Now when you are all set, navigate to a suitable directory and clone the repository there.
git clone ssh://aur@aur.archlinux.org/<packagename>
As above if you don't have this repository it will create it and then clone it. You might see an error telling 'You have cloned an empty repository' and it's okay because now we will copy PKGBUILD and . SRCINFO to this repository.
Now the time has come to finally push our PKGBUILD to AUR.
cd <packagename>
git add .
git commit -m "< your commit message >"
git push
Now uninstall the package you installed using local PKGBUILD.
pacman -Rns < your-packagename >
As you have successfully pushed a package on AUR, try installing with the help of some AUR helper such as 'yay'.
yay -S < your-packagename >
πππ Congrats on successfully publishing your package on AUR! πππ By sharing your package with the Arch Linux community through AUR, you've become a valuable contributor to the ever-growing repository of software solutions. πͺπ»π Your efforts will not only benefit fellow users but also inspire and empower others to create and share their own innovative packages. ππ€π‘ Embrace this achievement as a milestone in your development journey, showcasing your expertise and dedication to producing high-quality software.
ππͺπ» Keep exploring, learning, and contributing to the open-source worldβit's a journey filled with endless possibilities. πππ‘