makepkg
is a script that creates a foreign (i.e. non-repo) package, which can be installed using pacman -U
.
Before we can make a package, we need to have both base-devel
and git
packages installed:
sudo pacman -S base-devel git --needed
On EndeavourOS, these should already be preinstalled.
Depending on the specific package, we may also need other programs, like compilers and build systems. These are called “make dependencies”.
Typically, making a package from the AUR involves the following steps:
- Find the package on aur.archlinux.org/packages
- Find the “Git Clone URL” for the package.
- Download everything needed to build the package (“clone”) using the
git clone
command. -
cd
into the directory where everything downloaded, including the PKGBUILD file. - Open the PKGBUILD file in a text editor and inspect it for anything suspicious (see my tips on what to look out for)
- Run
makepkg -si
inside the directory where the PKGBUILD file is.
In the makepkg
command, the option -s
means “automatically install dependencies (including installing make dependencies – programs needed to build the program you’re packaging)”, and -i
means “if package is built successfully, install it”. If you don’t provide the -i
option, makepkg
will only create the package, which you can install later manually using pacman -U
command.
Here is a concrete example:
On vanilla Arch, you don’t get the program yay
preinstalled, and it is not available in the official repos (so sudo pacman -S yay
will not work). This is probably intentional to force you to go through the above process at least once in your life. So you would do the following:
- Find the AUR page for
yay
, this is it: https://aur.archlinux.org/packages/yay/ - Look under “Git Clone URL” and you’ll see it says this:
https://aur.archlinux.org/yay.git
Take this opportunity to look at the package popularity, the names of the maintainer and the last packager, date when it was last updated, etc… and also to read the comments if there is anything unusual you should pay attention to. Clearly,yay
is a very popular AUR package! - Run the following command:
git clone https://aur.archlinux.org/yay.git
- Notice that a directory named
yay
has been created.cd
into it:cd yay
- Notice that there is a PKGBUILD file inside. We can quickly glance through it using the
less
command:
Looks like a normal PKGBUILD to me1 , nothing malicious in there, so we’re good to go (hit Q to exitless PKGBUILD
less
). - Run:
A make dependency formakepkg -si
yay
isgo
(the compiler for the Go language). Unless you already have it installed,pacman
will be launched and prompt you to install it from the repos (asking you for yoursudo
password). After you do so, the building of the packageyay
will commence. Give it some time… When the package is built,pacman
will be launched again to install it. And there you go, now you haveyay
installed (assuming there were no errors).
Of course, when it comes to yay
on EndeavourOS specifically, you don’t have to do this, because the yay
package happens to be in the endeavouros
repo, for our convenience. So we can just sudo pacman -S yay
(we don’t even need to do this, because EndeavourOS comes with yay
preinstalled).
This whole process of building and installing a package from the AUR is what an AUR helper like yay
does automatically for you (except step 5, but yay
gives you a convenient way to look at the PKGBUILD file), and it also keeps track of all installed foreign packages, and allows you to update them when they are updated on the AUR. This is why, normally, you should use an AUR helper, because it makes life so much easier. But in order to understand what’s going on, and avoid potential pitfalls, it’s beneficial to know how to do this manually.
With time and experience, you’ll be much more comfortable with all of this.
More reading:
- https://wiki.archlinux.org/title/Arch_User_Repository
- https://wiki.archlinux.org/title/Makepkg
man makepkg
To learn how to use yay
to automate this process:
-
man yay
TL;DR, usually it is sufficient to just run:
yay package_name
Though you should at least look up at the package on aur.archlinux.org, regardless.
Good luck!
1 Famous last words…