Friday, December 9, 2011

HowTo: Compile MediaTomb with JavaScript support on Ubuntu 11.10 Oneiric Ocelot

This is a follow-up post to my original article on compiling MediaTomb with enabled JavaScript support for Ubuntu 10.04. Since Ubuntu 11.10 (Oneiric Ocelot) is now available, it was time for an update.

Since some time in Ubuntu MediaTomb is compiled without JavaScript support. JavaScript support is needed for example to handle/import playlists. This HowTo gives you a walk-through to compiling and installing MediaTomb with JScript support under Ubuntu 11.10. For this HowTo, I assume you start from a freshly installed Ubuntu.

You might ask why the version of MediaTomb provided with Ubuntu is compiled without JS support. To make long stories short: The problem is with SpiderMonkey, the Mozzila JavaScript engine. MediaTomb needs a header called jsapi.h to compile. As Ubuntu comes with packages providing these headers (libmozjs185-1.0, libmozjs185-dev) I gave it a try, but didn't manage to get is running this way.


But I managed to build MediaTomb on my Ubuntu Oneiric Ocelot from source with enabled JS support. Here is a step-by-step walk-trough of what worked for me:
  1. change to root or use sudo (I will assume you use sudo)
  2. sudo apt-get build-dep mediatomb
  3. sudo apt-get source mediatomb
  4. sudo vim mediatomb-0.12.1/debian/rules
  5. change --disable-libjs to --enable-libjs
  6. Now you should update the changelog file in the same directory
  7. get libmozjs2d and libmozjs-dev from the debian squeeze distibution: libmozjs2d_1.9.1.16-10_i386.deb and libmozjs-dev_1.9.1.16-10_i386.deb
  8. If you are running 64-bit Ubuntu (amd64), you should get the corresponding amd64 libraries instead: libmozjs2d_1.9.1.16-10_amd64.deb and libmozjs-dev_1.9.1.16-10_amd64.deb
  9. sudo dpkg -i libmozjs2d_1.9.1.16-10_i386
  10. If you have missing dependencies:  sudo apt-get install -f
  11. sudo dpkg -i libmozjs-dev_1.9.1.16-10_i386
  12. If you have missing dependenciessudo apt-get install -f
  13. Now you can cd to mediatomb-0.12.1 and try a sudo ./configure. You should see a line in the configuration summary that reads
    libjs                 : yes
  14. Now its time to install additional libs you might what to have for the build. Check the configuration summary. When you are done let's go!
  15. If you are not already there: cd mediatomb-0.12.1
  16. sudo dpkg-buildpackage -rfakeroot -us -uc (omit the -rfakeroot if you are working as root)
That's it! If all went well you should now have three new .deb files in the directory you did the apt-get in. You can install them all in one go by dpkg -i mediatomb*.deb. Again, if you have missing dependenciessudo apt-get install -f

10 comments:

  1. After I followed these instructions I couldn't access the web interface with a good config...

    Also after I ran a apt-get upgrade it removed the js support...

    ReplyDelete
  2. Hi Sam,
    I assume you have enabled the web UI in the config file and tried accessing it via the URL that Mediatomb writes to the console when starting up? I actually don't have any problem accessing the web UI. You will need to provide a little more information on your configuration....
    On the problem with apt "updating" you custom build: Did you update the changelog (step 6) with reasonable information? This should prevent your custom build being considered older that the upstream version.
    Cheers,
    Tobias

    ReplyDelete
  3. hi tobias,
    sounds promising, but alredy in the 1st step i get

    sudo apt-get build-dep mediatomb
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Unable to find a source package for mediatomb

    any idea ?

    ReplyDelete
  4. I can't tell why it does not work for you. Can you get other sources via sudo apt-get source 'foo' or is it all sources you can't get?

    ReplyDelete
  5. One thing I discovered from this link http://askubuntu.com/questions/60962/why-is-mediatomb-not-compiled-with-javascript-support

    If you have attempted to use the libjs that is available in Ubuntu, compile errors will occur, unless you remove the libraries first.

    sudo apt-get remove libmozjs185*


    After that, the compile and build appeared to work.
    Thanks for your instructions.
    Although I am not sure about editing the changelog file, not clear here.
    -Bill
    ====================================================

    The error you will see:

    ../src/scripting/script.h:69:5: error: 'JSScript' does not name a type
    ../src/scripting/script.h:70:5: error: 'JSScript' does not name a type
    ../src/scripting/script.h:118:5: error: 'JSScript' does not name a type
    ../src/scripting/script.h:119:19: error: 'JSScript' has not been declared

    ReplyDelete
  6. Confirm this process works on Ubuntu 12.04 LTS Server

    ReplyDelete
  7. Commenting on the problem gigabass has:

    This issue appears when you dont have the deb sources. Check if you have an entry in the apt sources list along the lines of "deb-src ........ main ...."

    Dots signify the repository information.

    ReplyDelete
  8. OK...I've done this successfully and installed it successfully. The whole reason I did this was in order to gain support for importing playlists. However, my playlists are not importing.

    Thoughts?

    ReplyDelete
  9. Format of the playlists not supported? Paths in the playlists not accessible? Update of the DB not yet finished successfully? ...

    Maybe you can narrow down a little what exactly fails in importing your playlists.

    ReplyDelete
    Replies
    1. Nice tutorial, anyway I have the same problem of drenze...format are m3u (so must be supported), paths are accesible and update has been finished...I don't understand

      Delete