我无法从 22.04 升级到 24.04.1,因为 do-release-upgrade 停止并且声称 usr 未合并。
但是如果我以 root 身份运行 usrmerge,它会出现一条消息,表明已成功合并 usr。
但还是有错误。我以为它可能会以 exit 1 退出,但事实似乎并非如此。echo $? 返回 0。
我创建了一个包装脚本,它调用 usrmerge 并以 0 退出。但 do-release-upgrade 仍然失败,声称 usr 未合并,我应该安装包 usrmerge 来解决这个问题。
$ sudo LANG=C do-release-upgrade
Checking for a new Ubuntu release
= Welcome to Ubuntu 24.04 LTS 'Noble Numbat' =
[...]
Reading state information... Done
Cannot upgrade system with unmerged /usr
Please install the usrmerge package to fix this, and then try the
upgrade again.
Restoring original system state
Aborting
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
=== Command detached from window (Thu Oct 17 23:28:58 2024) ===
=== Command terminated with exit status 1 (Thu Oct 17 23:29:08 2024) ===
我编写了一个包装脚本,但是它像原始脚本一样返回 0,尽管原始脚本在第 172 行的 Smartmatch 上发出了警告。
$ sudo cat /usr/lib/usrmerge/convert-usrmerge
#!/bin/bash
/usr/lib/usrmerge/convert-usrmerge_bin 2> /dev/null
exit 0
运行包装器
$ sudo LANG=C /usr/lib/usrmerge/convert-usrmerge
The system has been successfully converted.
直接运行 usrmerge 脚本
$ sudo LANG=C /usr/lib/usrmerge/convert-usrmerge_bin
Smartmatch is experimental at /usr/lib/usrmerge/convert-usrmerge_bin line 172.
The system has been successfully converted.
$ echo $?
0
$ LANG=C apt policy usrmerge
usrmerge:
Installed: 25ubuntu2
Candidate: 25ubuntu2
Version table:
*** 25ubuntu2 500
500 http://de.archive.ubuntu.com/ubuntu jammy/main amd64 Packages
500 http://de.archive.ubuntu.com/ubuntu jammy/main i386 Packages
100 /var/lib/dpkg/status
$ sudo LANG=C sha1sum /usr/lib/usrmerge/convert-usrmerge_bin
ddc18b09fdc448c2d8aa2c94669501500482388e /usr/lib/usrmerge/convert-usrmerge_bin
$ sudo LANG=C cat -n /usr/lib/usrmerge/convert-usrmerge_bin | egrep '^[[:space:]]*172'
172 if (-e "/usr$n" && $n ~~ @generated_files) {
$ sudo LANG=C cat -n /usr/lib/usrmerge/convert-usrmerge_bin | egrep -C10 '^[[:space:]]*172'
162 fatal("Both $n and /usr$n exist");
163 }
164
165 # generated files
166 # if it was already re-generated in the new place, clear the legacy location
167 # Origin of generated files:
168 # /lib/udev/hwdb.bin -> 'systemd-hwdb --usr update'
169 my @generated_files = qw(
170 /lib/udev/hwdb.bin
171 );
172 if (-e "/usr$n" && $n ~~ @generated_files) {
173 rm('-f', "$n");
174 return;
175 }
176
177 fatal("$n is a directory and /usr$n is not")
178 if -d $n and -e "/usr$n";
179 fatal("/usr$n is a directory and $n is not")
180 if -d "/usr$n";
181 fatal("Both $n and /usr$n exist")
182 if -e "/usr$n";
以下是 strace 输出 https://pastebin.ubuntu.com/p/c3wghnxPJ7/
我编辑了 convert-usrmerge 以避免出现警告,它有效
use lib "/usr/lib/usrmerge/lib";
use warnings;
# https://www.reddit.com/r/perl/comments/60b3tr/ how_to_suppress_experimental_warning_for/
# to solve https://askubuntu.com/questions/1530232/do-release-upgrade-fails-due-to-usrmerge-and-smartmatch
no if $] >= 5.018, warnings => "experimental::smartmatch";
use feature "switch";
use strict;
use autodie;
但不幸的是,它并没有解决 do-release-upgrade 声称 usr 没有合并并对此抱怨并且没有启动升级过程的问题。
因此 Smartmatch 似乎不是罪魁祸首。
我不知道如何调试 perlscript,但我还是发布了我的尝试:
$ sudo LANG=C perl -d /usr/lib/usrmerge/convert-usrmerge
Loading DB routines from perl5db.pl version 1.60
Editor support available.
Enter h or 'h h' for help, or 'man perldebug' for more help.
main::(/usr/lib/usrmerge/convert-usrmerge:27):
27: my $Debug = 1;
DB<1> n
main::(/usr/lib/usrmerge/convert-usrmerge:28):
28: my $Program_RC = 0;
DB<1> n
main::(/usr/lib/usrmerge/convert-usrmerge:30):
30: check_free_space();
DB<1> n
main::(/usr/lib/usrmerge/convert-usrmerge:32):
32: go_faster();
DB<1> n
main::(/usr/lib/usrmerge/convert-usrmerge:35):
35: $SIG{__DIE__} = sub { fatal($_[0]); };
DB<1> n
main::(/usr/lib/usrmerge/convert-usrmerge:38):
38: foreach my $name (early_conversion_files()) {
DB<1> n
main::(/usr/lib/usrmerge/convert-usrmerge:38):
38: foreach my $name (early_conversion_files()) {
DB<1> n
main::(/usr/lib/usrmerge/convert-usrmerge:43):
43: my @dirs = directories_to_merge();
DB<1> n
main::(/usr/lib/usrmerge/convert-usrmerge:46):
46: foreach my $dir (@dirs) {
DB<1> n
main::(/usr/lib/usrmerge/convert-usrmerge:47):
47: mkdir("/usr$dir") if not -e "/usr$dir";
DB<1> n
main::(/usr/lib/usrmerge/convert-usrmerge:47):
47: mkdir("/usr$dir") if not -e "/usr$dir";
DB<1> n
main::(/usr/lib/usrmerge/convert-usrmerge:47):
47: mkdir("/usr$dir") if not -e "/usr$dir";
DB<1> n
main::(/usr/lib/usrmerge/convert-usrmerge:47):
47: mkdir("/usr$dir") if not -e "/usr$dir";
DB<1> n
main::(/usr/lib/usrmerge/convert-usrmerge:47):
47: mkdir("/usr$dir") if not -e "/usr$dir";
DB<1> n
main::(/usr/lib/usrmerge/convert-usrmerge:47):
47: mkdir("/usr$dir") if not -e "/usr$dir";
DB<1> n
main::(/usr/lib/usrmerge/convert-usrmerge:50):
50: my @later;
DB<1> n
main::(/usr/lib/usrmerge/convert-usrmerge:51):
51: my $rule = File::Find::Rule->mindepth(1)->maxdepth(1)->start(@dirs);
DB<1> n
main::(/usr/lib/usrmerge/convert-usrmerge:52):
52: while (defined (my $name = $rule->match)) {
DB<1> n
main::(/usr/lib/usrmerge/convert-usrmerge:58):
58: convert_file($_) foreach @later;
DB<1> n
main::(/usr/lib/usrmerge/convert-usrmerge:60):
60: verify_links_only($_) foreach @dirs;
DB<1> n
main::(/usr/lib/usrmerge/convert-usrmerge:62):
62: convert_directory($_) foreach @dirs;
DB<1> n
main::(/usr/lib/usrmerge/convert-usrmerge:64):
64: exit($Program_RC) if $Program_RC;
DB<1> n
main::(/usr/lib/usrmerge/convert-usrmerge:65):
65: print "The system has been successfully converted.\n";
DB<1> n
The system has been successfully converted.
main::(/usr/lib/usrmerge/convert-usrmerge:66):
66: exit;
DB<1> n
Debugged program terminated. Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.
DB<1> q
据我所知 usr 已经合并
lrwxrwxrwx 1 root root 7 Jun 24 2022 bin -> usr/bin
drwxr-xr-x 44 root root 4096 Okt 16 11:59 boot
drwxr-xr-x 2 root root 4096 Okt 2 2012 cdrom
drwxr-xr-x 3 root root 4096 Okt 31 2019 custom
drwxr-xr-x 22 root root 5720 Okt 17 23:14 dev
drwxr-xr-x 2 root root 4096 Aug 29 2021 dracut
drwxr-xr-x 244 root root 20480 Okt 17 23:13 etc
drwxr-xr-x 2 root root 4096 Dez 19 2019 export
drwxr-xr-x 6 root root 4096 Okt 30 2012 export_ofs
drwxr-xr-x 3 root root 4096 Okt 2 2012 home
drwxr-xr-x 2 root root 4096 Jan 19 2020 images
lrwxrwxrwx 1 root root 8 Mai 6 15:35 lib -> /usr/lib
lrwxrwxrwx 1 root root 9 Jun 24 2022 lib32 -> usr/lib32
lrwxrwxrwx 1 root root 9 Jun 24 2022 lib64 -> usr/lib64
lrwxrwxrwx 1 root root 36 Mär 30 2014 libnss3.so -> /usr/lib/x86_64-linux-gnu/libnss3.so
drwxr-xr-x 3 root root 4096 Mai 5 01:02 lib-rootfolder
lrwxrwxrwx 1 root root 10 Jun 24 2022 libx32 -> usr/libx32
drwx------ 2 root root 16384 Sep 30 2012 lost+found
drwxr-xr-x 4 root root 4096 Jul 2 2022 media
drwxr-xr-x 8 root root 4096 Feb 22 2022 mnt
drwxr-xr-x 3 root root 4096 Okt 31 2012 net
drwxr-xr-x 2 root root 4096 Jan 19 2020 NST
drwxr-xr-x 5 root root 4096 Jun 24 2022 opt
dr-xr-xr-x 413 root root 0 Okt 17 23:14 proc
drwx------ 17 root root 4096 Okt 18 14:34 root
drwxr-xr-x 51 root root 1560 Okt 18 00:00 run
lrwxrwxrwx 1 root root 8 Jun 24 2022 sbin -> usr/sbin
drwxr-xr-x 38 root root 4096 Aug 10 17:54 snap
drwxr-xr-x 2 root root 4096 Apr 25 2012 srv
dr-xr-xr-x 13 root root 0 Okt 17 23:14 sys
drwxrwxrwt 26 root root 12288 Okt 18 14:45 tmp
drwxr-xr-x 17 root root 4096 Jun 24 2022 usr
drwxr-xr-x 15 root root 4096 Jun 3 2018 var
drwxr-xr-x 2 root root 4096 Sep 2 2020 zfspool
$ ls -l /usr
insgesamt 324
drwxr-xr-x 2 root root 135168 Okt 17 23:13 bin
drwxr-xr-x 2 root root 4096 Okt 17 23:09 games
drwxr-xr-x 3 root root 4096 Jun 24 2022 i686-w64-mingw32
drwxr-xr-x 105 root root 20480 Okt 14 14:33 include
drwxr-xr-x 203 root root 57344 Okt 16 12:33 lib
drwxr-xr-x 3 root root 4096 Jun 26 15:18 lib32
drwxr-xr-x 3 root root 4096 Jun 26 15:18 lib64
drwxr-xr-x 32 root root 12288 Okt 14 14:34 libexec
drwxr-xr-x 2 root root 4096 Jun 24 2022 libx32
drwxr-xr-x 12 root root 4096 Mai 21 2022 local
drwxr-xr-x 3 root root 4096 Jul 31 2016 locale
drwxr-xr-x 2 root root 32768 Okt 16 11:59 sbin
drwxr-xr-x 555 root root 20480 Okt 17 23:09 share
drwxr-xr-x 19 root root 4096 Okt 16 11:50 src
drwxr-xr-x 3 root root 4096 Jun 24 2022 x86_64-w64-mingw32
我希望有人知道解决方法。
我只看到手动更新我的 sources.list 并进行升级而没有 do-release-upgrade,因为 usrmerge 说 usr 已成功转换而 do-release-upgrade 说相反,我不明白为什么。
短暂性脑缺血发作
弗洛吉