Skip to content

Fixed an RPM issue that also broke OS-tree installs (#29) - #30

Open
PizzaLovingNerd wants to merge 2 commits into
netbirdio:mainfrom
PizzaLovingNerd:fix/rpm-ostree-installs
Open

Fixed an RPM issue that also broke OS-tree installs (#29)#30
PizzaLovingNerd wants to merge 2 commits into
netbirdio:mainfrom
PizzaLovingNerd:fix/rpm-ostree-installs

Conversation

@PizzaLovingNerd

@PizzaLovingNerd PizzaLovingNerd commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #29

Validation

Tested on Fedora Silverblue

  • task quality:full for risky changes

Summary by CodeRabbit

  • Bug Fixes

    • Improved RPM installation and removal handling for SELinux policies.
    • Added safer migration and cleanup behavior for legacy policy configurations.
    • Improved compatibility with immutable hosts and recovery from command failures.
    • Preserved service and policy reload behavior with fallback handling.
  • Tests

    • Added automated compatibility coverage for RPM and DEB packaging lifecycles.
    • Packaging checks now run as part of standard test workflows.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4eb021f9-833d-4b40-9763-3807c17b5b37

📥 Commits

Reviewing files that changed from the base of the PR and between 49055f7 and 4802f12.

📒 Files selected for processing (5)
  • .goreleaser.yml
  • packaging/rpm/network-manager-netbird.spec.tmpl
  • packaging/scripts/postinstall-rpm.sh
  • packaging/scripts/selinux-install-rpm.sh
  • scripts/test-immutable-packaging.sh
🚧 Files skipped from review as they are similar to previous changes (3)
  • .goreleaser.yml
  • scripts/test-immutable-packaging.sh
  • packaging/rpm/network-manager-netbird.spec.tmpl

📝 Walkthrough

Walkthrough

RPM packaging now uses dedicated lifecycle hooks for SELinux policy management. The hooks support legacy policy migration, final removal, service reloads, and immutable-host compatibility tests. Generic DEB hooks no longer manage SELinux policy.

Changes

RPM packaging lifecycle

Layer / File(s) Summary
Lifecycle hook separation
.goreleaser.yml, packaging/rpm/network-manager-netbird.spec.tmpl, packaging/scripts/postinstall.sh, packaging/scripts/postremove.sh
RPM packages use dedicated lifecycle scripts. Generic DEB scripts no longer install or remove SELinux policy.
RPM installation and migration
packaging/scripts/selinux-install-rpm.sh, packaging/scripts/postinstall-rpm.sh
Installation adds the priority-200 SELinux module, validates legacy priority-400 ownership, removes only matching legacy state, restores contexts, and reloads services.
RPM removal and policy refresh
packaging/scripts/postremove-rpm.sh, packaging/rpm/network-manager-netbird.spec.tmpl
Final removal deletes only the priority-200 module, refreshes SELinux policy, and reloads D-Bus and NetworkManager with fallbacks.
Packaging compatibility validation
scripts/test-immutable-packaging.sh, Taskfile.yml, .github/workflows/release.yml, docs/reference.md
The test harness validates RPM migration and removal behavior, DEB isolation, and immutable-host compatibility. Task, CI, and reference targets run the test.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RPM transaction
  participant postinstall-rpm.sh
  participant selinux-install-rpm.sh
  participant semodule
  participant NetworkManager
  RPM transaction->>postinstall-rpm.sh: Run RPM post-install hook
  postinstall-rpm.sh->>selinux-install-rpm.sh: Install and migrate SELinux policy
  selinux-install-rpm.sh->>semodule: Install nm_netbird at priority 200
  postinstall-rpm.sh->>NetworkManager: Reload D-Bus and NetworkManager
Loading

Possibly related PRs

Poem

A rabbit packs the policy right,
At priority two hundred bright.
Old layers move when checks agree,
DEB stays clean, RPM runs free.
Tests hop through each lifecycle night.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the RPM installation fix and its impact on OSTree-based installs.
Description check ✅ Passed The description includes the required Description and Validation sections and records Fedora Silverblue validation.
Linked Issues check ✅ Passed The changes address [#29] by avoiding immutable-host-incompatible state writes and adding safe RPM SELinux lifecycle handling.
Out of Scope Changes check ✅ Passed The packaging, lifecycle scripts, tests, and documentation changes directly support the immutable RPM installation fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
scripts/test-immutable-packaging.sh (1)

244-253: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider a scenario for a failing semodule -lfull -m.

The scenarios cover a failed priority-200 install, a checksum mismatch, an absent legacy module, and a failed legacy removal. They do not cover the branch at packaging/scripts/postinstall-rpm.sh Lines 82-85, where the checksum inspection itself fails. That branch must preserve both the legacy module and the marker. Older policycoreutils versions without semodule -m reach exactly this path, so it is the most likely real-world branch on old hosts.

Add a FAIL_MODULE_LIST=1 case to the fake semodule and assert that neither -X 400 -r nm_netbird runs nor the marker is removed.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/test-immutable-packaging.sh` around lines 244 - 253, Extend the
immutable packaging test around the fake semodule setup to support
FAIL_MODULE_LIST=1, then add a scenario covering checksum inspection failure
from semodule -lfull -m. Assert that legacy removal with -X 400 -r nm_netbird is
not attempted and the legacy marker remains after the postinstall script exits.
packaging/rpm/network-manager-netbird.spec.tmpl (1)

83-136: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Deduplicate the migration logic shared with postinstall-rpm.sh.

This %post block now reimplements the priority-200 install, marker validation, checksum comparison, and legacy priority-400 cleanup that packaging/scripts/postinstall-rpm.sh already implements. The two copies differ in style: the spec uses || var= plus -z tests, while the script uses || { ...; return 0; } and a module_checksum helper. Both run as root and must stay behaviorally identical.

scripts/test-immutable-packaging.sh executes only the nFPM scripts. For the spec it asserts two literal substrings (Lines 67-69). A future change to one copy can therefore diverge without a test failure.

Consider shipping one helper script and calling it from both packaging paths, for example install a nm-netbird-selinux-lifecycle helper under %{_datadir}/%{name}/ and invoke it from %post and %postun.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packaging/rpm/network-manager-netbird.spec.tmpl` around lines 83 - 136,
Extract the shared SELinux lifecycle logic from the spec’s %post block and
packaging/scripts/postinstall-rpm.sh into one installed
nm-netbird-selinux-lifecycle helper, including priority-200 installation, marker
validation, checksum comparison, and legacy priority-400 cleanup. Update both
packaging paths to invoke this helper from their install and uninstall flows,
preserving identical behavior and adapting scripts/test-immutable-packaging.sh
so the shared implementation remains covered without relying on duplicated
literal blocks.
packaging/scripts/postinstall-rpm.sh (1)

49-61: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Run -m on the oldest supported RHEL/Fedora target.

semodule -lfull -m currently prints priority, name, type, status, then sha256:HASH, so $4 can read disabled for a disabled module. Run the command on the oldest supported target before relying on the checksum field offset.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packaging/scripts/postinstall-rpm.sh` around lines 49 - 61, Validate
`semodule -lfull -m` output on the oldest supported RHEL/Fedora target before
finalizing `module_checksum`. Update the awk parsing to extract the checksum
from the actual `sha256:HASH` field rather than assuming `$4`, including
disabled-module output, while preserving priority and `nm_netbird` filtering.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/test-immutable-packaging.sh`:
- Around line 131-138: Update rewrite_for_harness to replace the bare
/var/lib/network-manager-netbird directory with the harness-specific path,
keeping the existing longer legacy marker replacement before the directory
replacement. Add a fake rmdir command and include it in the fake-command symlink
setup so cleanup attempts are intercepted and asserted instead of touching the
host filesystem.

---

Nitpick comments:
In `@packaging/rpm/network-manager-netbird.spec.tmpl`:
- Around line 83-136: Extract the shared SELinux lifecycle logic from the spec’s
%post block and packaging/scripts/postinstall-rpm.sh into one installed
nm-netbird-selinux-lifecycle helper, including priority-200 installation, marker
validation, checksum comparison, and legacy priority-400 cleanup. Update both
packaging paths to invoke this helper from their install and uninstall flows,
preserving identical behavior and adapting scripts/test-immutable-packaging.sh
so the shared implementation remains covered without relying on duplicated
literal blocks.

In `@packaging/scripts/postinstall-rpm.sh`:
- Around line 49-61: Validate `semodule -lfull -m` output on the oldest
supported RHEL/Fedora target before finalizing `module_checksum`. Update the awk
parsing to extract the checksum from the actual `sha256:HASH` field rather than
assuming `$4`, including disabled-module output, while preserving priority and
`nm_netbird` filtering.

In `@scripts/test-immutable-packaging.sh`:
- Around line 244-253: Extend the immutable packaging test around the fake
semodule setup to support FAIL_MODULE_LIST=1, then add a scenario covering
checksum inspection failure from semodule -lfull -m. Assert that legacy removal
with -X 400 -r nm_netbird is not attempted and the legacy marker remains after
the postinstall script exits.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 919f5581-9a67-4f48-b785-35e6ec08e047

📥 Commits

Reviewing files that changed from the base of the PR and between 1c1e87d and 49055f7.

📒 Files selected for processing (10)
  • .github/workflows/release.yml
  • .goreleaser.yml
  • Taskfile.yml
  • docs/reference.md
  • packaging/rpm/network-manager-netbird.spec.tmpl
  • packaging/scripts/postinstall-rpm.sh
  • packaging/scripts/postinstall.sh
  • packaging/scripts/postremove-rpm.sh
  • packaging/scripts/postremove.sh
  • scripts/test-immutable-packaging.sh
💤 Files with no reviewable changes (2)
  • packaging/scripts/postremove.sh
  • packaging/scripts/postinstall.sh

Comment thread scripts/test-immutable-packaging.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

network-manager-netbird rpm install fails on immutable distro

1 participant