Loading...
X

How to install and use pikaur and makepkg on a server

How to run pikaur as root

For more information on pikaur, see the article: Automatic installation and update of AUR packages

The makepkg utility and (sometimes) pikaur do not work when run as root. This is not usually a problem for most users, but I have encountered a situation where on a headless server where there is only one user (root), I cannot use pikaur because it does not run as root, and I cannot switch to another user because there is only one user.

When trying to install pikaur, an error occurs:

==> ERROR: Running makepkg as root is not allowed as it can cause permanent, catastrophic damage to your system.

There are several ways to get around this limitation. The easiest one, in my opinion, is the following:

1) Create a regular user

2) Install and run pikaur as this regular user

How to create a regular user to run pikaur

You can create a user with the following command (in this and the following commands, replace mial with the name you chose for the new user):

useradd -m -g users -G wheel,video -s /bin/bash mial

Set a password for this user (if this is a work environment, then set a strong password):

passwd mial

How to install pikaur as root

Install the following dependencies:

pacman -S --needed base-devel git pyalpm python-markdown-it-py python-installer python-build python-hatchling

If you have already cloned the pikaur repository to your local machine, then delete this folder, since you downloaded and unzipped the files as root and he is the owner of these files – a regular user does not have permissions to modify the files.

Now go to the home directory of the user you created in the previous step (replace mial with your username in this and all subsequent commands):

cd /home/mial/

To clone the pikaur repository, use a command like this:

sudo -u mial git clone https://github.com/actionless/pikaur

Go to the folder with the pikaur files

cd pikaur/

When trying to install, I encountered an error that the CHANGELOG file was not found:

==> ERROR: changelog file (CHANGELOG) does not exist or is not a regular file.

If you have the same problem, then create it with the following command:

sudo -u mial touch CHANGELOG

Now run the package build and install pikaur with the following command:

sudo -u mial makepkg -fsri

How to run pikaur as root

After installation, pikaur in my case works without errors even if run with root privileges:

pikaur -Syu
pikaur -S PACKAGE
pikaur -R PACKAGE

However, if you encounter errors due to problems running with root privileges, you can always use the following constructs to run pikaur as a normal user:

sudo -u mial pikaur -Syu
sudo -u mial pikaur -S PACKAGE
sudo -u mial pikaur -R PACKAGE

Leave Your Observation

Your email address will not be published. Required fields are marked *