Arch uses the pacman package manager and the package format is tar.zst. Arch provides a number of tools for creating tar.zst packages, first you need to install the base-devel package and the devtools package.

1
pacman -S base-devel devtools

Arch’s packaging process works like this, starting with writing a PKGBUILD file that describes all the information needed to build a package, such as where to download the source code from, what the dependencies are, what the build version is, how to build, etc.

PKGBUILD

A basic PKGBUILD format is as follows.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Maintainer: justforlxz <justforlxz@gmail.com>

pkgname=dtkcore-git
pkgver=5.4.0.r1.ge7e7a99
pkgrel=1
pkgdesc='DTK core modules'
arch=('x86_64')
url="https://github.com/linuxdeepin/dtkcore"
license=('LGPL3')
depends=('dconf' 'deepin-desktop-base-git' 'python' 'gsettings-qt' 'lshw')
makedepends=('git' 'qt5-tools' 'gtest')
conflicts=('dtkcore')
provides=('dtkcore')
groups=('deepin-git')
source=("$pkgname::git://github.com/linuxdeepin/dtkcore.git")
sha512sums=('SKIP')

pkgver() {
    cd $pkgname
    git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
  cd $pkgname
  qmake-qt5 PREFIX=/usr DTK_VERSION=$pkgver LIB_INSTALL_DIR=/usr/lib
  make
}

package() {
  cd $pkgname
  make INSTALL_ROOT="$pkgdir" install
}

Take dtkcore as an example, the whole configuration file is very clear and straightforward, at a glance you can see how the build tool makes a package step by step.

Save the configuration file to a directory named after PKGBUILD and then execute makepkg.

makepkg is the tool used to execute the PKGBUILD file and it builds the package according to the description in the file.

How to submit a package to aur

When you want your package to be used by others, you usually request to upload it to the official repository, but the process of entering the official repository is exceptionally tedious and can be demanding for contributors. arch provides a user repository for users to freely share configuration files, and all you need to do is download the configuration file and package it locally.

According to aur’s contribution guidelines, we can easily upload our own configuration files and borrow aur tools like yay to download and build packages automatically.

Users can share PKGBUILD through the Arch User Repository. AUR does not contain any binary packages, only PKGBUILD uploaded by users for other users to download and use. All packages are unofficial and are used at your own risk.

Before submitting aur, it is necessary to understand some requirements of aur. Rules of submission provides some rules to upload and maintain our own packages as long as we follow them.

First you need to go to the aur website and register an account and upload your ssh key We do this by cloning a new repository as a way to upload.

1
git clone ssh://aur@aur.archlinux.org/<pkgname>.git

Take dtkcore for example, change the pkgname to dtkcore when cloning.

1
git clone ssh://aur@aur.archlinux.org/dtkcore.git

If it is the first time you create it, you will be prompted for an empty repository that you cloned.

Copy the PKGBUILD file to the cloned directory, then run makepkg --printsrcinfo > .SRCINFO to create a package message, add both the .SRCINFO and PKGBUILD files to git, then commit the commit message and push it to the server.

Note: If you forget to include .SRCINFO in your initial commit, you can use rebasing with -root or filtering the tree to make the AUR accept your first push

Tip: To keep your working directory and commits as clean as possible, you can create a gitignore file to exclude all files, and then add files as needed.

Reference.

https://wiki.archlinux.org/index.php/PKGBUILD