/[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.70 Revision 1.75
1# Copyright 1999-2010 Gentoo Foundation 1# Copyright 1999-2011 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.70 2010/11/29 17:07:22 ulm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/elisp-common.eclass,v 1.75 2011/08/30 20:10:13 ulm Exp $
4#
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>
8# Copyright 2007-2008 Christian Faulhammer <fauli@gentoo.org>
9# Copyright 2007-2010 Ulrich Müller <ulm@gentoo.org>
10# 4#
11# @ECLASS: elisp-common.eclass 5# @ECLASS: elisp-common.eclass
12# @MAINTAINER: 6# @MAINTAINER:
13# Feel free to contact the Emacs team through <emacs@gentoo.org> if you 7# Gentoo Emacs team <emacs@gentoo.org>
14# have problems, suggestions or questions. 8# @AUTHOR:
9# Matthew Kennedy <mkennedy@gentoo.org>
10# Jeremy Maitin-Shepard <jbms@attbi.com>
11# Mamoru Komachi <usata@gentoo.org>
12# Christian Faulhammer <fauli@gentoo.org>
13# Ulrich Müller <ulm@gentoo.org>
15# @BLURB: Emacs-related installation utilities 14# @BLURB: Emacs-related installation utilities
16# @DESCRIPTION: 15# @DESCRIPTION:
17# 16#
18# Usually you want to use this eclass for (optional) GNU Emacs support 17# Usually you want to use this eclass for (optional) GNU Emacs support
19# of your package. This is NOT for XEmacs! 18# of your package. This is NOT for XEmacs!
169# @FUNCTION: elisp-emacs-version 168# @FUNCTION: elisp-emacs-version
170# @DESCRIPTION: 169# @DESCRIPTION:
171# Output version of currently active Emacs. 170# Output version of currently active Emacs.
172 171
173elisp-emacs-version() { 172elisp-emacs-version() {
173 local ret
174 # The following will work for at least versions 18-23. 174 # The following will work for at least versions 18-23.
175 echo "(princ emacs-version)" >"${T}"/emacs-version.el 175 echo "(princ emacs-version)" >"${T}"/emacs-version.el
176 ${EMACS} ${EMACSFLAGS} -l "${T}"/emacs-version.el 176 ${EMACS} ${EMACSFLAGS} -l "${T}"/emacs-version.el
177 ret=$?
177 rm -f "${T}"/emacs-version.el 178 rm -f "${T}"/emacs-version.el
179 if [[ ${ret} -ne 0 ]]; then
180 eerror "elisp-emacs-version: Failed to run ${EMACS}"
181 fi
182 return ${ret}
178} 183}
179 184
180# @FUNCTION: elisp-need-emacs 185# @FUNCTION: elisp-need-emacs
181# @USAGE: <version> 186# @USAGE: <version>
182# @RETURN: 0 if true, 1 otherwise 187# @RETURN: 0 if true, 1 otherwise
183# @DESCRIPTION: 188# @DESCRIPTION:
184# Test if the eselected Emacs version is at least the major version 189# Test if the eselected Emacs version is at least the major version
185# specified as argument. 190# specified as argument.
186 191
187elisp-need-emacs() { 192elisp-need-emacs() {
188 local need_emacs=$1 193 local need_emacs=$1 have_emacs
189 local have_emacs=$(elisp-emacs-version) 194 have_emacs=$(elisp-emacs-version) || return
190 einfo "Emacs version: ${have_emacs}" 195 einfo "Emacs version: ${have_emacs}"
191 if ! [[ ${have_emacs%%.*} -ge ${need_emacs%%.*} ]]; then 196 if ! [[ ${have_emacs%%.*} -ge ${need_emacs%%.*} ]]; then
192 eerror "This package needs at least Emacs ${need_emacs%%.*}." 197 eerror "This package needs at least Emacs ${need_emacs%%.*}."
193 eerror "Use \"eselect emacs\" to select the active version." 198 eerror "Use \"eselect emacs\" to select the active version."
194 return 1 199 return 1
282 287
283 [[ ${sf} == [0-9][0-9]*-gentoo*.el ]] \ 288 [[ ${sf} == [0-9][0-9]*-gentoo*.el ]] \
284 || ewarn "elisp-site-file-install: bad name of site-init file" 289 || ewarn "elisp-site-file-install: bad name of site-init file"
285 sf="${T}/${sf/%-gentoo*.el/-gentoo.el}" 290 sf="${T}/${sf/%-gentoo*.el/-gentoo.el}"
286 ebegin "Installing site initialisation file for GNU Emacs" 291 ebegin "Installing site initialisation file for GNU Emacs"
287 [[ $1 = ${sf} ]] || cp "$1" "${sf}" 292 [[ $1 = "${sf}" ]] || cp "$1" "${sf}"
288 sed -i -e "1{:x;/^\$/{n;bx;};/^;.*${PN}/I!s:^:${header}\n\n:;1s:^:\n:;}" \ 293 sed -i -e "1{:x;/^\$/{n;bx;};/^;.*${PN}/I!s:^:${header}\n\n:;1s:^:\n:;}" \
289 -e "s:@SITELISP@:${EPREFIX}${SITELISP}/${my_pn}:g" \ 294 -e "s:@SITELISP@:${EPREFIX}${SITELISP}/${my_pn}:g" \
290 -e "s:@SITEETC@:${EPREFIX}${SITEETC}/${my_pn}:g;\$q" "${sf}" 295 -e "s:@SITEETC@:${EPREFIX}${SITEETC}/${my_pn}:g;\$q" "${sf}"
291 ( # subshell to avoid pollution of calling environment 296 ( # subshell to avoid pollution of calling environment
292 insinto "${SITELISP}/site-gentoo.d" 297 insinto "${SITELISP}/site-gentoo.d"
310elisp-site-regen() { 315elisp-site-regen() {
311 local sitelisp=${ROOT}${EPREFIX}${SITELISP} 316 local sitelisp=${ROOT}${EPREFIX}${SITELISP}
312 local sf i line null="" page=$'\f' 317 local sf i line null="" page=$'\f'
313 local -a sflist 318 local -a sflist
314 319
315 if [ ! -d "${sitelisp}" ]; then 320 if [[ ! -d ${sitelisp} ]]; then
316 eerror "elisp-site-regen: Directory ${sitelisp} does not exist" 321 eerror "elisp-site-regen: Directory ${sitelisp} does not exist"
317 return 1 322 return 1
318 fi 323 fi
319 324
320 if [ ! -d "${T}" ]; then 325 if [[ ! -d ${T} ]]; then
321 eerror "elisp-site-regen: Temporary directory ${T} does not exist" 326 eerror "elisp-site-regen: Temporary directory ${T} does not exist"
322 return 1 327 return 1
323 fi 328 fi
324 329
325 einfon "Regenerating site-gentoo.el for GNU Emacs (${EBUILD_PHASE}) ..." 330 einfon "Regenerating site-gentoo.el for GNU Emacs (${EBUILD_PHASE}) ..."
329 rm -f "${sitelisp}"/00site-gentoo.el 334 rm -f "${sitelisp}"/00site-gentoo.el
330 335
331 for sf in "${sitelisp}"/[0-9][0-9]*-gentoo.el \ 336 for sf in "${sitelisp}"/[0-9][0-9]*-gentoo.el \
332 "${sitelisp}"/site-gentoo.d/[0-9][0-9]*.el 337 "${sitelisp}"/site-gentoo.d/[0-9][0-9]*.el
333 do 338 do
334 [ -r "${sf}" ] || continue 339 [[ -r ${sf} ]] || continue
335 # sort files by their basename. straight insertion sort. 340 # sort files by their basename. straight insertion sort.
336 for ((i=${#sflist[@]}; i>0; i--)); do 341 for ((i=${#sflist[@]}; i>0; i--)); do
337 [[ ${sf##*/} < ${sflist[i-1]##*/} ]] || break 342 [[ ${sf##*/} < ${sflist[i-1]##*/} ]] || break
338 sflist[i]=${sflist[i-1]} 343 sflist[i]=${sflist[i-1]}
339 done 344 done

Legend:
Removed from v.1.70  
changed lines
  Added in v.1.75

  ViewVC Help
Powered by ViewVC 1.1.20