9

When trying to update, the error weighs:

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

I tried to fix it with the commands: sudo apt -f install, sudo dpkg --configure -a, nothing helps, the error does not disappear! Tell me how you can fix it?

N0rbert
  • 99,918
rixxar
  • 221
  • 1
    You may want to report it as a bug. https://help.ubuntu.com/stable/ubuntu-help/report-ubuntu-bug.html.en – David Apr 25 '21 at 09:01
  • 1
    Please [edit] your question to indicate what you were updating from to 21.04 and the steps taken to do so. – graham Apr 25 '21 at 09:01
  • Have you tried to run sudo /usr/lib/usrmerge/convert-usrmerge ? – N0rbert Apr 25 '21 at 10:46
  • Tried it, it did not help (, Here is the log from the terminal below: – rixxar Apr 25 '21 at 10:59
  • 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.

    – rixxar Apr 25 '21 at 10:59

4 Answers4

13

Thank you! I found a solution to my problem! Maybe someone will come in handy!

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

I also encountered the problem. It is kinda linked to https://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge/ (I did not followed all the history of this).

I identified also files were duplicated between /bin and /usr/bin for example, but more recent in /bin. And usrmerge was unable to managed this situation. So I helped him and I did this:

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

It can be adapted to any folder in conflict. For your case, I think:

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

It only creates symlinks pointing to /usr/.*

  • All those files you are moving around belong to various packages,and I imagine that you will have created a lot of future problems with updating those packages. – mc0e Oct 24 '23 at 12:13
  • 1
    No problem at all since this post neither since 2012, the year of my last fresh install of Linux I have ever done on my native Linux machine. Updated & upgraded every week , regularly moved on different hardware, without any (major) problem. Of course, when you move / modify system binaries, you take some risk. I know them and how to fix them. Users should learn them too. – cactuschibre Oct 25 '23 at 16:12
1

I had a system where many files in different subdirectories of /usr would have to have corrected manually in order to get /usr/lib/usrmerge/convert-usrmerge running w/o errors.

Inspired by the answer from @cactuschibre I created a little shell script which does an automated correction of a given directory with some more sanity checks:

#!/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

Use the script like this:

  1. start with /usr/lib/usrmerge/convert-usrmerge
  2. if convert-usrmerge returns with an error with a file in a certain directory (e.g. /lib) then call the above script with this directory
  3. the script will correct all files in the given directory
  4. start over with 1. convert-usrmerge will possibly complain about a conflict in another directory...
  • I'm thinking I needs something similar, but in my case the bad duplicate files are not owned by any packages, which can be checked with e.g. dpkg-query -S /usr/bin/bash. As a more cautious first step I want to only delete files in /usr/bin that are not owned by any package, and where there's a duplicate in /bin. thanks for writing most of the script I want though. – mc0e Oct 24 '23 at 14:27
0

It worked for me.

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

complains that: dpkg: warning: files list file for package 'usrmerge' missing; assuming package has no files currently installed

but it runs fine otherwise, so I can live with this.