Monday 30 March 2015

Installing conflicting packages on Ubuntu

Currently, Wine and CUDA cannot be both installed due to a conflict between ocl-icd-libopencl1 and nvidia-opencl-icd-340, because they both contain the files /usr/lib/x86_64-linux-gnu/libOpenCl.so.1.0.0 and /usr/lib/i386-linux-gnu/libOpenCL.so.1.0.0 as well as symlinks for those files.


Method 1:
One way to solve this problem is to cheat the Ubuntu package manager that CUDA is not installed but if fact it is installed.
The steps are as follows:
  1. a. get the package list: dpkg --get-selections > anyfile
    b. edit anyfile to set nvidia-opencl-icd-340 as deinstalled, save the file
    c. set the package list: dpkg --set-selections < anyfile
  2. edit the corresponding file /var/lib/dpkg/status, for every package you want to set to deinstalled, delete the entire entry, save the file.
  3. Resolve conflicts apt-get clean aptitude
Repeat Steps 1-3 for every conflicts you encounter, set those packages to deinstalled.
  1. Install wine using apt-get or aptitude
In this way, you will have both Wine and CUDA physically installed (and you can run both correctly), but the package manager will only see that Wine is installed. As a result, you won't be able to directly install subsequent packages like python-pycuda which depends on CUDA. You can either install them from source or download the .deb file and use dpkg to force install them ignoring dependency, and then repeat Steps 1 and 2 to set them as deinstalled.


Method 2 (better):
Once you understand how this mechanism works. Now you can make the whole process easier by directly modifying the Conflict/Depends/Provides entries of related packages in /var/lib/dpkg/status before running apt-get install, so that the conflicts no longer exist in the first place when you run apt-get install.
For INSTALLED packages, you can modify the dependency settings in /var/lib/dpkg/status so that they will no longer cause any conflict with new packages to be installed.
For not-yet-installed packages, you can modify their dependencies in /var/lib/apt/lists/*_Packages, so that they can be installed without conflicting with existing packages.
Since the dependency information is also present in the *.deb package files, direct installation using apt-get/aptitude will fail, you need to install them forcefully, i.e.,
dpkg --force-all -i *.deb

The second method is more powerful because the package manager will now see both Wine and CUDA installed. Thus, you can use apt-get to install subsequent packages which depends on Wine and CUDA without incurring any conflict or unmet dependencies. Moreover, changing or updating repositories (apt-get update) will not cause the conflict to re-occur.

No comments:

Post a Comment