Fix apparmor_parser not found error in desktop postinst script#9728
Fix apparmor_parser not found error in desktop postinst script#9728dpage merged 1 commit intopgadmin-org:masterfrom
Conversation
Add a runtime guard in the postinst so apparmor_parser is only called when available. Previously, packages built on Ubuntu 24+ would fail to install on headless servers or systems without AppArmor tools. A warning is printed when the profile load is skipped to aid debugging.
WalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/debian/build.sh (1)
87-91: LGTM! The guard correctly prevents installation failures on systems without AppArmor tools.The
command -vcheck is POSIX-compliant and the warning message clearly explains the consequence. Since the profile isunconfinedanyway (perpkg/debian/pgadmin4-aa-profile), skipping the load on AppArmor-less systems is a safe degradation.Optional: Consider redirecting the warning to stderr for cleaner separation from normal postinst output:
♻️ Optional: redirect warning to stderr
if command -v apparmor_parser >/dev/null 2>&1; then apparmor_parser -r /etc/apparmor.d/pgadmin4 else - echo "Warning: apparmor_parser not found, skipping profile load. pgAdmin desktop may not work on Ubuntu 24+ with userns restrictions." + echo "Warning: apparmor_parser not found, skipping profile load. pgAdmin desktop may not work on Ubuntu 24+ with userns restrictions." >&2 fi,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/debian/build.sh` around lines 87 - 91, The warning currently printed by the else branch uses echo which writes to stdout; change it to send the warning to stderr so it doesn't mix with normal postinst output — replace the else branch's echo "Warning: apparmor_parser not found, ..." with a stderr-directed write (e.g., use printf or echo with >&2) so the message from the apparmor_parser guard (the command -v apparmor_parser check and the apparmor_parser -r /etc/apparmor.d/pgadmin4 invocation) is emitted to stderr instead of stdout.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@pkg/debian/build.sh`:
- Around line 87-91: The warning currently printed by the else branch uses echo
which writes to stdout; change it to send the warning to stderr so it doesn't
mix with normal postinst output — replace the else branch's echo "Warning:
apparmor_parser not found, ..." with a stderr-directed write (e.g., use printf
or echo with >&2) so the message from the apparmor_parser guard (the command -v
apparmor_parser check and the apparmor_parser -r /etc/apparmor.d/pgadmin4
invocation) is emitted to stderr instead of stdout.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 135d5d3e-c3b5-4df7-8efb-1bbc54c91c6d
📒 Files selected for processing (1)
pkg/debian/build.sh
Add a runtime guard in the postinst so apparmor_parser is only called
when available. Previously, packages built on Ubuntu 24+ would fail to
install on headless servers or systems without AppArmor tools. A warning
is printed when the profile load is skipped to aid debugging.
Summary by CodeRabbit
Bug Fixes