Package: libreadline8t64
Version: 8.2-3.1~exp1
Severity: serious
Tags: patch
User: helm...@debian.org
Usertags: dep17p1
Control: affects -1 + libreadline8
X-Debbugs-Cc: vor...@debian.org, mwhud...@debian.org, bug-readl...@gnu.org

Hi,

readline upstream: Please skip the next paragraph.

the time64 transition causes a DEP17 P1 problem for the actual shared
libraries contained in libreadline8t64. These were located below /lib in
libreadline8 in bookworm and thus can be lost in an upgrade. I'm
attaching a patch to add protective diversions for this situation. Since
this library is rather close to essential, I'm using the conservative
method of keeping the diversions beyond postinst. In forky, we can
remove the diversions and in forky+1, we can remove the maintainer
scripts introduced here.

Given the proximity of readline to the base system (e.g. fdisk and
python3 depend on it), I also looked into alternatives.
https://adrien.dcln.fr/misc/armhf-time_t/2024-02-01T09:53:00/compat_reports/libreadline-dev/base_to_lfs/compat_report.html
indicates that we are not faced with LFS ABI changes, but
https://adrien.dcln.fr/misc/armhf-time_t/2024-02-01T09:53:00/compat_reports/libreadline-dev/lfs_to_time_t/compat_report.html
indicates that we are faced with history_get_time changing its return
type from 32bit to 64bit. Providing ABI duality here is even easier than
in the case of libselinux and upstream is vaguely active (last commit 3
weeks ago). Also note that this function already handles range errors
and returns 0 in that case. This behaviour could naturally be extended
for 2038. I think providing duality here would reduce the risk of failed
upgrades breaking user systems.

Context:
https://sources.debian.org/src/readline/8.2-3/history.c/?hl=241#L241

Sketch:

// .h
#if time64 changes ABI
typedef time_t time64_t;
typedef int32_t time32_t;
time64_t history_get_time64 (HIST_ENTRY *hist);
time32_t history_get_time (HIST_ENTRY *hist);
#define history_get_time history_get_time64
#else
time_t history_get_time (HIST_ENTRY *hist);
#endif

// .c
time_t
// The earlier #define may change the function name
history_get_time (HIST_ENTRY *hist)
{
  // original function unchanged
}

#if time64 changes ABI
#undef history_get_time
time32_t
history_get_time (HIST_ENTRY *hist)
{
  time64_t ret64 = history_get_time(hist);
  time32_t ret32 = ret64;
  if ((time64_t)ret32 != ret64)
    return (time32_t)0;
  return ret32;
}
#endif

I've directly Cced readline upstream to see whether they're interested.

Helmut
diff --minimal -Nru readline-8.2/debian/changelog readline-8.2/debian/changelog
--- readline-8.2/debian/changelog       2024-02-19 23:47:01.000000000 +0100
+++ readline-8.2/debian/changelog       2024-02-20 09:18:09.000000000 +0100
@@ -1,3 +1,11 @@
+readline (8.2-3.1~exp1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * DEP17 P1: Mitigate file loss due to package rename with concurrent
+    aliasing change. Closes: #-1.
+
+ -- Helmut Grohne <hel...@subdivi.de>  Tue, 20 Feb 2024 09:18:09 +0100
+
 readline (8.2-3.1~exp1) experimental; urgency=medium
 
   * Non-maintainer upload.
diff --minimal -Nru readline-8.2/debian/libreadline8t64.postrm.in 
readline-8.2/debian/libreadline8t64.postrm.in
--- readline-8.2/debian/libreadline8t64.postrm.in       1970-01-01 
01:00:00.000000000 +0100
+++ readline-8.2/debian/libreadline8t64.postrm.in       2024-02-20 
09:17:54.000000000 +0100
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+set -e
+
+if test "$1" = remove; then
+       # DEP17 P1 mitigation. Remove these diversions via postinst once trixie 
is released.
+       for lib in libhistory.so.8 libhistory.so.8.2 libreadline.so.8 
libreadline.so.8.2; do
+               dpkg-divert --package libreadline8t64 --no-rename --divert 
"/lib/#DEB_HOST_MULTIARCH#/$lib.usr-is-merged" --remove 
"/lib/#DEB_HOST_MULTIARCH#/$lib"
+       done
+fi
+
+#DEBHELPER#
+
+exit 0
diff --minimal -Nru readline-8.2/debian/libreadline8t64.preinst.in 
readline-8.2/debian/libreadline8t64.preinst.in
--- readline-8.2/debian/libreadline8t64.preinst.in      1970-01-01 
01:00:00.000000000 +0100
+++ readline-8.2/debian/libreadline8t64.preinst.in      2024-02-20 
09:18:03.000000000 +0100
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+set -e
+
+if test "$1" = install -o "$1" = upgrade; then
+       # DEP17 P1 mitigation. Remove these diversions via postinst once trixie 
is released.
+       for lib in libhistory.so.8 libhistory.so.8.2 libreadline.so.8 
libreadline.so.8.2; do
+               dpkg-divert --package libreadline8t64 --no-rename --divert 
"/lib/#DEB_HOST_MULTIARCH#/$lib.usr-is-merged" --add 
"/lib/#DEB_HOST_MULTIARCH#/$lib"
+       done
+fi
+
+#DEBHELPER#
+
+exit 0
diff --minimal -Nru readline-8.2/debian/rules readline-8.2/debian/rules
--- readline-8.2/debian/rules   2024-02-19 23:47:01.000000000 +0100
+++ readline-8.2/debian/rules   2024-02-20 09:18:09.000000000 +0100
@@ -154,6 +154,9 @@
 
        touch configure-stamp
 
+debian/%:debian/%.in
+       sed 's/#DEB_HOST_MULTIARCH#/$(DEB_HOST_MULTIARCH)/g' $< > $@
+
 build: build-stamp $(if $(filter 
cross,$(DEB_BUILD_PROFILES)),,build-rlfe-stamp)
 build-arch: build
 build-indep: build
@@ -228,6 +231,7 @@
        rm -f debian/shlibs.local
        find . -type d | xargs chmod g-s
        rm -f support/config.guess support/config.sub
+       rm -f debian/libreadline8t64.preinst debian/libreadline8t64.postrm
        dh_clean
 
 install: install-stamp
@@ -441,7 +445,7 @@
        dh_md5sums -i
        dh_builddeb -i
 
-binary-arch: build install
+binary-arch: build install debian/libreadline8t64.preinst 
debian/libreadline8t64.postrm
        dh_testdir
        dh_testroot
        dh_installdocs -p$(p_rl) \

Reply via email to