My first archlinux package - ttyrec

Having been experimenting with archlinux on eeepc for a few months now. I've been itching to package something up for fun to see how easy/hard it would be. I've finally got a chance make a package. Here's the resulting PKGBUILD file for ttyrec

# Maintainer: Jimmy Tang <jtang@tchpc.tcd.ie>

pkgname=ttyrec-git
pkgver=20100201
pkgrel=1
pkgdesc="ttyrec is a tty recorder - this is not the official upstream version"
arch=('i686' 'x86_64')
url="http://git.kitenet.net/?p=ttyrec.git"
license=('BSD')
makedepends=('git')

_gitroot="git://git.kitenet.net/ttyrec.git"
_gitname="ttyrec"

build() {
  cd "$srcdir"
  msg "Connecting to GIT server...."

  if [ -d $_gitname ] ; then
    cd $_gitname && git pull origin
    msg "The local files are updated."
  else
    git clone $_gitroot
  fi

  msg "GIT checkout done or server timeout"
  msg "Starting make..."

  rm -rf "$srcdir/$_gitname-build"
  git clone "$srcdir/$_gitname" "$srcdir/$_gitname-build"
  cd "$srcdir/$_gitname-build"

  #
  # BUILD HERE
  #
  make CFLAGS="-O2 -Wall -DSVR4 -D_XOPEN_SOURCE=500" || return 1
  install -d $pkgdir/usr/share/doc/$pkgname $pkgdir/usr/share/man/man1 $pkgdir/usr/bin
  install -D ttyrec.1 ttyplay.1 ttytime.1 $pkgdir/usr/share/man/man1
  install -D README $pkgdir/usr/share/doc/$pkgname
  install -Dm755 ttyrec ttyplay ttytime $pkgdir/usr/bin
}

It's actually a butchered version of what I found inside the PKGBUILD file for ikiwiki-git. The above isn't for the official version of ttyrec, but rather a patched up verion from Joey Hess. I had stumbled on his repo for it when I was reading his blog post on termcasting and got interested in ttyrec. I can think up a few useful things to do with ttyrec already, such as replacing a user's shell with ttyrec to record their sessions to playback :)

Making Ikiwiki go faster

I've been using ikiwiki for the past year or two for my blog, but it's gotten progressively slower. So I've turned off some of the RSS and ATOM feeds that are on my blog in hopes that things will run faster. Maybe I should turn off more stuff? The question is, how much do I turn off? Anyway, step 1. upgrade ikiwiki, step 2. upgrade all its dependancies!

Setting up a handle.net account for DSPACE

This assumes you have DSPACE 1.5.x already running and working and that you had previously only used a dummy handle. It's as simple as doing

/dspace/bin/dsrun net.handle.server.SimpleSetup /dspace/handle-server

I found this buried in the DSPACE installation manual http://www.dspace.org/1_5_2Documentation/ch03.html#N10AA6 this link was forwarded to me from the handle.net crowd, as far as I know its the CNRI who run the show.

Just follow the instructions, have a credit card and paypal account ready to pay and make sure you have at least these details prepared...

  • Description of server site
  • Organisation name
  • Contact person's name
  • Telephone number
  • Email address for a contact
  • Two passwords for securing the system, I guess make sure you have them in a safe place and don't lose them.

Once the simple setup is completed and you have followed all the instructions, you will be directed to a page to pay the fee for the setup. Then you will be asked to upload sitebndl.zip to the handle.net site. Overall I found the experience with setting a handle.net account and server with DSPACE to be generally pleasant. Now all I need to do is put the system into production. Overall is two thumbs up for CNRI and the DSPACE devs for making it easy to setup this stuff and being helpful in the process.

Archlinux on my eeepc 701

Been playing with archlinux recently, its everything that gentoo should have been. I downloaded the USB image then proceeded to install it on to my eeepc 701. I then found this http://wiki.archlinux.org/index.php/Asus_Eee_PC_701, which I so rightly read and took some hints from it.

I did all the usual things of turn off the swap disk, mounting /tmp and /var/log into a tmpfs and I made sure that noatime was enabled for the filesystems that I do have on the SSD.

Another thing I did was put nilfs2 on my SD card and mounted /home on it. So most of my writes are now either in memory or on my SD card which I can replace relatively cheaply and easily.

Made ikiwiki go faster

I eventually made ikiwiki go much faster than what I was experiencing before. It had turned out that the aggregate plugin left some trash in my tree of files, I some how ended up accumulating about 10k number of small files.

After I had removed the loose files I ran a rebuild/refresh, and now its down to ~3seconds for a refresh of my site. Not bad I guess.

Using dar to archive directories of files

I've been migrating user home directories from one machine to another machine recently. In doing so I've come across the age old problem of users having too much junk, old user directories that need to be backed up for future reference and so on.

Instead of using tar like I normally would for most things, I chose to use dar. dar gives me the possibility of being able extract a single file without needing to stream through the entire archive.

To archive a user's home directory this is what I run

dar -c user -R / -g home/user -v

I guess rtfm and check man pages to see what the above options mean. Note I also have this in my .darrc

    #########################
    #           #
    #   Shared options pro  #
    #    DAR archiver   #
    #           #
    #########################

# Jakub Holy, 25.4.2005
# This file: /etc/darrc
# Note: If the user has her $HOME/.darrc, this file is ignored => it must be included with the option -B /etc/darrc to dar

###
### Files that shall not be compressed (because they're already)
###
# archives (Note: .tar is archive, but not compressed => do compress it).
-Z "*.bz2" -Z "*.deb" -Z "*.gz" -Z "*.Z" -Z "*.zip" -Z "*.rar" -Z "*.tbz2" -Z "*.tgz" -Z "*.jar" -Z "*.ear" -Z "*.war"
-Z "*.BZ2" -Z "*.DEB" -Z "*.GZ" -Z "*.Z" -Z "*.ZIP" -Z "*.RAR" -Z "*.TBZ2" -Z "*.TGZ" -Z "*.JAR" -Z "*.EAR" -Z "*.WAR"
# media - images
-Z "*.gif" -Z "*.jpeg" -Z "*.jpg" -Z "*.png" 
-Z "*.GIF" -Z "*.PNG" -Z "*.JPEG" -Z "*.JPG"
# media - audio
-Z "*.ogg" -Z "*.mp3"
-Z "*.OGG" -Z "*.MP3"
# media - video
-Z "*.avi" -Z "*.mov" -Z "*.mp4" -Z "*.mpg"
-Z "*.AVI" -Z "*.MOV" -Z "*.MP4" -Z "*.MPG"
# documents - compressed formats
-Z "*.pdf" -Z "*.swf" -Z "*.sxw"
-Z "*.PDF" -Z "*.SWF" -Z "*.SXW"
# strange formats, binaries and other hard to compress (empirical)
-Z "*.gpg" -Z "*.rnd" -Z "*.scm" -Z "*.svgz" -Z "*.vlt" -Z "*.zargo" -Z "*.wings" -Z "*.xpi" -Z "*.chm"
-Z "*.GPG" -Z "*.RND" -Z "*.SCM" -Z "*.SVGZ" -Z "*.VLT" -Z "*.ZARGO" -Z "*.WINGS" -Z "*.XPI" -Z "*.CHM"
-Z "*.obj" -Z "*.tif" -Z "*.tiff"
-Z "*.OBJ" -Z "*.TIF" -Z "*.TIFF"

###
### Ignored files
###
-X "*~" -X "*.o"    
# *~ are backups, *.o are compiled unlinked files

### jt's custom options
# -m dont compress files less than this size in bytes
# -v verbose
# -s slice up in this size
# -y compress with bzip2
-m 256 
-v
-s 2000M
-y

Once the archive has been created, it's probably not a bad idea to test it, you can do so by doing

dar -t user --noconf
State of the Irish Economy

I had previously posted this rant elsewhere, but here it goes again here.

It's cracked. There is a load of media hype targeted at the public sector in Ireland right now. The public sector is also getting (or has got) yet another pay cut. To top it all off, the Irish government has been pushing for a smart knowledge based economy, but guess what, all those contract staff that aren't seeing any benefit of being a public civil servant is getting a pay cut too!

Other sucky things so far in the system is NAMA and the raiding of state pensions, the government is just driving the state into a huge hole. It's forcing people to leave, and thus creates a feedback loop in creating even more debt or rather the lack of paying it back.

If the state had any sense then they should let the system sort itself out and not intervene. Let the strong prevail and let the weak fail. I mean it is meant to be a capitalistic state/society.

What's my name?

I've recently sent in an application to get naturalised, but it was returned to me due to some mistakes in the application form. For the love of god, if you are applying for naturalisation in Ireland, read the forms and double check simple things like names and make sure they match up to what you have on your birth certificate. If not you will require a Birth Affidavit.

The process so far has been obscure, painful and full of legal mine fields.


Related posts:

GNIB 2011 (till 2012) - Here I go again
Posted

New Irish citizens will have to swear oath of fidelity
Posted

Astro, Particle, High Energy physics is cool
Posted

2011-05 -- Update on long naturalisation times in Ireland
Posted

Do people give a crap when they can not give a crap?
Posted

One Step Closer to OAI Compliance

After Setting up a handle.net account for DSPACE I needed to start and look at making my DSPACE install OAI compliant. I was directed to Open Archives, after a bit of googling I ended up at the wiki page Use the OAI-PMH interface. It turns out that to enable the OAI-PMH interface all I had to do was just drop the dspace-oai.war file into the same webapps directory as my dspace.war deployment, restart my app server and bob's you're uncle.

To quote the dspace wiki page on OAI-PMH

  • Identify . used to retrieve information about a repository: http://web-address-to-my-dspace/dspace-oai/request?verb=Identify
  • ListMetadataFormats . lists metadata formats supported for OAI-PMH: http://web-address-to-my-dspace/dspace-oai/request?verb=ListMetadataFormats
  • ListRecords . permits metadata harvesting of all or a selection of items: http://web-address-to-my-dspace/dspace-oai/request?verb=ListRecords&metadataPrefix=oai_dc
  • ListSets . lists the .sets. (i.e. DSpace Collections) available in a repository: http://web-address-to-my-dspace/dspace-oai/request?verb=ListSets

Using the above knowledge I tested my OAI-PMH interface with a web browser. I was quite pleased at yet again how easy it was to get this functionality working. That's another two thumbs up to DSPACE and friends.

Your Country Your Call, if I had a choice...

It seems that the smart economy is just yet more glarg..%&^"?!'... it's a clear sign of desperation. I'm not too sure on how to react or respond to this. According to the website that the prize fund is provided fully by Irish and non-Irish corporations, as well as a small number of Irish firms and individuals. It also has the backing of the Irish government. I wonder what the break down is in terms of funding between the various bodies. Still 1.2 million euro as prize money plus development money is no small amount. Still, I question what the government did to convince the various corporations to put forward the funding.

DWM and Java based programs

Every so often I need to run java based programs or programs that use a java based front end. For example I occasionally need to fire up openoffice, matlab, mathematica, ireports and almost everytime I forget what environment variables to try and set to get the interfaces working properly under DWM

So try

export AWT_TOOKIT=MToolkit
./app

or

wmname LG3D
unset AWT_TOOLKIT
./app

Usually one or the other will work. If not I usually just start up Xnest or a secondary Xserver running a different windowmanger to run that one application. Note, wmname is a suckless.org tool.

Otaku and in Ireland?

It just occured to me that I am a bit of an anime junkie, or well I used to be. I feel too old to watch anime, yet I still watch my weekly fix of Bleach and Naruto. I still look forward to all the good stuff that Studio Ghibli has to offer and of course, I'm quite partial to the Gundam and Macross franchise. There's so little time and so much anime that needs my attention.

So back to being an Otaku in Ireland, you really need to be a part of eirtakon.com. There's also an irc channel that the members frequent. The irc channel can be found at irc.synirc.net on channel #eirtakon and irc.synirc.net on channel #eirtaku

By the way did I mention I'm a narutard?

Compiling scalapack on SL5x

Just some notes for myself nothing to see here...

List of needed software

Steps

To install scalapack from source you will need to above list of dependancies installed. We will assume that your system has gcc, g++ and gfortran installed.

Configure, Compile and Install openmpi

tar zxvf src/openmpi-1.4.1.tar.gz 
cd openmpi-1.4.1/
./configure --prefix=$HOME/local
export PATH=$HOME/local/bin:$PATH
export LD_RUN_PATH=$HOME/local/lib
export LD_LIBRARY_PATH=$HOME/local/lib

Configure, Compile BLAS

tar zxvf blas.tgz
cd BLAS
make all FORTRAN=gfortran LOADER=gfortran
cp blas_LINUX.a $HOME/local/lib/libblas.a

you may or may not want to edit make.inc to customise the build more.

Configure, Compile LAPACK

tar zxvf lapack.tar.gz
cd lapack-3.2.1/
cp make.inc.example make.inc

The default settings are pretty sensible and should work fine with gfortran. Copy the BLAS library that you compiled earlier on to the lapack build directory. (or edit make.inc to point to the correct blas library)

cp ../BLAS/blas_LINUX.a .

Then just type make in the lapack directory. It will compile the lapack library and also run some tests. You should go into the TESTING directory and look for failures in the *.out files and investigate any significant failures. You should be left with a lapack_LINUX.a in the build directory

Configure, Compile mpiblacs

tar zxvf mpiblacs.tgz
cd BLACS
cp BMAKES/Bmake.MPI-LINUX ./Bmake.inc

Before you can compile BLACS/MPIBLACS you should go into the INSTALL directory and type make help. You will need to run some of the tests to correctly set the options needed to make BLACS work correctly.

You will need to know the location of the build directory in my case it was /home/jtang/develop/hpce2-scalapack/BLACS

So I did

cd INSTALL
make xintface F77=gfortran BTOPdir=$HOME/develop/hpce2-scalapack/BLACS
make xsize F77=gfortran BTOPdir=$HOME/develop/hpce2-scalapack/BLACS
make xsyserrors F77=gfortran BTOPdir=$HOME/develop/hpce2-scalapack/BLACS MPIdir=$HOME/local MPILIBDir=${MPIdir}/lib MPILIB="$HOME/local/lib/libmpi.so"

Run the above programs

./EXE/xintface
For this platform, set INTFACE = -DAdd_

./EXE/xsize 
ISIZE=4
SSIZE=4
DSIZE=8
CSIZE=8
ZSIZE=16


mpirun -np 4 ./EXE/xsyserrors 
libibverbs: Fatal: couldn't read uverbs ABI version.
--------------------------------------------------------------------------
[[34681,1],0]: A high-performance Open MPI point-to-point messaging module
was unable to find any relevant network interfaces:

Module: OpenFabrics (openib)
  Host: duo

Another transport will be used instead, although this may result in
lower performance.
--------------------------------------------------------------------------
If this routine does not complete, you should set SYSERRORS = -DZeroByteTypeBug.
Leave SYSERRORS blank for this system.

Take note of the output as you will need it to build BLACS. You should also build and run the following targets to make sure you get the right settings.

make xtc_CsameF77 F77=mpif90 BTOPdir=$HOME/develop/hpce2-scalapack/BLACS MPIdir=$HOME/local MPILIBDir=${MPIdir}/lib MPILIB="$HOME/local/lib/libmpi.so"

mpirun -np 4 ./EXE/xtc_CsameF77
--------------------------------------------------------------------------

[[42923,1],0]: A high-performance Open MPI point-to-point messaging module
was unable to find any relevant network interfaces:

Module: OpenFabrics (openib)
  Host: duo

Another transport will be used instead, although this may result in
lower performance.
--------------------------------------------------------------------------
libibverbs: Fatal: couldn't read uverbs ABI version.
libibverbs: Fatal: couldn't read uverbs ABI version.
libibverbs: Fatal: couldn't read uverbs ABI version.
libibverbs: Fatal: couldn't read uverbs ABI version.
 If this routine does not complete successfully,
 Do _NOT_ set TRANSCOMM = -DCSameF77


[duo:27485] *** An error occurred in MPI_Comm_free
[duo:27485] *** on communicator MPI_COMM_WORLD
[duo:27485] *** MPI_ERR_COMM: invalid communicator
[duo:27485] *** MPI_ERRORS_ARE_FATAL (your MPI job will now abort)
 Do _NOT_ set TRANSCOMM = -DCSameF77
--------------------------------------------------------------------------
mpirun has exited due to process rank 3 with PID 27486 on
node duo exiting without calling "finalize". This may
have caused other processes in the application to be
terminated by signals sent by mpirun (as reported here).
--------------------------------------------------------------------------
[duo:27482] 3 more processes have sent help message help-mpi-btl-base.txt / btl:no-nics
[duo:27482] Set MCA parameter "orte_base_help_aggregate" to 0 to see all help / error messages
[duo:27482] 1 more process has sent help message help-mpi-errors.txt / mpi_errors_are_fatal

The next two are just sanity checks

make xcmpi_sane F77=gfortran BTOPdir=$HOME/develop/hpce2-scalapack/BLACS MPIdir=$HOME/local MPILIBDir=${MPIdir}/lib MPILIB="$HOME/local/lib/libmpi.so"
make xfmpi_sane F77=mpif90 BTOPdir=$HOME/develop/hpce2-scalapack/BLACS MPIdir=$HOME/local MPILIBDir=${MPIdir}/lib MPILIB="$HOME/local/lib/libmpi.so"

mpirun -np 4 ./EXE/xcmpi_sane
mpirun -np 4 ./EXE/xfmpi_sane

With the above information I go back into the build directory. (see also http://www.open-mpi.org/faq/?category=mpi-apps#blacs, the TRANSCOMM option needs to be set to -DUseMpi2)

make F77=mpif90 BTOPdir=$HOME/develop/hpce2-scalapack/BLACS MPIdir=$HOME/local MPILIBDir=${MPIdir}/lib MPILIB="$HOME/local/lib/libmpi.so" TRANSCOMM=-DUseMpi2 INTFACE=-DAdd_  mpi what=clean
make F77=mpif90 BTOPdir=$HOME/develop/hpce2-scalapack/BLACS MPIdir=$HOME/local MPILIBDir=${MPIdir}/lib MPILIB="$HOME/local/lib/libmpi.so" TRANSCOMM=-DUseMpi2 INTFACE=-DAdd_  mpi

Then cd into the TESTING Directory

make F77=mpif90 BTOPdir=$HOME/develop/hpce2-scalapack/BLACS MPIdir=$HOME/local MPILIBDir=${MPIdir}/lib MPILIB="$HOME/local/lib/libmpi.so" TRANSCOMM=-DUseMpi2 INTFACE=-DAdd_

Then if you wish and have time, run the tests.

Going back to the root of the BLACS directory you should see that there is now a LIB directory containing the libraries that you have built.

Configure, Compile SCALAPACK

You will need to know the locations of the above compiled BLAS, LAPACK and BLACS libraries and some of the settings from the BLACS compilation.

tar zxvf scalapack.tgz
cd scalapack-1.8.0
cp  SLmake.inc.example SLmake.in
make home=$HOME/develop/hpce2-scalapack/scalapack-1.8.0 BLASLIB=$HOME/develop/hpce2-scalapack/BLAS/blas_LINUX.a LAPACKLIB=$HOME/develop/hpce2-scalapack/lapack-3.2.1/lapack_LINUX.a BLACSFINIT=$HOME/develop/hpce2-scalapack/BLACS/LIB/blacsF77init_MPI-LINUX-0.a BLACSCINIT=$HOME/develop/hpce2-scalapack/BLACS/LIB/blacsCinit_MPI-LINUX-0.a BLACSLIB=$HOME/develop/hpce2-scalapack/BLACS/LIB/blacs_MPI-LINUX-0.a CDEFS="-DAdd_ -DNO_IEEE -DUsingMpiBlacs" SMPLIB=""
Libtool was broken on my macbook

I recently got errors similar to this

libtool: Version mismatch error. This is libtool 2.2.6, but the
libtool: definition of this LT_INIT comes from libtool 2.2.4.
libtool: You should recreate aclocal.m4 with macros from libtool 2.2.6
libtool: and run autoconf again.

This was happening when I wanted to do a "port upgrade gimp2", basically almost anything that needed libtool and automake would fail miserably. Libtool had probably been upgraded at some point and since I don't blanket upgrade everything I didn't notice that it wasn't working. I tried a number of things to upgrade/fix the brokeness.

So I tried doing

port -v -nR upgrade --force libtool

This would rebuild a handful of packages that depended on libtool. Doing this still failed for me, it appeared that autoconf was picking the system versions of libtool, autoconf and automake. This had baffled me for a while since when I echo'd my $PATH it was showing the correct path.

Then it had occured to me to check if macports was resetting/setting my environment before it built a package. After looking at http://guide.macports.org/chunked/reference.variables.html I checked my macports.conf, it turned out that my binpath was just wrong, I had the system paths defined before my macport install. I just commented out the binpath variable and ran a rebuild of gimp2, everything was working again.

I must have changed the binpath for some reason or another at somepoint to fix something else, that something else makes me think it was openssl that was boned.

Flattening out a XML containing metadata for my iCAT metadata (iRODS)

I've been thinking again about flattening some metadata that is stored in a hierarchical structure in an XML file to a form that the XML micro service understands. The microservice effectively only takes in XML files with this type of data

<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<AVU>
<Attribute>Alice</Attribute>
<Value>1</Value>
<Unit>Years Old</Unit>
</AVU>

Of course my metadata.xml doesn't fit this model, it is of the form.

<?xml version="1.0" encoding="UTF-8"?>
<Metadata xsi:schemaLocation="http://www.hpc-europaII.org/jra3 schema.xsd" 
xmlns="http://www.hpc-europaII.org/jra3" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Source>
        <Experiment>
            <expUID>SOMEVALUE</expUID>
            <expURI></expURI>
        </Experiment>
        <Tools>
            <ShortName>
            UG
            </ShortName>
            <Version>0bcfb63f7c6c67cd954609c3a90a27b2</Version>
        </Tools>
        <Authors>
            <Name>
                <First>
Alice
</First>
                <Middle></Middle>
                <Last>
Bob
</Last>
            </Name>
            <Role>
            Group Leader
            </Role>
            <Address>
                <Street>Some Street</Street>
                <PostalCode>Some PostalCode</PostalCode>
                <City>Some City</City>
                <Country>Some Country</Country>
                <Phone>Some Number</Phone>
                <E-mail>Some E-mail Address</E-mail>
                <Web>Some Web Address</Web>
            </Address>
        </Authors>
        <Institutes>
            <ShortName>Some ShortName for a Lab</ShortName>
            <Address>
                <Street>Some Street</Street>
                <PostalCode>Some PostalCode</PostalCode>
                <City>Some City</City>
                <Country>Some Country</Country>
                <Phone>Some Number</Phone>
                <E-mail>Some E-mail Address</E-mail>
                <Web>Some Web Address</Web>
            </Address>
        </Institutes>
    </Source>
    <Science>
    </Science>
    <Results>
    </Results>
</Metadata>

I had a look at http://nwalsh.com/docs/tutorials/extreme04/, http://www.w3.org/TR/xslt20/ and the example posted at http://groups.google.com/group/irod-chat/browse_thread/thread/1a1669bf1e36c205/46a904d3e5d651fd?lnk=gst&q=irods+%26+ddi%3F#46a904d3e5d651fd

In the end I came up with this simple xsl file

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
                xmlns:jra3="http://www.hpc-europaII.org/jra3"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                exclude-result-prefixes="xsi jra3">

  <!-- output will be in XML with indents for ease of reading -->
  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

  <!-- skip over first tag -->
  <!-- xsl:template match="jra3:Metadata" priority="2"/ -->

  <!-- strip out the white space at the top of the file -->
  <xsl:strip-space elements="*"/>

  <!-- puts <avu></avu> around the attribute-value-unit triplets -->
  <xsl:template match="/">
    <metadata>
      <xsl:text>&#xA;</xsl:text>
      <xsl:text>&#xA;</xsl:text>
      <xsl:apply-templates/>
    </metadata>
  </xsl:template>

  <!-- call the templates -->
  <xsl:template match="jra3:Source">
    <xsl:apply-templates select="jra3:Experiment//jra3:expUID"/>
    <xsl:apply-templates select="jra3:Experiment//jra3:expURI"/>
    <xsl:apply-templates select="jra3:Tools//jra3:ShortName"/>
    <xsl:apply-templates select="jra3:Tools//jra3:Version"/>
    <xsl:apply-templates select="jra3:Authors//jra3:Name//jra3:First"/>
    <xsl:apply-templates select="jra3:Authors//jra3:Name//jra3:Middle"/>
    <xsl:apply-templates select="jra3:Authors//jra3:Name//jra3:Last"/>
    <xsl:apply-templates select="jra3:Authors//jra3:Role"/>
    <xsl:apply-templates select="jra3:Authors//jra3:Address"/>
    <xsl:apply-templates select="jra3:Institutes//jra3:ShortName"/>
    <xsl:apply-templates select="jra3:Institutes//jra3:Address"/>
  </xsl:template>

  <!-- begin output -->
  <xsl:template match="jra3:Experiment//jra3:expUID">
    <AVU>
      <Attribute>Source/Experiment/expUID</Attribute>
      <Value>
        <xsl:value-of select="normalize-space(.)"/>
      </Value>
      <Unit>
        <!-- xsl:value-of select="normalize=space(.)"/ -->
      </Unit>
    </AVU>
    <xsl:text>&#xA;</xsl:text>
    <xsl:text>&#xA;</xsl:text>
  </xsl:template>

  <xsl:template match="jra3:Experiment//jra3:expURI">
    <AVU>
      <Attribute>Source/Experiment/expURI</Attribute>
      <Value>
        <xsl:value-of select="normalize-space(.)"/>
      </Value>
      <Unit/>
    </AVU>
    <xsl:text>&#xA;</xsl:text>
    <xsl:text>&#xA;</xsl:text>
  </xsl:template>

  <xsl:template match="jra3:Tools//jra3:Version">
    <AVU>
      <Attribute>Source/Tools/Version</Attribute>
      <Value>
        <xsl:value-of select="normalize-space(.)"/>
      </Value>
      <Unit/>
    </AVU>
    <xsl:text>&#xA;</xsl:text>
    <xsl:text>&#xA;</xsl:text>
  </xsl:template>

  <xsl:template match="jra3:Tools//jra3:ShortName">
    <AVU>
      <Attribute>Source/Tools/ShortName</Attribute>
      <Value>
        <xsl:value-of select="normalize-space(.)"/>
      </Value>
      <Unit/>
    </AVU>
    <xsl:text>&#xA;</xsl:text>
    <xsl:text>&#xA;</xsl:text>
  </xsl:template>

  <xsl:template match="jra3:Authors//jra3:Name//jra3:First">
    <AVU>
      <Attribute>Authors/Name/First</Attribute>
    </AVU>
    <xsl:apply-templates select="jra3:Authors//jra3:Name//jra3:First"/>
  </xsl:template>

  <!-- begin output -->
  <xsl:template match="jra3:Experiment//jra3:expUID">
    <AVU>
      <Attribute>Source/Experiment/expUID</Attribute>
      <Value>
        <xsl:value-of select="normalize-space(.)"/>
      </Value>
      <Unit>
        <!-- xsl:value-of select="normalize=space(.)"/ -->
      </Unit>
    </AVU>
    <xsl:text>&#xA;</xsl:text>
    <xsl:text>&#xA;</xsl:text>
  </xsl:template>

  <xsl:template match="jra3:Experiment//jra3:expURI">
    <AVU>
      <Attribute>Source/Experiment/expURI</Attribute>
      <Value>
        <xsl:value-of select="normalize-space(.)"/>
      </Value>
      <Unit/>
    </AVU>
    <xsl:text>&#xA;</xsl:text>
    <xsl:text>&#xA;</xsl:text>
  </xsl:template>

  <xsl:template match="jra3:Tools//jra3:Version">
    <AVU>
      <Attribute>Source/Tools/Version</Attribute>
      <Value>
        <xsl:value-of select="normalize-space(.)"/>
      </Value>
      <Unit/>
    </AVU>
    <xsl:text>&#xA;</xsl:text>
    <xsl:text>&#xA;</xsl:text>
  </xsl:template>

  <xsl:template match="jra3:Tools//jra3:ShortName">
    <AVU>
      <Attribute>Source/Tools/ShortName</Attribute>
      <Value>
        <xsl:value-of select="normalize-space(.)"/>
      </Value>
      <Unit/>
    </AVU>
    <xsl:text>&#xA;</xsl:text>
    <xsl:text>&#xA;</xsl:text>
  </xsl:template>

  <xsl:template match="jra3:Authors//jra3:Name//jra3:First">
    <AVU>
      <Attribute>Authors/Name/First</Attribute>
    </AVU>
    <xsl:apply-templates select="jra3:Authors//jra3:Name//jra3:First"/>
  </xsl:template>

  <!-- begin output -->
  <xsl:template match="jra3:Experiment//jra3:expUID">
    <AVU>
      <Attribute>Source/Experiment/expUID</Attribute>
      <Value>
        <xsl:value-of select="normalize-space(.)"/>
      </Value>
      <Unit>
        <!-- xsl:value-of select="normalize=space(.)"/ -->
      </Unit>
    </AVU>
    <xsl:text>&#xA;</xsl:text>
    <xsl:text>&#xA;</xsl:text>
  </xsl:template>

  <xsl:template match="jra3:Experiment//jra3:expURI">
    <AVU>
      <Attribute>Source/Experiment/expURI</Attribute>
      <Value>
        <xsl:value-of select="normalize-space(.)"/>
      </Value>
      <Unit/>
    </AVU>
    <xsl:text>&#xA;</xsl:text>
    <xsl:text>&#xA;</xsl:text>
  </xsl:template>

  <xsl:template match="jra3:Tools//jra3:Version">
    <AVU>
      <Attribute>Source/Tools/Version</Attribute>
      <Value>
        <xsl:value-of select="normalize-space(.)"/>
      </Value>
      <Unit/>
    </AVU>
    <xsl:text>&#xA;</xsl:text>
    <xsl:text>&#xA;</xsl:text>
  </xsl:template>

  <xsl:template match="jra3:Tools//jra3:ShortName">
    <AVU>
      <Attribute>Source/Tools/ShortName</Attribute>
      <Value>
        <xsl:value-of select="normalize-space(.)"/>
      </Value>
      <Unit/>
    </AVU>
    <xsl:text>&#xA;</xsl:text>
    <xsl:text>&#xA;</xsl:text>
  </xsl:template>

  <xsl:template match="jra3:Authors//jra3:Name//jra3:First">
    <AVU>
      <Attribute>Authors/Name/First</Attribute>
      <Value>
        <xsl:value-of select="normalize-space(.)"/>
      </Value>
    </AVU>
    <xsl:text>&#xA;</xsl:text>
    <xsl:text>&#xA;</xsl:text>
  </xsl:template>

  <xsl:template match="jra3:Authors//jra3:Name//jra3:Middle">
    <AVU>
      <Attribute>Authors/Name/Middle</Attribute>
      <Value>
        <xsl:value-of select="normalize-space(.)"/>
      </Value>
    </AVU>
    <xsl:text>&#xA;</xsl:text>
    <xsl:text>&#xA;</xsl:text>
  </xsl:template>

  <xsl:template match="jra3:Authors//jra3:Name//jra3:Last">
    <AVU>
      <Attribute>Authors/Name/Last</Attribute>
      <Value>
        <xsl:value-of select="normalize-space(.)"/>
      </Value>
    </AVU>
    <xsl:text>&#xA;</xsl:text>
    <xsl:text>&#xA;</xsl:text>
  </xsl:template>

  <xsl:template match="jra3:Authors//jra3:Role">
    <AVU>
      <Attribute>Authors/Role</Attribute>
      <Value>
        <xsl:value-of select="normalize-space(.)"/>
      </Value>
    </AVU>
    <xsl:text>&#xA;</xsl:text>
    <xsl:text>&#xA;</xsl:text>
  </xsl:template>

  <xsl:template match="jra3:Authors//jra3:Address">
    <AVU>
      <Attribute>Authors/Address</Attribute>
      <Value>
        <xsl:value-of select="normalize-space(jra3:Street)"/>,
        <xsl:value-of select="normalize-space(jra3:PostalCode)"/>,
        <xsl:value-of select="normalize-space(jra3:City)"/>,
    <xsl:value-of select="normalize-space(jra3:Country)"/>,
        <xsl:value-of select="normalize-space(jra3:Phone)"/>,
        <xsl:value-of select="normalize-space(jra3:E-mail)"/>,
        <xsl:value-of select="normalize-space(jra3:Web)"/>.
      </Value>
    </AVU>
    <xsl:text>&#xA;</xsl:text>
    <xsl:text>&#xA;</xsl:text>
  </xsl:template>



  <xsl:template match="jra3:Institutes//jra3:ShortName">
    <AVU>
      <Attribute>Institutes/ShortName</Attribute>
      <Value>
        <xsl:value-of select="normalize-space(.)"/>,
      </Value>
    </AVU>
    <xsl:text>&#xA;</xsl:text>
    <xsl:text>&#xA;</xsl:text>
  </xsl:template>


  <xsl:template match="jra3:Institutes//jra3:Address">
    <AVU>
      <Attribute>Institutes/Address</Attribute>
      <Value>
        <xsl:value-of select="normalize-space(jra3:Street)"/>,
        <xsl:value-of select="normalize-space(jra3:PostalCode)"/>,
        <xsl:value-of select="normalize-space(jra3:City)"/>,
        <xsl:value-of select="normalize-space(jra3:Country)"/>,
        <xsl:value-of select="normalize-space(jra3:Phone)"/>,
        <xsl:value-of select="normalize-space(jra3:E-mail)"/>,
        <xsl:value-of select="normalize-space(jra3:Web)"/>.
      </Value>
    </AVU>
    <xsl:text>&#xA;</xsl:text>
    <xsl:text>&#xA;</xsl:text>
  </xsl:template>

<!--      
  <xsl:template match="jra3:Tools//jra3:">
    <AVU>
      <Attribute>Source/Tools</Attribute>
      <Value>
        <xsl:value-of select="normalize-space(.)"/>
      </Value>
      <Unit/>
    </AVU>
    <xsl:text>&#xA;</xsl:text>
    <xsl:text>&#xA;</xsl:text>
  </xsl:template>
-->

<!-- delete the rest -->
  <xsl:template match="jra3:Results"/>
  <xsl:template match="jra3:Science"/>

</xsl:stylesheet>

Running this xsl file on my metadata.xml file I get this type of output

<?xml version="1.0" encoding="UTF-8"?>
<metadata>

<AVU><Attribute>Source/Experiment/expUID</Attribute><Value>SOMEVALUE</Value><Unit/></AVU>

<AVU><Attribute>Source/Experiment/expURI</Attribute><Value></Value><Unit/></AVU>

<AVU><Attribute>Source/Tools/ShortName</Attribute><Value>UG</Value><Unit/></AVU>

<AVU><Attribute>Source/Tools/Version</Attribute><Value>0bcfb63f7c6c67cd954609c3a90a27b2</Value><Unit/></AVU>

<AVU><Attribute>Authors/Name/First</Attribute><Value>Alice</Value></AVU>

<AVU><Attribute>Authors/Name/Middle</Attribute><Value></Value></AVU>

<AVU><Attribute>Authors/Name/Last</Attribute><Value>Bob</Value></AVU>

<AVU><Attribute>Authors/Role</Attribute><Value>Group Leader</Value></AVU>

<AVU><Attribute>Authors/Address</Attribute><Value>Some Street,
    Some PostalCode,
    Some City,
    Some Number,
    Some E-mail Address,
    Some Web Address.
      </Value></AVU>

<AVU><Attribute>Institutes/ShortName</Attribute><Value>Some ShortName for a Lab,
      </Value></AVU>

<AVU><Attribute>Institutes/Address</Attribute><Value>Some Street,
    Some PostalCode,
    Some City,
    Some Country,
    Some Number,
    Some E-mail Address,
    Some Web Address.
      </Value></AVU>

</metadata>

This flattened output would allow the XML micro service to load it up and associate it as metadata to my collection of files. I think using the XSLT microservice to transform the data on the server side would be ideal.

It seems this is the most effective strategy for a number of iRODS users out there in the world.

Writing and debugging iRODS micro-services

Before I forget, here's list of useful resources for learning how to write a micro-service.

Some micro-services that I've been thinking about cooking up are resolving an irods path to a physical path, a plotting service (either with gnuplot or plplot). So far my gnuplot micro-service attempt hasn't been too sucessful, doing gnuplot_init() seems to cause my micro-service to exit for some reason.

assert.h is where it's at for debugging C programs

Having spent a few hours refreshing myself with C programming and being influenced by the java programmers in work, I've decided to be a bit more sensible about how I write C code. Armed with the that in mind, I looked around at how people did unit testing to do test driven software development for C.

It turns out that a lot of the frame works are just over engineered packages that rely on automake and autoconf hell to get working properly. I resorted to looking up and refering to The C Programming Language (book), it had reminded me of just using assert.h.

Using assert() is easier than you would expect and people should probably use it a bit more than not using it!

#include <assert.h>
void assert(scalar expression)

If the assertion is true the program will continue, otherwise it will abort. If you wish to turn of the assertions you could just add #define NDEBUG ahead of the #include and the assertions won't be compiled.

Here's an example usage of assert()

#include <stdio.h>
#include <assert.h>

int main(int argc, char **argv) { 
  int i; 
  for (i=5; i>0; i--) {
    fprintf(stdout, "i => %d\n", i); 
  } 
  assert(i > 0); 
  return 0; 
}

The assertion is that i cannot be zero, so the code will fail. This is probably a bad example of how to use assert() but it does demonstrate what it does. I find that I usually just end up using assertions to check that things aren't NULL or to make sure that things are greater than or less than expected values for variables in my code.

How long does it take to get naturalised in Ireland?

This one slipped through the cracks recently, I haven't been keeping an eye on my post much recently. Two weeks after I submitted my Birth Affidavit, I have received a confirmation that the Irish Naturalisation and Immigration Services (INIS) have received my application. It is waiting to be reviewed and has been placed in chronological order with other recently received applications. It's now the end of February 2010 and they are currently processing applications from early 2008, and the estimated turn around time is 24 months. It's going to be a long wait assuming it all goes well.


Related posts:

New Irish citizens will have to swear oath of fidelity
Posted

Astro, Particle, High Energy physics is cool
Posted

2011-05 -- Update on long naturalisation times in Ireland
Posted

Do people give a crap when they can not give a crap?
Posted

The depressingly long naturalisation times in Ireland
Posted

Bookmark and Share