Skip to content

chore: extract common postinst service enablement pattern into shared template #70

@mairas

Description

@mairas

Summary

Multiple HaLOS repositories now use the same deb-systemd-helper pattern for service enablement in their debian/postinst scripts. This pattern should be extracted into a shared template or script to reduce duplication and ensure consistency.

Current State

The following repositories have nearly identical postinst service enablement code:

The common pattern:

# Enable the systemd service
# Using deb-systemd-helper which works in chroots during image build
if command -v deb-systemd-helper >/dev/null 2>&1; then
    deb-systemd-helper unmask 'SERVICE_NAME.service' >/dev/null || true
    deb-systemd-helper enable 'SERVICE_NAME.service' >/dev/null || true
fi

# Start the service if systemd is running
if [ -d /run/systemd/system ]; then
    systemctl --system daemon-reload >/dev/null || true
    systemctl start SERVICE_NAME.service >/dev/null || true
fi

Proposed Solution

Options to consider:

  1. Shared script in container-packaging-tools: A helper script that can be sourced or called from postinst
  2. Template generation: Generate postinst from a template during build
  3. Documentation: At minimum, document this pattern in the workspace so new repos follow it

Benefits

  • Single source of truth for the pattern
  • Easier to update if the approach needs to change
  • Reduces copy-paste errors when creating new packages

Related

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions