ubuntu-22.04

E: Package 'lib32gcc1' has no installation candidate


I installed the UR-Sim file (https://www.universal-robots.com/download/software-cb-series/simulator-linux/offline-simulator-cb-series-linux-ursim-1816941tarqz/). Im Using Ubuntu 22.04.

When i run $ ./install.sh i recived the error $ Installed java version is too old, exiting so i replaced in install.sh the needToInstallJava() function

needToInstallJava() {
    echo "Checking java version"
    if command -v java; then
    # source https://stackoverflow.com/questions/7334754/correct-way-to-check-java-version-from-bash-script
        version=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}')

    echo "Stripping the front end"
    majorVersion=${version%%.*}
        echo Java major version "$majorVersion"
    if [ "`echo "$majorVersion > 1.6" | bc`" -eq 1 ]; then
        echo "java version accepted"
            return 0
    fi
    fi
    return 1
}

When i run with the changed file $ ./install.sh i get following output.

Checking java version
/usr/bin/java
Stripping the front end
Java major version 11
java version accepted
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'libjava3d-java-doc' for glob 'libjava3d-*'
Note, selecting 'libjava3d-jni' for glob 'libjava3d-*'
Note, selecting 'libjava3d-java' for glob 'libjava3d-*'
Note, selecting 'ttf-dejavu-core' for glob 'ttf-dejavu*'
Package lib32gcc1 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  lib32gcc-s1

Package libcurl3 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  libcurl4:i386 libcurl4

E: Package 'lib32gcc1' has no installation candidate
E: Package 'libcurl3' has no installation candidate

How can i solve this?


Solution

  • Source of the problem

    In the install.sh script, the following two lines are problematic on the Ubuntu 22.04 distro:

    sudo apt-get install -y lib32gcc1 libc6-i386
    sudo dpkg -i urtool/*.deb
    

    The problem arises because the package lib32gcc1 was renamed to lib32gcc-s1 in this distro's repos. In the second line, the urtool/*.deb (urtool/urtool3_0.3_amd64.deb) has lib32gcc1 as a dependency. As the dependency is not present, dpkg refuses to install the package.

    Solution by editing the .deb file

    In order to fix this, you can edit the .deb file to have lib32gcc-s1 as a dependency instead of lib32gcc1. First, you should install the lib32gcc-s1 package.


    Note for similar problems to this one: This approach would not work if the binaries inside the dependency packages changed names. You can check this with:

    dpkg -L lib32gcc-s1 | xargs file
    

    Which shows the following output:

    /.:                         directory
    /usr:                       directory
    /usr/lib32:                 directory
    /usr/lib32/libgcc_s.so.1:   ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, BuildID[sha1]=bc9d0c313ce683defc25191bac6f913fa197d2d1, stripped
    /usr/share:                 directory
    /usr/share/doc:             directory
    /usr/share/doc/lib32gcc-s1: symbolic link to gcc-12-base
    

    There's only one executable in this package - namely, libgcc_s.so.1. If you check the content of lib32gcc1 package, you will find identically named file there. (If you wanted to be completely sure the executables are the same, you could compare their md5 checksums or look into source code and see if there were any changes since the package rename.)


    Analyzing the .deb file

    A .deb file is just an ar archive file that contains the data relevant for installing the package: executables, installation instructions, dependencies, metadata, etc. To extract the archive data, cd into urtool and run:

    ar x urtool3_0.3_amd64.deb
    

    You should be able to see the following list of files: control.tar.gz, data.tar.gz, debian-binary. Dependency data is contained inside control.tar.gz.

    Unpacking control.tar.gz

    Let's create new directory and extract the control archive there:

    mkdir extras-control
    tar -C extras-control -zxf control.tar.gz
    

    You should see the following list of files inside extras-control: conffiles, control, md5sums, postinst, postrm, shlibs. Dependency info is inside the control file. Open it with your text editor of choice and change the line:

    Depends: lib32gcc1, ...
    

    to

    Depends: lib32gcc-s1, ...
    

    Packing it back up

    Now that the dependency is changed, first pack up the unpacked .tar directory, and then move it to the outer directory:

    tar cfz control.tar.gz *
    mv control.tar.gz ..
    

    Then, in the outer directory, using ar pack up the following files into a new .deb package with:

    ar r new_urtool3.deb debian-binary control.tar.gz data.tar.gz 
    

    Finally, install your new package:

    sudo dpkg -i new_urtool3.deb