DietPi icon indicating copy to clipboard operation
DietPi copied to clipboard

G_AG_CHECK_INSTALL_PREREQ does not work in some cases

Open Sympatron opened this issue 2 months ago • 1 comments

Creating a bug report/issue

  • [x] I have searched the existing open and closed issues

Required Information

  • DietPi version | cat /boot/dietpi/.version
G_DIETPI_VERSION_CORE=8
G_DIETPI_VERSION_SUB=1
G_DIETPI_VERSION_RC=2
G_GITBRANCH='master'
G_GITOWNER='MichaIng'
G_LIVE_PATCH_STATUS[0]='applied'
G_LIVE_PATCH_STATUS[1]='applied'
G_LIVE_PATCH_STATUS[2]='not applicable'
G_LIVE_PATCH_STATUS[3]='not applicable'
  • Distro version | echo $G_DISTRO_NAME $G_RASPBIAN
    • bullseye 0
  • Kernel version | uname -a
    • Linux LidarTestPi 5.10.92-v8+ #1514 SMP PREEMPT Mon Jan 17 17:39:38 GMT 2022 aarch64 GNU/Linux
  • SBC model | echo $G_HW_MODEL_NAME or (EG: RPi3)
    • RPi 4 Model B (aarch64)
  • Power supply used | (EG: 5V 1A RAVpower)
    • 5V 2A
  • SD card used | (EG: SanDisk ultra)

Additional Information (if applicable)

  • Software title | (EG: Nextcloud)
    • sytemd-timesyncd
  • Was the software title installed freshly or updated/migrated?
  • Can this issue be replicated on a fresh installation of DietPi?
    • Maybe
  • Bug report ID | echo $G_HW_UUID

Steps to reproduce

I don't know how sytemd-timesyncd got into this state, but on my machine running dpkg-query -s systemd-timesyncd (which is what is used by G_AG_CHECK_INSTALL_PREREQ) returns (with exit code 0):

Package: systemd-timesyncd
Status: deinstall ok config-files
Priority: optional
Section: admin
Installed-Size: 197
Maintainer: Debian systemd Maintainers <[email protected]>
Architecture: arm64
Multi-Arch: foreign
Source: systemd
Version: 247.3-6
Config-Version: 247.3-6
Replaces: systemd (<< 245.4-2~), time-daemon
Provides: time-daemon
Depends: libc6 (>= 2.29), systemd (= 247.3-6), adduser
Breaks: systemd (<< 245.4-2~)
Conflicts: time-daemon
Conffiles:
 /etc/dhcp/dhclient-exit-hooks.d/timesyncd c66e563f4050725592e2da20a4e1bfef
 /etc/systemd/timesyncd.conf e563c788b019216ec2ad3a43bf89e315
Description: minimalistic service to synchronize local time with NTP servers
 The package contains the systemd-timesyncd system service that may be used to
 synchronize the local system clock with a remote Network Time Protocol server.
Homepage: https://www.freedesktop.org/wiki/Software/systemd

Because it exists with exit code 0, G_AG_CHECK_INSTALL_PREREQ will not install the package. This was discovered, because setting time synchronization to "daemon + drift" in dietpi-config did not work properly.

Expected behaviour

G_AG_CHECK_INSTALL_PREREQ should only skip installation if it is actually fully installed.

Actual behaviour

G_AG_CHECK_INSTALL_PREREQ skips installation if the package status is "deinstall ok config-files". This may be true for other status values as well.

Extra details

I know I am using an old version of DietPi, but the source code that triggers this behaviour is still the same: My version: https://github.com/MichaIng/DietPi/blob/fb8d2dd08bcae898ec8e8846554244f667480f67/dietpi/func/dietpi-globals#L1677 Current master: https://github.com/MichaIng/DietPi/blob/4471bf892e57845714b820f4f0df238f8a8f4392/dietpi/func/dietpi-globals#L1723

Sympatron avatar Oct 09 '25 16:10 Sympatron

Thanks for your report. That is true, if the package has been removed, but not purged, and config files were left in place. One solution would be dpkg-query -s "$i" | grep -q '^Status: install ok installed$', but I'll check whether there is a dpkg-query-internal filter which allows to skip the additional pipe.

This affects a lot of other places in DietPi code. It rarely plays a role, since at least we consequently purge packages internally as long as they are not reinstalled afterwards within the same script/run, and many packages we check this way, like kernel packages, do not have config files. But makes sense to make this check failsafe in all cases.

MichaIng avatar Oct 09 '25 17:10 MichaIng