Skip to content

Fix apparmor_parser not found error in desktop postinst script#9728

Merged
dpage merged 1 commit intopgadmin-org:masterfrom
maqeel75:master
Mar 10, 2026
Merged

Fix apparmor_parser not found error in desktop postinst script#9728
dpage merged 1 commit intopgadmin-org:masterfrom
maqeel75:master

Conversation

@maqeel75
Copy link
Contributor

@maqeel75 maqeel75 commented Mar 10, 2026

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

  • Debian package installation now handles missing AppArmor tools gracefully, displaying a warning and continuing installation instead of failing.

  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.
@coderabbitai
Copy link

coderabbitai bot commented Mar 10, 2026

Walkthrough

The pkg/debian/build.sh post-installation script now includes a conditional guard that checks for apparmor_parser availability before attempting to load the AppArmor profile. If the tool is missing, it prints a warning and continues without fatal error.

Changes

Cohort / File(s) Summary
AppArmor Profile Loading Guard
pkg/debian/build.sh
Added conditional check for apparmor_parser availability in post-installation script. If present, loads /etc/apparmor.d/pgadmin4 profile; if absent, prints warning and skips load to prevent installation failure.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a guard to fix the apparmor_parser error in the postinstallation script, which directly matches the file modification shown in the summary.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pkg/debian/build.sh (1)

87-91: LGTM! The guard correctly prevents installation failures on systems without AppArmor tools.

The command -v check is POSIX-compliant and the warning message clearly explains the consequence. Since the profile is unconfined anyway (per pkg/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

📥 Commits

Reviewing files that changed from the base of the PR and between a0e6da0 and 83ab7fa.

📒 Files selected for processing (1)
  • pkg/debian/build.sh

@dpage dpage merged commit c8bd75c into pgadmin-org:master Mar 10, 2026
33 checks passed
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.

2 participants