Monday, 27 January 2014

Building FreeRadius RPM for EL5

Hopefully this might be useful for some poor sucker who has to build a FreeRadius RPM for an antiquated OS.
I used this useful page as a starting point, so some of this is duplicated with a few important additions. My build is for version 2.2.3
  1. yum install rpm-build
  2. find /usr/src/redhat -type d | xargs chmod a+wx
  3. yum install autoconf automake gdbm-devel libtool libtool-ltdl-devel openssl-devel pam-devel zlib-devel net-snmp-devel net-snmp-utils readline-devel libpcap-devel openldap-devel perl-devel perl-ExtUtils-Embed python-devel mysql-devel postgresql-devel unixODBC-devel gcc make
  4. wget
  5. rpm -ihv --nomd5 freeradius-2.2.3-6.fc19.src.rpm
  6. cd /usr/src/redhat/SPECS; wget
  7. cd /usr/src/redhat/SOURCES; wget
  8. edit freeradius-2.2.3-6.spec to remove -fPIC stuff
    #%ifarch s390 s390x
    #export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -fPIC -fPIE -DPIE"
    #export LDFLAGS="-pie -Wl,-znow"
    #export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -fpic -fPIE -DPIE"
    #export LDFLAGS="-pie -Wl,-znow"
  9. rpmbuild --buildroot /tmp/rpmbuild -ba /usr/src/redhat/SPECS/freeradius-2.2.3-6.spec

  1. I found that the -fPIC CFLAGs made the libtool fail with a confusing message saying you need to add -fPIC.
  2. If you don't add --buildroot to the rpmbuild command you'll find it'll be blank and things will be put in all sorts of interesting locations. More worryingly it then deletes stuff and you end up losing things like /usr/include/* which is not good!

Friday, 29 November 2013

Spring-boot with Ant and Ivy

After seeing loads of exciting news about spring-boot I was a little disappointed to find, even though it was mentioned, no examples for building projects using Ant and Ivy. I contacted the team via Twitter and they pointed me at the spring-boot-loader-tools and suggested I give it a go myself. It turns out to be not all that difficult to get something simple going and here are the results in case any other Luddites are still using Ant and Ivy!
First we need to tell Ivy where the Maven repo is:


 <!-- this file overrides the default ivysettingsx.xml that is found inside the ivy.jar file -->
 <property name="ivy.checksums" value="sha1,md5" />
 <settings defaultResolver="default" />
  <chain name="public">
   <ibiblio name="spring-milestones" m2compatible="true" root=""  />
   <ibiblio name="ibiblio" m2compatible="true" />

 <include url="${ivy.default.settings.dir}/ivysettings-shared.xml" />
 <include url="${ivy.default.settings.dir}/ivysettings-local.xml" />
 <include url="${ivy.default.settings.dir}/ivysettings-main-chain.xml" />
 <include url="${ivy.default.settings.dir}/ivysettings-default-chain.xml" />
Then we set up our ivy.xml to download the project dependencies


<ivy-module version="2.0" xmlns:xsi="" xsi:noNamespaceSchemaLocation="" xmlns:m=""
 <info organisation="adrian" module="boot" />
 <configurations defaultconfmapping="*->default">
  <conf name="main" />
  <dependency org="org.springframework.boot" name="spring-boot" rev="0.5.0.M6" conf="main"/>
  <dependency org="org.springframework.boot" name="spring-boot-starter-web" rev="0.5.0.M6" conf="main"/>
  <dependency org="org.springframework.boot" name="spring-boot-loader-tools" rev="0.5.0.M6" conf="main"/>
Next, a very simple spring boot application, shamelessly ripped off:
package adrian;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

public class SampleController {

    String home() {
        return "Hello World!";

    public static void main(String[] args) throws Exception {, args);
This will compile and run in Eclipse, if we include all the downloaded jars in the classpath but, to make a nice single jar file application, we need to package up the code and the dependencies using some simple code:


package adrian;



public class Packager {
 public static void main(String[] args) throws Exception {
  String srcJar = args[0];
  String mainClass = args[1];
  final String libDir = args[2];
  Repackager repackager = new Repackager(new File(srcJar));
  repackager.repackage(new Libraries() {
   public void doWithLibraries(LibraryCallback libraryCallback) throws IOException {
    File lib = new File(libDir);
    String[] jars = lib.list();
    for (String jar : jars) {
     System.err.println("adding " + jar);
     libraryCallback.library(new File(lib + "/" + jar), LibraryScope.RUNTIME);

An example Ant build.xml

<?xml version="1.0"?>
<project name="boot" default="package" xmlns:ivy="antlib:org.apache.ivy.ant">
 <target name="clean">
  <delete dir="build"/>
 <target name="retrieve" unless="no.retrieve" depends="clean">
  <ivy:retrieve pattern="build/lib/main/[artifact]-[revision].[ext]" conf="main" type="jar,bundle" />

 <target name="resolve" description="ivy" depends="retrieve">
  <ivy:cachepath pathid="main.classpath" conf="main" />
 <target name="compile" depends="resolve">
  <mkdir dir="build/classes"/>
  <javac destdir="build/classes" classpathref="main.classpath" srcdir="src/main/java" includeantruntime="false"/>
 <target name="jar" depends="compile">
  <jar destfile="build/boot.jar" basedir="build/classes"/>
 <target name="package" depends="jar">
  <java classname="adrian.Packager">
    <path refid="main.classpath"/>
    <pathelement location="build/classes"/>
   <arg value="build/boot.jar"/>
   <arg value="adrian.SampleController"/>
   <arg value="build/lib/main"/>
And to run the final application we simply run
java -jar build/boot.jar

Monday, 28 March 2011

Adding additional repositories in ivy

Although I've been using ivy for quite a while, it's been pretty light touch as we had someone on the team who did all the config. Moving to another project where we're using it in a more traditional way I have started to get a bit more involved.

One of the first things we needed to do was add configuration for some more repositories. On the face of it, ivy is very well documented, but sometimes you can't see the wood for the trees (or should that be ivy :-)). I'm going to describe my understanding of the process I followed in the hope that it'll help someone else, or even that someone might comment and tell me how I could have done it much more simply.

The first part is understanding how the ivysettings.xml file works. This page shows how the default ivysettings.xml file, contained in the ivy jar file, is set up. To create your own settings, you must override the complete file in the current directory adding in all the sections contained in the original.

Starting with the original:

<settings defaultResolver="default"/>
<include url="${ivy.default.settings.dir}/ivysettings-public.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-shared.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-local.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-main-chain.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-default-chain.xml"/>

I ended up with this:

<settings defaultResolver="default" />
<chain name="public">
<ibiblio name="ibiblio" m2compatible="true" />

<url name="com.springsource.repository.bundles.milestone" m2compatible="true">
<artifact pattern="[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
<url name="jboss" m2compatible="true">
<artifact pattern="[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />

<include url="${ivy.default.settings.dir}/ivysettings-shared.xml" />
<include url="${ivy.default.settings.dir}/ivysettings-local.xml" />
<include url="${ivy.default.settings.dir}/ivysettings-main-chain.xml" />
<include url="${ivy.default.settings.dir}/ivysettings-default-chain.xml" />

Most of the file is the same as the original except that we have overridden the public resolver chain. The original
<include url="${ivy.default.settings.dir}/ivysettings-public.xml"/>
section includes a file that looks like this:

<ibiblio name="public" m2compatible="true"/>

This content has been replace with an identical inline section that starts with the original ibiblio resolver and then add 2 additional Maven repos for Spring milestones and jboss.

Sunday, 10 October 2010

Good customer service

My super Philips electric toothbrush recently decided to give up the ghost. It developed a most unwelcome fault of switching itself on in the middle of the night. It's a brilliant brush that I bought new from an eBay seller for a good price well over a year ago and as it went wrong while I was on holiday I decided to buy another one. Luckily they were on special offer in Boots!

When I returned from holiday I decided I had nothing much to lose by sending it back to Philips with a covering letter. I reckon around 18 months is not very good for a product that retails for over £100.

Well, low and behold, on Saturday, a new one arrived in the post.

Top marks to Philips. Probably costs them very little and now means I'll be buying their products in the future.

Tuesday, 5 October 2010

Child Benefit

I have decided to write to my MP.


Tuesday, 16 March 2010


Just got one of those plastic bags through the door to fill up with junk in aid of the Air Ambulance.

It's amazing in this country that we think it's normal to have major charities for 2 really important things, #1, various Air Ambulance groups and #2, the RNLI.

How is it that we're prepared to spend millions, or is it billions, of pounds funding the armed forces to go and blow people up all around the world, but we can't spare a few boats and helicopters plus crew to save the lives of people in our own country?

Sunday, 10 January 2010

Adria Altea 542 DT Caravan review

We bought this caravan last June (2009) and I thought it'd be good to do a small review to help other prospective purchasers.
We got ours from Broad Lane leisure in Daventry as VERY nearly new purchase, someone else had had it for a couple of months and only used it once, so it was hard to tell.

Our main criteria (in order) for selecting this caravan were:
  1. Layout - a good compomise for us, as the bunk beds are very wide and the bathroom is still much more than a cupboard.
  2. Weight - for the size, these vans are lightweight and we are limited by the car we tow with (Citreon C4 Picasso 138bhp).
  3. Price - these vans are very competitivley priced.
  4. Good reputation for build quality.
Of course, all caravans are a compromise and nearly all of the above come at a price of one sort or another, so I thought a list of the pros and cons might be useful, although I'll try and justify the reasons that certain things might be somewhat lacking.

  1. Price, about £11K for a 6 berth van is pretty much un-beatable.
  2. Layout is pretty much unique and as our 2 children grow older the wide bunks and also the wide single bed will hopefully be appreciated. A half-decent bathroom is also nice to have.
  3. Lightweight - about 1300KG fully loaded is amazing for this size of caravan.
  1. Small fridge - probably to keep the weight and cost down.
  2. Slightly flimsy fittings in some areas, again probably to keep the weight down. In particular the bunk beds do seem to flex a bit an I wonder if their stated 85 kg weight limit might be a bit optimistic. Also the overhead cupboard stays are plastic and I wonder if they will last.
  3. Heater is gas only, was sort of expecting electric as well, again probably budget related.
  4. Nose weight has to be very carefully checked. We only have one small 3.9kg propane gas cylinder in the front locker and it's already on the limit.
  5. Shower tray and basin plugs are very odd and I suspect peculiar to either Adira or continental caravan in general. They get jammed in very easily and you'd be advised to have a pair of pliars on hand to loosen them if necessary.
  6. Velcro cushion fixings have nearly all come off but I'm manged to glue them all back down again.
  7. Slightly dingy lighting at the rear end near the bunk beds, I noticed at recent show at Milton Keynes shopping centre, that the display model had an extra skylight there, not sure if this is now standard, or just an optional extra.