Publish and install a package#
In this tutorial you put a upatch into a package, publish the package to an OCI registry on your host and install it on the test target from there. Targets always pull: the operator publishes to a registry, and the target fetches, checks and loads.
A package is a .bee archive built from a Beefile. It holds the
Beefile, the signed upatches, the signed unload directive of each,
the certificate of the key that signed them, the README when the package
directory has one, and build-environment.json, a record of the build.
Before you begin#
The test VM from the Quickstart, running as
quickstartThe operator shell from the quickstart: in the root of your checkout, with
shirudoandshirudo-buildonPATHandKEYSnaming the test VM’s key directoryDocker on the operator host, for a local registry
A root shell on the target (
make -C testing vm-ssh VM_NAME=quickstart) in whichshirudoruns the runtime binary:target# alias shirudo=shirudo-runtime
Start a registry#
Run a registry on the host’s loopback interface:
operator$ docker run -d --name shirudo-registry -p 127.0.0.1:5000:5000 docker.io/library/registry:3
The registry speaks plain HTTP on port 5000. The test VM reaches the host’s loopback interface at
10.0.2.2through QEMU’s user network.
Build the package#
Make a package directory with a upatch in it:
operator$ mkdir ~/hello operator$ cp testing/fixtures/basic.bpf.c ~/hello/hello.bpf.c
Link the checkout’s vendored headers into it:
operator$ ln -s "$PWD/vendor" ~/hello/vendor
The helper compiles in the package directory and looks for the libbpf headers and
vmlinux.hundervendor/there. An installed operator package uses its own copies under/usr/share/shirudoand needs no link.Write
~/hello/Beefile:[package] name = "hello" description = "A first shirudo package" license = "GPL-2.0 OR BSD-2-Clause" [[upatches]] source = "hello.bpf.c"
Each
[[upatches]]table names one BPF source. The upatch takes its name,hello, from the file name.Write
~/hello/README.md:# hello The hello package installs the hello upatch, an fentry program on do_nanosleep that does nothing.shirudo bpm infoprints this file from a package archive or anoci://reference, for whoever inspects the package.Build the package from its parent directory:
operator$ cd ~ operator$ shirudo bpm build hello --version 1.0.0 --keys-dir "$KEYS" wrote /tmp/shirudo-bpm-build.<random>/0.upatch (insns=992 sig=4853 data=2376 sections=2 maps=0 progs=1 decoders=0 name=hello) wrote /tmp/shirudo-bpm-build.<random>/0.unload.upatch (insns=1320 sig=4853 data=2808 sections=2 maps=1 progs=1 decoders=0 name=hello UNLOAD) /root/hello-1.0.0.bee
<random>is the suffix of a temporary directory. The builder compiles and signs the upatch, signs an unload directive bound to its payload, and writes<name>-<version>.beeto the current directory. The archive itself is not signed: what protects the target are the signatures on its upatches and directives.
Publish it#
Push the package to the registry:
operator$ BPM_OCI_SCHEME=http shirudo bpm push hello-1.0.0.bee oci://127.0.0.1:5000/example/hello --keys-dir "$KEYS" --new-index oci://127.0.0.1:5000/example/hello:1.0.0
The push tags the package with its version. With
--keys-dir, it also adds the package to the registry’s signed index,<namespace>/bpm-index:stable, which targets read when they install from a registered repository.--new-indexstarts that index, as this is the namespace’s first package; later pushes leave it out.BPM_OCI_SCHEME=httpdrops TLS, which suits only a registry on your own host. Without it, shirudo speaks HTTPS with TLS 1.3 and a hybrid ML-KEM key exchange.
Install it on the target#
On a production target, the signed config image registers the repositories the target may install from. The test VM’s config registers none, so here the target installs by direct reference.
Install the package:
target# BPM_OCI_SCHEME=http shirudo bpm install oci://10.0.2.2:5000/example/hello:1.0.0 upatch load: --no-precheck, pre-flight state check skipped upatch load: signed loader accepted, keyring 272801410, 124 instructions upatch load: loader ran, 0 maps and 1 programs upatch load: program 0 (raw_tracepoint) pinned at /run/shirudo/bpffs/upatches/hello/link upatch load: hello loaded, 1 programs, keyring 272801410 upatch load: hello measured, register 55a8c670eb10d9bc6a9dc7475e3fc94407066016798dddbc59870138525f61b6
The target honors
BPM_OCI_SCHEMEas the operator does. It downloads the package and checks its digest against the registry’s manifest. It refuses the package unless the package’s certificate holds the same public key as the target’s/var/lib/shirudo/keys/cert.der. Then it loads every upatch in the package asshirudo upatch load --no-precheckdoes: the kernel checks each signature and the target measures each load.List the installed packages:
target# shirudo bpm list Installed packages: NAME VERSION SOURCE hello 1.0.0 direct
directmarks a package installed by reference rather than from a registered repository.Check that its upatch is loaded:
target# shirudo upatch list Archived upatches (/var/lib/shirudo/upatches): NAME LOADED TYPE KIND PAYLOAD hello yes load bpf 109848737a32f431..
Remove it#
Uninstall the package on the target:
target# shirudo bpm uninstall hello upatch unload: --no-precheck, pre-flight state check skipped upatch unload: signed loader accepted, keyring 272801410, 165 instructions upatch unload: hello carries the directive's payload upatch unload: hello measured, register f4f9b2f7cb9b442d78acc3b0527ad79a4cf9dd1eae1eaedffce9263c53571c05 upatch unload: hello detached and unpinned
The target runs the unload directives that shipped in the package and removes the package.
shirudo bpm listno longer lists it.target# shirudo bpm list Installed packages: none
Stop the registry on the host:
operator$ docker rm -f shirudo-registry
Next steps#
Beefile describes every key of a
Beefile.Publish a package publishes to a registry and to the signed upatch tree.
Deliver packages registers repositories in the signed config and lets the timers keep targets up to date.
shirudo bpm describes every
shirudo bpmcommand.