Sync eclasses from Emacs overlay (revision 1012).
authorUlrich Müller <ulm@gentoo.org>
Fri, 7 Mar 2008 08:19:19 +0000 (08:19 +0000)
committerUlrich Müller <ulm@gentoo.org>
Fri, 7 Mar 2008 08:19:19 +0000 (08:19 +0000)
elisp-common.eclass:
Work around Paludis borkage, where variable T is empty in pkg_postrm.
Clean up temporary files.

eclass/elisp-common.eclass

index e9f4909a9077fe7657932a633a20f294c1fe17fe..11d09451771d5d1ec9c62ec779ff3c8a42469800 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/elisp-common.eclass,v 1.36 2008/02/22 09:30:40 ulm Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/elisp-common.eclass,v 1.37 2008/03/07 08:19:19 ulm Exp $
 #
 # Copyright 2002-2004 Matthew Kennedy <mkennedy@gentoo.org>
 # Copyright 2003      Jeremy Maitin-Shepard <jbms@attbi.com>
@@ -203,6 +203,7 @@ elisp-emacs-version() {
        # The following will work for at least versions 18--23.
        echo "(princ emacs-version)" >"${T}"/emacs-version.el
        ${EMACS} ${EMACSFLAGS} -l "${T}"/emacs-version.el
+       rm -f "${T}"/emacs-version.el
 }
 
 # @FUNCTION: elisp-make-autoload-file
@@ -262,16 +263,18 @@ elisp-install() {
 # Install Emacs site-init file in SITELISP directory.
 
 elisp-site-file-install() {
-       local sf="${1##*/}" my_pn="${2:-${PN}}"
+       local sf="${T}/${1##*/}" my_pn="${2:-${PN}}" ret
        ebegin "Installing site initialisation file for GNU Emacs"
-       cp "$1" "${T}/${sf}"
+       cp "$1" "${sf}"
        sed -i -e "s:@SITELISP@:${SITELISP}/${my_pn}:g" \
-               -e "s:@SITEETC@:${SITEETC}/${my_pn}:g" "${T}/${sf}"
+               -e "s:@SITEETC@:${SITEETC}/${my_pn}:g" "${sf}"
        ( # subshell to avoid pollution of calling environment
                insinto "${SITELISP}/site-gentoo.d"
-               doins "${T}/${sf}"
+               doins "${sf}"
        )
-       eend $? "doins failed"
+       ret=$?
+       rm -f "${sf}"
+       eend ${ret} "doins failed"
 }
 
 # @FUNCTION: elisp-site-regen
@@ -285,11 +288,12 @@ elisp-site-file-install() {
 elisp-site-regen() {
        local i sf line obsolete
        local -a sflist
+       local tmpdir=${T:-/tmp}
 
        if [ ! -e "${ROOT}${SITELISP}"/site-gentoo.el ] \
                && [ ! -e "${ROOT}${SITELISP}"/site-start.el ]; then
                einfo "Creating default ${SITELISP}/site-start.el ..."
-               cat <<-EOF >"${T}"/site-start.el
+               cat <<-EOF >"${tmpdir}"/site-start.el
                ;;; site-start.el
 
                ;;; Commentary:
@@ -330,7 +334,7 @@ elisp-site-regen() {
 
        eval "${old_shopts}"
 
-       cat <<-EOF >"${T}"/site-gentoo.el
+       cat <<-EOF >"${tmpdir}"/site-gentoo.el
        ;;; site-gentoo.el --- site initialisation for Gentoo-installed packages
 
        ;;; Commentary:
@@ -339,8 +343,8 @@ elisp-site-regen() {
 
        ;;; Code:
        EOF
-       cat "${sflist[@]}" </dev/null >>"${T}"/site-gentoo.el
-       cat <<-EOF >>"${T}"/site-gentoo.el
+       cat "${sflist[@]}" </dev/null >>"${tmpdir}"/site-gentoo.el
+       cat <<-EOF >>"${tmpdir}"/site-gentoo.el
 
        (provide 'site-gentoo)
 
@@ -350,16 +354,17 @@ elisp-site-regen() {
        ;;; site-gentoo.el ends here
        EOF
 
-       if cmp -s "${ROOT}${SITELISP}"/site-gentoo.el "${T}"/site-gentoo.el; then
+       if cmp -s "${ROOT}${SITELISP}"/site-gentoo.el "${tmpdir}"/site-gentoo.el
+       then
                # This prevents outputting unnecessary text when there
                # was actually no change.
                # A case is a remerge where we have doubled output.
                echo " no changes."
        else
-               mv "${T}"/site-gentoo.el "${ROOT}${SITELISP}"/site-gentoo.el
-               [ -f "${T}"/site-start.el ] \
+               mv "${tmpdir}"/site-gentoo.el "${ROOT}${SITELISP}"/site-gentoo.el
+               [ -f "${tmpdir}"/site-start.el ] \
                        && [ ! -e "${ROOT}${SITELISP}"/site-start.el ] \
-                       && mv "${T}"/site-start.el "${ROOT}${SITELISP}"/site-start.el
+                       && mv "${tmpdir}"/site-start.el "${ROOT}${SITELISP}"/site-start.el
                echo; einfo
                for sf in "${sflist[@]##*/}"; do
                        einfo "  Adding ${sf} ..."
@@ -404,4 +409,7 @@ EOF
                [ "${sf%/*}" = "${ROOT}${SITELISP}/site-gentoo.d" ] \
                        && cat "${sf}" >>"${ROOT}${SITELISP}"/00site-gentoo.el
        done
+
+       # cleanup
+       rm -f "${tmpdir}"/site-{gentoo,start}.el
 }