AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi Updated
My last AirPi post has been popular – and still is – but part of why of like Arch linux is that it is constantly updating so you must be hands on, learning a new part of the OS the hard way!
Since my post a year ago, Shairport has some new features and dependencies, and Arch has moved to the systemd service manager, changing the tutorial process somewhat. In order to update it, I have run through the process with the current build (2013-02-11).
The initial steps are the same:
Install Pacman Packages
pacman -Syu
Next you’ll need to install the tools required to compile in Arch.
pacman -S kernel26-headers file base-devel abs
Then git to clone the Shairport repo.
pacman -S git
Shairport has a number of dependencies so we’ll install them and there dependencies too.
pacman -S avahi libao openssl perl-crypt-openssl-rsa perl-io-socket-inet6 perl-libwww
A new dependency for Shairport is perl-net-sdp. This isn’t a package yet in the pacman repos so must be installed from the AUR.
READ THE UPDATES BELOW IF YOU HAVE PROBLEMS AT THIS STEP
pacman -S wget wget https://aur.archlinux.org/packages/pe/perl-net-sdp/perl-net-sdp.tar.gz tar -zxvf perl-net-sdp.tar.gz cd perl.net.sdp makepkg -s pacman -U perl.net.sdp.pkg.tar.gz
Finally, alsa is required to get sound output in Arch on the RPi.
pacman -S alsa-utils alsa-firmware alsa-lib alsa-plugins
Change the default output to the 3.5mm jack
amixer cset numid=3 1
After all the installs, best to reboot
shutdown -r now
Make Shairport
Create a directory to do the build
mkdir shairport
Now clone the repo, cd
into it and make
.
git clone https://github.com/albertz/shairport.git shairport cd shairport make
All being well, Shairport should have built and you can now run it with the name ‘AirPi’.
./shairport.pl -a AirPi
If all is well, install
make install
Systemd
The biggest change is dropping rc.conf
in favour of systemd. The sound module snd-bcm2835
now autoloads but Avahi
must be enabled as a service.
systemctl enable avahi-daemon
A .service file needs creating for systemd to start Shairport as a service at boot. Create this using vi
in /etc/systemd/system/
vi /etc/systemd/system/shairport.service
Copy this code
[Unit] Description=Startup ShairPort (Apple AirPlay) After=network.target After=avahi-daemon.service [Service] Type=oneshot ExecStart=/usr/local/bin/shairport -a AirPi -b 256 -d ExecStop=/usr/bin/killall shairport RemainAfterExit=yes [Install] WantedBy=multi-user.target
Or you get use wget
again and download mine:
wget /assets/img/uploads/2013/05/shairport.service -O /etc/systemd/system/shairport.service
Now enable the new service
systemctl enable shairport
UPDATE MARCH 2014
I recently created another ‘AirPi’ for my sister so went through these steps. As before, ArchPi has changed a few things. The main problem I came across was ivp6 being disabled, preventing Shairport binding to the socket. To enable it, change ipv6.disable=1
in /boot/cmdline.txt to false (0).
UPDATE FEBRUARY 2015
More updates a year on. As a commenter has said, this tutorial is done as root (because that’s the default for the Arch ARM image). You can’t makepkg
as root anymore. The solution is to create a build folder and sudo as a lower user:
pacman -S sudo<br />
mkdir /home/build<br />
chgrp nobody /home/build<br />
chmod g+ws /home/build<br />
setfacl -m u::rwx,g::rwx /home/build<br />
setfacl -d --set u::rwx,g::rwx,o::- /home/build<br />
cd /home/build
Copy extract the perl package from the AUR here then sudo -u nobody makepkg
to make the package.
I also had issues with my file system becoming read only. To fix this edit ‘/boot/cmdline.txt’ and add ‘rw’ at the end of the line before ‘rootwait’, reboot.
Finally, James picked up that the audio quality is off now by default. To fix it:
echo “use_mmap=no” >> /etc/libao.conf