build_library: Add mangle script for incus sysext

This requests the `incus.service` for the multi-user.target

Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
This commit is contained in:
Mathieu Tortuyaux 2024-03-27 17:54:08 +01:00
parent 0355630109
commit 47f47b4393
No known key found for this signature in database
GPG Key ID: AC5CCFB52545D9B8

View File

@ -0,0 +1,28 @@
#!/bin/bash
set -euo pipefail
rootfs="${1}"
pushd "${rootfs}"
pushd ./usr/lib/systemd/system
mkdir -p "multi-user.target.d"
{ echo "[Unit]"; echo "Upholds=incus.service"; } > "multi-user.target.d/10-incus.conf"
popd
mkdir -p ./usr/lib/tmpfiles.d
pushd ./usr/lib/tmpfiles.d
cat <<EOF >./10-incus.conf
d /var/lib/lxc/rootfs 0755 root root - -
w+ /etc/subuid - - - - root:1065536:65536
w+ /etc/subgid - - - - root:1065536:65536
EOF
popd
# Add 'core' user to 'incus-admin' group to avoid prefixing
# all commands with sudo.
mkdir -p ./usr/lib/userdb/
echo " " > ./usr/lib/userdb/core:incus-admin.membership
popd