Lyrion Music Server from Source

Introduction
Steps
References

Introduction

Logitech's server software for their Slimdevices Squeezebox product line has gone through many names: slimserver, squeezeboxserver, logitechmediaserver, Lyrion, etc. Over the years it has been painful to upgrade FreeBSD because of the "dependency hell" induced by this program's packaging of Perl libraries. I used to be able to build it from ports, and more recently I used packages, but the software is very sensitive to the version of Perl you have installed. Changing the Perl version is fraught with peril:

Forums are littered with NAS users trying to build it themselves in complicated jails, and until now I never had any luck developing a clean, consistent method for building it. At one point I was using a custom repository from an Italian gent, but even that posed problems during major OS upgrades. His article gave me clues to developing a process to build it successfully from source as needed. I can now upgrade my OS without worries.

Steps

This example uses Lyrion 9.0.0 and perl 5.36, but it applies to any versions.
  1. Download a nightly LMS build and a corresponding vendor zip file.

       wget https://downloads.lms-community.org/nightly/lyrionmusicserver-9.0.0-1713442161-noCPAN.tgz
       wget https://github.com/Logitech/slimserver-vendor/archive/public/9.0.zip
  2. Build slimserver-vendor CPAN using the system-wide version of perl you already have installed on your machine.
      unzip 9.0.zip
      cd slimserver-vendor-public-9.0/CPAN
      ./buildme.sh -t | tee /tmp/build.log
    

    There was a comment in a blog that mentions building your own custom version of perl, but I don't think it's worth the trouble. If this build of LMS ever breaks after an OS upgrade, I'll just rebuild it quickly from source.

  3. Now go into the source tree for LMS and copy the slimserver-vendor CPAN build into the appropriate directory under CPAN/arch.

    My version of perl happened to be 5.36. You may have to create this directory under CPAN/arch. I chose to remove all the other subdirectories under arch/ for unused versions of perl.

      cd lyrionmusicserver-9.0.0-1713442161-noCPAN/CPAN/arch
      cp -Rp ../../../slimserver-vendor-public-9.0/CPAN/build/arch/5.36 .
    
  4. Copy the final result to another directory where you'll ultimately run it. This step is optional, but I like it because it keeps my source and builds separate.
      cp -Rp lyrionmusicserver-9.0.0-1713442161-noCPAN /usr/local/lms/
    
  5. Change the shebang lines of the topmost .pl executables.

    This makes slimserv.pl, scanner.pl, etc. use the system-wide perl. I couldn't get FreeBSD's rc.subr(8) command_interpreter to handle this the way I wanted it to, so I ended up modifying them myself.

      cd /usr/local/lms/
      perl -p -i -e 's,^#\!/usr/bin/perl,#\!/usr/bin/env perl,' *.pl
  6. Test it out on the command line.

    Verify everything works by running slimserver in the foreground (without --daemon). I based the following command on FreeBSD's rc script; your mileage may vary.

      /usr/local/bin/perl /usr/local/lms/slimserver.pl --pidfile=/var/run/logitechmediaserver/logitechmediaserver.pid \
      --user=slimserv --group=slimserv --logdir=/var/log/logitechmediaserver --cachedir=/var/db/logitechmediaserver/cache \
      --prefsdir=/var/db/logitechmediaserver/prefs --playlistdir=/var/db/logitechmediaserver/playlists
    
  7. Edit startup file.

    Since I already had a previous port of LMS on my machine, the user/group slimserv:slimserv and appropriate directories were already created. All I had to do was edit an existing copy of the startup script. Here are the tweaks I made.

    diff --git a/rc.d/logitechmediaserver b/rc.d/logitechmediaserver
    index 608353d..65e6cd8 100755
    --- a/rc.d/logitechmediaserver
    +++ b/rc.d/logitechmediaserver
    @@ -20,7 +20,9 @@ start_precmd="logitechmediaserver_start_precmd"
     stop_postcmd="logitechmediaserver_stop_postcmd"
     rcvar=logitechmediaserver_enable
    
    -command=/usr/local/share/logitechmediaserver/slimserver.pl
    +#command=/usr/local/share/logitechmediaserver/slimserver.pl
    +command=/usr/local/lms/slimserver.pl
     command_interpreter=/usr/local/bin/perl
     pidfile=/var/run/${name}/${name}.pid
     logdir=/var/log/${name}
    @@ -30,7 +32,9 @@ prefsdir=${statedir}/prefs
     playlistdir=${statedir}/playlists
     u=slimserv
     g=slimserv
    -command_args="--daemon --pidfile=${pidfile} --user=${u} --group=${g}"
    +#command_args="--daemon --pidfile=${pidfile} --user=${u} --group=${g}"
    +command_args="--daemon --pidfile=${pidfile} --user=${u} --group=${g} --logdir=${logdir} --statedir=${statedir} --cachedir=${cachedir} --prefsdir=${prefsdir} --playlistdir={$playlistdir}"
     logitechmediaserver_user=${u}
     logitechmediaserver_group=${g}
    
    If it fails to start at boot time, ensure the startup script's $PATH contains perl. FreeBSD 14.1 exhibits different behavior than previous versions where you have to explicity set $PATH.
    export PATH="${PATH}:/usr/local/bin"
    
  8. Enjoy. I was surprised at not seeing an endless stream of CPAN dependency errors like I was used to!

References