1 |
The patch below will introduce two changes to function |
2 |
elisp-site-regen (which is called in postinst and postrm phases): |
3 |
|
4 |
1. Site-init files of Elisp packages will only be looked for in |
5 |
the site-gentoo.d subdirectory, but no longer in the main |
6 |
/usr/share/emacs/site-lisp dir. The elisp-site-file-install |
7 |
function installs them in the former location since 2007. |
8 |
|
9 |
I am not aware of any ebuild that would still install its site-init |
10 |
file in the top-level site-lisp dir (bypassing the proper eclass |
11 |
function). Also emacs-updater warns about this since a long time. |
12 |
However, if your ebuild does this, now is the time for changing it. |
13 |
|
14 |
2. Some additional error checks added. Since callers usually don't |
15 |
test for the function's return status, die on errors, instead of |
16 |
returning bad exit status. |
17 |
|
18 |
Please review. I intend to commit the changes in a few days from now. |
19 |
|
20 |
Ulrich |
21 |
|
22 |
--- a/eclass/elisp-common.eclass |
23 |
+++ b/eclass/elisp-common.eclass |
24 |
@@ -1,4 +1,4 @@ |
25 |
-# Copyright 1999-2013 Gentoo Foundation |
26 |
+# Copyright 1999-2014 Gentoo Foundation |
27 |
# Distributed under the terms of the GNU General Public License v2 |
28 |
# $Header: $ |
29 |
# |
30 |
@@ -349,39 +349,27 @@ elisp-site-file-install() { |
31 |
|
32 |
elisp-site-regen() { |
33 |
local sitelisp=${ROOT}${EPREFIX}${SITELISP} |
34 |
- local sf i null="" page=$'\f' |
35 |
+ local sf i ret=0 null="" page=$'\f' |
36 |
local -a sflist |
37 |
|
38 |
- if [[ ! -d ${sitelisp} ]]; then |
39 |
- eerror "elisp-site-regen: Directory ${sitelisp} does not exist" |
40 |
- return 1 |
41 |
- fi |
42 |
- |
43 |
- if [[ ! -d ${T} ]]; then |
44 |
- eerror "elisp-site-regen: Temporary directory ${T} does not exist" |
45 |
- return 1 |
46 |
- fi |
47 |
- |
48 |
if [[ ${EBUILD_PHASE} = *rm && ! -e ${sitelisp}/site-gentoo.el ]]; then |
49 |
ewarn "Refusing to create site-gentoo.el in ${EBUILD_PHASE} phase." |
50 |
return 0 |
51 |
fi |
52 |
|
53 |
+ [[ -d ${sitelisp} ]] \ |
54 |
+ || die "elisp-site-regen: Directory ${sitelisp} does not exist" |
55 |
+ |
56 |
+ [[ -d ${T} ]] \ |
57 |
+ || die "elisp-site-regen: Temporary directory ${T} does not exist" |
58 |
+ |
59 |
ebegin "Regenerating site-gentoo.el for GNU Emacs (${EBUILD_PHASE})" |
60 |
|
61 |
- for sf in "${sitelisp}"/[0-9][0-9]*-gentoo.el \ |
62 |
- "${sitelisp}"/site-gentoo.d/[0-9][0-9]*.el |
63 |
- do |
64 |
- [[ -r ${sf} ]] || continue |
65 |
- # sort files by their basename. straight insertion sort. |
66 |
- for ((i=${#sflist[@]}; i>0; i--)); do |
67 |
- [[ ${sf##*/} < ${sflist[i-1]##*/} ]] || break |
68 |
- sflist[i]=${sflist[i-1]} |
69 |
- done |
70 |
- sflist[i]=${sf} |
71 |
+ for sf in "${sitelisp}"/site-gentoo.d/[0-9][0-9]*.el; do |
72 |
+ [[ -r ${sf} ]] && sflist+=("${sf}") |
73 |
done |
74 |
|
75 |
- cat <<-EOF >"${T}"/site-gentoo.el |
76 |
+ cat <<-EOF >"${T}"/site-gentoo.el || ret=$? |
77 |
;;; site-gentoo.el --- site initialisation for Gentoo-installed packages |
78 |
|
79 |
;;; Commentary: |
80 |
@@ -391,8 +379,8 @@ elisp-site-regen() { |
81 |
;;; Code: |
82 |
EOF |
83 |
# Use sed instead of cat here, since files may miss a trailing newline. |
84 |
- sed '$q' "${sflist[@]}" </dev/null >>"${T}"/site-gentoo.el |
85 |
- cat <<-EOF >>"${T}"/site-gentoo.el |
86 |
+ sed '$q' "${sflist[@]}" </dev/null >>"${T}"/site-gentoo.el || ret=$? |
87 |
+ cat <<-EOF >>"${T}"/site-gentoo.el || ret=$? |
88 |
|
89 |
${page} |
90 |
(provide 'site-gentoo) |
91 |
@@ -405,7 +393,10 @@ elisp-site-regen() { |
92 |
;;; site-gentoo.el ends here |
93 |
EOF |
94 |
|
95 |
- if cmp -s "${sitelisp}"/site-gentoo.el "${T}"/site-gentoo.el; then |
96 |
+ if [[ ${ret} -ne 0 ]]; then |
97 |
+ eend ${ret} "elisp-site-regen: Writing site-gentoo.el failed." |
98 |
+ die |
99 |
+ elif cmp -s "${sitelisp}"/site-gentoo.el "${T}"/site-gentoo.el; then |
100 |
# This prevents outputting unnecessary text when there |
101 |
# was actually no change. |
102 |
# A case is a remerge where we have doubled output. |
103 |
@@ -414,7 +405,7 @@ elisp-site-regen() { |
104 |
einfo "... no changes." |
105 |
else |
106 |
mv "${T}"/site-gentoo.el "${sitelisp}"/site-gentoo.el |
107 |
- eend |
108 |
+ eend $? "elisp-site-regen: Replacing site-gentoo.el failed" || die |
109 |
case ${#sflist[@]} in |
110 |
0) [[ ${PN} = emacs-common-gentoo ]] \ |
111 |
|| ewarn "... Huh? No site initialisation files found." ;; |