更新后出现错误 Ubuntu 从 20.10 更新至 Hirsute Hippo (21.04)

更新后出现错误 Ubuntu 从 20.10 更新至 Hirsute Hippo (21.04)

尝试更新时,错误重重:

FATAL ERROR:
Both /lib/x86_64-linux-gnu/libselinux.so.1 and /usr/lib/x86_64-linux-gnu/libselinux.so.1 exist.

You can try correcting the errors reported and running again
/usr/lib/usrmerge/convert-usrmerge until it will complete without errors.
Do not install or update other Debian packages until the program
has been run successfully.

dpkg: error processing usrmerge package (--configure): 
installed usrmerge package post-installation script subprocess returned error exit status 1

我尝试使用以下命令修复它:sudo apt -f install,,sudo dpkg --configure -a但没有任何帮助,错误没有消失!告诉我你如何修复它?

答案1

谢谢!我找到了解决问题的方法!也许有人会用得上!

cd /var/lib/dpkg/info
sudo rm usrmerge.*
sudo apt-get -f install

答案2

我也遇到了这个问题。它有点与https://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge/(我并未关注此事的全部历史)。

我还发现文件在 /bin 和 /usr/bin 之间重复,但 /bin 中的文件较新。我usrmerge没法处理这种情况。所以我帮了他,我做了以下事情:

for f in `find /bin -mindepth 1 ! -type l`; do sudo mv $f /usr/bin/$(basename ${f}); sudo ln -s /usr/bin/$(basename ${f}) $f;done
for f in `find /sbin -mindepth 1 ! -type l`; do sudo mv $f /usr/sbin/$(basename ${f}); sudo ln -s /usr/sbin/$(basename ${f}) $f;done
for f in `find /lib/systemd/system -mindepth 1 ! -type l`; do sudo mv $f /usr/lib/systemd/system/$(basename ${f}); sudo ln -s /usr/lib/systemd/system/$(basename ${f}) $f;done
for f in `find /lib/udev/rules.d -mindepth 1 ! -type l`; do sudo mv $f /usr/lib/udev/rules.d/$(basename ${f}); sudo ln -s /usr/lib/udev/rules.d/$(basename ${f}) $f;done

它可以适应任何有冲突的文件夹。对于你的情况,我认为:

for f in `find /lib/x86_64-linux-gnu -mindepth 1 ! -type l`; do sudo mv $f /usr/lib/x86_64-linux-gnu/$(basename ${f}); sudo ln -s /usr/lib/x86_64-linux-gnu/$(basename ${f}) $f;done

它仅创建指向 /usr/ 的符号链接.*

答案3

我有一个系统许多必须手动更正 /usr 不同子目录中的文件才能正常/usr/lib/usrmerge/convert-usrmerge运行。

受到@cactuschibre 的回答的启发,我创建了一个小型 shell 脚本,它可以自动更正给定的目录并进行一些健全性检查:

#!/bin/sh                                                                                                                                                                                                           

dir=$1

if [ ! -d $dir -o ! -d /usr/$dir ]; then
    exit 1
fi

verbose () {
    echo "$@" >&2
    "$@"
}

for f in $(find $dir -mindepth 1 ! -type l ! -type d); do

    # check if the same file exists in /usr
    #
    if [ -e /usr$f ]; then

        echo "---" >&2

        # check if either the file in /usr is older or if both files are the same
        #
        if [ /usr$f -ot $f ] || cmp -s /usr$f $f; then

            ls -l $f /usr$f
            dpkg -S $f
            dpkg -S /usr$f

            # if the `dpkg -S /usr$f command above failed it means that no
            # package installed the file to /usr. Therefore it should be safe
            # to overwrite the file in /usr w/o interfering with an installed
            # package.
            #
            if [ $? = 1 ]; then
                verbose rm /usr$f
                verbose mv $f /usr$f
                verbose ln -s /usr$f $f
            fi
        else
            echo /usr$f is newer than $f or files are not the same. >&2
            echo PLEASE RESOLVE THIS CONFLICT MANUALLY. >&2
        fi
    fi
done

使用如下脚本:

  1. 从...开始/usr/lib/usrmerge/convert-usrmerge
  2. 如果convert-usrmerge返回某个目录(例如 /lib)中的文件错误,则使用该目录调用上述脚本
  3. 该脚本将更正给定目录中的所有文件
  4. 从 1 重新开始。convert-usrmerge可能会抱怨另一个目录中的冲突......

答案4

它对我有用。

sudo apt-get update && sudo apt-get upgrade

抱怨:dpkg:警告:缺少软件包“usrmerge”的文件列表文件;假设软件包当前没有安装任何文件

但除此之外,它运行良好,所以我可以忍受。

相关内容