Building MediaTomb for the Drobo using Ubunutu


Seeing as it constantly comes up on the Drobo developer forums, I thought i’d take the time to put in some work and compile MediaTomb for the DroboShare. For those of you who don’t know, DroboShare is a NAS device that attaches to the Drobo and allows for the device to be used over the network instead of direct USB connections. The beauty of the DroboShare is that it’s an embedded Linux machine with an ARM processor and shell access. Gotta love that! The default media server on the Drobo forums is FUPPES. No offense to it’s author, but I really can’t stand using it. :( It seems slow and I really dislike the interface. I also don’t like the amount of configuration that it takes to get it to work with my Xbox 360 so I decided to do MediaTomb instead.

The first part of this is going to require a working Ubuntu 8.10 installation. I use Kubuntu 8.10 as my desktop OS so I already had this part covered. ;) You can also use a VMware image if you don’t have a Ubuntu Linux machine around. Everything is done in a chroot environment and can be easily deleted after the software is compiled and uploaded to the DroboShare.

First, let’s create the jailed environment.

sudo mkdir -p /var/chroot/drobo

Install schroot (you can also use chroot if you’d like) and debootstrap

sudo apt-get install schroot debootstrap

Create the file /etc/schroot/chroot.d/drobo with the following contents
——– /etc/schroot/chroot.d/drobo ——–

[drobo]
description=Ubunutu Intrepid for DroboApps
location=/var/chroot/drobo
priority=3
users=<Your Username>
groups=sbuild
root-groups=root

——– /etc/schroot/chroot.d/drobo ——–

Create a minimal system in the chroot jail

sudo debootstrap --variant=buildd --arch i386 intrepid /var/chroot/drobo

Create a place to extract the new downloads

sudo mkdir /var/chroot/drobo/root/code

Download the Drobo toolchain to a temporary directory
http://www.codesourcery.com/gnu_toolchains/arm/releases/2006q1-6
(Select ARM GNU/Linux, then IA32 GNU/Linux, then click Download)

Extract the Drobo toolchain

cd /var/chroot/drobo/usr/local
sudo tar xfj <DownloadDir>/arm-2006q1-6-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2

Download MediaTomb
Grab a copy from here : http://mediatomb.cc/pages/download#source_code
Extract the files into the chroot

cd /var/chroot/drobo/root/code
sudo tar xfz <DownloadDir>/mediatomb-0.11.0.tar.gz

Because i’m building MediaTomb, i’ll need SQLite, ZLib, expat, and a few other things … Let’s start with SQLite
Grab a copy from here : http://www.sqlite.org/download.html
I used ‘sqlite-amalgamation-3.6.7.tar.gz’
Extract to the code directory

cd /var/chroot/drobo/root/code
sudo tar xfz <DownloadDir>/sqlite-amalgamation-3.6.7.tar.gz

ZLib – http://www.zlib.net/
I used ‘zlib-1.2.3.tar.gz’
Extract to the directory

cd /var/chroot/drobo/root/code
sudo tar xfz <DownloadDir>/zlib-1.2.3.tar.gz

Expat – http://sourceforge.net/projects/expat/
I used ‘expat-2.0.1.tar.gz’
Extract to the directory

cd /var/chroot/drobo/root/code
sudo tar xfz <DownloadDir>/expat-2.0.1.tar.gz

File – http://www.darwinsys.com/file/
Note : The site admin removed the 4.24 version of file so I had to get mine from here
ftp://ftp.sunfreeware.com/pub/freeware/SOURCES/file-4.24.tar.gz
I used ‘file-4.24.tar.gz’
Extract to the directory

cd /var/chroot/drobo/root/code
sudo tar xfz <DownloadDir>/file-4.24.tar.gz

TagLib – http://developer.kde.org/~wheeler/taglib.html
I used ‘taglib-1.5.tar.gz’
Extract to the directory

cd /var/chroot/drobo/root/code
sudo tar xfz <DownloadDir>/taglib-1.5.tar.gz

libexif – http://libexif.sourceforge.net
I used ‘libexif-0.6.17.tar.gz’
Extract to the directory

cd /var/chroot/drobo/root/code
sudo tar xfz <DownloadDir>/libexif0.6.17.tar.gz

ffmpeg – http://ffmpeg.org
FFmpeg doesn’t really do releases so I used a snapshot from a Gentoo mirror. The filename was ‘ffmpeg-0.4.9-p20081219.tar.bz2′ and I got it from http://gentoo-distfiles.mirrors.tds.net/distfiles/ffmpeg-0.4.9-p20081219.tar.bz2
Extract to the directory

cd /var/chroot/drobo/root/code
sudo tar xfj <DownloadDir>/ffmpeg-0.4.9-p20081219.tar.bz2

Create a directory for the resulting binaries.

sudo mkdir -p /var/chroot/drobo/usr/arm

Now it’s time to enter the chroot jail and start compiling!

Mount the required filesystems

sudo mount -o bind /proc /var/chroot/drobo/proc
sudo cp /etc/resolv.conf /var/chroot/drobo/etc/resolv.conf

Activate the chroot

sudo schroot -c drobo -d /root

Load some extra packages

apt-get install vim

(Feel free to use whatever editor you like in place of vim)

apt-get install automake autoconf libtool autotools-dev m4

Setup some environment variables. The trick to cross-compiling is to use the system’s binaries for running autotools but tell the compiler to link against the ARM headers, libraries, and binaries. These environment variables ease the pain when building in a non-standard directory. If they’re not set, a few of the below builds will fail miserably. :(

Seeing as we know the CPU/Architecture of the Drobo and the version of GCC, a quick check of the docs gives us some additional command line switches to further tweak things for our processor. The Drobo is no speed demon so everything helps.

export CFLAGS="-I/usr/arm/include -march=armv5te"
export CPPFLAGS=${CFLAGS}
export LDFLAGS="-L/usr/arm/lib"
export CC=arm-none-linux-gnueabi-gcc

With that out of that way, let’s build some software! ZLib is up first

cd /root/code/zlib-1.2.3
./configure --prefix=/usr/arm --shared
make
make install

Now Expat

cd /root/code/expat-2.0.1
./configure --host=arm-none-linux-gnueabi --prefix=/usr/arm
make
make install

SQLite

cd /root/code/sqlite-3.6.7
./configure --host=arm-none-linux-gnueabi --prefix=/usr/arm
make
make install

File proved to be a bit more tricky, but nothing too horid…

cd /root/code/file-4.24

Edit magic/Makefile.am

vi magic/Makefile.am

Change line 224 from

${MAGIC}: $(EXTRA_DIST) $(FILE_COMPILE)

to

${MAGIC}: $(EXTRA_DIST)

Now run the following to rebuild the build system …

aclocal
autoheader
autoconf
libtoolize
automake
./configure --host=arm-none-linux-gnueabi --prefix=/usr/arm
make
make install

Libexif

cd /root/code/libexif-0.6.17
./configure --host=arm-none-linux-gnueabi --prefix=/usr/arm
make
make install

Taglib time!

cd /root/code/taglib-1.5
./configure --host=arm-none-linux-gnueabi --prefix=/usr/arm
make
make install

Hold on to your cookies … it’s time for ffmpeg. This is a seriously daunting command line but I have a feeling that this version is broken when cross compiling. Who knows what the problem is … this build works, just no Matroska. :(

cd /root/code/ffmpeg
./configure --cross-prefix=arm-none-linux-gnueabi- --prefix=/usr/arm --arch=arm --enable-armv5te --enable-nonfree --disable-network --disable-ipv6 --enable-pthreads --disable-zlib --disable-bzlib --disable-ffserver --disable-ffplay --disable-devices --disable-encoders --disable-muxers --enable-shared --disable-static --disable-vhook --enable-avfilter --enable-cross-compile --disable-decoder=matroska
make
make install

MediaTomb leaves a lot to be desired when it comes to properly detecting items in a cross-compiled environment. It also looks like some of the distributions move header files around… which of course breaks it further. :( The following hack fixes it up for us to use again.

mkdir -p /usr/arm/include/ffmpeg
cp -v /usr/arm/include/libavcodec/* /usr/arm/include/ffmpeg
cp -v /usr/arm/include/libavutil/* /usr/arm/include/ffmpeg
cp -v /usr/arm/include/libavformat/* /usr/arm/include/ffmpeg
cp -v /usr/arm/include/libavdevice/* /usr/arm/include/ffmpeg
cp -v /usr/arm/include/libswscale/* /usr/arm/include/ffmpeg

Last but not least … MediaTomb! Time for some build system hacking again.
Enter the code directory

cd /root/code/mediatomb-0.11.0

Hack up the configure script a little. :)

vi configure.ac

Change the following line numbers.
2378, 2395, 2402, 2418
On each of those lines, you’re going to see the following section

"-lavformat -lavutil"

With this version of FFmpeg, a

"-lavcodec"

is needed. Here’s how mine turned out.
Line 2378

FFMPEG_LIBS="-L$FFMPEG_SEARCH_LIBS -lavcodec -lavformat -lavutil -lz"

Line 2395

FFMPEG_LIBS="-lavcodec -lavformat -lavutil"

Line 2402

FFMPEG_LIBS="-L$SEARCH_DIR_LIBS -lavcodec -lavformat -lavutil -lz"

Line 2418

FFMPEG_LIBS="-L$SEARCH_DIR_LIBS -lavcodec -lavformat -lavutil -lz"

Now it’s autotools time again.

aclocal
autoheader
autoconf
libtoolize
automake
./configure --host=arm-none-linux-gnueabi --prefix=/usr/arm --disable-external-transcoding --enable-ffmpeg --with-taglib-cfg=/usr/arm/bin/taglib-config --disable-libjs --disable-rpl-malloc --with-ffmpeg-lbs=/usr/arm/lib --disable-inotify --disable-mysql
make
make install

If all went well, you should see the following output

CONFIGURATION SUMMARY ----
sqlite3               : yes
mysql                 : disabled
libjs                 : disabled
libmagic              : yes
inotify               : disabled
libexif               : yes
expat                 : yes
id3lib                : disabled
taglib                : yes
ffmpeg                : yes
external transcoding  : disabled
libextractor          : disabled

Okay, now to create the required scripts, tar it up and send it to the Drobo! I’ve attached them here as text files and also as a ZIP file all of the necessary files.

The following two files go in the

/usr/arm

directory
mediatomb-stop.sh
mediatomb-start.sh

The following file goes into the

/usr/arm/config

directory. This directory does not exist in the default MediaTomb setup, just create it and put the file in there. This is the default configuration that MediaTomb creates on first startup except that the paths have been modified to work on the DroboShare. This file will definitely need some more tweaking.
config.xml

This ZIP file contains all of the original files in their original form. Just unzip this file to /usr/arm and move the configuration file to /usr/arm/config
configs_for_mediatomb.zip

Almost home … just create the Tarball

cd /usr/arm
tar cvfz ../mediatomb.tgz *

Now exit the chroot jail and upload

/var/chroot/drobo/usr/mediatomb.tgz

to the Drobo. For more information on how to add applications to the DroboShare, check out the DroboSpace site.

, , , , , , , ,

  1. #1 by Dave on January 9, 2009 - 2:00 pm

    Any chance of posting a version of your drobo mediatomb that I could install and test. Be happy to send you reports if you like.

    I’m getting a bit sick of fuppes…

    Here’s hoping!

    Dave

  2. #2 by ekrunch on February 3, 2009 - 12:00 pm

    Sorry Dave, but I cannot post it in binary format due to licensing restrictions. I’d really like to submit it to DroboSpace but licensing makes that a problem unless I include all of the source code and such with it.

  3. #3 by officialtrash on May 24, 2009 - 2:12 am

    Many thanks for posting this! I custom build MediaTomb (and all requirements) for my MacMini and thought “I should do this on my DroboShare.” Looks like you thought the same thing. Anyway, nice to have found your step-by-step!

  4. #4 by hoss on June 5, 2009 - 12:59 pm

    Thanks for the great post, Although I haven’t had the time to compile my own from the source I did go to mediatomb and download the static ARM bin, and it worked right away, well almost, still having problems getting it to multicast out on port 1900 but I’m sure I’ll get that figured out. if not this should help me to compile my own.

  5. #5 by Bruce on December 22, 2009 - 2:58 pm

    I’m having a problem creating the chroot jail. When I execute the debootstrap as shown at top of post, I get an error back that “E: No such script: intrepid”. It seems like I must be missing a development package, but I can’t figure out which ones. Any assistance would be greatly appreciated.

    Thanks.

  6. #6 by ekrunch on December 29, 2009 - 12:48 am

    The only thing I can think of is that you’re using an older version of Ubuntu and the intrepid build scripts aren’t there yet. You might try substituting the word “intrepid” for whatever the tag is for the release you’re running. If you’re using intrepid then you’re definitely missing a development package. I thought I had gotten them all in my instructions though.

  7. #7 by Bruce on December 29, 2009 - 11:15 am

    ekrunch :
    The only thing I can think of is that you’re using an older version of Ubuntu and the intrepid build scripts aren’t there yet. You might try substituting the word “intrepid” for whatever the tag is for the release you’re running. If you’re using intrepid then you’re definitely missing a development package. I thought I had gotten them all in my instructions though.

    I got it to work eventually by specifying the ubuntu source in the debootstrap command as a final parameter (essentially added http://ubuntu…... to the end of your command). I’m not sure why I needed it, but the environment worked like a champ! I’ve now completed compiling MediaTomb and built a new dropbear that (while bigger) contains public-key authentication. Automated rsync of my music library to the Drobo and made available on my living room PlayStation is almost there….

    Thanks for the blog!

  8. #8 by ianlondon on December 30, 2009 - 7:52 am

    Any chance of posting a version of your drobo mediatomb that I could install and test

  9. #9 by Bruce on December 30, 2009 - 9:23 am

    Another great thing to add to your tar file before installing it on the droboshare is a file to make the DroboApps Admin page link correctly to the cofiguration page of MediaTomb. Simply create a file called admin.url and put :49521 (or what ever port you have MediaTomb listening to.

  10. #10 by ekrunch on January 25, 2010 - 10:13 pm

    Bruce :

    I got it to work eventually by specifying the ubuntu source in the debootstrap command as a final parameter (essentially added http://ubuntu…... to the end of your command). I’m not sure why I needed it, but the environment worked like a champ! I’ve now completed compiling MediaTomb and built a new dropbear that (while bigger) contains public-key authentication. Automated rsync of my music library to the Drobo and made available on my living room PlayStation is almost there….

    Thanks for the blog!

    So apparently the font I use in this theme has messed up some of the commands. It turned the double dash into a single dash and is incorrectly pasted to the terminal window. I was repeating my steps for a new post i’m about to do (uShare on the DroboShare) and I had the same issue.

    The correct command has a double dash in front of the “variant” and “arch” words. The following example still won’t work in a copy/paste situation, but you’ll get the idea. :)
    sudo debootstrap – -variant=buildd – -arch i386 intrepid /var/chroot/drobo

    Sorry about that!

  11. #11 by RockZors on January 30, 2010 - 8:01 pm

    I have been following this and im up at taglib time.
    i get an error at the ./configure line

    configure: error: C++ preprocessor… “/lib/cpp” fails sanity check See ‘config.log’ for more details.

    and i dont know what im looking for… anyhelp?

    Link to contents of file: http://www.textdump.com/v/?k=NTY2Ng==

    I really want this to work cause i hate fuppes…

  12. #12 by ekrunch on January 31, 2010 - 10:15 am

    RockZors :

    I have been following this and im up at taglib time.
    i get an error at the ./configure line

    configure: error: C++ preprocessor… “/lib/cpp” fails sanity check See ‘config.log’ for more details.

    and i dont know what im looking for… anyhelp?

    Link to contents of file: http://www.textdump.com/v/?k=NTY2Ng==

    I really want this to work cause i hate fuppes…

    You might be having a copy and paste error. When you do the “prefix” and other commands on the configure line, you need two dashes in front of them. This blog theme messed them up when I posted this and put them as one dash instead of two.

    Try that and see what happens. Good luck!

  13. #13 by ekrunch on January 31, 2010 - 10:26 am

    UPDATE : I’ve put all of the code in a different format and it seems to have fixed the dash problems. You should be able to copy/paste things now or at least see if there are differences. Sorry for the confusion guys. WordPress displayed it differently and I never really snapped to it until recently.

  14. #14 by RockZors on February 1, 2010 - 9:10 pm

    Well i built it and moved it all over to my drobo, in the droboapps folder. It was extracted but thats all i get, it wont run, or anything. I didnt get any errors during the compile, so im not sure where i went wrong.

    The config page (:49521) wont work either

    You think you could email my your latest build for testing purposes?

  15. #15 by ekrunch on February 2, 2010 - 12:08 pm

    RockZors :

    Well i built it and moved it all over to my drobo, in the droboapps folder. It was extracted but thats all i get, it wont run, or anything. I didnt get any errors during the compile, so im not sure where i went wrong.

    The config page (:49521) wont work either

    You think you could email my your latest build for testing purposes?

    Sorry, but I don’t have my copy any more. I accidentally deleted it and haven’t rebuilt it yet. I’ve been super busy at work so I just haven’t had time to mess with it. I’ve also been using Xbox 360 to stream video and MediaTomb doesn’t support that anyway. :(

    Did you put the startup scripts in the archive? Make sure you reboot your droboshare after you upload the archive as well. I’d also SSH into the droboshare and see if you can start it manually. While you’re there, check the process table to see if it’s running. If it is, then use Netstat to find the port. 49152 is the default but it can change unless you specify it in the configuration. It’s worth a look. :)

  16. #16 by j_hah on June 21, 2010 - 3:13 am

    I found your article very helpful to getting my environment setup and to build mediatomb. I did have some issues enabling FFmpeg in mediatomb but gave up on that option since it doesn’t seem to add too much value.

    I’m writing up notes similar to yours for how to setup the environment and then how to build the latest mediatomb. I want to thank your for you effort.

    http://intellidick.com/wordpress/2008/12/30/building-mediatomb-for-the-drobo-using-ubunutu/

(will not be published)