Friday 1 May 2015

Install Office2010 in Wine1.7 on Ubuntu 14.04

At May 2015, since newer versions of Ubuntu and Wine does not install winbind and samba by default, using the old method for installing Office2010 will cause an error:
err:msi:ITERATE_Actions Execution halted, action L"CAInstallSppPlugin.x86" returned 1603

and fail halfway with "Microsoft Office has encountered an error during setup" and the installation will abort.

Here are the steps:
1. install wine1.7 via ppa (root)
add-apt-repository ppa:ubuntu-wine/ppa
apt-get update
apt-get install wine1.7

2. install OpenGL packages
apt-get install mesa-utils mesa-utils-extra libgl1-mesa-glx:i386 libgl1-mesa-dev lib32z1

3. link OpenGL packages
ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/mesa/libGL.so
ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so /usr/lib/i386-linux-gnu/libGL.so

4. install samba and winbind
apt-get install samba winbind

5. create 32-bit wine prefix
export WINEARCH=win32
export WINEPREFIX=$HOME/.wine32
(you can name .wine32 to anything you like, but subsequent things you do will only apply to that prefix folder)


6. (Optional) install winetrick dll components
winetricks vcrun2008 dotnet20 dotnet40 msxml6
winetricks riched20 riched30 gdiplus vb6run ie8 corefonts

7. run winecfg
make sure it is Windows XP, with riched20 and gdiplus set to native(windows)

8. Run office2010 setup
wine office2010-setup/setup.exe

9. Edit registry
If you encounter a window pop out saying "Please wait while windows configures Microsoft Office Professional Plus 2010" everytime you open Word2010, run registry editor to add the following variable:
reg add HKCU\Software\Microsoft\Office\14.0\Word\Options /v NoReReg /t REG_DWORD /d 1

10. Set environment to type Chinese in Office,
LC_ALL=zh_CN.UTF-8 wine .wine32/drive_c/Program\ Files/Microsoft\ Office/Office14/WINWORD.EXE

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.