GNAT 2012 for Debian Wheezy

For purposes known mostly within our company, I’ve created a magic makefile that takes care of most of the work involved with getting a GNAT 2012 (and up-to-date various support tools) up and running on a Debian.

The makefile requires you to download some files manually, but that’s okay, as it gives you a great opportunity to visit AdaCore’s libre webpage. The readme file explains it in more detail.

At this point, the makefile will build (and/or install) the following projects.

  • GNAT 2012 – binary
  • GNATCOLL (Gnatlib) – SVN build
  • AWS (Ada Web Server) – Git build
  • Florist GPL 2012 release
  • XML-Ada 4.3 (release)
  • Yolk (AWS support library)
In time, the makefile will be expanded to support more libraries and projects.

The makefile can be found at GitHub, hope you find it useful or want to contribute.

Beamer i LaTeX

Jeg er blevet opfordret til at skrive en lille introduktion til LaTeX – nærmere betegnet Beamer klassen.

Beamer er en præsentations-dokumentklasse der kan bruges til at lave slides med.

Først og fremmest skal du have latex-beamer og pdflatex installeret:

# apt-get install latex-beamer texlive-latex-base

Burde kunne klare opgaven på et Debian (men sikkert også Ubuntu) system. Herfter har du dokumentklassen beamer tilgængelig, så vi kan starte dokumentet således:

documentclass[presentation]{beamer}
\usepackage[T1]{fontenc} % Sørger for danske tegn

Herefter begynder vi dokumentet og giver lidt information om os selv.

\begin{document}
 
\author{Mig!}
\title{Fed titel\\
\small{Endnu bedre undertitel}}
\institute[]{ Et herligt sted }

Nu kan vi bruge den information vi har indtastet til at lave en titelside og dernæst en indholdsfortegnelse.

\begin{frame}
  \maketitle
\end{frame}
 
\begin{frame}
  \frametitle{Indhold}
  \tableofcontents
\end{frame}

Nu kan vi så reelt starte med at lave indholdssider. Disse består typisk af et antal punkter som her:

\section{Første slide}
\begin{frame}
  \frametitle{Fantastisk titel}
  \framesubtitle{- snart}
  \begin{itemize}
    \item Detter er et punkt med en pause
    \pause 
    \item Og endnu en
    \pause
    \item Det er den sidste - på ære
  \end{itemize}
\end{frame}

Hvis man ønsker et billede i sin præsentation kan man inkludere det på samme måde som ved andre LaTeX dokumenter. Husk at der gælder de samme billedformatbegrænsninger som ellers ved brug af pdflatex.

\section{Et billede}
\begin{frame}
  \frametitle{Et billede}
  \framesubtitle{}
\begin{figure}[h]
 \centering
 \includegraphics[width=120pt]{database.pdf}
 \label{fig:database}
\end{figure}  
\end{frame}

En af de helt store styrker ved LaTeX er jo den matematiknotation – som der selvfølgelig også er til at integere en præsentation.

\begin{frame}
  \frametitle{Lad os \emph{} lave matematik}
  \framesubtitle{}
  \begin{equation}
    \displaystyle\sum\limits_{i=1}^{n} \frac{C_i}{T_i} \leq n \left( 2^{\frac{1}{n}} - 1 \right) 
  \end{equation}
\end{frame}

Til slut kan man jo indsætte klassikeren:

\begin{frame}
  \frametitle{}
  \framesubtitle{}
  \centering
  Spørgsmål?
\end{frame}
 
Og huske at slutte dokumentet
<pre lang="latex">
\end{document}

Du kan nu bygge din præsentation med

$ pdflatex presentation.tex

Hvis man ønsker at skifte tema, kan man gøre det med følgende kommandoer i starten af dokumentet.

\usepackage{listings}
\usetheme{Pittsburgh}
\usecolortheme{dove}

Der kan findes en fantastisk oversigt over de forskellige temaer med farvekombinationer på http://www.hartwork.org/beamer-theme-matrix/.

Du kan hente et fuldt eksempel (med billedfil) her:

Persistant enumeration of network interfaces across hardware addresses

If you’ve ever created a Linux virtual machine image for distribution, you have probably encountered this problem. The Virtualization is not really important – the problem exists on VirtualBox, VMWare, KVM, Xen and others supporting Linux guests.

So, what is the issue exactly?

The problem is that when you recreate a a virtual machine using an existing image, a new MAC address is generated. Udev sees this new address and creates a static name for it – e.g. eth1. Keeping the original – now removed – eth0 in the persistant naming file.

This interface typically does not exist in the /etc/network/interfaces file, and therefore is never “upped”. This leaves you with a machine that has no network connection out of the box.

Well, how do I fix it then?

The simple solution is to remove the /etc/udev/rules.d/70-persistent-net.rules file and reboot.
This means you have to remove the file as the last thing you do before shipping the image. I you make changes to the image, and reship it – you must do this every time. Plus it prevents easy redistribution of your image.

So, I’ve placed a small bash script at /usr/local/bin/reenumerate_interfaces and called it from /etc/rc.local.

This script also have the advantage, that you do not have to reboot the machine for the changes to take effect.

#! /bin/sh
 
echo Re-enumerating the network interfaces...
 
# Stop networking
/etc/init.d/networking stop
<pre lang="bash">
# Get the drivers and bounce the NICs
lspci -nnv | awk '{
if ($0 ~ /^$/) { getDriver = 0; }
if (getDriver == 0 && $0 ~ /.*Ethernet controller.*/) { getDriver=1; }
if (getDriver == 1 && $0 ~ /.*Kernel driver.*/) { printf ("%s\n", $5); }
}' | sort | uniq | while read a; do
 
echo Unloading network module $a from kernel space
rmmod $a
done
 
# Remove the static enumerations
rm /etc/udev/rules.d/70-persistent-net.rules
 
echo Reloading driver via udev
# Tickle udev
/sbin/udevadm trigger
 
# Start networking
/etc/init.d/networking start

Modløsheden melder sig

Jeg har i sidste uge modtaget et nyt uddannelseskort – på trods af jeg ikke har bestilt det. Der er oprettet en betalingsaftale, så de trækker beløbet direkte – uden godkendelse.

Jeg har ingen forelæsninger i december måned, så jeg havde egentlig ikke nogen planer om at bestille et kort.

Efter sidste omgang har jeg simpelhen ikke mod på at prøve at få refunderet beløbet.

Thinkfan on a Lenovo T420

Warning: tampering with the fan control on you laptop is potentially dangerous, and I will not take any responsibility if anything happens to your machine. With that being said; I have used Thinkfan for various Thinkpads (7 I think) with no problems at all. Just be warned.

A lovely Lenovo T420 has recently dropped into my possession – not the worst thing that can happen. Well, actually it is a company laptop – but enough with the chit-chat.

Linux support on this machine is far from perfect, but one of the most annoying things about it, is the fan noise. It is constantly on at ~3500rpm and very noticeable (read: annoying).

First, install Thinkfan. (I owe my sanity to these developers!)

$ sudo aptitude install thinkfan

To enable fan control, the kernel acpi module must be enabled with explicit support.

$ sudo su -c "echo \"options thinkpad_acpi fan_control=1\" > /etc/modprobe.d/thinkfan.conf"

And reload the module.

$ sudo modprobe -rv thinkpad_acpi && sudo modprobe -v thinkpad_acpi

We also need the coretemp module, which is not autoloaded.

$ sudo modprobe -v coretemp

To make it autoload, append it to /etc/modules.

sudo su -c "echo \"coretemp\" >> /etc/modules"

Now, edit /etc/default/thinkfan to enable the thinkfan service to start. There are a lot of precautions here :-|

START=yes

Then, the following to /etc/thinkfan.conf, just after the comments – before the threshold declarations.

sensor /sys/devices/platform/coretemp.0/temp1_input
sensor /sys/devices/platform/coretemp.0/temp2_input
sensor /sys/devices/virtual/hwmon/hwmon0/temp1_input

Finally, start Thinkfan.

sudo /etc/init.d/thinkfan start

And.. Enjoy the silence :-)

Heads up for the people who led me to the solution:
[1] http://ubuntuforums.org/showthread.php?t=1749186#9
[2] http://thinkpad-wiki.org/Thinkfan

 

Malet op i et hjørne

Jeg har altid godt kunne lide at skille ting ad og finde fejl og mangler i systemer – indrømmet.

Og nu har jeg vist gjort det igen. Jeg har fået inde-klikket mig i et digitalt hjørne af www.uddannelseskort.dk systemet.

Hvordan så det? – Følg med, det er lidt indviklet.

Jeg har sidste gang jeg bestilte kort, fået bestilt to kort; et der løber fra 1/10 til 31/10, og et der løber fra 1/10 – 30/11. Det førstnævnte er godkendt hos DSB og betalt, det andet har fået “afvist” status i DSB’s ende.

Jeg kan ikke bestille et nyt via hjemmesiden, da en patching runde her i mandags (systemet siger det er Version: 4.4.1.g (18-10-2011)) angiveligvis har rettet fejlen med at man kan bestille overlappende kort. Dette betyder i praksis at jeg ikke kan bestille et kort til perioden 1/11 til 30/11, da dette kort har status “aktiv” hos uddannelseskort, og status “afvist” hos DSB.

Hvordan finder man så ud af det?

- Man ringer til DSB, sidder i kø, og får at vide aben ligger hos uddannelsesstyrelsen (som driver uddannelseskort). Så ringer man til uddannelsestyrelsen, sidder i kø, og får at vide at de intet kan gøre, men man derimod skal kontakte DSB.

Kan i se mønsteret?

DSB får andet opkald, og efter den obligatoriske kø, får jeg overtalt den rare DSB medarbejder til kontakte en specialist (hendes ord), for så kontakte mig igen.

Her ligger den så. Jeg ved ikke om jeg er købt eller solgt. Men for at historien ikke skal ende i meningsløs brok, har jeg desperat forsøgt at få henholdsvis uddannelsesstyrelsen og DSB til oplyse kontaktinformation for de drifts-eller udviklingsansvarlige. Det er selvfølgelig den samme mudderkastning; uddannelsesstyrelsen siger at det er DSB der driver hjemmesiden, og DSB siger det uddannelsesstyrelsen.

Whois siger det er uddannelsesstyren, så de fik min mail. Jeg syntes selv den er ret nøgternt formuleret:

 

 

Hej Uddannelseskortfolk

Nu har jeg gang på gang oplevet særheder/fejl med mituddannelseskort.dk
systemet (hjemmesiden).

Da jeg er klar over at i ikke har noget med det tekniske aspekt af
systemet, vil jeg gerne i kontakt med dem der har.

Det er ikke for at brokke mig, det er for at få afleveret min liste over
fejl og mangler – rent konstruktivt.

Det kan kun være i jeres interesse at få strømlinet systemet og rettet
fejl i det, da dette drastisk vil nedsætte antallet af henvendelser pr. dag.

Jeg har haft kontakt til DSB der har oplyst mig om at det ikke er dem,
men jer driver hjemmesiden.

Mvh
Kim Rostgaard Christensen
(Selvstændig IT-ingeniør, og studerende ved DTU)

Yet another goodbye

For those who are about to halt -p, we salute you.

I’m moving out – of my first vserver that is.

I have had the server running for, well

lucretia:~# uptime 
 19:19:59 up 700 days, 22:51,  2 users,  load average: 0.02, 0.06, 0.02

Wow.. Time flies.

I have been migrating the services running in the machine to another, server. Not is the time to do the inevitable.

Sorry old chap, better you than me.

lucretia:~# halt -p

Broadcast message from root@lucretia (pts/1) (Fri Sep 30 19:23:24 2011):

The system is going down for system halt NOW!
lucretia:~# Connection to lucretia.greenpc.dk closed by remote host.
Connection to lucretia.greenpc.dk closed.

Of course, prior to this, I made sure to make a complete copy of the file system like so. Isn’t rsync the best tool?

rsync --progress -poazuHK -e ssh --delete --exclude /proc --exclude sys --exclude dev / home.greenpc.dk:/mnt/primary/backup/lucretia.greenpc.dk

Letting go

It pains me to let my N900 go. We have been together for almost two years now – but I have to move on.

I can still remember the unwrapping of the shiny Nokia box back in that gentle, fresh late-autumn morning back in November ’09.
Moving from a Sony Ericsson K800i, this was a large leap for me, and the N900 would be the phone that introduced me to the world of smartphones.

Suddenly I could do anything! I had a big screen where I could surf the high seas of the treacherous internet. And even with Flash content.
I was able to check anything, anywhere. I was king of information and technology.

As the N900 was build around my favourite Linux distribution; Debian, I felt right at home. A had a busybox and and xterm. This was not just a phone – it was a mini-computer with a built-in phone.

N900 and me hit it off – big time. We went everywhere together, did everything together.

Until…

I was appointed project manager of an Android programming project. I obviously needed a device for the development process (at least that was what I told myself).
For that purpose I bought a HTC Wildfire. This was the first step towards the end.

I could not help being drawn towards the much smoother interface of the HTC phone, despite the lower resolution on the Wildfire compared to the N900.

Suddenly my N900 did not seem so smart anymore. A lot the tasks that was difficult and hacky to do on the N900, was integrated in the to the user interface of the Wildfire.

Last week we broke up definitely. I found my new phone at a cheap Danish phone reseller, at lowered price.
Now I have a HTC Desire Z, because I would the Qwerty keyboard too much.

Still, I is  sad – to let a trusty life companion go.