commit a2d9fd95213095441bbd766410781edc7621fb88 parent 486d82b399d118358788ada886f6a39dfddfb9d6 Author: Damian Myrda <damian@prime8.dev> Date: Sat, 31 Jan 2026 19:50:44 -0600 use --uninstall flag for single-transaction rpm updates Diffstat:
| M | setup.sh | | | 35 | ++++++++++++++--------------------- |
1 file changed, 14 insertions(+), 21 deletions(-)
diff --git a/setup.sh b/setup.sh @@ -176,33 +176,26 @@ if [ -d "$RPMS_DIR" ]; then fi done - # Separate new installs from updates - new_rpms=() - update_pkgs=() - update_rpms=() + # Build uninstall flags for updates and collect all rpms to install + uninstall_flags=() + all_rpms=() for rpm in "${rpms_to_install[@]}"; do pkg_name=$(rpm -qp --queryformat '%{NAME}' "$rpm" 2>/dev/null) if rpm -q "$pkg_name" &>/dev/null; then - update_pkgs+=("$pkg_name") - update_rpms+=("$rpm") - else - new_rpms+=("$rpm") + uninstall_flags+=("--uninstall=$pkg_name") fi + all_rpms+=("$rpm") done - # Handle updates first (uninstall old + install new in one transaction) - if [ ${#update_pkgs[@]} -gt 0 ]; then - echo "Updating ${#update_pkgs[@]} package(s)..." - sudo rpm-ostree uninstall "${update_pkgs[@]}" && sudo rpm-ostree install --idempotent "${update_rpms[@]}" - fi - - # Handle new installs - if [ ${#new_rpms[@]} -gt 0 ]; then - echo "Installing ${#new_rpms[@]} new package(s)..." - sudo rpm-ostree install --idempotent "${new_rpms[@]}" - fi - - if [ ${#rpms_to_install[@]} -eq 0 ]; then + # Single transaction for all operations + if [ ${#rpms_to_install[@]} -gt 0 ]; then + if [ ${#uninstall_flags[@]} -gt 0 ]; then + echo "Updating ${#uninstall_flags[@]} and installing ${#all_rpms[@]} package(s)..." + else + echo "Installing ${#all_rpms[@]} package(s)..." + fi + sudo rpm-ostree install --idempotent "${uninstall_flags[@]}" "${all_rpms[@]}" + else echo "All local RPMs already installed" fi fi