Monday, May 19, 2008

SML hacking tip: installing on Ubuntu x86_64 by manual transfer from i386

Note: Narrowly targeted Google-food. Skip if you do not program in Standard ML.

Update 2010-05-05: As of Lucid, SML/NJ is now available on 64-bit. So you should probably just upgrade.

Ubuntu x86_64 does not have smlnj (the Standard ML of New Jersey (SML/NJ) distribution); nor does SML/NJ currently build out-of-the-box on Ubuntu x86_64. I elide here a long, dull story about trying to build it --- using 32-bit libraries, etc. --- and cut to the chase: ultimately, I installed it on a 32-bit Ubuntu box, and then manually transferred the files over.

In general, I almost never install software on my Linux box unless it's either (a) completely managed by my packaging system or (b) can be removed by simply rm -Rf /some/directory. Fortunately, SML/NJ more or less satisfies (b).

Assuming you have both a 32-bit Ubuntu install and a 64-bit Ubuntu install available, the transfer process is straightforward. The only trickiness is that there's no simple way to get all SML/NJ packages and libraries at once, so you'll have to apt-get several times if you want a "batteries included" installation.

Steps (unless otherwise noted, perform all these commands on your 32-bit machine):

  • sudo apt-get install smlnj
  • Optionally, do apt-cache search smlnj and install as many of the resulting lib*-smlnj libraries as you want.
  • Optionally, install the following extra packages:
    • ml-lpt ("language processing tools"; includes ml-ulex and ml-antlr)
    • ml-yacc (ML-Yacc)
    These are particularly of interest because probably 90% of ML programmers are also programming language hackers of one stripe or another. (Note that, annoyingly, these packages do not have smlnj as a substring of the package name. And, of course, apt-cache search ml yields a huge fusillade of results because "ml" is a common substring. Couldn't they at least use sml-* or better yet standard-ml-*? Blech.)
  • cd /usr/lib
  • tar -czvf smlnj.tar.gz smlnj
  • Copy the tarball smlnj.tar.gz to your target machine of choice and untar it under /usr/lib
  • pushd /usr/bin && tar -czvf ~/smlnj-scripts.tar.gz `dpkg -L smlnj smlnj-runtime ml-lpt ml-yacc |cut -b 10-` && popd
  • Copy the tarball smlnj-scripts.tar.gz to your target machine, and untar it under a binary directory on your PATH. (I have $HOME/bin in my PATH for user-local executables, so I put it there.)

As far as I can tell, everything works.

3 comments:

  1. If you can get all the 32 bit .deb packages for sml that you need, they can be installed on your 64-bit system with 'dpkg -i --force-architecture'. This methods keeps all the smlnj and library files under the control of the package manager, and it installs everything in the proper place. The easiest way to get them in one place is to (on your 32-bit system) clear the package cache, remove all sml packages, then install all the sml packages you want. Copy /var/cache/apt/archives/*.deb to somewhere on your 64-bit system, then boot into it and run 'dpkg -i --force-architecture *.deb'.

    ReplyDelete
  2. I just installed smlnj on my x86_64:

    $ lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description: Ubuntu 8.10
    Release: 8.10
    Codename: intrepid

    $ aptitude search smlnj
    i smlnj Standard ML of New Jersey interactive compiler
    i A smlnj-runtime Standard ML of New Jersey runtime system

    So, you can simply use apt to install smlnj.

    ReplyDelete
  3. Those packages are new to Ubuntu 8.10, they weren't present in the 64-bit versions of 8.04 and prior.

    ReplyDelete