1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: common-lisp-common.eclass
6 # Common Lisp project <common-lisp@gentoo.org>
7 # @AUTHOR: Matthew Kennedy <mkennedy@gentoo.org>
8 # @BLURB: eclass for installing Common Lisp packages.
10 # Sundry code common to many Common Lisp related ebuilds.
12 inherit eutils multilib
14 # Some handy constants
15 CLFASLROOT=/usr/$(get_libdir)/common-lisp/
16 CLSOURCEROOT=/usr/share/common-lisp/source/
17 CLSYSTEMROOT=/usr/share/common-lisp/systems/
19 # Many of our Common Lisp ebuilds are either inspired by, or actually
20 # use packages and files from the Debian project's archives.
24 for i in copyright README.Debian changelog; do
25 # be silent, since all files are not always present
26 dodoc "${S}"/debian/${i} &>/dev/null || true
31 # Most of the code below is from Debian's Common Lisp Controller
34 register-common-lisp-implementation() {
35 PROGNAME=$(basename $0)
36 # first check if there is at least a compiler-name:
39 usage: $PROGNAME compiler-name
41 registers a Common Lisp compiler to the
42 Common-Lisp-Controller system.
47 FILE="/usr/$(get_libdir)/common-lisp/bin/$IMPL.sh"
48 if [ ! -f "$FILE" ] ; then
50 $PROGNAME: I cannot find the script $FILE for the implementation $IMPL
54 if [ ! -r "$FILE" ] ; then
56 $PROGNAME: I cannot read the script $FILE for the implementation $IMPL
60 # install CLC into the lisp
61 sh "$FILE" install-clc || (echo "Installation of CLC failed" >&2 ; exit 3)
62 mkdir /usr/$(get_libdir)/common-lisp/$IMPL &>/dev/null || true
63 chown cl-builder:cl-builder /usr/$(get_libdir)/common-lisp/$IMPL
65 # now recompile the stuff
66 for i in /usr/share/common-lisp/systems/*.asd ; do
67 if [ -f $i -a -r $i ] ; then
70 clc-autobuild-check $IMPL $package
72 echo recompiling package $package for implementation $IMPL
73 /usr/bin/clc-send-command --quiet recompile $package $IMPL
77 for i in /usr/share/common-lisp/systems/*.system ; do
78 if [ -f $i -a -r $i ] ; then
81 clc-autobuild-check $IMPL $package
83 echo recompiling package $package for implementation $IMPL
84 /usr/bin/clc-send-command --quiet recompile $package $IMPL
88 echo "$PROGNAME: Compiler $IMPL installed"
91 unregister-common-lisp-implementation() {
92 PROGNAME=$(basename $0)
93 if [ `id -u` != 0 ] ; then
94 echo $PROGNAME: you need to be root to run this program
99 usage: $PROGNAME compiler-name
101 un-registers a Common Lisp compiler to the
102 Common-Lisp-Controller system.
107 IMPL_BIN="/usr/$(get_libdir)/common-lisp/bin/$IMPL.sh"
108 if [ ! -f "$IMPL_BIN" ] ; then
110 $PROGNAME: No implementation of the name $IMPL is registered
111 Cannot find the file $IMPL_BIN
113 Maybe you already removed it?
117 if [ ! -r "$IMPL_BIN" ] ; then
119 $PROGNAME: No implementation of the name $IMPL is registered
120 Cannot read the file $IMPL_BIN
122 Maybe you already removed it?
127 sh $IMPL_BIN remove-clc || echo "De-installation of CLC failed" >&2
128 clc-autobuild-impl $IMPL inherit
129 # Just remove the damn subtree
130 (cd / ; rm -rf "/usr/$(get_libdir)/common-lisp/$IMPL/" ; true )
131 echo "$PROGNAME: Common Lisp implementation $IMPL uninstalled"
134 reregister-all-common-lisp-implementations() {
135 # Rebuilds all common lisp implementations
136 # Written by Kevin Rosenberg <kmr@debian.org>
138 local clc_bin_dir=/usr/$(get_libdir)/common-lisp/bin
139 local opt=$(shopt nullglob); shopt -s nullglob
141 for impl_bin in *.sh; do
142 impl=$(echo $impl_bin | sed 's/\(.*\).sh/\1/')
143 unregister-common-lisp-implementation $impl
144 register-common-lisp-implementation $impl
147 [[ $opt = *off ]] && shopt -u nullglob
150 # BIG FAT HACK: Since the Portage emerge step kills file timestamp
151 # information, we need to compensate by ensuring all FASL files are
152 # more recent than their source files.
154 # The following `impl-*-timestamp-hack' functions SHOULD NOT be used
155 # outside of this eclass.
157 impl-save-timestamp-hack() {
159 dodir /usr/share/${impl}
160 tar cpjf "${D}"/usr/share/${impl}/portage-timestamp-compensate -C "${D}"/usr/$(get_libdir)/${impl} .
163 impl-restore-timestamp-hack() {
165 tar xjpfo /usr/share/${impl}/portage-timestamp-compensate -C /usr/$(get_libdir)/${impl}
168 impl-remove-timestamp-hack() {
170 rm -rf /usr/$(get_libdir)/${impl} &>/dev/null || true
177 if [ $i == ${symbol} ]; then
184 standard-impl-postinst() {
186 rm -rf /usr/$(get_libdir)/common-lisp/${impl}/* &>/dev/null || true
187 chown cl-builder:cl-builder /usr/$(get_libdir)/common-lisp/${impl}
188 if test-in ${impl} cmucl sbcl; then
189 impl-restore-timestamp-hack ${impl}
191 chown -R root:0 /usr/$(get_libdir)/${impl}
192 /usr/bin/clc-autobuild-impl ${impl} yes
193 register-common-lisp-implementation ${impl}
196 standard-impl-postrm() {
197 local impl=$1 impl_binary=$2
198 # Since we keep our own time stamps we must manually remove them
200 if [ ! -x ${impl_binary} ]; then
201 if test-in ${impl} cmucl sbcl; then
202 impl-remove-timestamp-hack ${impl}
204 rm -rf /usr/$(get_libdir)/common-lisp/${impl}/*
208 # Local Variables: ***
209 # mode: shell-script ***