Building Mosquitto on a Raspberry Pi

Just a few notes in case anyone wants to build the latest version of Mosquitto on a Raspberry Pi before Roger makes it even easier. Luckily there were already a couple of articles describing how to build Mosquitto, and the comments definitely saved some head scratching:

Hopefully the following steps should get MQTT on your Raspberry Pi in double quick time…

Firstly install a few packages. The unscientific list I went with were these, since Python was definitely installed already:

$ sudo aptitude update
$ sudo aptitude install build-essential quilt libwrap0-dev libssl-dev devscripts python-setuptools

Next the sneaky tweak to avoid Python 2.6 errors while building. You can edit /usr/share/python/debian_defaults by hand to move the python2.6 entry from the list of supported versions, or the following should do the trick:

$ sudo cp /usr/share/python/debian_defaults /usr/share/python/debian_defaults.orig
$ sudo sed -E -e '/^old-versions|^unsupported-versions/ s/$/, python2.6/' -e '/^supported-versions/ s/python2\.6,+ +//' /usr/share/python/debian_defaults.orig | sudo tee /usr/share/python/debian_defaults

Now it’s time to grab all the Mosquitto source and packaging files needed to run the build. These were the latest at the time of writing:

$ mkdir mosquitto-build
$ cd mosquitto-build/
$ wget http://mosquitto.org/files/source/mosquitto-1.1.tar.gz -O mosquitto_1.1.orig.tar.gz
$ tar -xvf mosquitto_1.1.orig.tar.gz
$ wget http://mentors.debian.net/debian/pool/main/m/mosquitto/mosquitto_1.1-1.debian.tar.gz
$ tar -zxf mosquitto_1.1-1.debian.tar.gz -C mosquitto-1.1/

Hopefully everything should be ready to go, so kick off the build:

$ cd mosquitto-1.1/
$ debuild -us -uc

That’s all there is to it. Assuming everything worked, just install the packages:

$ sudo dpkg -i ../*mosquitto*.deb

Update: Alternatively, you could just use the new, experimental, debian repository for mosquitto. (13 January 2013)

3 thoughts on “Building Mosquitto on a Raspberry Pi

  1. Pingback: MQTT Joggler | Notes from a small field

  2. I’m hoping to get the very latest version onto my Pi so i can use SSL functionality. but running into a problem and not sure how to proceed…

    daniel@minion ~/mosquitto-build/mosquitto-1.3.2 $ debuild -us -uc
    dpkg-buildpackage -rfakeroot -D -us -uc
    dpkg-buildpackage: source package mosquitto
    dpkg-buildpackage: source version 1.3.2-1
    dpkg-buildpackage: source changed by Roger A. Light
    dpkg-source –before-build mosquitto-1.3.2
    dpkg-buildpackage: host architecture armhf
    dpkg-checkbuilddeps: Unmet build dependencies: libc-ares-dev python-all (>= 2.6.6-3~) python3-all uthash-dev
    dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting
    dpkg-buildpackage: warning: (Use -d flag to override.)
    debuild: fatal error at line 1357:
    dpkg-buildpackage -rfakeroot -D -us -uc failed

Leave a comment