January 11, 2018

IRAF package development

This is all about using "mkpkg", so you may find the reference pages for that to be useful: I am trying to follow a recipe given me by an old hand at doing this. I have an iraf package written in SPP that has only ever run on old SPARC systems, and want to build it to run on linux.

My IRAF install has a directory /iraf/iraf/extern. I make a directory "mirror" in here and untar a copy of the entire SPARC package here to get started.

On an intel based system, the question is whether to build 32 or 64 bit packages. To work with 32 bit, define the IRAFARCH environment variable to be "linux". To work 64 bit, define it to be linux64. I will do my development 32 bit.

You must use the csh

Now an important note. IRAF development using anything other than the csh is completely broken. I have had nothing but misery including crazy recursive bash loops that hung my system requiring a reboot. So forget using bash. I created a fictitious user with the csh as a login shell just to do IRAF development, and that improved my life.

The next thing is to set a bunch of environment variables. I simply made a .cshrc for that user that looks like this:

setenv iraf /iraf/iraf/
setenv IRAFARCH linux
setenv mirror /iraf/iraf/extern/mirror/
source /iraf/iraf/unix/hlib/irafuser.csh
A significant part of the problem (other than nasty bugs in the bash scripts provided with the current IRAF release) is that the IRAF development system (such that it is) makes heavy use of aliases, which do not propogate to child processes in the nice way that enviroment variables do. Consider this (if you care):
$ which mkpkg
/usr/local/bin/mkpkg
$ ls -l /usr/local/bin/mkpkg
lrwxrwxrwx 1 root root 35 Jan  4 16:10 /usr/local/bin/mkpkg -> /iraf/iraf/unix/bin.linux64/mkpkg.e
$ source /iraf/iraf/unix/hlib/irafuser.sh
$ which mkpkg
alias mkpkg='/iraf/iraf/unix/bin.linux/mkpkg.e'
	/iraf/iraf/unix/bin.linux/mkpkg.e
I tried using the BASH_ENV variable to specify a file with all the baloney that is necessary, but then ugly things began to happen and I went back to using the csh.

Before I got involved in the nasty recursive bash things that hung my system, I was having issues where mkpkg would build a 64 bit xx.o file, then try to link it against 32 bit libraries. This was related to the lack of alias propogation to child processes. The whole intensive use of aliases in the build system is a bad idea, and clearly only works properly with the csh.

32 bit libraries

You will need a bunch of these, like so:
dnf install glibc.i686
dnf install glibc-devel.i686
dnf install ncurses-compat-libs.i686
When I try to run mkpkg, I get this:
$ mkpkg -p mirror linux
bash: /iraf/iraf/unix/bin.linux/mkpkg.e: No such file or directory
But in fact, the file mkpkg.e exists and is executable. What is going on? This is a highly misleading error message. What is actually going on is that certain 32 bit libraries are missing. (namely glibc.i686 from the list above).

Build the package

Once all the plumbing is set up, this is what you do to build a package:
cd /iraf/iraf/extern/mirror
mkpkg -p mirror linux
mkpkg -p mirror >& spool
mkpkg -p mirror summary
The game is to look at "spool" to make sure there are no errors.
Have any comments? Questions? Drop me a line!