1 | # Copyright 1999-2009 Gentoo Foundation |
1 | # Copyright 1999-2009 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.63 2009/11/22 12:06:43 ulm Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/elisp-common.eclass,v 1.64 2009/12/07 21:05:08 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 <fauli@gentoo.org> |
8 | # Copyright 2007-2008 Christian Faulhammer <fauli@gentoo.org> |
… | |
… | |
141 | SITEETC=/usr/share/emacs/etc |
141 | SITEETC=/usr/share/emacs/etc |
142 | |
142 | |
143 | # @ECLASS-VARIABLE: EMACS |
143 | # @ECLASS-VARIABLE: EMACS |
144 | # @DESCRIPTION: |
144 | # @DESCRIPTION: |
145 | # Path of Emacs executable. |
145 | # Path of Emacs executable. |
146 | EMACS=/usr/bin/emacs |
146 | EMACS=${EPREFIX}/usr/bin/emacs |
147 | |
147 | |
148 | # @ECLASS-VARIABLE: EMACSFLAGS |
148 | # @ECLASS-VARIABLE: EMACSFLAGS |
149 | # @DESCRIPTION: |
149 | # @DESCRIPTION: |
150 | # Flags for executing Emacs in batch mode. |
150 | # Flags for executing Emacs in batch mode. |
151 | # These work for Emacs versions 18-23, so don't change them. |
151 | # These work for Emacs versions 18-23, so don't change them. |
… | |
… | |
259 | || ewarn "elisp-site-file-install: bad name of site-init file" |
259 | || ewarn "elisp-site-file-install: bad name of site-init file" |
260 | sf="${T}/${sf/%-gentoo*.el/-gentoo.el}" |
260 | sf="${T}/${sf/%-gentoo*.el/-gentoo.el}" |
261 | ebegin "Installing site initialisation file for GNU Emacs" |
261 | ebegin "Installing site initialisation file for GNU Emacs" |
262 | [[ $1 = ${sf} ]] || cp "$1" "${sf}" |
262 | [[ $1 = ${sf} ]] || cp "$1" "${sf}" |
263 | sed -i -e "1{:x;/^\$/{n;bx;};/^;.*${PN}/I!s:^:${header}\n\n:;1s:^:\n:;}" \ |
263 | sed -i -e "1{:x;/^\$/{n;bx;};/^;.*${PN}/I!s:^:${header}\n\n:;1s:^:\n:;}" \ |
264 | -e "s:@SITELISP@:${SITELISP}/${my_pn}:g" \ |
264 | -e "s:@SITELISP@:${EPREFIX}${SITELISP}/${my_pn}:g" \ |
265 | -e "s:@SITEETC@:${SITEETC}/${my_pn}:g;\$q" "${sf}" |
265 | -e "s:@SITEETC@:${EPREFIX}${SITEETC}/${my_pn}:g;\$q" "${sf}" |
266 | ( # subshell to avoid pollution of calling environment |
266 | ( # subshell to avoid pollution of calling environment |
267 | insinto "${SITELISP}/site-gentoo.d" |
267 | insinto "${SITELISP}/site-gentoo.d" |
268 | doins "${sf}" |
268 | doins "${sf}" |
269 | ) |
269 | ) |
270 | ret=$? |
270 | ret=$? |
… | |
… | |
281 | # Note: Before December 2007, site initialisation files were installed |
281 | # Note: Before December 2007, site initialisation files were installed |
282 | # in /usr/share/emacs/site-lisp/. For backwards compatibility, this |
282 | # in /usr/share/emacs/site-lisp/. For backwards compatibility, this |
283 | # location is still supported when generating site-gentoo.el. |
283 | # location is still supported when generating site-gentoo.el. |
284 | |
284 | |
285 | elisp-site-regen() { |
285 | elisp-site-regen() { |
|
|
286 | local sitelisp=${ROOT}${EPREFIX}${SITELISP} |
286 | local i sf line obsolete null="" page=$'\f' |
287 | local i sf line obsolete null="" page=$'\f' |
287 | local -a sflist |
288 | local -a sflist |
288 | |
289 | |
289 | if [ ! -d "${ROOT}${SITELISP}" ]; then |
290 | if [ ! -d "${sitelisp}" ]; then |
290 | eerror "elisp-site-regen: Directory ${SITELISP} does not exist" |
291 | eerror "elisp-site-regen: Directory ${sitelisp} does not exist" |
291 | return 1 |
292 | return 1 |
292 | fi |
293 | fi |
293 | |
294 | |
294 | if [ ! -d "${T}" ]; then |
295 | if [ ! -d "${T}" ]; then |
295 | eerror "elisp-site-regen: Temporary directory ${T} does not exist" |
296 | eerror "elisp-site-regen: Temporary directory ${T} does not exist" |
… | |
… | |
298 | |
299 | |
299 | einfon "Regenerating site-gentoo.el for GNU Emacs (${EBUILD_PHASE}) ..." |
300 | einfon "Regenerating site-gentoo.el for GNU Emacs (${EBUILD_PHASE}) ..." |
300 | |
301 | |
301 | # Until January 2009, elisp-common.eclass sometimes created an |
302 | # Until January 2009, elisp-common.eclass sometimes created an |
302 | # auxiliary file for backwards compatibility. Remove any such file. |
303 | # auxiliary file for backwards compatibility. Remove any such file. |
303 | rm -f "${ROOT}${SITELISP}"/00site-gentoo.el |
304 | rm -f "${sitelisp}"/00site-gentoo.el |
304 | |
305 | |
305 | # set nullglob option, there may be a directory without matching files |
306 | # set nullglob option, there may be a directory without matching files |
306 | local old_shopts=$(shopt -p nullglob) |
307 | local old_shopts=$(shopt -p nullglob) |
307 | shopt -s nullglob |
308 | shopt -s nullglob |
308 | |
309 | |
309 | for sf in "${ROOT}${SITELISP}"/[0-9][0-9]*-gentoo.el \ |
310 | for sf in "${sitelisp}"/[0-9][0-9]*-gentoo.el \ |
310 | "${ROOT}${SITELISP}"/site-gentoo.d/[0-9][0-9]*.el |
311 | "${sitelisp}"/site-gentoo.d/[0-9][0-9]*.el |
311 | do |
312 | do |
312 | [ -r "${sf}" ] || continue |
313 | [ -r "${sf}" ] || continue |
313 | # sort files by their basename. straight insertion sort. |
314 | # sort files by their basename. straight insertion sort. |
314 | for ((i=${#sflist[@]}; i>0; i--)); do |
315 | for ((i=${#sflist[@]}; i>0; i--)); do |
315 | [[ ${sf##*/} < ${sflist[i-1]##*/} ]] || break |
316 | [[ ${sf##*/} < ${sflist[i-1]##*/} ]] || break |
316 | sflist[i]=${sflist[i-1]} |
317 | sflist[i]=${sflist[i-1]} |
317 | done |
318 | done |
318 | sflist[i]=${sf} |
319 | sflist[i]=${sf} |
319 | # set a flag if there are obsolete files |
320 | # set a flag if there are obsolete files |
320 | [ "${sf%/*}" = "${ROOT}${SITELISP}" ] && obsolete=t |
321 | [ "${sf%/*}" = "${sitelisp}" ] && obsolete=t |
321 | done |
322 | done |
322 | |
323 | |
323 | eval "${old_shopts}" |
324 | eval "${old_shopts}" |
324 | |
325 | |
325 | cat <<-EOF >"${T}"/site-gentoo.el |
326 | cat <<-EOF >"${T}"/site-gentoo.el |
… | |
… | |
344 | ;; End: |
345 | ;; End: |
345 | |
346 | |
346 | ;;; site-gentoo.el ends here |
347 | ;;; site-gentoo.el ends here |
347 | EOF |
348 | EOF |
348 | |
349 | |
349 | if cmp -s "${ROOT}${SITELISP}"/site-gentoo.el "${T}"/site-gentoo.el |
350 | if cmp -s "${sitelisp}"/site-gentoo.el "${T}"/site-gentoo.el; then |
350 | then |
|
|
351 | # This prevents outputting unnecessary text when there |
351 | # This prevents outputting unnecessary text when there |
352 | # was actually no change. |
352 | # was actually no change. |
353 | # A case is a remerge where we have doubled output. |
353 | # A case is a remerge where we have doubled output. |
354 | echo " no changes." |
354 | echo " no changes." |
355 | else |
355 | else |
356 | mv "${T}"/site-gentoo.el "${ROOT}${SITELISP}"/site-gentoo.el |
356 | mv "${T}"/site-gentoo.el "${sitelisp}"/site-gentoo.el |
357 | echo |
357 | echo |
358 | case ${#sflist[@]} in |
358 | case ${#sflist[@]} in |
359 | 0) ewarn "... Huh? No site initialisation files found." ;; |
359 | 0) ewarn "... Huh? No site initialisation files found." ;; |
360 | 1) einfo "... ${#sflist[@]} site initialisation file included." ;; |
360 | 1) einfo "... ${#sflist[@]} site initialisation file included." ;; |
361 | *) einfo "... ${#sflist[@]} site initialisation files included." ;; |
361 | *) einfo "... ${#sflist[@]} site initialisation files included." ;; |