#!/bin/bash
# Exit immediately on error, treat unset variables as errors, propagate pipe failures.
set -euo pipefail
# Load shared log/warn/skip helpers from the installer library.
source "$(dirname "${BASH_SOURCE[0]}")/../../lib/logging.sh"

log "Installing Podman (rootless containers, buildah, skopeo)..."
# podman: daemonless OCI container engine; podman-compose: docker-compose replacement;
# buildah: low-level image builder; skopeo: inspect/copy images between registries.
sudo pacman -S --noconfirm --needed podman podman-compose buildah skopeo

log "Enabling user lingering so rootless containers survive logout..."
# Without lingering, the user's systemd session (and its cgroups) is torn down
# on logout, killing any running rootless containers.  enable-linger keeps the
# session alive so background containers persist across user sessions.
loginctl enable-linger "$USER"
log "Podman installed (rootless, no daemon). User lingering enabled."
