Skip to content

Commit

Permalink
Support ostree bootc containers
Browse files Browse the repository at this point in the history
Red Hat's Atomic OS is a read-only filesystem that uses ostree
underneath.  Installing packages using dnf does not work.  Instead use
the native package installer 'rpm-ostree install' if an ostree booted
filesystem is detected.

Utilize various options
-y: always install
--apply-live: apply changes now instead of waiting for a reboot
--idempotent: do not error if package is already installed
--allow-inactive: do not error if package is already committed

Split out the '--apply-live' option as that is an install only option
and will not work with remove.

Also include detection of CentOS Stream and leverage the same plugins.

Signed-off-by: Don Zickus <[email protected]>
  • Loading branch information
dzickusrh committed Jan 13, 2025
1 parent e97e7c5 commit 01aca99
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
13 changes: 13 additions & 0 deletions plugins/pkg_commands.d/centos
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

. /etc/os-release

if [ -f "/run/ostree-booted" ];then
# OSTree based filesystems are read-only and install with rpm-ostree
RSTRNT_PKG_CMD=${RSTRNT_PKG_CMD:-rpm-ostree}
RSTRNT_PKG_ARGS=${RSTRNT_PKG_ARGS:--y --idempotent --allow-inactive}
RSTRNT_PKG_INSTALL=${RSTRNT_PKG_INSTALL:-install --apply-live}
elif [ 0"$(echo $VERSION_ID | cut -d'.' -f1)" -ge 8 ]; then
# CentOS 8 and newer use dnf as default
RSTRNT_PKG_CMD=${RSTRNT_PKG_CMD:-dnf}
fi
9 changes: 7 additions & 2 deletions plugins/pkg_commands.d/fedora
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

. /etc/os-release

# Fedora 22 and newer use dnf as default
if [ 0"$VERSION_ID" -gt 21 ]; then
if [ -f "/run/ostree-booted" ]; then
# OSTree based filesystems are read-only and install with rpm-ostree
RSTRNT_PKG_CMD=${RSTRNT_PKG_CMD:-rpm-ostree}
RSTRNT_PKG_ARGS=${RSTRNT_PKG_ARGS:--y --idempotent --allow-inactive}
RSTRNT_PKG_INSTALL=${RSTRNT_PKG_INSTALL:-install --apply-live}
elif [ 0"$VERSION_ID" -gt 21 ]; then
# Fedora 22 and newer use dnf as default
RSTRNT_PKG_CMD=${RSTRNT_PKG_CMD:-dnf}
fi
9 changes: 7 additions & 2 deletions plugins/pkg_commands.d/rhel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

. /etc/os-release

# RHEL 8 and newer use dnf as default
if [ 0"$(echo $VERSION_ID | cut -d'.' -f1)" -ge 8 ]; then
if [ -f "/run/ostree-booted" ];then
# OSTree based filesystems are read-only and install with rpm-ostree
RSTRNT_PKG_CMD=${RSTRNT_PKG_CMD:-rpm-ostree}
RSTRNT_PKG_ARGS=${RSTRNT_PKG_ARGS:--y --idempotent --allow-inactive}
RSTRNT_PKG_INSTALL=${RSTRNT_PKG_INSTALL:-install --apply-live}
elif [ 0"$(echo $VERSION_ID | cut -d'.' -f1)" -ge 8 ]; then
# RHEL 8 and newer use dnf as default
RSTRNT_PKG_CMD=${RSTRNT_PKG_CMD:-dnf}
fi

0 comments on commit 01aca99

Please sign in to comment.