/[gentoo-x86]/eclass/elisp-common.eclass
Gentoo

Diff of /eclass/elisp-common.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.35 Revision 1.41
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.35 2008/02/22 09:28:53 ulm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/elisp-common.eclass,v 1.41 2008/07/01 22:10:06 ulm Exp $
4# 4#
5# 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> 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 2007-2008 Christian Faulhammer <opfer@gentoo.org> 8# Copyright 2007-2008 Christian Faulhammer <opfer@gentoo.org>
139# @DESCRIPTION: 139# @DESCRIPTION:
140# Name of package's site-init file. 140# Name of package's site-init file.
141SITEFILE=50${PN}-gentoo.el 141SITEFILE=50${PN}-gentoo.el
142 142
143EMACS=/usr/bin/emacs 143EMACS=/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.
145EMACSFLAGS="-batch -q --no-site-file" 145EMACSFLAGS="-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:
198# @FUNCTION: elisp-emacs-version 198# @FUNCTION: elisp-emacs-version
199# @DESCRIPTION: 199# @DESCRIPTION:
200# Output version of currently active Emacs. 200# Output version of currently active Emacs.
201 201
202elisp-emacs-version() { 202elisp-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
264elisp-site-file-install() { 265elisp-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 "$1" "${T}/${sf}" 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}/site-gentoo.d" 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. The old location for site initialisation 282# Regenerate site-gentoo.el file. The old location for site initialisation
283# when generating the start-up file. 286# when generating the start-up file.
284 287
285elisp-site-regen() { 288elisp-site-regen() {
286 local i sf line obsolete 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
305 EOF 315 EOF
306 fi 316 fi
307 317
308 einfon "Regenerating ${SITELISP}/site-gentoo.el ..." 318 einfon "Regenerating ${SITELISP}/site-gentoo.el ..."
309 319
310 # remove auxiliary file 320 # remove any auxiliary file (from previous run)
311 rm -f "${ROOT}${SITELISP}"/00site-gentoo.el 321 rm -f "${ROOT}${SITELISP}"/00site-gentoo.el
312 322
313 # set nullglob option, there may be a directory without matching files 323 # set nullglob option, there may be a directory without matching files
314 local old_shopts=$(shopt -p nullglob) 324 local old_shopts=$(shopt -p nullglob)
315 shopt -s nullglob 325 shopt -s nullglob
328 [ "${sf%/*}" = "${ROOT}${SITELISP}" ] && obsolete=t 338 [ "${sf%/*}" = "${ROOT}${SITELISP}" ] && obsolete=t
329 done 339 done
330 340
331 eval "${old_shopts}" 341 eval "${old_shopts}"
332 342
333 cat <<-EOF >"${T}"/site-gentoo.el 343 cat <<-EOF >"${tmpdir}"/site-gentoo.el
334 ;;; site-gentoo.el --- site initialisation for Gentoo-installed packages 344 ;;; site-gentoo.el --- site initialisation for Gentoo-installed packages
335 345
336 ;;; Commentary: 346 ;;; Commentary:
337 ;; Automatically generated by elisp-common.eclass 347 ;; Automatically generated by elisp-common.eclass
338 ;; DO NOT EDIT THIS FILE 348 ;; DO NOT EDIT THIS FILE
339 349
340 ;;; Code: 350 ;;; Code:
341 EOF 351 EOF
342 cat "${sflist[@]}" </dev/null >>"${T}"/site-gentoo.el 352 cat "${sflist[@]}" </dev/null >>"${tmpdir}"/site-gentoo.el
343 cat <<-EOF >>"${T}"/site-gentoo.el 353 cat <<-EOF >>"${tmpdir}"/site-gentoo.el
344 354
345 (provide 'site-gentoo) 355 (provide 'site-gentoo)
346 356
347 ;; Local Variables: 357 ;; Local Variables:
348 ;; no-byte-compile: t 358 ;; no-byte-compile: t
349 ;; End: 359 ;; End:
350 ;;; site-gentoo.el ends here 360 ;;; site-gentoo.el ends here
351 EOF 361 EOF
352 362
353 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
354 # This prevents outputting unnecessary text when there 365 # This prevents outputting unnecessary text when there
355 # was actually no change. 366 # was actually no change.
356 # A case is a remerge where we have doubled output. 367 # A case is a remerge where we have doubled output.
357 echo " no changes." 368 echo " no changes."
358 else 369 else
359 mv "${T}"/site-gentoo.el "${ROOT}${SITELISP}"/site-gentoo.el 370 mv "${tmpdir}"/site-gentoo.el "${ROOT}${SITELISP}"/site-gentoo.el
360 [ -f "${T}"/site-start.el ] \ 371 [ -f "${tmpdir}"/site-start.el ] \
361 && [ ! -e "${ROOT}${SITELISP}"/site-start.el ] \ 372 && [ ! -e "${ROOT}${SITELISP}"/site-start.el ] \
362 && mv "${T}"/site-start.el "${ROOT}${SITELISP}"/site-start.el 373 && mv "${tmpdir}"/site-start.el "${ROOT}${SITELISP}"/site-start.el
363 echo; einfo 374 echo; einfo
364 for sf in "${sflist[@]##*/}"; do 375 for sf in "${sflist[@]##*/}"; do
365 einfo " Adding ${sf} ..." 376 einfo " Adding ${sf} ..."
366 done 377 done
367 einfo "Regenerated ${SITELISP}/site-gentoo.el." 378 einfo "Regenerated ${SITELISP}/site-gentoo.el."
382can be added by individual users to their initialisation files, or, 393can be added by individual users to their initialisation files, or,
383for greater flexibility, users can load individual package-specific 394for greater flexibility, users can load individual package-specific
384initialisation files from /usr/share/emacs/site-lisp/site-gentoo.d/. 395initialisation files from /usr/share/emacs/site-lisp/site-gentoo.d/.
385EOF 396EOF
386 echo 397 echo
387
388 if [ "${obsolete}" ]; then
389 while read line; do ewarn "${line}"; done <<-EOF
390 Site-initialisation files of Emacs packages are now installed in
391 /usr/share/emacs/site-lisp/site-gentoo.d/. You may consider using
392 /usr/sbin/emacs-updater to rebuild the installed Emacs packages.
393 However, the old location is still supported.
394 EOF
395 echo
396 fi
397 fi 398 fi
398 399
400 if [ "${obsolete}" ]; then
401 while read line; do ewarn "${line}"; done <<-EOF
402 Site-initialisation files of Emacs packages are now installed in
403 /usr/share/emacs/site-lisp/site-gentoo.d/. We strongly recommend
404 that you use /usr/sbin/emacs-updater to rebuild the installed
405 Emacs packages.
406 EOF
407 echo
408
399 # Kludge for backwards compatibility: During pkg_postrm, old versions 409 # Kludge for backwards compatibility: During pkg_postrm, old versions
400 # of this eclass (saved in the VDB) won't find packages' site-init files 410 # of this eclass (saved in the VDB) won't find packages' site-init
401 # in the new location. So we copy them to an auxiliary file that is 411 # files in the new location. So we copy them to an auxiliary file
402 # visible to old eclass versions. 412 # that is visible to old eclass versions.
403 for sf in "${sflist[@]}"; do 413 for sf in "${sflist[@]}"; do
404 [ "${sf%/*}" = "${ROOT}${SITELISP}/site-gentoo.d" ] \ 414 [ "${sf%/*}" = "${ROOT}${SITELISP}/site-gentoo.d" ] \
405 && cat "${sf}" >>"${ROOT}${SITELISP}"/00site-gentoo.el 415 && cat "${sf}" >>"${ROOT}${SITELISP}"/00site-gentoo.el
406 done 416 done
417 fi
418
419 # cleanup
420 rm -f "${tmpdir}"/site-{gentoo,start}.el
407} 421}

Legend:
Removed from v.1.35  
changed lines
  Added in v.1.41

  ViewVC Help
Powered by ViewVC 1.1.20