~hristoast/hristoast

hristoast/site/wine-is-not-an-emulator-but-it-is-awesome.html -rw-r--r-- 8.8 KiB
4c97c4e5Hristos N. Triantafillou No more zen2 12 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<h1 id="title">Wine is not an emulator, but it is awesome</h1>

<div id="dates">
  <span>Posted: <time id="post-date">2015-09-08</time> | Updated: <time>2019-11-09</time></span>
</div>

<p><span class="bold">UPDATE 2, 2019-11-09:</span>Since I initially posted this, Valve has released <a href="https://github.com/ValveSoftware/Proton">Proton</a> and a whole lot has changed!</p>

<p><strong>UPDATE 2015-09-25</strong>: <a href="https://wine-staging.com/news/2015-09-25-winehq-integration.html" target="_blank">It looks like wine-staging will soon be integrated into the main wine codebase</a>!</p>

<p id="post-excerpt"><a href="http://winehq.org/" target="_blank">Wine</a> sometimes seems to get a bad wrap, but it really is an amazing project. With it, GNU/Linux users (and Mac users, too!) can run Windows applications - <a href="https://appdb.winehq.org/" target="_blank">many of them nearly flawlessly</a>. One thing I&#39;ve found that&#39;s helped me get the most out of wine is to use the latest development versions. Debian and friends usually only keep stable releases in their repositories, so you can easily miss out on a lot.</p>

<p>If you aren&#39;t using a rolling-release distribution it can be hard to find up-to-date packages for your package manager. Or maybe it isn&#39;t exactly hard to find them, but I personally don&#39;t love adding 3rd party repositories (especially just for one package.)</p>

<p>But hey, this is free/open source software we&#39;re talking about, so why not just build and package it ourselves?! In the spirit of DIY, I&#39;ll go over installing the <a href="https://github.com/wine-compholio/wine-staging/" target="_blank">wine-staging</a> patchset, compiling wine, and then finally, package it up into a deb. Get your compilers ready kids!</p>

<div id="toc"></div>

<h3>Getting ready</h3>

<p>I&#39;m working on a 32-bit Linux Mint Debian Edition system; your mileage may vary if this isn&#39;t what you use, but it should be fine as a guide for other distributions. I personally prefer to build on a VM, but that isn&#39;t necessary. Commands that start with a <code>#</code> mean they need to be ran as a superuser or with superuser privileges, commands starting with <code>$</code> need to be ran as a regular non-privileged user. The version of wine I&#39;ll be building is <a href="https://www.winehq.org/announce/1.7.51" target="_blank">1.7.51</a>.</p>

<p>You first need to make sure that source packages are enabled in your <code>sources.list</code> or similar. Here&#39;s what mine looks like:</p>

<pre><code>deb http://packages.linuxmint.com betsy main upstream import
deb-src http://packages.linuxmint.com betsy main upstream import

deb http://ftp.us.debian.org/debian jessie main contrib non-free
deb-src http://ftp.us.debian.org/debian jessie main contrib non-free
deb http://ftp.us.debian.org/debian jessie-updates main contrib non-free
deb-src http://ftp.us.debian.org/debian jessie-updates main contrib non-free
deb http://security.debian.org jessie/updates main contrib non-free

deb http://www.deb-multimedia.org jessie main non-free
deb-src http://www.deb-multimedia.org jessie main non-free

deb http://extra.linuxmint.com betsy main
deb-src http://extra.linuxmint.com betsy main</code></pre>

<p>Those are the lines starting with <code>deb-src</code>. Then, update:</p>

<pre><code># apt-get update</code></pre>

<p>Next, install the required packages for building wine:</p>

<pre><code># apt-get build-dep wine
# apt install libcapi20-dev libgtk-3-dev libsane-dev ocl-icd-opencl-dev git libva-dev</code></pre>

<p>This will get you everything you need to build a fully functioning wine. Now, we&#39;ll get the rest of the things we need to wrap everything up.</p>

<h3>Build tools</h3>

<p>It is with the aid of many build tools that this endeavor is even possible. We&#39;ll be using standard build tools along with some more specialized ones that will make creating the final <code>.deb</code> package a breeze.</p>

<p>Install the system package requirements:</p>

<pre><code># apt-get install build-essential git ruby</code></pre>

<p>Then, use gem to install the ruby dependencies:</p>

<pre><code># gem install fpm lolcat</code></pre>

<p>Note that <code>lolcat</code> isn&#39;t mandatory, but they make the experience better. You can also use something like <a href="https://github.com/sstephenson/rbenv" target="_blank">rbenv</a> instead of installing a system ruby, and that&#39;s totally cool too.</p>

<h3>Get the code</h3>

<p>Now&#39;s when you&#39;ll want to download the wine sources as well as the staging patchset. Make sure you&#39;re in the place you want to keep the sources in, if that matters to you, and also that you&#39;re not a superuser anymore:</p>

<pre><code>$ cd ~
$ git clone git://source.winehq.org/git/wine.git
$ git clone https://github.com/wine-compholio/wine-staging.git</code></pre>

<p>Then, check out the appropriate versions:</p>

<pre><code>$ cd ~
$ cd ~/wine
$ git checkout wine-1.7.51
$ cd ~/wine-staging
$ git checkout v1.7.51</code></pre>

<p>Now, we&#39;re ready to patch wine and build.</p>

<h3>Patch and build!</h3>

<p>And now, the action begins. First we need to apply the patches from wine-staging:</p>

<pre><code>$ cd ~/wine-staging/patches
$ ./patchinstall.sh --all DESTDIR=~/wine</code></pre>

<p>With that we are ready to begin building wine, follow along:</p>

<pre><code>$ mkdir wine1751
$ cd ~/wine
$ ./configure --prefix=${INSTALL_PREFIX}
$ let &quot;j=$(cat /proc/cpuinfo | grep pro | wc -l) + 1&quot;
$ make -j${j}
$ make install DESTDIR=${HOME}/wine1751</code></pre>

<p>Here I&#39;m programatically telling <code>make</code> to use all of your CPUs plus one, so if that&#39;s not what you want please feel free to omit the <code>-j${j}</code> bit from the above snippet. It will make the build go by more quickly, but at the expense of using all of your CPU.</p>

<p>And finally, we create our <code>.deb</code> package (this one&#39;s a doozy):</p>

<pre><code>$ fpm -m your_email@goes-here.com -s dir -t deb -n &quot;wine&quot; -v 1.7.51 \
    -C ${HOME}/wine1751 -p ~/wine-full_VERSION-ITERATION_ARCH.deb \
    --category otherosfs --depends libasound2-plugins --depends libc6 \
    --depends libgstreamer-plugins-base0.10-0 --depends libfreetype6 \
    --depends libldap-2.4-2 --depends libmpg123-0 --depends libncurses5 \
    --depends libpng12-0 --depends x11-utils --description &quot;${DESCRIPTION}&quot; \
    --iteration 1 --provides libwine --provides libwine-capi \
    --provides libwine-gl --provides libwine-ldap --provides libwine-openal \
    --provides libwine-print --provides libwine-sane --provides wine32 \
    --provides wine-bin --provides wine-doc --provides wine-utils \
    --replaces libwine --replaces libwine-capi --replaces libwine-gl \
    --replaces libwine-ldap --replaces libwine-openal --replaces libwine-print \
    --replaces libwine-sane --replaces wine32 --replaces wine-bin \
    --replaces wine-doc --replaces wine-utils usr</code></pre>

<p>To sum up what I&#39;m doing here: we&#39;re telling fpm to make a package with the sources I just compiled, and I&#39;m setting several flags to indicate which packages this <code>.deb</code> will depend on, provide, and replace. This allows for not only easy updating, but it will fully replace the &quot;stock&quot; wine from the repositories if you have that installed already. These will of course be different if you are using a different distribution (even Ubuntu may have different package names/versions, so beware!)</p>

<p>Note that I&#39;ve omitted the <code>$DESCRIPTION</code> variable for brevity, but it is linked to below if you are curious.</p>

<h3>Wrapping up</h3>

<p>By now you should have a <code>.deb</code> file ready for installing. This process is repeatable, too, so when wine 1.7.52 comes out you&#39;ll be ready to package that as well!</p>

<p>One might argue that using fpm is &quot;cheating&quot;, and perhaps if the goal was to build a package for submission into the official Debian repositories it might well be. At the very least it&#39;d be doing it wrong. But for my purposes, and probably yours too (that is personal usage), fpm is not only just fine - it kicks ass!</p>

<p>The process outlined above is summarized in <a href="https://gist.github.com/hristoast/6b985037e34fd6659e4d" target="_blank">this shell script</a>, which is essentially exactly what I run to get my new wine builds. I do a few things not described here, such as using <a href="https://github.com/sstephenson/rbenv" target="_blank">rbenv</a> to install ruby, but that&#39;s just a personal preference; the system ruby will be just fine for this purpose.</p>

<p>Of course, run it at your own risk! I&#39;ve ran this several times and consider the process to be quite hardened, but nonetheless always exercise caution when running scripts posted online by others. Ah yes, that is another post for another day I guess. Or maybe for another blog? Who knows.</p>

<p>Thanks for reading!</p>