Home of the Squeezebox™ & Transporter® network music players.
Page 1 of 7 123 ... LastLast
Results 1 to 10 of 61
  1. #1
    Senior Member
    Join Date
    Aug 2012
    Location
    Austria
    Posts
    652

    Howto: build a self-contained LMS

    While installing LMS from a binary package (deb, rpm) is convenient and simple, there is one disadvantage to this approach: Some OS/perl updates tend to break the installed LMS, with no easy fix until the package has been updated as well.

    On a Linux/Unix system, there is an elegant solution to this, provided you have some basic technical knowledge: don't use a pre-packaged LMS (rpm etc.), but build your own with it's own perl installation:

    - build a supported perl (e.g. 5.14) and install it somewhere outside of the regular file hierarchy (e.g. in /opt/perl-5.14.2-LMS/). Any perl modules needed for LMS also should be installed using this perl.
    - build LMS using this perl, and not the standard perl

    Using this approach, you are independent of the OS updates and the problems with perl versions (and even worse, the specific perl module versions required by LMS) completely disappear. On my server, the LMS and LMS-perl installation has been unchanged since the initial build over a year ago, while the standard OS perl (and all it's modules) have been upgraded several times.

    A short guide to building LMS
    (Note: while this guide uses 7.7.2 as an example, this approach will work for any LMS version, you'll just have to adjust the paths accordingly. For nightlies, see "Advanced topics" below)

    - download the perl sources from here. Untar and run the configuration:
    Code:
    ./Configure -des -Dprefix=/opt/perl-5.14.2-LMS -Dusethreads
    - compile and install perl
    Code:
    make
    make test
    make install-strip
    - download the LMS source distribution (logitechmediaserver-7.7.2-noCPAN.tgz) from here
    - untar into /opt (which will give you /opt/logitechmediaserver-7.7.2-33893-noCPAN/ as the full path) and fix ownership:

    Code:
    chown -R root:root /opt/logitechmediaserver-7.7.2-33893-noCPAN/
    - create a directory to build the binary perl modules (somewhere outside of /opt/, e.g. /tmp/perlmods or in your home directory) and download everything from here into it (for 7.8, use this instead).
    - adjust the buildme.sh script to use the perl in /opt. Look for the lines:
    Code:
    # Path to Perl 5.14.1
    if [ -x "$HOME/perl5/perlbrew/perls/perl-5.14.1/bin/perl5.14.1" ]; then
        PERL_514=$HOME/perl5/perlbrew/perls/perl-5.14.1/bin/perl5.14.1
    fi
    and add the following after these:

    Code:
    if [ -x "/opt/perl-5.14.2-LMS/bin/perl5.14.2" ]; then
        PERL_514=/opt/perl-5.14.2-LMS/bin/perl5.14.2
    fi

    (Note: the 7.8 script (not used in this guide) has been updated to make this easier: No edits required, just run it:
    PERL_514=/opt/perl-5.14.2-LMS/bin/perl5.14.2 ./buildme.sh
    )

    - run the builme.sh script. It should output "Building with Perl 5.14 at /opt/perl-5.14.2-LMS/bin/perl5.14.2" at the beginning. If it uses a different perl 5.14, something went wrong (note that it might build the modules for several perls (e.g. your system perl is 5.12, the the modules for 5.12 and 5.14 will be build)
    - if you get errors during the build, you'll have to fix them. The only recent issue I'm aware of is in Font::FreeType (fix described here).
    - if the build was successful, you'll find the modules in build/arch/5.14/<architecture e.g. x86_64-linux-thread-multi>/
    - copy the build/arch directory to /opt/logitechmediaserver-7.7.2-33893-noCPAN/CPAN/ (the full final path will be e.g /opt/logitechmediaserver-7.7.2-33893-noCPAN/CPAN/arch/5.14/x86_64-linux-thread-multi/auto/Audio etc.)

    After that, you'll need a start/stop script - the easiest way is probably to take the existing one for your linux distribution (e.g debian, gentoo, ...) and simply adjust the directory/file paths. E.g. for Debian:

    Code:
    DAEMON=/opt/logitechmediaserver-7.7.2-33893-noCPAN/slimserver.pl
    and change the line
    Code:
    --exec $DAEMON_SAFE \
    to
    Code:
    --exec $DAEMON \
    Copy the script to the appropriate location:
    Code:
    cp logitechmediaserver.init /etc/init.d/logitechmediaserver
    Then create a user (matching the one specified in the init script, e.g. squeezeboxserver for debian), create any missing directories referenced in the init script (usually something like /etc/squeezeboxserver, /var/lib/squeezeboxserver, and /var/log/squeezeboxserver), and finally, set the owner for these directories, e.g.
    Code:
    chown squeezeboxserver:nogroup /etc/squeezeboxserver -R
    chown squeezeboxserver:nogroup /var/lib/squeezeboxserver -R
    chown squeezeboxserver:nogroup /var/log/squeezeboxserver -R
    The last step is to edit scanner.pl and slimserver.pl (both in /opt/logitechmediaserver-7.7.2-33893-noCPAN/) and change the first line from
    #!/usr/bin/perl
    to
    #!/opt/perl-5.14.2-LMS/bin/perl5.14.2

    Advanced topics
    Performance optimization
    Using the latest gcc version available is usually a good idea. Additionally, you can build perl and the binary LMS modules using more aggressive compiler optimizations than the default. How much of an improvement (if any) this is depends on a lot of factors, so you'll have to decide for yourself if it's worth it.
    Note that using too aggressive or unsuitable optimization flags might result in an unstable/buggy build. For a list of (hopefully) safe flags, see this page.

    To build perl with custom compiler flags:
    Code:
    ./Configure -des -Dprefix=/opt/perl-5.14.2-LMS -Dusethreads -Doptimize='-march=core2 -msse4.1 -msse4.2 -O2 -pipe -fomit-frame-pointer'
    (Note: Don't just copy this line - you need to adjust the flags for your system.)

    Upgrading LMS
    Since the binary perl modules used by LMS have stayed at the same version for a long time, upgrading to a new LMS version is usually fairly simple
    - untar the new version to /opt and adjust the file ownership
    - copy (or symlink) the CPAN/arch directory from the old version to the new
    - edit scanner.pl and slimserver.pl to point to the perl in /opt/perl-x.y.z-LMS
    - adjust your init script to use the new path for slimserver.pl

    Upgrading perl
    If you want to switch to a newer perl version, you'll have to
    - build the new perl, install to /opt/perl-x.y.z-LMS
    - re-build the binary LMS perl modules using the buildme.sh script (which needs to be adjusted to use the new perl)
    - install the binary modules to /opt/logitechmediaserver.../CPAN/arch
    - edit scanner.pl and slimserver.pl to point to the new perl in /opt/perl-x.y.z-LMS/

    Using newer perl modules
    Sometimes, it might be necessary to use a newer version of a binary perl module for LMS than the one provided (e.g. if the supplied version fails to build). In this case, you'll have to
    - download the sources for this module from CPAN to the build directory
    - modify the buildme.sh script, e.g. change
    Code:
    build_module DBI-1.616
    to
    Code:
    build_module DBI-1.628
    (Note: the 7.8 script has been updated for perl 5.18 and already includes the DBI update (among others))
    Important: Since the non-binary parts of the module have to match the binary, and the version of the module supplied with LMS doesn't match the one just built, you will also have to install the perl parts of the module to
    /opt/logitechmediaserver-7.7.2-33893-noCPAN/CPAN/arch/5.14/x86_64-linux-thread-multi/
    For example, if you install JSON::XS, you therefore should have
    Code:
    /opt/logitechmediaserver-7.7.2-33893-noCPAN/CPAN/arch/5.14/x86_64-linux-thread-multi/JSON/XS.pm
    /opt/logitechmediaserver-7.7.2-33893-noCPAN/CPAN/arch/5.14/x86_64-linux-thread-multi/JSON/XS/Boolean.pm
    Running the latest LMS code
    While this approach works for the nightlies as well, downloading the whole .tar.gz every time is quite inefficient. A better method is to check out the sources (e.g. to /opt/logitechmediaserver-7.7.8-git/) and keep them updated using git or svn.
    Things to keep in mind:
    - In this case /opt/logitechmediaserver-7.7.8-git should be owned by a regular user (not root), and the check out/update should be executed by this user
    - If slimserver.pl or scanner.pl get updated, you have to remember to adjust them to point to your perl by modifying the first line
    - if you've built your own binaries, you should tell git to ignore the CPAN/arch tree as described in the linked post
    Last edited by Roland0; 2013-10-20 at 12:27. Reason: added "Advanced topics"

  2. #2
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    19,782

    Howto: build a self-contained LMS

    Nice writeup - you should have done it on the wiki. And have done so years
    ago :-): I've been running my own build for several years now. Not because
    my distribution was too bleeding edge, but on the contrary. Still based on
    some CentOS5, it comes with Perl 5.8.5 only... First time I built my own
    perl was quite a bit of a trial & error experience.

    > - create a directory to build the binary perl modules and download
    > everything from 'here'
    > (https://github.com/Logitech/slimserv...ublic/7.7/CPAN)
    > into it
    > - adjust the buildme.sh script to use the perl in /opt. Look for the
    > lines:


    Please note that if you were to build one of the officially supported
    architecture/Perl version combinations, you wouldn't have to build these
    modules on your own. In 7.8 we have i386 modules up to Perl 5.16, and
    x86_64 for 5.16 and up.

    --

    Michael

  3. #3
    Senior Member SlimChances's Avatar
    Join Date
    Apr 2005
    Posts
    1,402
    This looks very useful. I am not overly technically minded but your instructions seem clear.
    To install with LMS 7.8 would I follow the same instructions substituting the 7.8 LMS nightly (ie logitechmediaserver-7.8.0-1378731839-noCPAN.tgz at http://downloads.slimdevices.com/nightly/?ver=7.8) and not changing
    Code:
    build_module DBI
    Logitech Media Server Version: 7.9.1 - 1504317335 @ Mon Sep 4 07:13:56 UTC 2017
    Operating system: Debian - EN - utf8 Platform Architecture: x86_64-linux
    Perl Version: 5.22.1 - x86_64-linux-gnu-thread-multi

    Database Version: DBD::SQLite 1.34_01 (sqlite 3.7.7.1)

    One SB Touch connected by Ethernet - Denon AVR -1912 Receiver, Paradigm 4.1 speakers
    Two SB Radios wireless

  4. #4
    Senior Member
    Join Date
    Aug 2012
    Location
    Austria
    Posts
    652
    Quote Originally Posted by SlimChances View Post
    To install with LMS 7.8 would I follow the same instructions substituting the 7.8 LMS nightly (ie logitechmediaserver-7.8.0-1378731839-noCPAN.tgz at http://downloads.slimdevices.com/nightly/?ver=7.8) and not changing
    Code:
    build_module DBI
    Correct, but you'd also have to download/use the CPAN modules for 7.8 (which are currently the same as for 7.7 unless you use perl 5,18, but still, just to be on the safe side...)
    I've updated the guide to include the url where you can find them, and also added a paragraph outlining a better method to use the latest LMS code.

  5. #5
    Senior Member
    Join Date
    Aug 2012
    Location
    Austria
    Posts
    652
    Quote Originally Posted by mherger View Post
    Nice writeup - you should have done it on the wiki.
    I can put this on the wiki if someone (you?) can give me access to it (and tell me where to put the page). Someone mentioned in another thread that one can just register on it, but I guess that this isn't enough to actually create/edit content.
    (btw, I would also like to update the "Skins" section to include extGUI4LMS)

  6. #6
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    19,782

    Howto: build a self-contained LMS

    > I can put this on the wiki if someone (you?) can give me access to it

    Is it still/again read-only?!? Do you have an account I can enable?

    --

    Michael

  7. #7
    Senior Member
    Join Date
    Feb 2013
    Posts
    368
    I worked through this process at the weekend before Roland0 made this post. Just a couple of points:

    0. You may need to install libexpat1-dev and nasm before you start.

    1. Non-programmers (that's me) might be wondering why use "make install-strip" instead just "make install" when building perl.

    2. After the untar of logitechmediaserver-7.7.2-noCPAN.tgz. It's worth checking that the files/dirs in the expanded tree have perms 755/644. I believe this sets the correct perms:
    Code:
    chmod -R u+rwX,go+rX,go-w /opt/logitechmediaserver-7.7.2-33893-noCPAN
    3. If you use, or copy as a different name, the standard debian initscript saved from an existing LMS deb packag install, you could alterantively simply edit two lines to read:

    Code:
    DAEMON=/opt/logitechmediaserver-7.7.2-33893-noCPAN/slimserver.pl
    DAEMON_SAFE=/opt/logitechmediaserver-7.7.2-33893-noCPAN/slimserver.pl
    4. It's not necessary to create a /etc/squeezeserver dir, as the files that would exist there are all present under /opt/logitechmediaserver-7.7.2-33893-noCPAN/

    5. If you need to add a "squeezeboxserver" user, it needs to be added as a system user, e.g:

    Code:
    adduser --system --home /usr/share/squeezeboxserver --no-create-home --gecos "Logitech Media Server" squeezeboxserver
    7. If you want to use LMS with squeezelite, I found the the "squeezeboxserver" user needs to be added to the audio group:

    Code:
    usermod -a -G audio squeezeboxserver

    8. It's worth checking you still have a functioning log rotate for this version of LMS. You need to edit /etc/logrotate.d/logitechmediaserver:

    change

    Code:
     /bin/kill -USR1 `pgrep squeezeboxserve -n 2>/dev/null` 2>/dev/null || :

    to

    Code:
     /bin/kill -USR1 `pgrep slimserver.pl -n 2>/dev/null` 2>/dev/null || :

  8. #8
    Senior Member
    Join Date
    Aug 2012
    Location
    Austria
    Posts
    652
    Quote Originally Posted by Krisbee View Post
    1. Non-programmers (that's me) might be wondering why use "make install-strip" instead just "make install" when building perl.
    install-strip runs strip during the install.

    2. After the untar of logitechmediaserver-7.7.2-noCPAN.tgz. It's worth checking that the files/dirs in the expanded tree have perms 755/644.
    Never had this issue (although I saw you mentioning something like this in the other thread). If the perms are wrong in the tar, I'd suggest raising this as an issue with Logitech.

    3. If you use, or copy as a different name, the standard debian initscript saved from an existing LMS deb packag install, you could alterantively simply edit two lines to read:

    Code:
    DAEMON=/opt/logitechmediaserver-7.7.2-33893-noCPAN/slimserver.pl
    DAEMON_SAFE=/opt/logitechmediaserver-7.7.2-33893-noCPAN/slimserver.pl
    I wouldn't do it like this - if you don't want to change the (pointless) DAEMON_SAFE (why?), assign $DAEMON to DAEMON_SAFE

    4. It's not necessary to create a /etc/squeezeserver dir, as the files that would exist there are all present under /opt/logitechmediaserver-7.7.2-33893-noCPAN/
    It's slightly more complicated than that. You do need a prefs location for runtime (as LMS will save it's preferences there). For gentoo, it's /etc/squeezeserver, for debian /var/lib/squeezeboxserver/prefs
    I'll make that clearer in the guide

    5. If you need to add a "squeezeboxserver" user, it needs to be added as a system user, e.g:
    Code:
    adduser --system --home /usr/share/squeezeboxserver --no-create-home --gecos "Logitech Media Server" squeezeboxserver
    For security reasons, I'd recommend setting home to /dev/null and shell to /sbin/nologin or /bin/false

    8. It's worth checking you still have a functioning log rotate for this version of LMS. You need to edit /etc/logrotate.d/logitechmediaserver:
    Good point - I'll add logrotate to the guide

  9. #9
    Senior Member
    Join Date
    Feb 2013
    Posts
    368
    Is it worth mentioning on the wiki entry that your method allows a LMS 7.7.X broken by the move from perl 5.14 to 5.16 or 5.18 to be revived without loss of cached data, db, logs etc. ?

    In debian at least, you have the “squeezeboxserver” user and can't you simply re-use all the relevant existing /var/lib/... and var/log.. files? Once you've built your own perl version etc. using your instructions, isn't all you need to do is to edit the /etc/int.d/logitechmediaserver file and relevant logrotate.d entry before restarting LMS?

    It's also possible to run a version of LMS according to your instructions alongside say a nightly build if your create a new separate set of /var/lib/... and /var.log/... files (and if necessary etc/...files) along with and a relevant init.d and logrotate.d file. This is what I did at the weekend.

  10. #10
    Senior Member
    Join Date
    Aug 2012
    Location
    Austria
    Posts
    652
    Quote Originally Posted by Krisbee View Post
    Is it worth mentioning on the wiki entry that your method allows a LMS 7.7.X broken by the move from perl 5.14 to 5.16 or 5.18 to be revived without loss of cached data, db, logs etc. ?

    In debian at least, you have the �squeezeboxserver� user and can't you simply re-use all the relevant existing /var/lib/... and var/log.. files? Once you've built your own perl version etc. using your instructions, isn't all you need to do is to edit the /etc/int.d/logitechmediaserver file and relevant logrotate.d entry before restarting LMS?
    Unless you uninstall the official package with the purge option, that't certainly possible. It's the same as a regular update in this regard.

    It's also possible to run a version of LMS according to your instructions alongside say a nightly build if your create a new separate set of /var/lib/... and /var.log/... files (and if necessary etc/...files) along with and a relevant init.d and logrotate.d file. This is what I did at the weekend.
    Actually, you don't even need separate directories (unless the db structure changes - which it hasn't for a long time). Preferences also stay the same (I'm not quite sure how LMS handles unknown prefs (e.g. those that exist in 7.8 and don't in 7.7), but I guess the only risk would be that they get lost)
    My setup is based on symlinks:
    Code:
    lrwxrwxrwx  1 root root   29 May 14 19:10 lms -> logitechmediaserver-7.7.8-git
    drwxr-xr-x 13 root root 4096 Apr 26  2012 logitechmediaserver-7.7.2-33893-noCPAN
    drwxr-xr-x 13 user user 4096 Sep 11 23:34 logitechmediaserver-7.7.8-git
    and the init script uses /opt/lms as the path, so switching to another version is done by pointing the symlink to this version

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •