1 | # Copyright 1999-2007 Gentoo Foundation |
1 | # Copyright 1999-2008 Gentoo Foundation |
2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/elisp-common.eclass,v 1.33 2007/12/12 21:58:57 ulm Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/elisp-common.eclass,v 1.40 2008/05/18 06:15:12 ulm Exp $ |
4 | # |
4 | # |
5 | # Copyright 2007 Christian Faulhammer <opfer@gentoo.org> |
|
|
6 | # Copyright 2002-2004 Matthew Kennedy <mkennedy@gentoo.org> |
5 | # Copyright 2002-2004 Matthew Kennedy <mkennedy@gentoo.org> |
|
|
6 | # Copyright 2003 Jeremy Maitin-Shepard <jbms@attbi.com> |
7 | # Copyright 2004-2005 Mamoru Komachi <usata@gentoo.org> |
7 | # Copyright 2004-2005 Mamoru Komachi <usata@gentoo.org> |
8 | # Copyright 2003 Jeremy Maitin-Shepard <jbms@attbi.com> |
8 | # Copyright 2007-2008 Christian Faulhammer <opfer@gentoo.org> |
9 | # Copyright 2007 Ulrich Mueller <ulm@gentoo.org> |
9 | # Copyright 2007-2008 Ulrich MΓΌller <ulm@gentoo.org> |
10 | # |
10 | # |
11 | # @ECLASS: elisp-common.eclass |
11 | # @ECLASS: elisp-common.eclass |
12 | # @MAINTAINER: |
12 | # @MAINTAINER: |
13 | # Feel free to contact the Emacs team through <emacs@gentoo.org> if you have |
13 | # Feel free to contact the Emacs team through <emacs@gentoo.org> if you have |
14 | # problems, suggestions or questions. |
14 | # problems, suggestions or questions. |
… | |
… | |
139 | # @DESCRIPTION: |
139 | # @DESCRIPTION: |
140 | # Name of package's site-init file. |
140 | # Name of package's site-init file. |
141 | SITEFILE=50${PN}-gentoo.el |
141 | SITEFILE=50${PN}-gentoo.el |
142 | |
142 | |
143 | EMACS=/usr/bin/emacs |
143 | EMACS=/usr/bin/emacs |
144 | # The following works for Emacs versions 18--23, don't change it. |
144 | # The following works for Emacs versions 18-23, don't change it. |
145 | EMACSFLAGS="-batch -q --no-site-file" |
145 | EMACSFLAGS="-batch -q --no-site-file" |
146 | |
146 | |
147 | # @FUNCTION: elisp-compile |
147 | # @FUNCTION: elisp-compile |
148 | # @USAGE: <list of elisp files> |
148 | # @USAGE: <list of elisp files> |
149 | # @DESCRIPTION: |
149 | # @DESCRIPTION: |
… | |
… | |
201 | |
201 | |
202 | elisp-emacs-version() { |
202 | elisp-emacs-version() { |
203 | # The following will work for at least versions 18-23. |
203 | # The following will work for at least versions 18-23. |
204 | echo "(princ emacs-version)" >"${T}"/emacs-version.el |
204 | echo "(princ emacs-version)" >"${T}"/emacs-version.el |
205 | ${EMACS} ${EMACSFLAGS} -l "${T}"/emacs-version.el |
205 | ${EMACS} ${EMACSFLAGS} -l "${T}"/emacs-version.el |
|
|
206 | rm -f "${T}"/emacs-version.el |
206 | } |
207 | } |
207 | |
208 | |
208 | # @FUNCTION: elisp-make-autoload-file |
209 | # @FUNCTION: elisp-make-autoload-file |
209 | # @USAGE: [output file] [list of directories] |
210 | # @USAGE: [output file] [list of directories] |
210 | # @DESCRIPTION: |
211 | # @DESCRIPTION: |
… | |
… | |
260 | # @USAGE: <site-init file> [subdirectory] |
261 | # @USAGE: <site-init file> [subdirectory] |
261 | # @DESCRIPTION: |
262 | # @DESCRIPTION: |
262 | # Install Emacs site-init file in SITELISP directory. |
263 | # Install Emacs site-init file in SITELISP directory. |
263 | |
264 | |
264 | elisp-site-file-install() { |
265 | elisp-site-file-install() { |
265 | local sf="$1" my_pn="${2:-${PN}}" |
266 | local sf="${T}/${1##*/}" my_pn="${2:-${PN}}" ret |
266 | ebegin "Installing site initialisation file for GNU Emacs" |
267 | ebegin "Installing site initialisation file for GNU Emacs" |
267 | cp "${sf}" "${T}" |
268 | cp "$1" "${sf}" |
268 | sed -i -e "s:@SITELISP@:${SITELISP}/${my_pn}:g" \ |
269 | sed -i -e "s:@SITELISP@:${SITELISP}/${my_pn}:g" \ |
269 | -e "s:@SITEETC@:${SITEETC}/${my_pn}:g" "${T}/${sf##*/}" |
270 | -e "s:@SITEETC@:${SITEETC}/${my_pn}:g" "${sf}" |
270 | ( # subshell to avoid pollution of calling environment |
271 | ( # subshell to avoid pollution of calling environment |
271 | insinto "${SITELISP}" |
272 | insinto "${SITELISP}/site-gentoo.d" |
272 | doins "${T}/${sf##*/}" |
273 | doins "${sf}" |
273 | ) |
274 | ) |
|
|
275 | ret=$? |
|
|
276 | rm -f "${sf}" |
274 | eend $? "doins failed" |
277 | eend ${ret} "doins failed" |
275 | } |
278 | } |
276 | |
279 | |
277 | # @FUNCTION: elisp-site-regen |
280 | # @FUNCTION: elisp-site-regen |
278 | # @DESCRIPTION: |
281 | # @DESCRIPTION: |
279 | # Regenerate site-gentoo.el file. |
282 | # Regenerate site-gentoo.el file. The old location for site initialisation |
280 | |
283 | # files of packages was /usr/share/emacs/site-lisp/. In December 2007 this |
281 | # Old location for site initialisation files of packages was |
284 | # has been changed to /usr/share/emacs/site-lisp/site-gentoo.d/. Remerge of |
282 | # /usr/share/emacs/site-lisp/. It is planned to change this to |
285 | # packages with Emacs support is enough, the old location is still supported |
283 | # /usr/share/emacs/site-lisp/site-gentoo.d/. |
286 | # when generating the start-up file. |
284 | |
287 | |
285 | elisp-site-regen() { |
288 | elisp-site-regen() { |
286 | local i sf line |
289 | local i sf line obsolete |
287 | local -a sflist |
290 | local -a sflist |
|
|
291 | # Work around Paludis borkage: variable T is empty in pkg_postrm |
|
|
292 | local tmpdir=${T:-$(mktemp -d)} |
|
|
293 | |
|
|
294 | if [ ! -d "${ROOT}${SITELISP}" ]; then |
|
|
295 | eerror "Directory ${SITELISP} does not exist" |
|
|
296 | return 1 |
|
|
297 | fi |
288 | |
298 | |
289 | if [ ! -e "${ROOT}${SITELISP}"/site-gentoo.el ] \ |
299 | if [ ! -e "${ROOT}${SITELISP}"/site-gentoo.el ] \ |
290 | && [ ! -e "${ROOT}${SITELISP}"/site-start.el ]; then |
300 | && [ ! -e "${ROOT}${SITELISP}"/site-start.el ]; then |
291 | einfo "Creating default ${SITELISP}/site-start.el ..." |
301 | einfo "Creating default ${SITELISP}/site-start.el ..." |
292 | cat <<-EOF >"${T}"/site-start.el |
302 | cat <<-EOF >"${tmpdir}"/site-start.el |
293 | ;;; site-start.el |
303 | ;;; site-start.el |
294 | |
304 | |
295 | ;;; Commentary: |
305 | ;;; Commentary: |
296 | ;; This default site startup file is installed by elisp-common.eclass. |
306 | ;; This default site startup file is installed by elisp-common.eclass. |
297 | ;; You may replace this file by your own site initialisation, or even |
307 | ;; You may replace this file by your own site initialisation, or even |
… | |
… | |
322 | for ((i=${#sflist[@]}; i>0; i--)); do |
332 | for ((i=${#sflist[@]}; i>0; i--)); do |
323 | [[ ${sf##*/} < ${sflist[i-1]##*/} ]] || break |
333 | [[ ${sf##*/} < ${sflist[i-1]##*/} ]] || break |
324 | sflist[i]=${sflist[i-1]} |
334 | sflist[i]=${sflist[i-1]} |
325 | done |
335 | done |
326 | sflist[i]=${sf} |
336 | sflist[i]=${sf} |
|
|
337 | # set a flag if there are obsolete files |
|
|
338 | [ "${sf%/*}" = "${ROOT}${SITELISP}" ] && obsolete=t |
327 | done |
339 | done |
328 | |
340 | |
329 | eval "${old_shopts}" |
341 | eval "${old_shopts}" |
330 | |
342 | |
331 | cat <<-EOF >"${T}"/site-gentoo.el |
343 | cat <<-EOF >"${tmpdir}"/site-gentoo.el |
332 | ;;; site-gentoo.el --- site initialisation for Gentoo-installed packages |
344 | ;;; site-gentoo.el --- site initialisation for Gentoo-installed packages |
333 | |
345 | |
334 | ;;; Commentary: |
346 | ;;; Commentary: |
335 | ;; Automatically generated by elisp-common.eclass |
347 | ;; Automatically generated by elisp-common.eclass |
336 | ;; DO NOT EDIT THIS FILE |
348 | ;; DO NOT EDIT THIS FILE |
337 | |
349 | |
338 | ;;; Code: |
350 | ;;; Code: |
339 | EOF |
351 | EOF |
340 | cat "${sflist[@]}" </dev/null >>"${T}"/site-gentoo.el |
352 | cat "${sflist[@]}" </dev/null >>"${tmpdir}"/site-gentoo.el |
341 | cat <<-EOF >>"${T}"/site-gentoo.el |
353 | cat <<-EOF >>"${tmpdir}"/site-gentoo.el |
342 | |
354 | |
343 | (provide 'site-gentoo) |
355 | (provide 'site-gentoo) |
344 | |
356 | |
345 | ;; Local Variables: |
357 | ;; Local Variables: |
346 | ;; no-byte-compile: t |
358 | ;; no-byte-compile: t |
347 | ;; End: |
359 | ;; End: |
348 | ;;; site-gentoo.el ends here |
360 | ;;; site-gentoo.el ends here |
349 | EOF |
361 | EOF |
350 | |
362 | |
351 | if cmp -s "${ROOT}${SITELISP}"/site-gentoo.el "${T}"/site-gentoo.el; then |
363 | if cmp -s "${ROOT}${SITELISP}"/site-gentoo.el "${tmpdir}"/site-gentoo.el |
|
|
364 | then |
352 | # This prevents outputting unnecessary text when there |
365 | # This prevents outputting unnecessary text when there |
353 | # was actually no change. |
366 | # was actually no change. |
354 | # A case is a remerge where we have doubled output. |
367 | # A case is a remerge where we have doubled output. |
355 | echo " no changes." |
368 | echo " no changes." |
356 | else |
369 | else |
357 | mv "${T}"/site-gentoo.el "${ROOT}${SITELISP}"/site-gentoo.el |
370 | mv "${tmpdir}"/site-gentoo.el "${ROOT}${SITELISP}"/site-gentoo.el |
358 | [ -f "${T}"/site-start.el ] \ |
371 | [ -f "${tmpdir}"/site-start.el ] \ |
359 | && [ ! -e "${ROOT}${SITELISP}"/site-start.el ] \ |
372 | && [ ! -e "${ROOT}${SITELISP}"/site-start.el ] \ |
360 | && mv "${T}"/site-start.el "${ROOT}${SITELISP}"/site-start.el |
373 | && mv "${tmpdir}"/site-start.el "${ROOT}${SITELISP}"/site-start.el |
361 | echo; einfo |
374 | echo; einfo |
362 | for sf in "${sflist[@]##*/}"; do |
375 | for sf in "${sflist[@]##*/}"; do |
363 | einfo " Adding ${sf} ..." |
376 | einfo " Adding ${sf} ..." |
364 | done |
377 | done |
365 | einfo "Regenerated ${SITELISP}/site-gentoo.el." |
378 | einfo "Regenerated ${SITELISP}/site-gentoo.el." |
… | |
… | |
377 | (require 'site-gentoo) |
390 | (require 'site-gentoo) |
378 | |
391 | |
379 | to /usr/share/emacs/site-lisp/site-start.el. Alternatively, that line |
392 | to /usr/share/emacs/site-lisp/site-start.el. Alternatively, that line |
380 | can be added by individual users to their initialisation files, or, |
393 | can be added by individual users to their initialisation files, or, |
381 | for greater flexibility, users can load individual package-specific |
394 | for greater flexibility, users can load individual package-specific |
382 | initialisation files from /usr/share/emacs/site-lisp/. |
395 | initialisation files from /usr/share/emacs/site-lisp/site-gentoo.d/. |
383 | EOF |
396 | EOF |
384 | echo |
397 | echo |
|
|
398 | |
|
|
399 | if [ "${obsolete}" ]; then |
|
|
400 | while read line; do ewarn "${line}"; done <<-EOF |
|
|
401 | Site-initialisation files of Emacs packages are now installed in |
|
|
402 | /usr/share/emacs/site-lisp/site-gentoo.d/. We strongly recommend |
|
|
403 | that you use /usr/sbin/emacs-updater to rebuild the installed |
|
|
404 | Emacs packages. |
|
|
405 | EOF |
|
|
406 | echo |
|
|
407 | fi |
385 | fi |
408 | fi |
386 | |
409 | |
387 | # Kludge for backwards compatibility: During pkg_postrm, old versions |
410 | # Kludge for backwards compatibility: During pkg_postrm, old versions |
388 | # of this eclass (saved in the PDB) won't find packages' site-init files |
411 | # of this eclass (saved in the VDB) won't find packages' site-init files |
389 | # in the new location. So we copy them to an auxiliary file that is |
412 | # in the new location. So we copy them to an auxiliary file that is |
390 | # visible to old eclass versions. |
413 | # visible to old eclass versions. |
391 | for sf in "${sflist[@]}"; do |
414 | for sf in "${sflist[@]}"; do |
392 | [ "${sf%/*}" = "${ROOT}${SITELISP}/site-gentoo.d" ] \ |
415 | [ "${sf%/*}" = "${ROOT}${SITELISP}/site-gentoo.d" ] \ |
393 | && cat "${sf}" >>"${ROOT}${SITELISP}"/00site-gentoo.el |
416 | && cat "${sf}" >>"${ROOT}${SITELISP}"/00site-gentoo.el |
394 | done |
417 | done |
|
|
418 | |
|
|
419 | # cleanup |
|
|
420 | rm -f "${tmpdir}"/site-{gentoo,start}.el |
395 | } |
421 | } |