We will compile and install software packages from source code.
- AUR vs Arch Packages
- Installing packages from source
- Step 1: Cloning the source code
- Step 2: Compiling the package
- Step 3: Installing the package
- Post Installation: Updating & removing external packages
AUR - Arch User Repository
AUR or Arch User Repository is a repo which holds PKGBUILDs or source code of various computer programs.
AUR can be used to find source code ready to be compile and make packages. You will realize while AUR lists these packages, source codes themselves are hosted on Github.
Let’s get to it.
AUR vs Arch Packages
Arch packages can be installed directly using the pacman package manager.
sudo pacman -S <packagename>
Installing packages through AUR requires a couple of extra steps.
In this mini-tutorial we will learn how to install packages directly from source code using 2 methods:
1. Cloning the source code
git clone https://aur.archlinux.org/librewolf.git
Make sure git clone isn’t run as root, a common mistake…
git clonewill create a folder with the necessary program files along with the PCKGBUILD (a script used to build packages). You can then navigate to this folder and continue with the instructions in the following steps from inside this folder.
2. Compiling the package
You can also use the following command to continue with installation of the package built from source code.
If you’ve used
makepkg -si, you don’t need to follow the 3rd step to install the package using pacman.
3. Installing the package
I prefer this method because I am used to using pacman to install packages.
pacman -U <.zst file>
pacman -U <.zst file>
Post Installation (Updating or Removing Packages)
You can still manage packages installed through compiling source code or other external sources to an extent.
You can’t update them automatically since they were compiled and they aren’t included in the pacman’s arch packages repo. But you can use pacman for related operations below:
- remove manually installed packages
pacman -R <packagename>
- get information about manually installed packages
pacman -Qi <packagename>
If you find out your package’s version is becoming outdated. You can update it using the same compiling and installation steps explained above and the package will be updated.
Here are a few of the most common makepkg errors and their solutions. It’s usually a simple fix to solve makepkg errors.
1- Pacman failed to install missing dependencies
makepkg -sis used, dependencies will be installed given they exist in the pacman repository. Sometimes this is not the case and dependencies can’t be satisfied. In which case you’ll get an error similar to below:
==> Missing dependencies: -> ocaml-ocamlsdl -> ocaml-graphics -> lablgtk2
==> ERROR: Could not resolve all dependencies.
makepkg -sto compile the main package you intended to install.
2- You do not have write permission for the directory $BUILDDIR
This is usually caused by wrong directory privileges and particularly package directory being owned by the root.
If you run
sudo git clone you might get write error.
Solution is to just remove the directory and rerun git clone without sudo or change directory ownership to the user. Simple as that.
If you run git clone as root you would be required to run makepkg as root as well. The problem is running makepkg as root is not allowed. You can see the specific explanation for that specific error in the following section.
3- Running makepkg as root is not allowed as it can cause permanent damage
Makepkg should never be run as root and the system won’t allow you to do so. If you attempt running makepkg as root you will get the following error.
The rationale behind this restriction is that if you compile a source code acquired from external resources as root then you would completely open the computer and the linux os to intentional and unintentional risks as these packages are created by users and added to the AUR (or another repo or Github) repo.