#!/bin/bash
# Runs in the target root during `rpm-ostree compose image` (edition 2024
# finalize.d hook). Records the installed package list next to the treefile so
# build.sh can hand it to release.sh without having to mount the built image.
set -euo pipefail

if [[ -z "${RPMOSTREE_WORKDIR:-}" ]]; then
  echo "RPMOSTREE_WORKDIR not set, skipping package list" >&2
  exit 0
fi

rpm -qa --root "${PWD}" --qf '%{NAME} %{EVR}\n' | sort > "${RPMOSTREE_WORKDIR}/packages-current.txt"
