Bug#1003452: dpkg: missing alternatives for x-terminal-emulator

2022-01-13 Thread Vincent Lefevre
Control: found -1 1.21.0
Control: notfound -1 1.21.1

since the issue really occurred in dpkg 1.21.0.

On 2022-01-13 13:17:42 +0100, Guillem Jover wrote:
[...]

Thanks for the explanations.

> On Wed, 2022-01-12 at 14:17:17 +0100, Vincent Lefevre wrote:
> > If this is the case,
> > is there a way to know which alternatives are missing? Those that
> > appear in /var/log/alternatives.log* while dpkg 1.20.0 was installed?
> 
> As long as alternatives.log has been kept for long enough,

I keep them for 1 year. :-) So, this was OK for me, except that
this does not say which packages could be affected, i.e. which
installed packages provide the considered alternative.

> otherwise grepping for u-a in maintscripts in the dpkg db might be
> more effective.

This is more complex than just a grep due to continuation lines.
For instance, /var/lib/dpkg/info/mlterm.postinst contains

update-alternatives \
  --install /usr/bin/x-terminal-emulator x-terminal-emulator 
/usr/bin/mlterm 20 \
  --slave /usr/share/man/man1/x-terminal-emulator.1.gz 
x-terminal-emulator.1.gz /usr/share/man/man1/mlterm.1.gz

So, if I'm not mistaken:

  pcregrep -Mr 
'^(.|\\\n)*update-alternatives(.|\\\n)*--install(.|\\\n)*\bx-terminal-emulator\b(.|\n)*?[^\\]$'
 /var/lib/dpkg/info

based on the idea from .

If there were a field in the control file, this could have been
much easier (and could also be useful in a more general way, e.g.
to search for non-installed packages providing some alternative).

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



Bug#1003452: dpkg: missing alternatives for x-terminal-emulator

2022-01-13 Thread Guillem Jover
On Wed, 2022-01-12 at 14:17:17 +0100, Vincent Lefevre wrote:
> On 2022-01-12 13:13:23 +0100, Guillem Jover wrote:
> > From this log, it looks like on 2021-12-06 you upgraded, and probably
> > got dpkg 1.20.0, which then lost the alternatives, and restored  the
> > ones for gnome-terminal and rxvt, the other ones are then missing,
> > even after restoring the misplaced db. :/ Unfortunately w/o
> > declarative alternatives the current restoring logic is the best that
> > can be done, that will not leave cruft behind.
> 
> I'm not sure I understand what you mean. dpkg 1.20.0 is very old.
> Perhaps you meant dpkg 1.21.0.

Err, yeah sorry.

> Indeed, on this machine, dpkg 1.21.0
> was installed on 2021-12-06 13:39:35. Then, do you mean that this
> was actually a bug in dpkg 1.21.0, which got fixed in 1.21.1, but
> alternatives settings had already been lost?

Yes and no. dpkg 1.21.0 had a bug where u-a would read and write its
db directly into /var/lib/dpkg (instead of within its alternatives/
subdir). Which meant that when removing or installing alternatives it
would ignore all existing ones. The recovery code I added in 1.21.1
moved any alternatives state file from /var/lib/dpkg/ back into
/var/lib/dpkg/alternatives, but at that point (further) state loss
would happen.

My thinking was that this version was on the archive for 1 day, that
alternatives are currently mostly self-healing (just reinstalling or
upgrading would recover the db, although it might lose the manual/auto
state). And that leaving lingering alternatives behind (after a
removal of an alternative with the bogus detached db not affecting
the real db) was worse than the other scenarios, as that was not
self-healing. So went for overwriting any alternatives state file that
had been newly created directly under /var/lib/dpkg/.

Just to be clear, the other options would have been:

 - simply remove the detached alternatives state files from
   /var/lib/dpkg/, missing alternative removals which are not
   self-healing, unless the package gets installed and removed again.
 - try to merge both, but I don't see how removals could be handled
   here, so it might cover component updates in alternatives better
   but it still would have the same problem as the previous one at
   a way higher implementation cost.

> If this is the case,
> is there a way to know which alternatives are missing? Those that
> appear in /var/log/alternatives.log* while dpkg 1.20.0 was installed?

As long as alternatives.log has been kept for long enough, otherwise
grepping for u-a in maintscripts in the dpkg db might be more
effective.

> I can see that on another machine, dpkg was upgraded directly from
> 1.20.9 to 1.21.1, and I haven't noticed any issue there.

Right. And sorry for the trouble!

Thanks,
Guillem



Bug#1003452: dpkg: missing alternatives for x-terminal-emulator

2022-01-12 Thread Vincent Lefevre
Hi,

On 2022-01-12 13:13:23 +0100, Guillem Jover wrote:
> On Mon, 2022-01-10 at 13:13:11 +0100, Vincent Lefevre wrote:
[...]
> > update-alternatives 2021-08-16 16:27:55: run with --install 
> > /usr/bin/x-terminal-emulator x-terminal-emulator /usr/bin/mlterm 20 --slave 
> > /usr/share/man/man1/x-terminal-emulator.1.gz x-terminal-emulator.1.gz 
> > /usr/share/man/man1/mlterm.1.gz
> > update-alternatives 2021-08-22 01:56:43: run with --install 
> > /usr/bin/x-terminal-emulator x-terminal-emulator 
> > /usr/bin/gnome-terminal.wrapper 40 --slave 
> > /usr/share/man/man1/x-terminal-emulator.1.gz x-terminal-emulator.1.gz 
> > /usr/share/man/man1/gnome-terminal.1.gz
> > update-alternatives 2021-09-13 09:49:58: run with --remove 
> > x-terminal-emulator /usr/bin/urxvtcd
> > update-alternatives 2021-09-13 09:50:00: run with --install 
> > /usr/bin/x-terminal-emulator x-terminal-emulator /usr/bin/urxvt 20 --slave 
> > /usr/share/man/man1/x-terminal-emulator.1.gz x-terminal-emulator.1.gz 
> > /usr/share/man/man1/urxvt.1.gz
> > update-alternatives 2021-09-27 14:08:32: run with --install 
> > /usr/bin/x-terminal-emulator x-terminal-emulator 
> > /usr/bin/gnome-terminal.wrapper 40 --slave 
> > /usr/share/man/man1/x-terminal-emulator.1.gz x-terminal-emulator.1.gz 
> > /usr/share/man/man1/gnome-terminal.1.gz
> > update-alternatives 2021-11-23 13:29:02: run with --install 
> > /usr/bin/x-terminal-emulator x-terminal-emulator 
> > /usr/bin/gnome-terminal.wrapper 40 --slave 
> > /usr/share/man/man1/x-terminal-emulator.1.gz x-terminal-emulator.1.gz 
> > /usr/share/man/man1/gnome-terminal.1.gz
> > update-alternatives 2021-12-06 13:49:47: run with --install 
> > /usr/bin/x-terminal-emulator x-terminal-emulator 
> > /usr/bin/gnome-terminal.wrapper 40 --slave 
> > /usr/share/man/man1/x-terminal-emulator.1.gz x-terminal-emulator.1.gz 
> > /usr/share/man/man1/gnome-terminal.1.gz
> > update-alternatives 2021-12-06 13:49:47: link group x-terminal-emulator 
> > updated to point to /usr/bin/gnome-terminal.wrapper
> > update-alternatives 2022-01-05 11:01:08: run with --remove 
> > x-terminal-emulator /usr/bin/urxvtcd
> > update-alternatives 2022-01-05 11:04:12: run with --install 
> > /usr/bin/x-terminal-emulator x-terminal-emulator /usr/bin/urxvt 20 --slave 
> > /usr/share/man/man1/x-terminal-emulator.1.gz x-terminal-emulator.1.gz 
> > /usr/share/man/man1/urxvt.1.gz
> > 
> > I wonder whether some upgrade of gnome-terminal or rxvt trashed the 
> > alternatives.
> 
> From this log, it looks like on 2021-12-06 you upgraded, and probably
> got dpkg 1.20.0, which then lost the alternatives, and restored  the
> ones for gnome-terminal and rxvt, the other ones are then missing,
> even after restoring the misplaced db. :/ Unfortunately w/o
> declarative alternatives the current restoring logic is the best that
> can be done, that will not leave cruft behind.

I'm not sure I understand what you mean. dpkg 1.20.0 is very old.
Perhaps you meant dpkg 1.21.0. Indeed, on this machine, dpkg 1.21.0
was installed on 2021-12-06 13:39:35. Then, do you mean that this
was actually a bug in dpkg 1.21.0, which got fixed in 1.21.1, but
alternatives settings had already been lost? If this is the case,
is there a way to know which alternatives are missing? Those that
appear in /var/log/alternatives.log* while dpkg 1.20.0 was installed?
Indeed, there's also

update-alternatives 2021-12-06 13:46:17: run with --install /bin/ksh ksh 
/bin/ksh93 20 --slave /usr/share/man/man1/ksh.1.gz ksh.1.gz 
/usr/share/man/man1/ksh93.1.gz --slave /usr/share/binfmts/ksh ksh-binfmt 
/usr/share/ksh/ksh93.binfmt --slave /bin/rksh rksh /bin/rksh93 --slave 
/usr/share/man/man1/rksh.1.gz rksh.1.gz /usr/share/man/man1/rksh93.1.gz
update-alternatives 2021-12-06 13:46:17: link group ksh updated to point to 
/bin/ksh93
update-alternatives 2021-12-06 13:46:17: run with --install /usr/bin/shcomp 
shcomp /usr/bin/shcomp93 20 --slave /usr/share/man/man1/shcomp.1.gz shcomp.1.gz 
/usr/share/man/man1/shcomp93.1.gz

at this date, and I can also see missing alternatives for ksh.

I can see that on another machine, dpkg was upgraded directly from
1.20.9 to 1.21.1, and I haven't noticed any issue there.

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



Bug#1003452: dpkg: missing alternatives for x-terminal-emulator

2022-01-12 Thread Guillem Jover
Hi!

On Mon, 2022-01-10 at 13:13:11 +0100, Vincent Lefevre wrote:
> Package: dpkg
> Version: 1.21.1
> Severity: important

> I notice that /usr/bin/mlterm is missing from the alternatives
> for x-terminal-emulator:
> 
> cventin:~> update-alternatives --display x-terminal-emulator
> x-terminal-emulator - manual mode
>   link best version is /usr/bin/gnome-terminal.wrapper
>   link currently points to /usr/bin/xterm
>   link x-terminal-emulator is /usr/bin/x-terminal-emulator
>   slave x-terminal-emulator.1.gz is 
> /usr/share/man/man1/x-terminal-emulator.1.gz
> /usr/bin/gnome-terminal.wrapper - priority 40
>   slave x-terminal-emulator.1.gz: /usr/share/man/man1/gnome-terminal.1.gz
> /usr/bin/koi8rxterm - priority 20
>   slave x-terminal-emulator.1.gz: /usr/share/man/man1/koi8rxterm.1.gz
> /usr/bin/lxterm - priority 30
>   slave x-terminal-emulator.1.gz: /usr/share/man/man1/lxterm.1.gz
> /usr/bin/urxvt - priority 20
>   slave x-terminal-emulator.1.gz: /usr/share/man/man1/urxvt.1.gz
> /usr/bin/uxterm - priority 20
>   slave x-terminal-emulator.1.gz: /usr/share/man/man1/uxterm.1.gz
> /usr/bin/xterm - priority 20
>   slave x-terminal-emulator.1.gz: /usr/share/man/man1/xterm.1.gz
> 
> This was also the case for the xterm related programs until
> I reinstalled xterm with dpkg -i.
> 
> Concerning mlterm and x-terminal-emulator, I can see in
> the /var/log/alternatives.log* log files from the latest
> mlterm upgrade until I noticed the issue:
> 
> update-alternatives 2021-08-16 16:27:55: run with --install 
> /usr/bin/x-terminal-emulator x-terminal-emulator /usr/bin/mlterm 20 --slave 
> /usr/share/man/man1/x-terminal-emulator.1.gz x-terminal-emulator.1.gz 
> /usr/share/man/man1/mlterm.1.gz
> update-alternatives 2021-08-22 01:56:43: run with --install 
> /usr/bin/x-terminal-emulator x-terminal-emulator 
> /usr/bin/gnome-terminal.wrapper 40 --slave 
> /usr/share/man/man1/x-terminal-emulator.1.gz x-terminal-emulator.1.gz 
> /usr/share/man/man1/gnome-terminal.1.gz
> update-alternatives 2021-09-13 09:49:58: run with --remove 
> x-terminal-emulator /usr/bin/urxvtcd
> update-alternatives 2021-09-13 09:50:00: run with --install 
> /usr/bin/x-terminal-emulator x-terminal-emulator /usr/bin/urxvt 20 --slave 
> /usr/share/man/man1/x-terminal-emulator.1.gz x-terminal-emulator.1.gz 
> /usr/share/man/man1/urxvt.1.gz
> update-alternatives 2021-09-27 14:08:32: run with --install 
> /usr/bin/x-terminal-emulator x-terminal-emulator 
> /usr/bin/gnome-terminal.wrapper 40 --slave 
> /usr/share/man/man1/x-terminal-emulator.1.gz x-terminal-emulator.1.gz 
> /usr/share/man/man1/gnome-terminal.1.gz
> update-alternatives 2021-11-23 13:29:02: run with --install 
> /usr/bin/x-terminal-emulator x-terminal-emulator 
> /usr/bin/gnome-terminal.wrapper 40 --slave 
> /usr/share/man/man1/x-terminal-emulator.1.gz x-terminal-emulator.1.gz 
> /usr/share/man/man1/gnome-terminal.1.gz
> update-alternatives 2021-12-06 13:49:47: run with --install 
> /usr/bin/x-terminal-emulator x-terminal-emulator 
> /usr/bin/gnome-terminal.wrapper 40 --slave 
> /usr/share/man/man1/x-terminal-emulator.1.gz x-terminal-emulator.1.gz 
> /usr/share/man/man1/gnome-terminal.1.gz
> update-alternatives 2021-12-06 13:49:47: link group x-terminal-emulator 
> updated to point to /usr/bin/gnome-terminal.wrapper
> update-alternatives 2022-01-05 11:01:08: run with --remove 
> x-terminal-emulator /usr/bin/urxvtcd
> update-alternatives 2022-01-05 11:04:12: run with --install 
> /usr/bin/x-terminal-emulator x-terminal-emulator /usr/bin/urxvt 20 --slave 
> /usr/share/man/man1/x-terminal-emulator.1.gz x-terminal-emulator.1.gz 
> /usr/share/man/man1/urxvt.1.gz
> 
> I wonder whether some upgrade of gnome-terminal or rxvt trashed the 
> alternatives.

From this log, it looks like on 2021-12-06 you upgraded, and probably
got dpkg 1.20.0, which then lost the alternatives, and restored  the
ones for gnome-terminal and rxvt, the other ones are then missing,
even after restoring the misplaced db. :/ Unfortunately w/o
declarative alternatives the current restoring logic is the best that
can be done, that will not leave cruft behind.

Thanks,
Guillem



Bug#1003452: dpkg: missing alternatives for x-terminal-emulator

2022-01-10 Thread Vincent Lefevre
Package: dpkg
Version: 1.21.1
Severity: important

I notice that /usr/bin/mlterm is missing from the alternatives
for x-terminal-emulator:

cventin:~> update-alternatives --display x-terminal-emulator
x-terminal-emulator - manual mode
  link best version is /usr/bin/gnome-terminal.wrapper
  link currently points to /usr/bin/xterm
  link x-terminal-emulator is /usr/bin/x-terminal-emulator
  slave x-terminal-emulator.1.gz is /usr/share/man/man1/x-terminal-emulator.1.gz
/usr/bin/gnome-terminal.wrapper - priority 40
  slave x-terminal-emulator.1.gz: /usr/share/man/man1/gnome-terminal.1.gz
/usr/bin/koi8rxterm - priority 20
  slave x-terminal-emulator.1.gz: /usr/share/man/man1/koi8rxterm.1.gz
/usr/bin/lxterm - priority 30
  slave x-terminal-emulator.1.gz: /usr/share/man/man1/lxterm.1.gz
/usr/bin/urxvt - priority 20
  slave x-terminal-emulator.1.gz: /usr/share/man/man1/urxvt.1.gz
/usr/bin/uxterm - priority 20
  slave x-terminal-emulator.1.gz: /usr/share/man/man1/uxterm.1.gz
/usr/bin/xterm - priority 20
  slave x-terminal-emulator.1.gz: /usr/share/man/man1/xterm.1.gz

This was also the case for the xterm related programs until
I reinstalled xterm with dpkg -i.

Concerning mlterm and x-terminal-emulator, I can see in
the /var/log/alternatives.log* log files from the latest
mlterm upgrade until I noticed the issue:

update-alternatives 2021-08-16 16:27:55: run with --install 
/usr/bin/x-terminal-emulator x-terminal-emulator /usr/bin/mlterm 20 --slave 
/usr/share/man/man1/x-terminal-emulator.1.gz x-terminal-emulator.1.gz 
/usr/share/man/man1/mlterm.1.gz
update-alternatives 2021-08-22 01:56:43: run with --install 
/usr/bin/x-terminal-emulator x-terminal-emulator 
/usr/bin/gnome-terminal.wrapper 40 --slave 
/usr/share/man/man1/x-terminal-emulator.1.gz x-terminal-emulator.1.gz 
/usr/share/man/man1/gnome-terminal.1.gz
update-alternatives 2021-09-13 09:49:58: run with --remove x-terminal-emulator 
/usr/bin/urxvtcd
update-alternatives 2021-09-13 09:50:00: run with --install 
/usr/bin/x-terminal-emulator x-terminal-emulator /usr/bin/urxvt 20 --slave 
/usr/share/man/man1/x-terminal-emulator.1.gz x-terminal-emulator.1.gz 
/usr/share/man/man1/urxvt.1.gz
update-alternatives 2021-09-27 14:08:32: run with --install 
/usr/bin/x-terminal-emulator x-terminal-emulator 
/usr/bin/gnome-terminal.wrapper 40 --slave 
/usr/share/man/man1/x-terminal-emulator.1.gz x-terminal-emulator.1.gz 
/usr/share/man/man1/gnome-terminal.1.gz
update-alternatives 2021-11-23 13:29:02: run with --install 
/usr/bin/x-terminal-emulator x-terminal-emulator 
/usr/bin/gnome-terminal.wrapper 40 --slave 
/usr/share/man/man1/x-terminal-emulator.1.gz x-terminal-emulator.1.gz 
/usr/share/man/man1/gnome-terminal.1.gz
update-alternatives 2021-12-06 13:49:47: run with --install 
/usr/bin/x-terminal-emulator x-terminal-emulator 
/usr/bin/gnome-terminal.wrapper 40 --slave 
/usr/share/man/man1/x-terminal-emulator.1.gz x-terminal-emulator.1.gz 
/usr/share/man/man1/gnome-terminal.1.gz
update-alternatives 2021-12-06 13:49:47: link group x-terminal-emulator updated 
to point to /usr/bin/gnome-terminal.wrapper
update-alternatives 2022-01-05 11:01:08: run with --remove x-terminal-emulator 
/usr/bin/urxvtcd
update-alternatives 2022-01-05 11:04:12: run with --install 
/usr/bin/x-terminal-emulator x-terminal-emulator /usr/bin/urxvt 20 --slave 
/usr/share/man/man1/x-terminal-emulator.1.gz x-terminal-emulator.1.gz 
/usr/share/man/man1/urxvt.1.gz

I wonder whether some upgrade of gnome-terminal or rxvt trashed the 
alternatives.

-- Package-specific info:

-- System Information:
Debian Release: bookworm/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'stable-updates'), (500, 
'stable-security'), (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 
'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.15.0-2-amd64 (SMP w/12 CPU threads)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, 
TAINT_UNSIGNED_MODULE
Locale: LANG=POSIX, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages dpkg depends on:
ii  libbz2-1.0   1.0.8-5
ii  libc62.33-1
ii  liblzma5 5.2.5-2
ii  libselinux1  3.3-1+b1
ii  tar  1.34+dfsg-1
ii  zlib1g   1:1.2.11.dfsg-2

dpkg recommends no packages.

Versions of packages dpkg suggests:
ii  apt2.3.13
pn  debsig-verify  

-- no debconf information

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)