Tuesday, February 7, 2012

Mosquitto on the PogoPlug

Pretend this is a Mosquitto...
Updated: Fixed the Makefile for the clients so they install to /usr.  Added links to the files and to the source package.

I got a PogoPlug this afternoon - the master plan being that all my gizmos talk to a broker on a low power computer of some sort - and this super cheap computer + an unused 8GB thumb drive seemed perfect.

The PogoPlug - in case you didn't click through - is a little linux computer intended to be "Your personal cloud" and allow you to share a USB drive via the Internet.  Which seems pretty cool.

For my purposes - it is a > $35 computer with 4 USB ports and Gig Ethernet.

So, after following these directions:  http://archlinuxarm.org/platforms/armv6/pogoplug-provideov3 and a couple issues (buggy udev and initscripts - a bit scary when ssh quit working a couple times*) I got ArchLinuxARM installed on this (a pretty well-paved path).

Next, I went looking for mosquitto for this in a "pacman" archive.  There was one there, but it was marked as "orphaned" (http://aur.archlinux.org/packages.php?ID=51571), so I updated this to install the bright and shiny 0.15 version that Roger just released the other day (http://mosquitto.org/download/).

Below are the files for this.  Keep in mind that I've never done this sort of packaging before - so be gentle. :)

They seem to work - at least they did for me - no guarantees though.  If you want to use them, copy them to a dir on your PogoPlug (assuming you have the dev environment installed already ('pacman -S kernel26-headers file base-devel abs python')), then as a non-root user, run 'makepkg -s' in the dir with these 2 files.  This will compile and build the pacman archive.  Then as root, run 'pacman -U mosquitto-0.15-1-arm.pkg.tar.xz' which will install this archive.

The benefits to installing like this is that you can now use pacman to manage (install, remove, etc) this package and don't end up with orphan files all over.

There is a repository for sharing this sort of thing at http://aur.archlinux.org/index.php - I haven't uploaded it yet - might be cool to have it up there though.

But it all works!  My Netduino is talking to Mosquitto on my PogoPlug!  :)

* If anyone wants to do this - let me know and I'll try to document the speed-bumps and the fixes.



# This is the PKGBUILD for mosquitto, an MQTT broker and example clients
# Maintainer: Gordon JC Pearce 
# Edits for 0.15 by Dan Anderson 
#

pkgname=mosquitto
pkgver=0.15
pkgrel=1
epoch=
pkgdesc="An MQTT broker and clients"
arch=(i686 x86_64 arm)
url="http://mosquitto.org/"
optdepends=('python: python support')
license=('BSD')
source=(http://mosquitto.org/files/source/$pkgname-$pkgver.tar.gz config.patch)
md5sums=('7ae0ac38f1f379578ab5530e5dc7269e'
         '2fd36955e7b5fe071e0a3e38e25ed46a')

build() {
  cd "$srcdir/$pkgname-$pkgver"
  patch -p1 < $srcdir/config.patch
  make
}

package() {
  cd "$srcdir/$pkgname-$pkgver"
  make DESTDIR="$pkgdir/" install
  install -Dm644 COPYING $pkgdir/usr/share/licenses/$pkgname/COPYING
}

# vim:set ts=2 sw=2 et:

And here is the config.patch file referenced above.


--- mosquitto-0.15/config.mk    2012-02-07 01:08:00.000000000 -0600
--- mosquitto-0.15/config.mk    2012-02-07 01:08:00.000000000 -0600
+++ mosquitto-0.15/config.mk.edit       2012-02-07 01:08:26.000000000 -0600
@@ -24,6 +24,6 @@ MSGMERGE=msgmerge
 MSGFMT=msgfmt
 DOCBOOK2MAN=docbook2man.pl

-prefix=/usr/local
+prefix=/usr
 mandir=${prefix}/share/man
 localedir=${prefix}/share/locale

--- mosquitto-0.15/client/Makefile      2012-02-05 03:13:24.000000000 -0600
+++ mosquitto-0.15/client/Makefile.edit 2012-02-07 22:54:00.000000000 -0600
@@ -2,7 +2,7 @@ CC=cc
 CFLAGS=-I../lib -Wall -ggdb
 LDFLAGS=-L../lib ../lib/libmosquitto.so.0
 INSTALL=install
-prefix=/usr/local
+prefix=/usr

 .PHONY: all install uninstall clean

Since copy/pasting these will mess with the md5 sums, here are links:
http://dananderson.us/pogo/PKGBUILD
http://dananderson.us/pogo/config.patch
Or both in a "source package"
http://dananderson.us/pogo/mosquitto-0.15-1.src.tar.gz
(Install with 'makepkg -s' then 'pacman -U mosquitto-0.15-1-arm.pkg.tar.xz')

I posted this to the AUR:  https://aur.archlinux.org/packages.php?ID=51571

6 comments:

  1. There's a bug... :)

    I need to go back and redo this tomorrow - I need to make diffs for several additional Makefiles to adjust the prefix (ArchLinux is not a fan of /usr/local).

    I'll do this tomorrow late (after the OMG meeting).

    ReplyDelete
  2. Try using "make prefix=/usr ..." instead of patching. It's much easier. It's also more robust that patching if the makefile changes in a future version.

    ReplyDelete
    Replies
    1. That doesn't actually work - it looks like config.mk doesn't check to see if $prefix is set and just overwrites it.

      Delete
    2. Odd, it definitely works here.

      Delete
    3. I don't know - I messed with it for a few more minutes and maybe I got it working - but I managed to clobber my mosquitto.conf in the process.

      I think I'll go fix that and then leave well enough alone until 0.16 comes out.

      Delete