Skip to content

fix: fallback to systemctl command when debian helpers are not available#3402

Merged
reubenmiller merged 2 commits intothin-edge:mainfrom
reubenmiller:fix-deb-package-deb-helper-checks
Feb 17, 2025
Merged

fix: fallback to systemctl command when debian helpers are not available#3402
reubenmiller merged 2 commits intothin-edge:mainfrom
reubenmiller:fix-deb-package-deb-helper-checks

Conversation

@reubenmiller
Copy link
Copy Markdown
Contributor

Proposed changes

Add additional checks to the *.deb (Debian) packages' maintainer scripts to check if the helpers (e.g. deb-systemd-helper and deb-systemd-invoke) are available before using them. If they are not available, then fallback to systemctl commands. Beaware that the debian helper scripts do more than what systemctl does, so there is not always a systemctl equivalent command, but this is ok.

The main motivation for this PR is to be more compatible with a Yocto based distribution where it can include the APT package manager but the debian helper scripts are not installed. This allows the debian packages to be installed on these Yocto images without printing warnings and failing to do the systemd service management actions (e.g. enable, start, restart etc.).

Writing a system test to check the functionality without the debian helper scripts is difficult as it requires building a custom Yocto image and therefore is out of scope for this ticket. A manual test will be done before the PR is merged.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue

#2994

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s)
  • I ran cargo fmt as mentioned in CODING_GUIDELINES
  • I used cargo clippy as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

…lable

Debian helpers are only on Debian and Ubuntu based OS's however apt (deb package manager) can be installed on Yocto based images and they generally don't have these debian helper scripts.
Using the debian helpers scripts is still preferred (when available) as it follows the debian best practices (as they offer some additional functionality on those OS's).
@reubenmiller reubenmiller added theme:packaging Theme: Packaging and release artefact topics theme:yocto Theme: Yocto image related topics labels Feb 14, 2025
@github-actions
Copy link
Copy Markdown
Contributor

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
585 0 3 585 100 1h35m45.027316s

Copy link
Copy Markdown
Member

@rina23q rina23q left a comment

Choose a reason for hiding this comment

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

LGTM

@reubenmiller
Copy link
Copy Markdown
Contributor Author

The manual test on a Yocto scarthgap release was successful. Below shows the setup and the previous warnings are no longer visible.

$ cat /etc/os-release

ID=poky
NAME="Poky (Yocto Project Reference Distro)"
VERSION="5.0.6 (scarthgap)"
VERSION_ID=5.0.6
VERSION_CODENAME="scarthgap"
PRETTY_NAME="Poky (Yocto Project Reference Distro) 5.0.6 (scarthgap)"
CPE_NAME="cpe:/o:openembedded:poky:5.0.6"

Then installing the package which was uploaded to a temporary cloudsmith tedge-dev repository (and it will be deleted shortly after the test):

$ apt-get install tedge-full

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  c8y-firmware-plugin c8y-remote-access-plugin tedge tedge-agent tedge-apt-plugin tedge-mapper tedge-watchdog
The following NEW packages will be installed:
  c8y-firmware-plugin c8y-remote-access-plugin tedge tedge-agent tedge-apt-plugin tedge-full tedge-mapper tedge-watchdog
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/5307 kB of archives.
After this operation, 11.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Selecting previously unselected package tedge.
(Reading database ... 7551 files and directories currently installed.)
Preparing to unpack .../0-tedge_1.4.3~148+g75d0797_arm64.deb ...
Unpacking tedge (1.4.3~148+g75d0797) ...
Selecting previously unselected package c8y-firmware-plugin.
Preparing to unpack .../1-c8y-firmware-plugin_1.4.3~148+g75d0797_arm64.deb ...
Unpacking c8y-firmware-plugin (1.4.3~148+g75d0797) ...
Selecting previously unselected package c8y-remote-access-plugin.
Preparing to unpack .../2-c8y-remote-access-plugin_1.4.3~148+g75d0797_arm64.deb ...
Unpacking c8y-remote-access-plugin (1.4.3~148+g75d0797) ...
Selecting previously unselected package tedge-agent.
Preparing to unpack .../3-tedge-agent_1.4.3~148+g75d0797_arm64.deb ...
Unpacking tedge-agent (1.4.3~148+g75d0797) ...
Selecting previously unselected package tedge-apt-plugin.
Preparing to unpack .../4-tedge-apt-plugin_1.4.3~148+g75d0797_arm64.deb ...
Unpacking tedge-apt-plugin (1.4.3~148+g75d0797) ...
Selecting previously unselected package tedge-mapper.
Preparing to unpack .../5-tedge-mapper_1.4.3~148+g75d0797_arm64.deb ...
Unpacking tedge-mapper (1.4.3~148+g75d0797) ...
Selecting previously unselected package tedge-watchdog.
Preparing to unpack .../6-tedge-watchdog_1.4.3~148+g75d0797_arm64.deb ...
Unpacking tedge-watchdog (1.4.3~148+g75d0797) ...
Selecting previously unselected package tedge-full.
Preparing to unpack .../7-tedge-full_1.4.3~148+g75d0797_all.deb ...
Unpacking tedge-full (1.4.3~148+g75d0797) ...
Setting up tedge (1.4.3~148+g75d0797) ...
No bridges to refresh.
Setting up tedge-watchdog (1.4.3~148+g75d0797) ...
Removed "/etc/systemd/system/tedge-watchdog.service".
Setting up c8y-remote-access-plugin (1.4.3~148+g75d0797) ...
Removed "/etc/systemd/system/c8y-remote-access-plugin.socket".
Setting up tedge-agent (1.4.3~148+g75d0797) ...
Removed "/etc/systemd/system/tedge-agent.service".
Setting up tedge-apt-plugin (1.4.3~148+g75d0797) ...
Setting up tedge-mapper (1.4.3~148+g75d0797) ...
Removed "/etc/systemd/system/tedge-mapper-aws.service".
Removed "/etc/systemd/system/tedge-mapper-az.service".
Removed "/etc/systemd/system/tedge-mapper-c8y.service".
Removed "/etc/systemd/system/tedge-mapper-collectd.service".
Removed "/etc/systemd/system/tedge-mapper-aws.target".
Removed "/etc/systemd/system/tedge-mapper-az.target".
Removed "/etc/systemd/system/tedge-mapper-c8y.target".
Setting up c8y-firmware-plugin (1.4.3~148+g75d0797) ...
Removed "/etc/systemd/system/c8y-firmware-plugin.service".
Setting up tedge-full (1.4.3~148+g75d0797) ...

@reubenmiller reubenmiller added this pull request to the merge queue Feb 17, 2025
Merged via the queue into thin-edge:main with commit b1dce70 Feb 17, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme:packaging Theme: Packaging and release artefact topics theme:yocto Theme: Yocto image related topics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants