Skip to content

Commit

Permalink
qm: introduction to qm dropin sub-packages(s)
Browse files Browse the repository at this point in the history
QM developers are always looking for ways to help new users and
engineers onboard more easily. With this in mind, they decided
to break complex configurations into drop-in sub-package(s) when
 possible for adjusting the Podman engine configurations specifically
within the QM environment. Why? This approach provides an easy way to
extend or override settings without modifying the core (original)
configuration files.

Signed-off-by: Douglas Schilling Landgraf <[email protected]>
  • Loading branch information
dougsland committed Oct 2, 2024
1 parent 26ba84b commit 8e2763e
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 3 deletions.
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,22 @@ rpm: clean dist
mkdir -p ${RPM_TOPDIR}/{RPMS,SRPMS,BUILD,SOURCES}
cp ./rpm/v${VERSION}.tar.gz ${RPM_TOPDIR}/SOURCES
rpmbuild -ba \
--define="enable_qm_dropin_img_tempdir 0" \
--define="_topdir ${RPM_TOPDIR}" \
--define="version ${VERSION}" \
${SPECFILE}

# ostree target is a helper for everything required for ostree
.PHONY: ostree
ostree: qm_dropin_img_tempdir

.PHONY: qm_dropin_img_tempdir
qm_dropin_img_tempdir:
sed -i 's/%define enable_qm_dropin_img_tempdir 0/%define enable_qm_dropin_img_tempdir 1/' ${SPECFILE}
sed -i 's/^Version:.*/Version: ${VERSION}/' ${SPECFILE}
make VERSION=${VERSION} rpm


install-policy: all
semodule -i ${TARGETS}.pp.bz2
sepolicy manpage --path . --domain ${TARGETS}_t
Expand Down
26 changes: 25 additions & 1 deletion docs/devel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

- [Building QM rpm manually with changes](#building-qm-rpm-manually-with-changes)
- [Building CentOS AutoSD and QM manually](#building-centos-autosd-and-qm-manually)
- [QM Drop-in sub-packages](#qm-drop-in-sub-packages)
- [Creating your own drop-in QM sub-package](#creating-your-own-drop-in-qm-sub-package)
- [Useful Commands](#useful-commands)
- [Installing software inside QM partition](#installing-software-inside-qm-partition)
- [Removing software inside QM partition](#removing-software-inside-qm-partition)
Expand Down Expand Up @@ -46,7 +48,7 @@ Make necessary changes using your preferred editor (e.g., vi/emacs).
**4.** Build the RPM

```bash
VERSION=1.0 make rpm
make clean && VERSION=1.0 make rpm
```

The rpm is created at the `${RPM_TOPDIR}/RPMS` folder, by default
Expand Down Expand Up @@ -244,3 +246,25 @@ bash-5.1# podman --root /usr/share/containers/storage pull alpine
Error: creating runtime static files directory "/usr/share/containers/storage/libpod":
mkdir /usr/share/containers/storage: read-only file system
```

## QM Drop-in sub-packages

QM developers are always looking for ways to help new users and engineers onboard more easily. With this in mind, they decided to break complex configurations into drop-in sub-package(s) when possible for adjusting the Podman engine configurations specifically within the QM environment. Why? This approach provides an easy way to extend or override settings without modifying the core (original) configuration files.

### Creating your own drop-in QM sub-package

We recommend using the existing drop-in files as a guide and adapting them to your specific needs. However, here are the step-by-step instructions:

1) Create a drop-in file in the directory: `etc/qm/containers/containers.conf.d`
2) Add it as a sub-package to `rpm/qm.spec`
3) Test it by running: `make clean && VERSION=YOURVERSIONHERE make rpm`
4) Additionally, test it with and without enabling the sub-package using (by default it should be disabled but there are cases where it will be enabled by default if QM community decide):

Example changing the spec and triggering the build via make (feel free to automate via sed, awk etc):
```bash
# Define the feature flag: 1 to enable, 0 to disable
# By default it's disabled: 0
%define enable_qm_dropin_img_tempdir 1

$ make clean && VERSION=YOURVERSIONHERE make rpm
```
13 changes: 13 additions & 0 deletions etc/qm/containers/containers.conf.d/qm_dropin_img_tempdir.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This configuration file was generated by qm-dropin sub-package:
# - qm-dropin-img-tempdir
#
# It configures the temporary directory used by the container engine
# for image copy operations. This setting is useful for performance
# optimizations or managing disk space.
#
# How it works?
#=================
# [engine] <- section
# image_copy_tmp_dir <- Specifies the directory for temporary image storage.
[engine]
image_copy_tmp_dir="/var/tmp.dir"
30 changes: 28 additions & 2 deletions rpm/qm.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
%global debug_package %{nil}

# Define the feature flag: 1 to enable, 0 to disable
# By default it's disabled: 0
%define enable_qm_dropin_img_tempdir 0

# Some bits borrowed from the openstack-selinux package
%global selinuxtype targeted
%global moduletype services
Expand All @@ -22,8 +26,6 @@
%bcond_without copr
%endif



%if 0%{?fedora}
%global podman_epoch 5
%else
Expand Down Expand Up @@ -91,6 +93,14 @@ sed -i 's/^install: man all/install:/' Makefile
%{__make} all

%install
# Create the directory for drop-in configurations
install -d %{buildroot}%{_sysconfdir}/qm/containers/containers.conf.d

%if %{enable_qm_dropin_img_tempdir}
install -m 644 %{_builddir}/qm-%{version}/etc/qm/containers/containers.conf.d/qm_dropin_img_tempdir.conf \
%{buildroot}%{_sysconfdir}/qm/containers/containers.conf.d/qm_dropin_img_tempdir.conf
%endif

# install policy modules
%_format MODULES $x.pp.bz2
%{__make} DESTDIR=%{buildroot} DATADIR=%{_datadir} install
Expand Down Expand Up @@ -127,6 +137,7 @@ fi
%license LICENSE
%doc CODE-OF-CONDUCT.md NOTICE README.md SECURITY.md
%dir %{_datadir}/selinux
%dir %{_sysconfdir}/qm/containers/containers.conf.d
%{_datadir}/selinux/*
%dir %{_datadir}/qm
%{_datadir}/qm/containers.conf
Expand All @@ -146,6 +157,21 @@ fi
%ghost %dir %{_installscriptdir}/rootfs
%ghost %{_installscriptdir}/rootfs/*

%if %{enable_qm_dropin_img_tempdir}
%package -n qm-dropin-img-tempdir
Summary: Drop-in configuration for QM containers
Requires: %{name} = %{version}-%{release}
BuildArch: noarch

%description -n qm-dropin-img-tempdir
This sub-package installs a drop-in configurations for the QM.
It creates the `/etc/qm/containers/containers.conf.d/` directory for adding
additional drop-in configurations.

%files -n qm-dropin-img-tempdir
%{_sysconfdir}/qm/containers/containers.conf.d/qm_dropin_img_tempdir.conf
%endif

%changelog
%if %{defined autochangelog}
%autochangelog
Expand Down

0 comments on commit 8e2763e

Please sign in to comment.