In readonly A/B update, debian package info will overwrite

Hello everybody
when using A/B mode, i used overlayfs for some places like:

  • /var/
  • /etc/
  • /home/
    this overlays has some side effects. one of them is debian package info will
    not updated when updating system.
    /var/lib/dpkg/ will be changed for the first boot and after update it will not updated.
    and dpkg-query always shows old package versions.
    has anyone a solution for this problem?
    thanks

i asked chatgpt for this problem and below solution is given. is it true?

update_pkginfo.bb:

SUMMARY = "Custom solution hook script for updating package information"
DESCRIPTION = "A custom solution hook script that updates package information after an A/B Mender update."

LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI = "file://update_package_info.sh"

S = "${WORKDIR}"

do_install() {
    install -d ${D}${sysconfdir}/mender/postinstall.d
    install -m 0755 ${S}/update_package_info.sh ${D}${sysconfdir}/mender/postinstall.d/
}

FILES_${PN} += "${sysconfdir}/mender/postinstall.d"

inherit mender-script

MENDER_POSTINSTALL_SCRIPT = "update_package_info.sh"

update_package_info.sh:

#!/bin/sh

# Update package information using dpkg
dpkg --configure -a

Sorry, @chezgi,

The snippet provided by ChatGPT seems to be mostly nonsense, especially given the fact that it is a Yocto-ish-looking thing, and you asked for Debian.

Greetz,
Josef

thanks @TheYoctoJester
i asked for yocto,
readonly rootfs and A/B update mechanism is used in yocto not debian.

the package management used for yocto is dpkg.
you can select package management system in yocto [rpm,dpkg,…]