• [PATCH] Factor out common code for reloading database files

    From Simon Richter@21:1/5 to All on Fri May 5 21:10:02 2023
    ---
    lib/dpkg/Makefile.am | 1 +
    lib/dpkg/db-fsys-common.c | 84 +++++++++++++++++++++++++++++++++++++
    lib/dpkg/db-fsys-divert.c | 43 ++++---------------
    lib/dpkg/db-fsys-override.c | 50 +++++-----------------
    lib/dpkg/dpkg-db.h | 13 ++++++
    5 files changed, 117 insertions(+), 74 deletions(-)
    create mode 100644 lib/dpkg/db-fsys-common.c

    diff --git a/lib/dpkg/Makefile.am b/lib/dpkg/Makefile.am
    index 3403338ce..45c3e01ff 100644
    --- a/lib/dpkg/Makefile.am
    +++ b/lib/dpkg/Makefile.am
    @@ -79,6 +79,7 @@ libdpkg_la_SOURCES = \
    db-ctrl-access.c \
    db-ctrl-format.c \
    db-ctrl-upgrade.c \
    + db-fsys-common.c \
    db-fsys-digest.c \
    db-fsys-divert.c \
    db-fsys-files.c \
    diff --git a/lib/dpkg/db-fsys-common.c b/lib/dpkg/db-fsys-common.c
    new file mode 100644
    index 000000000..fc52e9f8b
    --- /dev/null
    +++ b/lib/dpkg/db-fsys-common.c
    @@ -0,0 +1,84 @@
    +/*
    + * libdpkg - Debian packaging suite library routines
    + * db-fsys-common.c - Common handling for admindb files
    + *
  • From Simon Richter@21:1/5 to All on Sun Mar 17 00:40:02 2024
    ---
    lib/dpkg/Makefile.am | 1 +
    lib/dpkg/db-fsys-common.c | 87 +++++++++++++++++++++++++++++++++++++
    lib/dpkg/db-fsys-divert.c | 43 ++++--------------
    lib/dpkg/db-fsys-override.c | 50 +++++----------------
    lib/dpkg/dpkg-db.h | 13 ++++++
    5 files changed, 120 insertions(+), 74 deletions(-)
    create mode 100644 lib/dpkg/db-fsys-common.c

    diff --git a/lib/dpkg/Makefile.am b/lib/dpkg/Makefile.am
    index 9ef3a37f7..9ab402cf5 100644
    --- a/lib/dpkg/Makefile.am
    +++ b/lib/dpkg/Makefile.am
    @@ -73,6 +73,7 @@ libdpkg_la_SOURCES = \
    db-ctrl-access.c \
    db-ctrl-format.c \
    db-ctrl-upgrade.c \
    + db-fsys-common.c \
    db-fsys-digest.c \
    db-fsys-divert.c \
    db-fsys-files.c \
    diff --git a/lib/dpkg/db-fsys-common.c b/lib/dpkg/db-fsys-common.c
    new file mode 100644
    index 000000000..be106aff6
    --- /dev/null
    +++ b/lib/dpkg/db-fsys-common.c
    @@ -0,0 +1,87 @@
    +/*
    + * libdpkg - Debian packaging suite library routines
    + * db-fsys-common.c - Common handling for admindb files
    + *
    +
  • From Simon Richter@21:1/5 to Simon Richter on Sun Mar 17 12:50:02 2024
    On 17.03.24 08:27, Simon Richter wrote:

    ---
    lib/dpkg/Makefile.am | 1 +
    lib/dpkg/db-fsys-common.c | 87 +++++++++++++++++++++++++++++++++++++
    lib/dpkg/db-fsys-divert.c | 43 ++++--------------
    lib/dpkg/db-fsys-override.c | 50 +++++----------------
    lib/dpkg/dpkg-db.h | 13 ++++++
    5 files changed, 120 insertions(+), 74 deletions(-)
    create mode 100644 lib/dpkg/db-fsys-common.c

    FWIW, this also needs translation changes, but for that the general
    direction needs to be useful. I think it is because it merges duplicated
    code, and it will be even more useful when I add a third file there.

    Simon

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Guillem Jover@21:1/5 to All on Sun Mar 17 17:30:01 2024
    Hi!

    Ah, thanks for the patch! At the time I prepared an alternative, which
    I queued in a branch, but then I forgot to mention this on the list,
    and to merge it. :/

    Attached is what I had, which I've polished a bit more now. Will
    include in my next push.

    Thanks,
    Guillem

    From defc49ccbf2e626155e77ba77a141fa9033473a0 Mon Sep 17 00:00:00 2001
    From: Guillem Jover <guillem@debian.org>
    Date: Sun, 17 Mar 2024 15:02:45 +0100
    Subject: [PATCH] libdpkg: Factor out filesystem database file loading into new
    function

    This code is duplicated on several places that load filesystem
    databases, refactor it into a new function that takes care of the
    (re)loading.

    Based-on-patch-by: Simon Richter <sjr@debian.org>
    ---
    lib/dpkg/Makefile.am | 1 +
    lib/dpkg/db-fsys-divert.c | 63 ++++++-------------------
    lib/dpkg/db-fsys-load.c | 91 +++++++++++++++++++++++++++++++++++++
    lib/dpkg/db-fsys-override.c | 69 +++++++---------------------
    lib/dpkg/db-fsys.h | 26 +++++++++++
    5 files changed, 149 insertions(+), 101 deletions(-)
    create mode 100644 lib/dpkg/db-fsys-load.c

    diff --git a/lib/dpkg/Makefile.am b/lib/dpkg/Makefile.am
    index 9ef3a37f7..b0243b157 100644
    --- a/lib/dpkg/Makefile.am
    +++ b/lib/dpkg/Makefile.am
    @@ -76,6 +76,7 @@ libdpkg_la_SOURCES = \
    db-fsys-digest.c \
    db-fsys-divert.c \
    db-fsys-files.c \
    + db-fsys-load.c \
    db-fsys-override.c \
    deb-version.c \
    debug.c \
    diff --git a/lib/dpkg/db-fsys-divert.c b/lib/dpkg/db-fsys-divert.c
    index e0054bb35..351e8ef87 100644
    --- a/lib/dpkg/db-fsys-divert.c
    +++ b/lib/dpkg/db-fsys-divert.c
    @@ -23,7 +23,6 @@
    #include <compat.h>

    #include <sys/types.h>
    -#include <sys/stat.h>

    #include <errno.h>
    #include <string
  • From Simon Richter@21:1/5 to Guillem Jover on Mon Mar 18 05:20:01 2024
    Hi Guillem,

    On 3/18/24 01:28, Guillem Jover wrote:

    Attached is what I had, which I've polished a bit more now. Will
    include in my next push.

    Nice, will rebase my branch on top of that. The new file probably needs
    to be added to po/POTFILES.in as well, since it contains translatable
    strings.

    Simon

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Guillem Jover@21:1/5 to Simon Richter on Wed Mar 20 01:10:02 2024
    Hi!

    On Mon, 2024-03-18 at 13:14:14 +0900, Simon Richter wrote:
    On 3/18/24 01:28, Guillem Jover wrote:
    Attached is what I had, which I've polished a bit more now. Will
    include in my next push.

    Nice, will rebase my branch on top of that. The new file probably needs to
    be added to po/POTFILES.in as well, since it contains translatable strings.

    Right, thanks. I amended the commit that that. Now in git main.

    Regards,
    Guillem

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