-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add doc about build rpm-ostree+autosd
Myself and Eric we spend a bunch of time to create rpm-ostree RPM for later inject it into autosd image. To avoid others to spend time in such effort, here a documentation. Signed-off-by: Douglas Schilling Landgraf <[email protected]> Signed-off-by: Eric Curtin <[email protected]>
- Loading branch information
Showing
1 changed file
with
171 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
<!-- markdownlint-disable-file MD013 MD033 --> | ||
# Building rpm-ostree in autosd image from scratch | ||
|
||
The AutoSD is an upstream repository for Red Hat In-Vehicle OS, much like CentOS Stream is to RHEL. AutoSD is based on CentOS Stream with a few divergences. If your base system is not a CentOS, you can use a container to generate a compatible CentOS Stream 9 RPM as showed below, otherwise just skip the step and use your raw system. | ||
|
||
## Building rpm-ostree rpm on CentOS Stream9 | ||
|
||
Create a **ContainerFile** with the content below. | ||
|
||
```bash | ||
FROM centos:stream9 | ||
|
||
RUN dnf update -y | ||
RUN dnf install -y 'dnf-command(config-manager)' epel-release | ||
RUN dnf config-manager --set-enabled crb | ||
RUN dnf config-manager --add-repo https://buildlogs.centos.org/9-stream/automotive/aarch64/packages-main/ | ||
RUN dnf config-manager --add-repo https://buildlogs.centos.org/9-stream/autosd/aarch64/packages-main/ | ||
RUN if [ $(uname -m) == "aarch64" ]; then dnf install -y --nogpgcheck autosig-u-boot; fi | ||
RUN dnf install -y --allowerasing --nogpgcheck mock cpio qemu-kvm rpm-build autoconf \ | ||
automake bison dracut git gpgme-devel gtk-doc libattr-devel libcap-devel libtool \ | ||
make openssl-devel fuse libarchive libselinux libsoup zlib \ | ||
gobject-introspection-devel e2fsprogs-devel fuse-devel libarchive-devel \ | ||
libcurl-devel libsoup-devel systemd-devel xz-devel flex python3-devel swig bc \ | ||
centos-release-automotive audit-libs-devel bzip2-devel cryptsetup-devel dbus-devel \ | ||
elfutils-devel firewalld-filesystem gcc-c++ gettext gnu-efi gnu-efi-devel \ | ||
gnutls-devel gperf hostname kmod-devel libacl-devel libfdisk-devel libgcrypt-devel \ | ||
libidn2-devel libmicrohttpd-devel libseccomp-devel libxkbcommon-devel \ | ||
libzstd-devel lz4 lz4-devel pam-devel perl tree valgrind-devel meson \ | ||
bash-completion tpm2-tss-devel attr dtc | ||
|
||
# Install deps required for recent rpm-ostree | ||
RUN cd rpmbuild/SPECS/ && curl -OL https://gitlab.com/redhat/centos-stream/rpms/rpm-ostree/-/raw/c9s/rpm-ostree.spec | ||
RUN cd /tmp && dnf builddep -y rpm-ostree.spec | ||
|
||
# Lets use the latest from community (see next curl rustup step). | ||
# Also avoids "cargo metadata: error: failed to run rustc to learn about target-specific information" | ||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
``` | ||
|
||
## Building the image | ||
|
||
```bash | ||
podman build -t rpmostreedevel -f ContainerFile | ||
``` | ||
|
||
## Running the image | ||
|
||
The strategy now is run the container sharing the current **HOME/rpmbuild** dir, so as soon the rpm is created in the container it will be located in the host machine in the running user dir. | ||
|
||
```bash | ||
sudo podman run --rm --privileged -v /home/$USER/rpmbuild/:/home/$USER/rpmbuild/ -ti rpmostreedevel /bin/bash | ||
|
||
[root@d1ec4ed543ec /]# | ||
``` | ||
|
||
## Building a forked rpm-ostree | ||
|
||
Now time to clone your [rpm-ostree](https://github.com/coreos/rpm-ostree) fork and build it. | ||
|
||
Cloning the repo and switch to your work branch | ||
|
||
```bash | ||
cd /tmp | ||
git clone https://github.com/dougsland/rpm-ostree.git && cd rpm-ostree | ||
git checkout remotes/origin/initoverlayfs -b initoverlayfs | ||
``` | ||
|
||
Adding required submodules for the build | ||
|
||
```bash | ||
git submodule update --init | ||
``` | ||
|
||
Generating source code | ||
|
||
```bash | ||
cd packaging | ||
cargo install cargo-vendor-filterer --version ^0.5 | ||
make -f Makefile.dist-packaging | ||
cp rpm-ostree-e2dbedd3.tar.xz $HOME/rpmbuild/SOURCES/ | ||
|
||
# Getting version and updating the spec file | ||
rpmostree_tarxz=$(ls rpm-ostree-*.tar.xz| sed 's/rpm-ostree-\(.*\)\.tar\.xz/\1/') | ||
sed -i "/^Version:/s/:.*/: $rpmostree_tarxz/" $HOME/rpmbuild/SPECS/rpm-ostree.spec | ||
|
||
# Remove any specific Patch for Fedora koji build | ||
# See: | ||
# https://gitlab.com/redhat/centos-stream/rpms/rpm-ostree/-/blob/8e861dccda62f170461da2b90cc2f549886094aa/0001-cliwrap-rpm-mark-eval-E-as-safe.patch#L14 | ||
# https://gitlab.com/redhat/centos-stream/rpms/rpm-ostree/-/blob/8e861dccda62f170461da2b90cc2f549886094aa/0001-cliwrap-rpm-mark-eval-E-as-safe.patch | ||
sed -i '/Patch[0-9]*:/d' $HOME/rpmbuild/SPECS/rpm-ostree.spec | ||
``` | ||
|
||
Keep in mind, the version of rpm-ostree must be higher than | ||
the current version shipped in the autosd image. In the time this document was created the source file generated in the rpm-ostree is based on hash commit which is not enough most of the times. Below a quick hack. | ||
|
||
```bash | ||
# untar the source file: | ||
tar xvf rpm-ostree-e2dbedd3.tar.xz | ||
|
||
# rename the dir | ||
mv rpm-ostree-e2dbedd3 rpm-ostree-2025.11 | ||
|
||
# tar again | ||
tar -cJf rpm-ostree-2025.11.tar.xz rpm-ostree-2025.11 | ||
|
||
# change the spec file to use this new version, replace in the | ||
# spec file the Version field to Version: 2025.11 | ||
vi /root/rpmbuild/SPECS/rpm-ostree.spec | ||
``` | ||
|
||
Finally generate the RPM | ||
|
||
```bash | ||
rpmbuild -ba ~/rpmbuild/SPECS/rpm-ostree.spec | ||
``` | ||
|
||
You are done, exit from the container | ||
|
||
```bash | ||
exit | ||
``` | ||
|
||
## Building autosd with the generated file | ||
|
||
Clone the autosd repo | ||
|
||
```bash | ||
git clone https://gitlab.com/CentOS/automotive/sample-images && cd sample-images | ||
``` | ||
|
||
Create a RPM repo in rpmbuild/RPMS, now it includes the fresh rpm-ostree | ||
|
||
```bash | ||
pushd ~/rpmbuild/RPMS | ||
createrepo . | ||
popd | ||
``` | ||
|
||
Add the new RPM repo just created into the sample-images project | ||
|
||
```bash | ||
vi osbuild-manifests/distro/cs9.ipp.yml | ||
- id: extra | ||
baseurl: file:///home/curtine/rpmbuild/RPMS/ | ||
``` | ||
|
||
Full diff Example: | ||
|
||
```bash | ||
diff --git a/osbuild-manifests/distro/cs9.ipp.yml b/osbuild-manifests/distro/cs9.ipp.yml | ||
index c2e3abc..1564c9d 100644 | ||
--- a/osbuild-manifests/distro/cs9.ipp.yml | ||
+++ b/osbuild-manifests/distro/cs9.ipp.yml | ||
@@ -15,6 +15,8 @@ mpp-vars: | ||
baseurl: https://mirror.stream.centos.org/SIGs/9-stream/autosd/$arch/packages-main/ | ||
- id: next | ||
baseurl: https://download.copr.fedorainfracloud.org/results/@centos-automotive-sig/next/epel-9-$arch/ | ||
+ - id: extra | ||
+ baseurl: file:///root/rpmbuild/RPMS/ | ||
distro_devel_repos: | ||
- id: crb | ||
baseurl: $distro_baseurl/CRB/$arch/os/ | ||
``` | ||
|
||
Generate the autosd image using initoverlayfs + rpm-ostree | ||
|
||
```bash | ||
pushd osbuild-manifests | ||
sudo make cs9-qemu-initoverlayfs-ostree.x86_64.qcow2 | ||
popd | ||
``` |