From Fedora Project Wiki

fp-wiki>ImportUser
(Imported from MoinMoin)
 
m (PackagingDrafts/Lisp moved to Archive:PackagingDrafts/Lisp: last revisions Aug 2008 but is Very close to Packaging:Lisp which was created Sep 2008.)
 
(15 intermediate revisions by 4 users not shown)
Line 1: Line 1:
= Lisp Packaging Guidelines =
= Lisp Packaging Guidelines =


This document seeks to document the conventions and customs surrounding the proper packaging of Lisp implementations and libraries in Fedora.
This document seeks to document the conventions and customs surrounding the proper packaging of Common Lisp implementations and libraries in Fedora.
This document does ''not'' describe conventions and customs for application programs that are written in Common Lisp.


= Introduction =


Most Common Lisp implementations provide a compiler to generate their own binary representation of source.  These binary files typically end in .fasl (for Fast Load).  These .fasl files are not compatible across Common Lisp implementations, or even between different versions of the same implementation.  This unique property calls for special support on the packaging front.


= common-lisp-controller =
The Common Lisp community currently rallies around a common packaging and deployment technology called asdf (Another System Definition Format).  Projects deployed using asdf include a system definition file.  These files include information about project dependencies, licensing, and the authors.  Projects don't typically distribute binaries, but rather depend on the asdf utilities to compile the Lisp source code on demand.  When you run program that depends on a library managed by asdf, the asdf system will automatically compile the dependent Lisp code on demand and cache the results.


Fedora Lisp implementations and libraries should be packages as per the common-lisp-controller guidelines found belowThese guidelines have been adopted from Debian's common-lisp-controller package and provide critical infrastructure for maintaining lisp libraries given a multitude of lisp implementations with incompatible binary forms (.fasl files, etc).
The Debian Lisp community have developed tools and guidelines for packaging and maintaining asdf managed libraries on Linux systemsTheir tool is called common-lisp-controller and, combined with asdf, it ensures that .fasl files are managed properly on the system. For instance, when a Common Lisp implementation is upgraded, the .fasl files for all of the packages built using the old implementation are deleted so that new ones may be generated on demand.


= Naming =
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.


Lisp implementations should be named as per usual.
= Guidelines for Libraries and Programs written in Common Lisp =
 
== Naming ==


Lisp libraries should have their package names prefixed with "cl-", except in the case where the library name already starts with "cl-".
Lisp libraries should have their package names prefixed with "cl-", except in the case where the library name already starts with "cl-".
Line 17: Line 22:
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.
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.


= Packaging libraries =
== -devel sub-package ==


Library packages should install .lisp files as per the common-lisp-controller guidelines described below.
Pure lisp libraries do not require -devel sub-packages, as they install source code by default.


== -devel sub-package ==
== Use of asdf ==


Pure lisp libraries do not require -devel sub-packages, as they install source code by default.
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: http://constantly.at/lisp/asdf/ .


= Further reading =
== Install location and hooking into the common-lisp-controller ==


See http://www.cliki.net/common-lisp-controller
Libraries should depend on the common-lisp-controller package.
Lisp source should be installed in %{_datadir}/common-lisp/source/<library>.
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/<library>.asd to %{_datadir}/common-lisp/source/<library>/<library>.asd (this target directory is also owned by common-lisp-controller).
The %post section should call "%{_sbindir}/register-common-lisp-source <library>".
The %preun section should call "%{_sbindir}/unregister-common-lisp-source <library>"
These scripts are provided by common-lisp-controller.


Here's the common-lisp-controller design document from Debian...
== Spec file template ==
<pre>
<pre>
; Copyright (C) 2000,2004  Peter Van Eynde and Kevin M. Rosenberg
Name:          # see normal package guidelines
; Licensed under the LLGPL, see debian/copyright file
Version:        # see normal package guidelines
Release:        1%{?dist}
Summary:        # see normal package guidelines (SNPG)
 
Group:          # SNPG
License:        # SNPG
URL:            # SNPG
Source0:        # 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
%{__rm} -rf %{buildroot}
 
# 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


This is the general design of the new 'light weight' common-lisp-controller v4.
%post
/usr/sbin/register-common-lisp-source @NAME@


Common Lisp Libraries:
%preun
/usr/sbin/unregister-common-lisp-source @NAME@


Libraries should:
%clean
- use adsf
%{__rm} -rf %{buildroot}
- install their source packages in /usr/share/common-lisp/source/<library>
- install a symlink to their asdf package from /usr/share/common-lisp/systems/<library>.asd to
/usr/share/common-lisp/source/<library>/<library>.asd
- after install call "/usr/sbin/register-common-lisp-source <library>"
- before removal of the package call "/usr/sbin/unregister-common-lisp-source <library>"
Libraries can be automaticly created with the "asdf-install-2-deb" package.


Common Lisp Implementations::
%files
%defattr(-,root,root,-)
%doc
%{_datadir}/common-lisp/source/@NAME@
%{_datadir}/common-lisp/systems/@NAME@.asd


Implementations should:
%changelog
- install a script /usr/lib/common-lisp/bin/<impl>.sh that has the following
</pre>
commands:
/usr/lib/common-lisp/bin/<impl>.sh install-clc
This should load /usr/share/common-lisp/source/common-lisp-controller/common-lisp-controller.lisp
then call
(common-lisp-controller:init-common-lisp-controller-v4 <implementation)
and then save the resulting image as default for the system.
- after install call "/usr/sbin/register-common-lisp-implementation <implementation>"
- before removal call "/usr/sbin/unregister-common-lisp-implementation <implementation>"
- should load /etc/lisp-config.lisp on startup.


There are 2 scenarious:
= Guidelines for Common Lisp implementations =


- a user wants to use a system-wide library.
== Naming ==
(asdf:oos 'asdf:compile-op :<library>)
will load the system at
/usr/share/common-lisp/systems/<library>.asd
that will use the source at
/usr/share/common-lisp/source/<library>
fasls will be placed in
/var/cache/common-lisp-controller/<userid>/<implementation>/<library>/
- a user wants to use another library. He or she used adsf-install
and the sources got placed in ~/.sbcl or ~/sdf-install-dir/. We do not interfere
with this use as we expect the user to be able to correct all errors :-).


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


To load a library "cil" do:
== -devel sub-package ==
(clc:clc-require :cil)


To recompile all libraries, dropping into the
Common Lisp implementations do not require -devel sub-packages, and they necessarily include all development tools by default.
debugger on error, do:
(clc:clc-build-all-packages)
to do so while ignoring build errors,
do:
(clc:clc-build-all-packages t)


To add user packages, use clc-register-user-package. This will
== Use of asdf ==
place a link to the user's asdf file in ~/.clc/systems.


Technical Implementation:
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.


- register-common-lisp-source:
== Install location and hooking into the common-lisp-controller ==
does nothing


- unregister-common-lisp-source:
Common Lisp implementations should depend on the common-lisp-controller package.
does: (after checking stuff):
rm -rf /var/cache/common-lisp-controller/*/*/<library>


- register-common-lisp-implementation
Common Lisp implementations should install a script in %{_libdir}/common-lisp/bin/<impl>.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 <implementation>) and then save the resulting image as default for the system.
does nothing


- unregister-common-lisp-implementation
The %post section should call "%{_sbindir}/register-common-lisp-implementation <implementation>".
does: (after checking stuff):
The %preun section should call "%{_sbindir}/unregister-common-lisp-implementation <implementation>"
rm -rf /var/cache/common-lisp-controller/*/<implementation>


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


loads adsf
All implementations should be modified to load common-lisp-controller's %{_sysconfdir}/lisp-config.lisp on startup.
builds pathname translations for /usr/share/common-lisp/source/
 
adds /usr/share/common-lisp/systems/ and <code>/.clc/systems
 
to the asdf registry
= Further reading =
</pre>
 
See http://www.cliki.net/common-lisp-controller and http://common-lisp.net/project/asdf/ for more details on common-lisp-controller and asdf.
 
[[Category:Archived packaging guideline drafts]]

Latest revision as of 20:53, 21 February 2009

Lisp Packaging Guidelines

This document seeks to document the conventions and customs surrounding the proper packaging of Common Lisp implementations and libraries in Fedora. This document does not describe conventions and customs for application programs that are written in Common Lisp.

Introduction

Most Common Lisp implementations provide a compiler to generate their own binary representation of source. These binary files typically end in .fasl (for Fast Load). These .fasl files are not compatible across Common Lisp implementations, or even between different versions of the same implementation. This unique property calls for special support on the packaging front.

The Common Lisp community currently rallies around a common packaging and deployment technology called asdf (Another System Definition Format). Projects deployed using asdf include a system definition file. These files include information about project dependencies, licensing, and the authors. Projects don't typically distribute binaries, but rather depend on the asdf utilities to compile the Lisp source code on demand. When you run program that depends on a library managed by asdf, the asdf system will automatically compile the dependent Lisp code on demand and cache the results.

The Debian Lisp community have developed tools and guidelines for packaging and maintaining asdf managed libraries on Linux systems. Their tool is called common-lisp-controller and, combined with asdf, it ensures that .fasl files are managed properly on the system. For instance, when a Common Lisp implementation is upgraded, the .fasl files for all of the packages built using the old implementation are deleted so that new ones may be generated on demand.

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

Naming

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: http://constantly.at/lisp/asdf/ .

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/<library>. 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/<library>.asd to %{_datadir}/common-lisp/source/<library>/<library>.asd (this target directory is also owned by common-lisp-controller). The %post section should call "%{_sbindir}/register-common-lisp-source <library>". The %preun section should call "%{_sbindir}/unregister-common-lisp-source <library>" 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
Source0:        # 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
%{__rm} -rf %{buildroot}

# 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
/usr/sbin/register-common-lisp-source @NAME@

%preun
/usr/sbin/unregister-common-lisp-source @NAME@

%clean
%{__rm} -rf %{buildroot}

%files
%defattr(-,root,root,-)
%doc
%{_datadir}/common-lisp/source/@NAME@
%{_datadir}/common-lisp/systems/@NAME@.asd

%changelog

Guidelines for Common Lisp implementations

Naming

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/<impl>.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 <implementation>) and then save the resulting image as default for the system.

The %post section should call "%{_sbindir}/register-common-lisp-implementation <implementation>". The %preun section should call "%{_sbindir}/unregister-common-lisp-implementation <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.


Further reading

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