Am 16.11.2026 um 07:01 schrieb evily:
> Hello!
> 
> My main goal is to build u-boot for PineTab 2, but I can't handle with
> ports system.
> 
> Is it possible to build port (with all dependencies) as non-root user?
> 
> For example if I do `make fake` in /usr/ports/sysutils/u-boot/rk356x
> it's trying to install binutils:
> 
> ===>  Installing aarch64-none-elf-binutils-2.40p0 from
> /usr/ports/packages/amd64/all/
> pkg_add: pkg_add must be run as root
> 
> 
> ==
> evily

Maybe let's test some modern search engine, no? You need to read that
yourself, of course. I won't.


"**Yes, but only partially.** You can build most of a port (including
compilation) as a normal user, but installing build dependencies and the
final package still requires root (via `doas` or running as root). That
is exactly why you hit:

```
pkg_add: pkg_add must be run as root
```

when running `make fake` / `make package` — the ports system tries to
install the aarch64-none-elf toolchain and other build dependencies.

### Recommended setup: privilege separation (`PORTS_PRIVSEP`)

This is the supported way to do most of the work as a non-root user
(fetching as `_pfetch`, building as `_pbuild`).

1. **Edit `/etc/mk.conf`** (create it if it doesn’t exist):
   ```
   PORTS_PRIVSEP=yes
   SUDO=doas
   # Optional but often useful:
   # WRKOBJDIR=/usr/obj/ports
   # DISTDIR=/usr/distfiles
   # PACKAGE_REPOSITORY=/usr/packages
   ```

2. **Configure `/etc/doas.conf`** (replace `youruser` with your username):
   ```
   permit keepenv nopass youruser as _pbuild
   permit keepenv nopass youruser as _pfetch
   permit keepenv youruser as root
   ```
   (The last line lets you install packages; you can make it more
restrictive if you prefer.)

3. **Set directory ownership** (as root):
   ```
   # install -d -o _pfetch -g _pfetch /usr/ports/distfiles
   # install -d -o _pbuild -g _pbuild /usr/ports/{packages,plist,pobj,bulk}
   ```
   (Or `chown` if the directories already exist.) The ports tree itself
should be readable by everyone.

4. Then as your normal user:
   ```
   cd /usr/ports/sysutils/u-boot/rk356x
   make package
   ```
   It will use `doas` only for the steps that really need it (installing
dependencies and creating the final package). After that you can install
with:
   ```
   doas make install
   ```
   or `doas pkg_add` the package from the packages directory.

See `bsd.port.mk(5)` and the Ports FAQ section on configuration for full
details.

### Simpler alternatives

- **Pre-install the build dependencies as root**, then build as a normal
user:
  ```
  cd /usr/ports/sysutils/u-boot/rk356x
  doas make build-depends
  # then as normal user (with WRKOBJDIR owned by you):
  make package
  ```

- For occasional builds many people just run the whole thing as root
(`doas make package`). It’s less ideal from a security perspective
(you’re compiling untrusted code as root), but it works and is common
for one-off ports work.

- For heavier use, consider **`dpb`** (Distributed Ports Builder). It
handles privilege dropping automatically and can run inside a chroot.

### About the u-boot / PineTab 2 port

The port you are in (`sysutils/u-boot/rk356x`) is the correct one for
Rockchip RK3566/RK3568 boards (PineTab 2 uses RK3566). Check the
`BOARDS` list in the Makefile to see which board targets are currently
packaged. After building/installing, the firmware images end up under
`/usr/local/share/u-boot/`.

Also check whether a binary package is already available for your release:
```
pkg_info -Q u-boot
# or
doas pkg_add u-boot-rk356x
```

That is often much simpler than building it yourself if the package exists."


Reply via email to