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 http://kojipkgs.fedoraproject.org/packages/freeradius/2.2.3/6.fc19/src/freeradius-2.2.3-6.fc19.src.rpm
  5. rpm -ihv --nomd5 freeradius-2.2.3-6.fc19.src.rpm
  6. cd /usr/src/redhat/SPECS; wget http://confluence.diamond.ac.uk/download/attachments/25140151/freeradius-2.2.3-6.spec
  7. cd /usr/src/redhat/SOURCES; wget https://raw.github.com/FreeRADIUS/freeradius-server/v2.x.x/redhat/freeradius-radiusd-init
  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"
    #%else
    #export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -fpic -fPIE -DPIE"
    #export LDFLAGS="-pie -Wl,-znow"
    #%endif
    
  9. rpmbuild --buildroot /tmp/rpmbuild -ba /usr/src/redhat/SPECS/freeradius-2.2.3-6.spec

Notes:
  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:

ivysetting.xml

<ivysettings>
 <!-- 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" />
 <resolvers>
  <chain name="public">
   <ibiblio name="spring-milestones" m2compatible="true" root="http://repo.springsource.org/libs-milestone/"  />
   <ibiblio name="ibiblio" m2compatible="true" />
  </chain>
 </resolvers>

 <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" />
</ivysettings>
Then we set up our ivy.xml to download the project dependencies

ivy.xml

<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd" xmlns:m="http://ant.apache.org/ivy/maven"
 xmlns:e="http://ant.apache.org/ivy/extra">
 
 <info organisation="adrian" module="boot" />
 <configurations defaultconfmapping="*->default">
  <conf name="main" />
 </configurations>
 
 <dependencies>
  <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"/>
 </dependencies>
</ivy-module>
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;

@Controller
@EnableAutoConfiguration
public class SampleController {

    @RequestMapping("/")
    @ResponseBody
    String home() {
        return "Hello World!";
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(SampleController.class, 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:

Packager

package adrian;

import java.io.File;
import java.io.IOException;

import org.springframework.boot.loader.tools.Libraries;
import org.springframework.boot.loader.tools.LibraryCallback;
import org.springframework.boot.loader.tools.LibraryScope;
import org.springframework.boot.loader.tools.Repackager;

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.setMainClass(mainClass);
  repackager.repackage(new Libraries() {
   @Override
   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>
 
 <target name="retrieve" unless="no.retrieve" depends="clean">
  <ivy:retrieve pattern="build/lib/main/[artifact]-[revision].[ext]" conf="main" type="jar,bundle" />
 </target>

 <target name="resolve" description="ivy" depends="retrieve">
  <ivy:cachepath pathid="main.classpath" conf="main" />
 </target>
 
 <target name="compile" depends="resolve">
  <mkdir dir="build/classes"/>
  <javac destdir="build/classes" classpathref="main.classpath" srcdir="src/main/java" includeantruntime="false"/>
 </target>
 
 <target name="jar" depends="compile">
  <jar destfile="build/boot.jar" basedir="build/classes"/>
 </target>
 
 <target name="package" depends="jar">
  <java classname="adrian.Packager">
   <classpath>
    <path refid="main.classpath"/>
    <pathelement location="build/classes"/>
   </classpath>
   <arg value="build/boot.jar"/>
   <arg value="adrian.SampleController"/>
   <arg value="build/lib/main"/>
  </java>
 </target>
</project>
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:

<ivysettings>
<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"/>
</ivysettings>

I ended up with this:

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

<url name="com.springsource.repository.bundles.milestone" m2compatible="true">
<artifact pattern="http://maven.springframework.org/milestone/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
</url>
<url name="jboss" m2compatible="true">
<artifact pattern="http://repository.jboss.org/nexus/content/groups/public-jboss/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
</url>
</chain>
</resolvers>

<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" />
</ivysettings>

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:

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

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.

mp

Tuesday, 16 March 2010

Charity

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.

Pros
  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.
Cons
  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.

Thursday, 17 September 2009

Spot the deliberate mistake

Got caught out today doing some Jave code at work.

I thought I'd be a good boy and use Commons Lang utilities to implement toString(), hashCode() and equals(). Spot the mistake here:

@Override
public int hashCode() {
return new HashCodeBuilder(13, 73).append(field1).append(field2).hashCode();
}


Any ideas? Here's the corrected version:

@Override
public int hashCode() {
return new HashCodeBuilder(13, 73).append(field1).append(field2).toHashCode();
}


An easy mistake to make when using an IDE with auto-complete.

Luckily I was saved by my unit tests!

Monday, 20 April 2009

More Ubuntu progress

With regard to my previous post, I have recently upgraded to 9.04. I was finally getting too fed up with sound and display issues on 8.04 so upgraded to 8.10 (Intrepid), but found no improvements with the NVidia integration and sound on Skype. I took the plunge and went for the 9.04 release candidate. I have to say it is a massive improvement for me with instant out of the box dual monitor support and the sound stuff all works without having to install pulseaudio.

I need Windows less and less now and I feel the writing really is on the wall for Microsoft. This seems to be confirmed by the increasing amount of laptops for sale with Linux rather than Windows.

Happy days.

Sunday, 8 March 2009

Printing from Windows XP to a CUPS shared printer on Ubuntu

On the face of it, this task would seem to be very simple and there are various pages with instructions on how to set this up. Basically you configure CUPS to allow the local USB printer to be shared and then set up a new network printer on windows that has the address http://<hostname>:631/printers/<printername>. The problem is that, whilst this all seems to work OK, when you print, nothing seems to actually hit the printer. Nothing meaningful in the CUPS logs.

Lots of Googling brought me to this page.

The really critical part which makes things work is :

"Now, once you have that information, you can open a command prompt on
Windows, and type in the following command (all on one line, it is
wrapped here):

rundll32 printui.dll,PrintUIEntry /b "Printer on Ubuntu" /x /n
"blah" /if /f %windir%\inf\ntprint.inf /r
"http://<hostname>:631/printers/<printername>" /m "MS Publisher Imagesetter"

That command will install the MS Publisher Imagesetter printer driver
(which is a printer driver that uses PostScript, which is what CUPS
takes as input), and setup the printer spool on Windows. You can then
open the Printers control panel and set the printer as the default
printer, and you will be able to print to it."

Thursday, 5 February 2009

Igloo in Milton Keynes

The most snow I've seen at home in my lifetime!

P1000623.JPG

Wednesday, 4 February 2009

Prince Caspian

My son Dylan got a Corn Snake for his 7th birthday. I made it's vivarium, but there is still quite a bit of kit to buy like a heat mat and thermostat.

Feeding time is once a week and is pretty amazing!


P1000568.JPG

Monday, 5 January 2009

Day 14 - going home

Pack up for the drive to Miami airport via Naples and the Delnor-Wiggins state park, basically a car park for the stunning beach where we stopped for lunch in the 85 degree sun. Luck enough to see a wild Dolphin cruising by.

Highway 41 takes us through the everglades where, unfortunately, we do not have enough time to stop and go on an air boat.

Day 13 - Chill out last full day

Our last real holiday day was spent mainly on the very local beach, apart from a short drive around to get some present shopping and a meal in Clearwater Beach at Clear Sky Cafe, highly recommended, followed by a walk up Pier 60 to look at all the local jewellry stalls.

Day 12 - Clearwater Aquarium

Today we head to the Clearwater Aquarium for a great day out including a boat trip around the Clearwater Harbour and talks about Winter, the Dolphin without a tail.

Day 11 - goodbye Disney, hello Gulf coast

Today we pack up and leave Tuscana Apartments and take a 90 minute drive west via Tampa to Indian Rocks beach where we have a beach apartment booked for 3 nights at Sun 'n' Fun.

The apartment is pretty old by US standards dating from 1925, and to be honest, it shows and could do with some investment on internal fixtures and fittings. You can't however fault the location as Indian Rocks is a quite area between Clearwater Beach and St. Pete's beach on a very narrow strip of land barely wide enough for the road. The beach is just out the back and is fantastic white fine sand leading to the Gulf of Mexico sea, a haven for Dolphins, Pelicans etc.

After a quick play on the beach, we head off to explore nearby Clearwater Beach and make a plan for tomorrow before a meal out at nearby JD's, a very nice local restaurant.

Thursday, 1 January 2009

Day 10 - Epcot twice and New Years Eve fireworks

Yet another early start to get to Epcot for the 8am opening and a rush to get Fast-passes for Soarin'. We get a 9:15-10:15 time-slot which is pretty quick as it soon gets to be 5pm plus with a 3 hour wait for the main queue.
n and
Once we get on, after also going to "Living with the land" and "Circle of Life", it's pretty clear why the queues get so big so quickly. The ride has us flying over various sights of California including Yosemite and Lake Tahoe.

Once done, we leave for lunch at Ponderosa steak house, probably all that is wrong with American food! Then back to our pool for the afternoon in really lovely sunshine.

Early evening sees us heading back to Epcot as we luckily discover that the usual 9:30pm fireworks are re-sheduled to 7:30pm as it's New Years Eve, making them early enough for Robyn and Dylan. The whole place is packed out, but it's worth it as they're the best fireworks I've ever seen, and they do them every evening of the year!

Wednesday, 31 December 2008

Day 9 - another visit to Blizzard Beach

Not too much to report today as we just had a slow start to get to Blizzard Beach by its 10am opening time before spending the whole day there until it closed at 5pm.

Good things about Florida (in no particular order)
  1. The weather
  2. Blue Diamond Wasabi and Soy roasted almonds
  3. Cheap petrol (29 pence/litre)
  4. Disney
  5. Minimum speed limit on Interstates
  6. Did I mention the weather?
  7. Right turn on red
  8. Overtaking on the inside
Bad things
  1. Annoying sales tax
  2. 4 way junctions

Tuesday, 30 December 2008

Day 8 - back to Animal Kingdom and an evening at Hollywood studios

Another early start sees us back to Animal Kingdom to get on the African Safari where we board a truck to see just about all of the major African animals in a very clever landscape. Then followed the Lion King show, a pretty cool 30 minute show and lunch in the Rainforest Cafe.

Following an afternoon back at the Apartment pool, we decide to head back into the Hollywood studios park for the evening Fantasmia show, and unfortunately have our first experience of bad Disney organization. Lots of un-organized queuing and a 15 minute late start.



click image to see pictures

Monday, 29 December 2008

Day 7 - back to Epcot

Time to get back to The Epcot Centre to try and finish off the bits we couldn't get to the first time around. The real highlight for me was Mission: Space, a simulated space flight to Mars. The simulator/ride was the best yet with loads of G forces, probably a bit too much for Dylan! I also really enjoyed the "Universe of Energy", presented/narrated by Ellen DeGeneres and also the huge aquarium tanks with sharks, rays, dolphins and turtles. A ride we missed again was "Soarin'", a hang gliding simulation that had a 160 minute queue and first fastpass ticket of about 9pm when we got to it.

We managed to finish up about our normal time allowing time to have a swim in the pool before tea.

Thinking about the 70-80 degrees temperature in winter, I wonder if I could swap the UKs climate, but of course give up our long summer evenings, I think it probably always gets dark by about 8pm at the latest here.