summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2007-12-11 12:28:05 +0000
committerUlrich Müller <ulm@gentoo.org>2007-12-11 12:28:05 +0000
commit0cad7ea0ad50317d2b095407bc4f49c5f9da9a50 (patch)
treefb5d5f7e2ea03bf77f33c7c683bbd11f87f2f4af /eclass
parentRemove vulnerable revision wrt bug #200297. (diff)
downloadgentoo-2-0cad7ea0ad50317d2b095407bc4f49c5f9da9a50.tar.gz
gentoo-2-0cad7ea0ad50317d2b095407bc4f49c5f9da9a50.tar.bz2
gentoo-2-0cad7ea0ad50317d2b095407bc4f49c5f9da9a50.zip
Partial sync from Emacs overlay:
Prepare for migration of packages' site files to site-gentoo.d subdirectory. Use bash arrays and a custom sort routine in elisp-site-regen. Set nullglob option, because there may be a directory without matching files. Use ebegin/eend instead of einfo where it is feasible.
Diffstat (limited to 'eclass')
-rw-r--r--eclass/elisp-common.eclass72
1 files changed, 55 insertions, 17 deletions
diff --git a/eclass/elisp-common.eclass b/eclass/elisp-common.eclass
index 9b999b7ba51f..03b7bae76069 100644
--- a/eclass/elisp-common.eclass
+++ b/eclass/elisp-common.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/elisp-common.eclass,v 1.31 2007/12/01 15:35:02 ulm Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/elisp-common.eclass,v 1.32 2007/12/11 12:28:05 ulm Exp $
#
# Copyright 2007 Christian Faulhammer <opfer@gentoo.org>
# Copyright 2002-2004 Matthew Kennedy <mkennedy@gentoo.org>
@@ -150,8 +150,9 @@ EMACSFLAGS="-batch -q --no-site-file"
# Byte-compile Emacs Lisp files.
elisp-compile() {
- einfo "Compiling GNU Emacs Elisp files ..."
+ ebegin "Compiling GNU Emacs Elisp files"
${EMACS} ${EMACSFLAGS} -f batch-byte-compile "$@"
+ eend $? "batch-byte-compile failed"
}
# @FUNCTION: elisp-comp
@@ -175,7 +176,7 @@ elisp-comp() {
[ $# -gt 0 ] || return 1
- einfo "Compiling GNU Emacs Elisp files ..."
+ ebegin "Compiling GNU Emacs Elisp files"
tempdir=elc.$$
mkdir ${tempdir}
@@ -189,6 +190,8 @@ elisp-comp() {
popd
rm -fr ${tempdir}
+
+ eend ${ret} "batch-byte-compile failed"
return ${ret}
}
@@ -210,7 +213,7 @@ elisp-emacs-version() {
elisp-make-autoload-file() {
local f="${1:-${PN}-autoloads.el}"
shift
- einfo "Generating autoload file for GNU Emacs ..."
+ ebegin "Generating autoload file for GNU Emacs"
sed 's/^FF/\f/' >"${f}" <<-EOF
;;; ${f##*/} --- autoloads for ${P}
@@ -233,6 +236,8 @@ elisp-make-autoload-file() {
--eval "(setq make-backup-files nil)" \
--eval "(setq generated-autoload-file (expand-file-name \"${f}\"))" \
-f batch-update-autoloads "${@-.}"
+
+ eend $? "batch-update-autoloads failed"
}
# @FUNCTION: elisp-install
@@ -243,11 +248,12 @@ elisp-make-autoload-file() {
elisp-install() {
local subdir="$1"
shift
- einfo "Installing Elisp files for GNU Emacs support ..."
+ ebegin "Installing Elisp files for GNU Emacs support"
( # subshell to avoid pollution of calling environment
insinto "${SITELISP}/${subdir}"
doins "$@"
)
+ eend $? "doins failed"
}
# @FUNCTION: elisp-site-file-install
@@ -257,7 +263,7 @@ elisp-install() {
elisp-site-file-install() {
local sf="$1" my_pn="${2:-${PN}}"
- einfo "Installing site initialisation file for GNU Emacs ..."
+ ebegin "Installing site initialisation file for GNU Emacs"
cp "${sf}" "${T}"
sed -i -e "s:@SITELISP@:${SITELISP}/${my_pn}:g" \
-e "s:@SITEETC@:${SITEETC}/${my_pn}:g" "${T}/${sf##*/}"
@@ -265,14 +271,20 @@ elisp-site-file-install() {
insinto "${SITELISP}"
doins "${T}/${sf##*/}"
)
+ eend $? "doins failed"
}
# @FUNCTION: elisp-site-regen
# @DESCRIPTION:
# Regenerate site-gentoo.el file.
+# Old location for site initialisation files of packages was
+# /usr/share/emacs/site-lisp/. It is planned to change this to
+# /usr/share/emacs/site-lisp/site-gentoo.d/.
+
elisp-site-regen() {
- local sflist sf line
+ local i sf line
+ local -a sflist
if [ ! -e "${ROOT}${SITELISP}"/site-gentoo.el ] \
&& [ ! -e "${ROOT}${SITELISP}"/site-start.el ]; then
@@ -294,6 +306,28 @@ elisp-site-regen() {
fi
einfon "Regenerating ${SITELISP}/site-gentoo.el ..."
+
+ # remove auxiliary file
+ rm -f "${ROOT}${SITELISP}"/00site-gentoo.el
+
+ # set nullglob option, there may be a directory without matching files
+ local old_shopts=$(shopt -p nullglob)
+ shopt -s nullglob
+
+ for sf in "${ROOT}${SITELISP}"/[0-9][0-9]*-gentoo.el \
+ "${ROOT}${SITELISP}"/site-gentoo.d/[0-9][0-9]*.el
+ do
+ [ -r "${sf}" ] || continue
+ # sort files by their basename. straight insertion sort.
+ for ((i=${#sflist[@]}; i>0; i--)); do
+ [[ ${sf##*/} < ${sflist[i-1]##*/} ]] || break
+ sflist[i]=${sflist[i-1]}
+ done
+ sflist[i]=${sf}
+ done
+
+ eval "${old_shopts}"
+
cat <<-EOF >"${T}"/site-gentoo.el
;;; site-gentoo.el --- site initialisation for Gentoo-installed packages
@@ -303,14 +337,7 @@ elisp-site-regen() {
;;; Code:
EOF
-
- for sf in "${ROOT}${SITELISP}"/[0-9][0-9]*-gentoo.el
- do
- [ -r "${sf}" ] || continue
- sflist="${sflist} ${sf##*/}"
- cat "${sf}" >>"${T}"/site-gentoo.el
- done
-
+ cat "${sflist[@]}" >>"${T}"/site-gentoo.el
cat <<-EOF >>"${T}"/site-gentoo.el
(provide 'site-gentoo)
@@ -332,11 +359,13 @@ elisp-site-regen() {
&& [ ! -e "${ROOT}${SITELISP}"/site-start.el ] \
&& mv "${T}"/site-start.el "${ROOT}${SITELISP}"/site-start.el
echo; einfo
- for sf in ${sflist}; do
+ for sf in "${sflist[@]##*/}"; do
einfo " Adding ${sf} ..."
done
- while read line; do einfo "${line}"; done <<EOF
+ einfo "Regenerated ${SITELISP}/site-gentoo.el."
+ echo
+ while read line; do einfo "${line}"; done <<EOF
All site initialisation for Gentoo-installed packages is added to
/usr/share/emacs/site-lisp/site-gentoo.el; site-start.el is no longer
managed by Gentoo. You are responsible for all maintenance of
@@ -354,4 +383,13 @@ initialisation files from /usr/share/emacs/site-lisp/.
EOF
echo
fi
+
+ # Kludge for backwards compatibility: During pkg_postrm, old versions
+ # of this eclass (saved in the PDB) won't find packages' site-init files
+ # in the new location. So we copy them to an auxiliary file that is
+ # visible to old eclass versions.
+ for sf in "${sflist[@]}"; do
+ [ "${sf%/*}" = "${ROOT}${SITELISP}/site-gentoo.d" ] \
+ && cat "${sf}" >>"${ROOT}${SITELISP}"/00site-gentoo.el
+ done
}