swick's blog

Fedora Silverblue Development Utils


In the previous post we explored all the different ways to develop software on Fedora Silverblue when Toolbx and Flatpak are not enough. Some of the ideas there are interesting, some are dead-ends and some are extremely useful.

I’ve extracted all the useful parts to a small script I’m calling silverblue-devel-utils.

$ silverblue-devel-utils 
Utils for developing on a Silverblue system

Syntax:
silverblue-devel-utils make_mutable [--temporary]
silverblue-devel-utils unmake_mutable
silverblue-devel-utils cleanup_mutable
silverblue-devel-utils rebase_image <IMAGE>

Let’s go over the functionality: make_mutable makes /usr writable and installs dnf. By default the mutable changes persist until unmake_mutable is called and the machine is rebooted. If you want the changes to automatically revert on the next boot you can use make_mutable --temporary. When you have booted into the previous state, you can call cleanup_mutable do get rid of the deployment containing your changes.

Last but not least, rebase_image can rebase your Silverblue install to any image in your local repository. This can be useful if you plan on keeping your changes for a long time, if creating all changes as rpms is hard or you just want to make very specific changes. Using a Dockerfile with the Silverblue OCI image as a base is the easiest way to create such images.


Let’s see how we can actually use the script! First of all, let’s install it:

curl -o ~/.local/bin/silverblue-devel-utils https://gist.githubusercontent.com/swick/968453815a1e918f0f0f56faff310a80/raw/65cb9b0581c22d9978daace0f850cbc5c5018d4b/silverblue-devel-utils && chmod +x ~/.local/bin/silverblue-devel-utils

Now, let’s try temporarily making our system mutable:

$ silverblue-devel-utils make_mutable --temporary
$ sudo dnf install -y gdb
$ sudo dnf debuginfo-install -y mutter gnome-shell
$ # do some serious debugging
$ dbus-run-session gdb --args gnome-shell --wayland --nested
$ systemctl reboot
...
$ # and we're back on our old system!

Let’s do the same, but this time with the changes persisting across boots:

$ silverblue-devel-utils make_mutable
$ sudo dnf builddep -y mutter
$ sudo dnf install -y libei-devel libeis-devel
$ meson setup mybuild --prefix=/usr
$ ninja -C mybuild/
$ sudo ninja -C mybuild/ install
$ # our new mutter is here!
$ mutter --version
mutter 45.beta.1
$ systemctl reboot
...
$ mutter --version
mutter 45.beta.1
$ # still the version we build!
$ silverblue-devel-utils unmake_mutable
$ systemctl reboot
...
$ silverblue-devel-utils cleanup_mutable
$ # our old version again
$ mutter --version
mutter 44.3

And finally, let’s build our own OS image based on Silverblue and boot into it:

ARG IMAGE_NAME="${IMAGE_NAME:-silverblue}"
ARG SOURCE_IMAGE="${SOURCE_IMAGE:-silverblue}"
ARG BASE_IMAGE="quay.io/fedora-ostree-desktops/${SOURCE_IMAGE}"
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-38}"

FROM ${BASE_IMAGE}:${FEDORA_MAJOR_VERSION} AS base

ARG IMAGE_NAME="${IMAGE_NAME}"
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION}"

# setup dnf
RUN rpm-ostree install -y dnf
RUN dnf install -y 'dnf-command(builddep)'

# install development packages
RUN dnf groupinstall -y 'Development Tools'
RUN ln -s /usr/bin/ld.gold /usr/bin/ld # ???
RUN dnf install -y meson strace gdb valgrind sysprof

# clean and commit
RUN rm -rf /tmp/* /var/*
RUN ostree container commit
RUN mkdir -p /var/tmp && chmod -R 1777 /var/tmp
$ podman build -f Dockerfile -t my-very-own-os-image
$ silverblue-devel-utils rebase_image my-very-own-os-image
$ systemctl reboot
...
$ # our OS has strace installed!
$ strace test

The system will stay on this image until another one is installed with silverblue-devel-utils rebase_image (every now and then, you might want to podman pull the base image and rebuild your own image to receive updates) or you manually rebase to another origin with rpm-ostree rebase.

Thanks to Jordan Petridis for his great blog post on systemd-sysext which made me explore all the available tools! Thanks to Ivan Molodetskikh and Tomáš Popela for the feedback on the previous post!

I hope you find this tool useful!


Do you have a comment?

Toot at me on mastodon or send me a mail!