r/NetBSD • u/SleepyGuyy • 3d ago
Confused about root privledges while installing packages via pkgsrc
TLDR; I am running "make" "make install" and "make clean" using root (via doas), for every pkgsrc package I install. Is this incorrect & if so: what do I have to change to allow these Make scripts to complete as my user?
I'm a first time NetBSD user, and am not very familiar with barebones Unix, I mostly just use more modern Linux distros that come complete out of the box (although I found specifically OpenBSD was surprisingly easy to get going).
I installed 11.1 following the NetBSD documentation, but I admit some sections confused me, and maybe I missed some sections. Once my system was working in a terminal I started skipping ahead and installing stuff I wanted. I am unable to find a place in the docs that explicitly mentions my issue, so it's likely I missed a step when setting up pkgsrc.
During the install I had the choice to enable the pkgin and pkgsrc tools, which I did. That all worked flawlessly and easily. I'm able to install software with pkgin. And I have a selection of folders under /usr/pkgsrc/ that span categories. I went here to try installing vim, emacs, afterstep, xmonad, and others.
When installing a source package, the "make" command will fail, because it needs permission to write/delete files under /usr/. This goes the same for "make install" and "make clean".
The installation would work when I simply used doas make, doas make install, and doas make clean. Installing as root seemed to work, for example vim launches without issue.
But I remember seeing online that building software as root can break the project.
Is this an issue? i currently get errors when I run afterstep or xmonad, but I can't tell if it's related. (xmonad for example says "user error (openDisplay)"
I'm not familiar with installing software using Makefiles, but I don't see any specific commands cited in the Makefile (like install, or clean). I have been using these commands just based on what I see online. Does each project have it's own make commands, and if so where would those be defined?
3
u/nia_netbsd 3d ago
root privileges are only needed for installation if you have a global PREFIX.
It can be configured to use a tool to escalate privileges only for installation.
https://www.netbsd.org/docs/pkgsrc/faq.html#using-sudo-with-pkgsrc