Pautas de empaquetamiento de Lisp

Este documento parece documentar las convenciones y personalizaciones relativas al empaquetado apropiado de implementaciones y bibliotecas de Common Lisp en Fedora. Este documento no describe convenciones y personalizaciones para programas de aplicación que sean escritos en Common Lisp.

Introducción

La mayoría de las implementaciones de Common Lisp proporcionan su propio compilador para generar su propia representación binaria del código fuente. Estos archivos binarios suelen terminar en .fasl, Fast Load, (carga rápida). Estos archivos .fasl no son compatibles entre implementaciones de Common Lisp, ni siquiera entre diferentes versiones de la misma implementación. Esta propiedad única requiere un mantenimiento especial en el área de empaquetado.

La comunidad Common Lisp se agrupa actualmente en torno a una tecnología común de empaquetado e implementación llamada asdf (Another System Definition Format). Los proyectos implementados con asdf incluyen un archivo de definición del sistema. Estos archivos incluyen información sobre las dependencias del proyecto, las licencias y los autores. Los proyectos no suelen distribuir binarios, sino que dependen de las utilidades de asdf para compilar el código fuente de Lisp bajo demanda. Al ejecutar un programa que depende de una biblioteca administrada por asdf, el sistema asdf compilará automáticamente el código Lisp dependiente bajo demanda y almacenará en caché los resultados.

La comunidad Debian Lisp ha desarrollado herramientas y directrices para empaquetar y mantener bibliotecas administradas por asdf en sistemas Linux. Su herramienta, common-lisp-controller, garantiza la correcta gestión de los archivos .fasl en el sistema. Por ejemplo, al actualizar una implementación de Common Lisp, se eliminan los archivos .fasl de todos los paquetes compilados con la implementación anterior para que se puedan generar nuevos cuando se necesite.

The rest of this packaging guideline aims to describe how to package Common Lisp implementations, libraries and programs to take advantage of asdf and the common-lisp-controller.

Guidelines for Libraries and Programs written in Common Lisp

Nombrando

Lisp libraries should have their package names prefixed with "cl-", except in the case where the library name already starts with "cl-".

Rationale: There is some overlap between Lisp library names and existing Fedora packages. Creating a special name space for Lisp libraries should simplify life for everybody.

-devel sub-package

Pure lisp libraries do not require -devel sub-packages, as they install source code by default.

Use of asdf

Libraries should be managed by asdf, a packaging format for Common Lisp libraries (see the cl-asdf package for details). Most modern Lisp libraries already ship with asdf system definition files (with names typically ending in ".asd"). If none exist, then one will have to be written. The contents of these files is not all that different from an RPM .spec file, so this should not be too difficult for a Lisp-savvy packager. The ASDF manual describing how to write .asd files is available here.

Install location and hooking into the common-lisp-controller

Libraries should depend on the common-lisp-controller package. Lisp source should be installed in %{_datadir}/common-lisp/source/. The package should own that directory. The parent directories are owned by the common-lisp-controller package. A symlink to the asdf system definition file should be created from %{_datadir}/common-lisp/systems/.asd to %{_datadir}/common-lisp/source//.asd (this target directory is also owned by common-lisp-controller). The %post section should call register-common-lisp-source. The %preun section should call unregister-common-lisp-source. These scripts are provided by common-lisp-controller.

Spec file template

Name:           # see normal package guidelines
Version:        # see normal package guidelines
Release:        1%{?dist}
Summary:        # see normal package guidelines (SNPG)

Group:          # SNPG
License:        # SNPG
URL:            # SNPG
Source:         # SNPG
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires:   common-lisp-controller
Requires:        common-lisp-controller
Requires(post):  common-lisp-controller
Requires(preun): common-lisp-controller

%description

%prep
%setup -q

%build

%install
# Replace @NAME@ below with the Common Lisp library name, which may be different from the
# package name if it is not already prefixed with "cl-".

mkdir -m 755 -p %{buildroot}%{_datadir}/common-lisp/source/@NAME@
mkdir -m 755 -p %{buildroot}%{_datadir}/common-lisp/systems
for s in *.lisp; do
  install -m 644 $s %{buildroot}%{_datadir}/common-lisp/source/@NAME@;
done;
for s in *.asd; do
  install -m 644 $s %{buildroot}%{_datadir}/common-lisp/source/@NAME@;
done;
cd %{buildroot}%{_datadir}/common-lisp/source/@NAME@
for asd in *.asd; do
  ln -s %{_datadir}/common-lisp/source/@NAME@/$asd ../../systems;
done

%post
register-common-lisp-source @NAME@

%preun
unregister-common-lisp-source @NAME@

%files
%doc
%{_datadir}/common-lisp/source/@NAME@
%{_datadir}/common-lisp/systems/@NAME@.asd

%changelog

Guidelines for Common Lisp implementations

Nombrando

There are no special requirements here. Common Lisp implementations should be packaged using their normal project name.

-devel sub-package

Common Lisp implementations do not require -devel sub-packages, and they necessarily include all development tools by default.

Use of asdf

Common Lisp implementations should be able to load asdf by simply entering "(require 'asdf)" at the Lisp Read-Eval-Print loop (REPL). This may involve modifying search paths or related changes at build time.

Install location and hooking into the common-lisp-controller

Common Lisp implementations should depend on the common-lisp-controller package.

Common Lisp implementations should install a script in %{_libdir}/common-lisp/bin/.sh that supports a single command on the command line: "install-clc". This should load %{_datadir}/common-lisp/source/common-lisp-controller/common-lisp-controller.lisp, call (common-lisp-controller:init-common-lisp-controller-v4 ) and then save the resulting image as default for the system.

The %post section should call register-common-lisp-implementation. The %preun section should call unregister-common-lisp-implementation.

These scripts, and the %{_libdir}/common-lisp/bin directory are provided and owned by the common-lisp-controller package.

All implementations should be modified to load common-lisp-controller’s %{_sysconfdir}/lisp-config.lisp on startup.

Más lecturas

See https://www.cliki.net/common-lisp-controller and https://common-lisp.net/project/asdf/ for more details on common-lisp-controller and asdf.