deb postinst fails when replacing stock caddy with masked service unit #1

Closed
opened 2026-06-12 19:20:49 +00:00 by madcat · 0 comments
Owner

Bug

When installing madcat-caddy on a host that has stock caddy with a masked caddy.service unit (/etc/systemd/system/caddy.service -> /dev/null), the postinst script fails:

  1. dpkg --force-confold -i removes the old caddy package
  2. The mask symlink (/etc/systemd/system/caddy.service -> /dev/null) is removed by systemctl unmask
  3. But the new unit file from the deb (/usr/lib/systemd/system/caddy.service) is not unpacked — it was listed in the manifest but never landed on disk
  4. systemctl enable caddy.service in postinst fails with "Unit file caddy.service does not exist"
  5. dpkg --configure fails

Workaround

Manually extract the unit from the deb and copy it:

dpkg-deb -x madcat-caddy_*.deb /tmp/extract
sudo cp /tmp/extract/usr/lib/systemd/system/caddy.service /usr/lib/systemd/system/
sudo systemctl daemon-reload
sudo dpkg --configure madcat-caddy

Reproduction

Confirmed on:

  • sin (DGX Spark, arm64, Ubuntu 24.04) — stock caddy 2.6.2 had caddy-api.service masked
  • bastion (arm64, Ubuntu 24.04) — stock caddy 2.11.3 had caddy.service masked

Expected fix

The postinst script should:

  1. Check if the unit file exists at /usr/lib/systemd/system/caddy.service before trying to enable
  2. If missing, extract it from the deb or ship it via a conffiles-safe path
  3. Run systemctl daemon-reload before systemctl enable
  4. Handle the masked-unit case gracefully (unmask first, then enable)

Also

The caddy-api.service mask on sin (/etc/systemd/system/caddy-api.service -> /dev/null) triggers a harmless warning during preinst (Failed to stop caddy-api.service: Unit caddy-api.service not loaded) — should be guarded with || true.

## Bug When installing `madcat-caddy` on a host that has stock `caddy` with a **masked** `caddy.service` unit (`/etc/systemd/system/caddy.service -> /dev/null`), the postinst script fails: 1. `dpkg --force-confold -i` removes the old `caddy` package 2. The mask symlink (`/etc/systemd/system/caddy.service -> /dev/null`) is removed by `systemctl unmask` 3. But the new unit file from the deb (`/usr/lib/systemd/system/caddy.service`) is **not unpacked** — it was listed in the manifest but never landed on disk 4. `systemctl enable caddy.service` in postinst fails with "Unit file caddy.service does not exist" 5. `dpkg --configure` fails ## Workaround Manually extract the unit from the deb and copy it: ```bash dpkg-deb -x madcat-caddy_*.deb /tmp/extract sudo cp /tmp/extract/usr/lib/systemd/system/caddy.service /usr/lib/systemd/system/ sudo systemctl daemon-reload sudo dpkg --configure madcat-caddy ``` ## Reproduction Confirmed on: - sin (DGX Spark, arm64, Ubuntu 24.04) — stock caddy 2.6.2 had caddy-api.service masked - bastion (arm64, Ubuntu 24.04) — stock caddy 2.11.3 had caddy.service masked ## Expected fix The postinst script should: 1. Check if the unit file exists at `/usr/lib/systemd/system/caddy.service` before trying to enable 2. If missing, extract it from the deb or ship it via a `conffiles`-safe path 3. Run `systemctl daemon-reload` before `systemctl enable` 4. Handle the masked-unit case gracefully (unmask first, then enable) ## Also The `caddy-api.service` mask on sin (`/etc/systemd/system/caddy-api.service -> /dev/null`) triggers a harmless warning during preinst (`Failed to stop caddy-api.service: Unit caddy-api.service not loaded`) — should be guarded with `|| true`.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: madcat-os/madcat-caddy#1