HOWTO: Spotify on FreeBSD/amd64

This quick and dirty guide will show you how to install Spotify on FreeBSD/amd64 using Wine. This guide assumes you already have FreeBSD's sources checked out in /usr/src and a bourne compatible root shell (/bin/sh for instance). The guide was tested on FreeBSD-10/amd64 (-CURRENT).

1. Build a 32-bit environment to install wine into.

Code:
# export CHROOTPATH=/jail/i386
# mkdir $CHROOTPATH
# cd /usr/src
# make buildworld TARGET=i386
# make installworld TARGET=i386 DESTDIR=$CHROOTPATH
# make distribution DESTDIR=$CHROOTPATH

# mount -t devfs devfs $CHROOTPATH/dev
# cp /etc/resolv.conf $CHROOTPATH/etc/

Note the buildworld step can be sped up on a multicore processor by adding -j <number of cores> to the command line.

2. Chroot to the new environment.

Code:
# UNAME_m=i386 UNAME_p=i386 chroot $CHROOTPATH

3. Install Wine

While inside the chroot do:

Code:
# pkg install wine-1.5.11,1

At the time of writing, the pkg repository contained 2 conflicting wine packages. You can find the latest
available version using:

Code:
# pkg search wine

4. Test wine

Using a terminal in your current X session, allow connections from the chroot to
the current X session (note: this is potentially unsafe on a multiuser system, see section 7):

Code:
$ xhost +

Then from the chroot shell:

Code:
# export DISPLAY=:0
# winecfg

If everything went well the wine configuration program should start. It will ask about installing mono and gecko. I believe the former isn't necessary for Spotify, while the latter probably is.

5. Install Spotify

Again from the chroot shell:
Code:
# fetch http://download.spotify.com/Spotify%20Installer.exe
# wine Spotify\ Installer.exe

At this point you should have a working spotify.

6. Create an easy Spotify startup script.

The following shell script can be used to quickly startup Spotify from within an X session (as a normal user):

Code:
#!/bin/sh
xhost +
sudo UNAME_m=i386 UNAME_p=i386 chroot /jail/i386 wine \
  /root/.wine/drive_c/users/root/Application\ Data/Spotify/spotify.exe

7. A note on security

Obviously, running Spotify as root can be improved upon. Running xhost + should not be done if your X-server listens for TCP connections (by default xorg doesn't) or untrusted users have access to your system. Probably some trickery with X cookies is required. Fixing these security concerns is left as an excercise to the reader ;-).
 
Thanks for the quick and dirty guide.

On 9.1-RC1/amd64, "make buildworld" didn't appear to build /usr/src/etc/sendmail, causing make distribution to fail. Running 'make' there by hand got around that, though I didn't dig any further to see what the root cause was.

I couldn't get the chroot environment to connect to the main X server. Ultimately I installed x11-servers/xephyr, ran
Code:
Xephyr -ac :1
, set the chroot's DISPLAY to localhost:1, and everything else worked as expected from there.
 
On 9.1-RC1/amd64, "make buildworld" didn't appear to build /usr/src/etc/sendmail, causing make distribution to fail. Running 'make' there by hand got around that, though I didn't dig any further to see what the root cause was.

When building an i386 world, installing and making 'distribution' you always need to specify the TARGET :

Code:
# export CHROOTPATH=/jail/i386
# mkdir $CHROOTPATH
# cd /usr/src
# make buildworld TARGET=i386
# make installworld TARGET=i386 DESTDIR=$CHROOTPATH
# make distribution [color="Red"][B]TARGET=i386[/B][/color] DESTDIR=$CHROOTPATH

# mount -t devfs devfs $CHROOTPATH/dev
# cp /etc/resolv.conf $CHROOTPATH/etc/

This is why the make distribution failed for some sendmail files, because it didn't look for the correct build path through the TARGET argument.
 
Back
Top