• converting conffile to dpkg-conffile and keeping piuparts happy

    From Marc Haber@21:1/5 to All on Sun Jun 1 22:30:01 2025
    Hi,

    another late night stupid question from me.

    In ferm, /etc/default/ferm used to be managed in postinst. I would like
    to convert that to a dpkg-conffile. I have therefore removed the code
    handling the conffile from postinst and the other maintainer scripts and
    am delivering the file via the normal way as package member file.

    The first version of the package with /etc/default/ferm being a
    dpkg-conffile is in experimental due to the freeze.

    When I change something in /etc/default/ferm, this triggers a
    dpkg-conffile prompt during installation. This, in turn, makes piuparts
    unhappy when it tries to update the package version that is currently in unstable (and will stay there until the release) to the new version.

    How can I change my new dpkg-conffile and keep piuparts happy at the
    same time?

    Greetings
    Marc

    P.S.: I wouldn't have that problem if I moved the conffile to ucf,
    right?

    -- ----------------------------------------------------------------------------- Marc Haber | "I don't trust Computers. They | Mailadresse im Header Leimen, Germany | lose things." Winona Ryder | Fon: *49 6224 1600402 Nordisch by Nature | How to make an American Quilt | Fax: *49 6224 1600421

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marc Haber@21:1/5 to Marc Haber on Wed Jun 4 12:20:01 2025
    Hi,

    On Sun, Jun 01, 2025 at 10:20:31PM +0200, Marc Haber wrote:
    How can I change my new dpkg-conffile and keep piuparts happy at the
    same time?

    Here is the solution I found myself:

    $ head -n-0 debian/ferm.p*
    debian/ferm.postrm <==
    #!/bin/sh
    set -e

    action=$1

    if [ "${action}" = "purge" ]; then
    rm -f \
    /etc/default/ferm \
    /etc/default/ferm.bak
    fi


    #DEBHELPER#

    debian/ferm.preinst <==
    #!/bin/sh
    set -e

    action=$1
    version=$2

    DEFAULTSFILE="/etc/default/ferm"
    BACKUPDEFAULTSFILE="${DEFAULTSFILE}.bak"
    # sha256 hashes of $DEFAULTSFILE in ferm 2.5.1-4,
    # with ENABLE="yes" and ENABLE="no"
    DEFAULTSFILEHASHES=" 64c84ccb16e984935c05dec6fa8d6b424b4f83735a9c53430a4ba34c5eb3074d 96affdfb381229de75cacb94412580df3938ad5f1e87ae1d004ab303630cd571
    "

    if [ "${action}" = "upgrade" ]; then
    # remove old cache files
    rm -f /var/cache/ferm/*.sh /var/cache/ferm/*.tmp

    # ferm 2.5.1-4 and earlier managed their defaultsfile in the
    # maintainer script. Move old defaultsfile away if unchanged
    if dpkg --compare-versions "${version}" le-nl "2.5.1-4"; then
    if [ -e "${DEFAULTSFILE}" ]; then
    CURRENT_HASH="$(sha256sum "${DEFAULTSFILE}" | cut -d ' ' -f 1)"
    if printf "%s\n" "${DEFAULTSFILEHASHES}" | grep --quiet --line-regexp --fixed-strings "${CURRENT_HASH}"; then
    if [ -e "${BACKUPDEFAULTSFILE}" ]; then
    TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
    mv "${BACKUPDEFAULTSFILE}" "${BACKUPDEFAULTSFILE}.${TIMESTAMP}"
    fi
    mv "${DEFAULTSFILE}" "${DEFAULTSFILE}.bak"
    fi
    fi
    fi
    fi


    #DEBHELPER#

    The idea is to detect whether the maintainer-script-managed file was
    changed by the local admin, and if not, move away the file so that dpkg
    can place the new conffile at the same path without showing a conffile
    prompt. If the local admin changed the file, a dpkg-conffile prompt is
    desired at this place.

    Greetings
    Marc

    -- ----------------------------------------------------------------------------- Marc Haber | "I don't trust Computers. They | Mailadresse im Header Leimen, Germany | lose things." Winona Ryder | Fon: *49 6224 1600402 Nordisch by Nature | How to make an American Quilt | Fax: *49 6224 1600421

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)