Tuesday, March 17, 2009

Lake

Within the Common Lisp atmosphere, ASDF is the tool of choice for build systems. It does for Lisp what Ant and Maven do for Java and what Make does for Unix, and it does so in a much cleaner and more powerful fashion. Instead of writing shell code or dealing with the most hideous XML ever conceived of, you can write a single lisp form in a single file:

(defsystem :system-name
:description "This is a great system"
:version "0.0.1"
:serial t
:components ((:file "lisp-source")
(:file "lisp-source2"))
:depends-on (:library1
:library2
:library3))

...and it does nearly everything for you. If you need to extend it or add support for other languages, file types or whatnot, you just extend the core system using methods. It's incredibly flexible, and the more I use it, the more i warm up to it.

However, there is just one thing I don't like about ASDF. It's all the symlinking. On Unix systems, to register a new asdf system, you have to symlink a .asd file into a systems directory. On my computer, installing a new system usually goes something like this:

wget http://somewhere.on.internet.com/system/system.tar.gz
tar -xvzf system.tar.gz
sudo ln -s /home/name/lisp/system/system.asd /usr/share/common-lisp/systems/

Really, it's not much more complicated than:

./configure
make
sudo make install

...But it is a little more complicated. For starters, I have to remember where the repository is and it's a lot of typing besides. Also, there is no easy way to manage different versions of the same library. And, furthermore, I generally don't know until after I've registered the system, loaded lisp, and tried to load the system, that I'm missing some dependency.

It gets to be nuisance.

There are solutions, such as ASDF-INSTALL, clbuild and the Common_Lisp_Controller, which handle dependencies, and automate installation of known libraries, but none quite do the one simple thing that I want, which is alleviate the need for me to type out the symlink. Even more troublesome, the can sometimes get in the way when a library needs manual configuration before installation.

ASDF-INSTALL, in particular, is annoying because it is so hard to install. This is ironic, because it is supposed to make installation easier, but it itself, is harder to install than your typical ASDF system. In addition, due to ASDF-INSTALL's tolerance for distributed libraries (That is, it allows people to add and modify dependencies for systems by editing a freely editable site on the Internet,) security concerns abound. The only was around this is to fetch the GPG key of nearly every Lisper who's library you want to download. This involves going right to their sites and to the sites of any dependencies. If you're going to do that, why not just down load the file's by hand?

Clbuild is better, but refuses to mix with any preexisting lisp configuration. Also, While ASDF-INSTALL will fetch only stables tars, Clbuild only fetches development versions from version control, which makes it impractical for production systems.

Really what I would like is for lisp system writers to start including simple Makefiles in their systems, which will configure the ASDF system to match my system, and ask me any questions that need asking, and then register itself automatically. It would be even better if the Makefile would then allow me to unregister the system as well. Because ASDF already does most of the dirty work, this wouldn't take much effort and most systems could just have a one size fits all Makefile. However, as long as I'm dreaming, I might ask that they just write me a full Common Lisp operating system while they're at it.

Oh well. The simplest solution to what I'm looking for is a simple alias:

alias asdf-register="ln -s ./*.asd /path/to/registry/"

Which is probably what most people do. But I want just a little more than that, so I wrote a script. It's called Lake and it's fairly simple: you can set it up just by typing

sudo make

and removal is

sudo make uninstall

To register a system:

lake register /path/to/system

The path can either point to a directory, a tarball, or an http path to a remote directory. Either way, it can handle the registration. Lake fits into my current environment and I can use it with clbuild, ADSF-INSTALL, or whatnot. It simply helps to simplify the process of manual ASDF system installation, rather than replace it completely. Which is how I like my tools.