How to stop worrying and make your own Perl FIX client

Date July 28th, 2015 Author Vitaly Agapov

You do the little job you're trained to do.
Pull a lever.
Push a button.
You don't understand any of it, and then you just die.

Chuck Palahniuk «Fight Club»

Keep-Calm-No-Quick-Fix-257x300

This story began with the situation when I needed to make my own FIX (Financial Information eXchange) client for some testing purposes. It was considered to be light and simple so Java/QuickFix and the similar implementaions were dismissed and I started to look for some other options. For some time I was considering Python QuickFix module but this module is just a wrapper for Python to use native C libraries so this option was dismissed too.

Then I looked through CPAN to find some Perl modules (I was always thinking that CPAN contains every module for Perl you can just imagine but this is not true of course) and still no luck. So I decided to create my own module and made it. 

I will not dive into details. Please visit the corresponding GitHub or CPAN pages if you are interested. There you can find the description, synopsis and examples.

How to build an RPM package

This post is still to short so I will add the snippet which builds the Perl module into the RPM package. You can make some Jenkins job out of it (as I did) or to use it right from CLI. You will need spanspec tool to create the spec-file. It is available in the repositories

git clone https://github.com/agapoff/FIX-Lite
mkdir -p rpm-build
rm -rf FIX-Lite-*
rm -rf perl-FIX-Lite.spec
Version=`grep Version FIX-Lite/lib/FIX/Lite.pm | awk '{print $2}'`
cp -r FIX-Lite FIX-Lite-${Version}
tar -czvf FIX-Lite-${Version}.tar.gz FIX-Lite-${Version}
cpanspec FIX-Lite-${Version}.tar.gz

rpmbuild --define "_topdir %(pwd)/rpm-build" --define "_builddir %{_topdir}" \
    --define "_rpmdir %{_topdir}" --define "_srcrpmdir %{_topdir}" --define '_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm' \
    --define "_specdir %(pwd)" --define "_sourcedir  %(pwd)" -bb perl-FIX-Lite.spec

# then we can put the RPM to the local repository if needed
build_num=`ls -v rpm-build/perl-FIX-Lite-${Version}-*rpm | tail -1 | cut -f2 -d / | cut -f 4,5 -d-`
rpm_file=`ls -v rpm-build/perl-FIX-Lite-*rpm | grep -v src | tail -1`
scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${rpm_file} <repouser>@<repohost>:<repopath>/
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no <repouser>@<repohost> "createrepo --update <repopath>/"

Tags:
Category: Perl | No comments »

Comments

Leave a comment

 Comment Form