You are not logged in.

#1 Yesterday 21:15:27

maesli
Member
Registered: 2024-09-26
Posts: 3

pacstrap inside package()

I have this makefile which installs a new systemd-nspawn container:

MACHINES_DIR=/var/lib/machines
CONT_NAME=generic-arch

all:
        echo "nothing to build, just 'make install'"

install:
        mkdir -p $(DESTDIR)$(MACHINES_DIR)/$(CONT_NAME)
        pacstrap -K -c $(DESTDIR)$(MACHINES_DIR)/$(CONT_NAME) base
        install -D -m644 generic-arch.nspawn $(DESTDIR)/etc/systemd/nspawn/$(CONT_NAME).nspawn
        cat init.sh | systemd-nspawn -P -D $(DESTDIR)$(MACHINES_DIR)/$(CONT_NAME)

init.sh:

#! /bin/bash

LC_ALL=C tr -dc '[:graph:]' </dev/urandom | head -c 16 | passwd -s
systemctl enable systemd-networkd
systemctl enable systemd-resolved

generic-arch.nspawn:

[Exec]
PrivateUsers=managed
ResolvConf=bind-static

[Network]
Bridge=br0

I created a PKGBUILD for that setup:

pkgname="msl-base-arch"
pkgver=r3.a235591
pkgrel=1
pkgdesc="Base arch container"
arch=(any)
url=""
license=('unknown')
groups=()
depends=('systemd' 'bash')
makedepends=('git' 'arch-install-scripts' 'pacman' 'fakeroot' 'systemd')
provides=("${pkgname}")
conflicts=("${pkgname}")
replaces=()
backup=()
options=()
install=
source=("${srcdir}/${pkgname}::git://generic-arch/msl-gen-cont.git")
noextract=()
sha256sums=('SKIP')

pkgver() {
        cd "${srcdir}/${pkgname}"
        printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
        cd "${srcdir}/${pkgname}"
        rename generic-arch base-arch *
        sed -i 's/generic-arch/base-arch/g' *
        sed -i 's/br0/msl-util-br/g' *
}

package() {
        cd "${srcdir}/${pkgname}"
        make DESTDIR="$pkgdir" install
}

When I run makepkg, I get the following:

==> Making package: msl-base-arch r2.0eddcf5-1 (Mon Apr 13 22:25:34 2026)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Updating /msl-base-arch git repo...
==> Validating source files with sha256sums...
    /msl-base-arch ... Skipped
==> Extracting sources...
  -> Creating working copy of /msl-base-arch git repo...
Reset branch 'makepkg'
==> Starting prepare()...
==> Starting pkgver()...
==> Removing existing $pkgdir/ directory...
==> Entering fakeroot environment...
==> Starting package()...
mkdir -p /home/maesli/projects/msl-base-arch/pkg/msl-base-arch/var/lib/machines/base-arch
pacstrap -K -c /home/maesli/projects/msl-base-arch/pkg/msl-base-arch/var/lib/machines/base-arch base
==> Creating install root at /home/maesli/projects/msl-base-arch/pkg/msl-base-arch/var/lib/machines/base-arch
ERROR: ld.so: object 'libfakeroot.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
mount: /home/maesli/projects/msl-base-arch/pkg/msl-base-arch/var/lib/machines/base-arch/proc: must be superuser to use mount.
       dmesg(1) may have more information after failed mount system call.
==> ERROR: failed to setup chroot /home/maesli/projects/msl-base-arch/pkg/msl-base-arch/var/lib/machines/base-arch
make: *** [makefile:9: install] Error 1
==> ERROR: A failure occurred in package().
    Aborting...

I get the same error when running

makechrootpkg -c -x failure -r $CHROOT

When I add sudo before pacstrap, makepkg prompts me my own password and fails at the fourth line of make install, while makechrootpkg prompts for builduser's password.

Why does pacstrap require root privileges in fakeroot? What am I missing here?

Offline

#2 Yesterday 21:41:46

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,420

Re: pacstrap inside package()

Does "pacstrap -N -…" work?

Offline

Board footer

Powered by FluxBB