| 1 | # Copyright 1999-2007 Gentoo Foundation |
1 | # Copyright 1999-2012 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/xemacs-elisp-common.eclass,v 1.2 2007/09/25 18:27:12 graaff Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/xemacs-elisp-common.eclass,v 1.6 2012/05/19 16:26:10 ulm Exp $ |
| 4 | # |
4 | # |
| 5 | # Copyright 2007 Hans de Graaff <graaff@gentoo.org> |
5 | # Copyright 2007-2011 Hans de Graaff <graaff@gentoo.org> |
| 6 | # |
6 | # |
| 7 | # Based on elisp-common.eclass: |
7 | # Based on elisp-common.eclass: |
| 8 | # Copyright 2007 Christian Faulhammer <opfer@gentoo.org> |
8 | # Copyright 2007 Christian Faulhammer <opfer@gentoo.org> |
| 9 | # Copyright 2002-2004 Matthew Kennedy <mkennedy@gentoo.org> |
9 | # Copyright 2002-2004 Matthew Kennedy <mkennedy@gentoo.org> |
| 10 | # Copyright 2004-2005 Mamoru Komachi <usata@gentoo.org> |
10 | # Copyright 2004-2005 Mamoru Komachi <usata@gentoo.org> |
| 11 | # Copyright 2003 Jeremy Maitin-Shepard <jbms@attbi.com> |
11 | # Copyright 2003 Jeremy Maitin-Shepard <jbms@attbi.com> |
| 12 | # Copyright 2007 Ulrich Mueller <ulm@gentoo.org> |
12 | # Copyright 2007 Ulrich MΓΌller <ulm@gentoo.org> |
| 13 | # |
13 | # |
| 14 | # @ECLASS: xemacs-elisp-common.eclass |
14 | # @ECLASS: xemacs-elisp-common.eclass |
| 15 | # @MAINTAINER: |
15 | # @MAINTAINER: |
| 16 | # xemacs@gentoo.org |
16 | # xemacs@gentoo.org |
| 17 | # @BLURB: XEmacs-related installation utilities |
17 | # @BLURB: XEmacs-related installation utilities |
| … | |
… | |
| 24 | # package (especially compilation), so this is mainly for standalone elisp |
24 | # package (especially compilation), so this is mainly for standalone elisp |
| 25 | # files you gathered from somewhere else. |
25 | # files you gathered from somewhere else. |
| 26 | # |
26 | # |
| 27 | # When relying on the xemacs USE flag, you need to add |
27 | # When relying on the xemacs USE flag, you need to add |
| 28 | # |
28 | # |
| 29 | # xemacs? ( virtual/xemacs ) |
29 | # xemacs? ( app-editors/xemacs ) |
| 30 | # |
30 | # |
| 31 | # to your DEPEND/RDEPEND line and use the functions provided here to bring |
31 | # to your DEPEND/RDEPEND line and use the functions provided here to bring |
| 32 | # the files to the correct locations. |
32 | # the files to the correct locations. |
| 33 | # |
33 | # |
| 34 | # .SS |
34 | # .SS |
| … | |
… | |
| 61 | # the files to be put in that directory. Usually the subdirectory |
61 | # the files to be put in that directory. Usually the subdirectory |
| 62 | # should be ${PN}, but you can choose something else. |
62 | # should be ${PN}, but you can choose something else. |
| 63 | # |
63 | # |
| 64 | # xemacs-elisp-install ${PN} *.el *.elc |
64 | # xemacs-elisp-install ${PN} *.el *.elc |
| 65 | # |
65 | # |
|
|
66 | # To let the XEmacs support be activated by XEmacs on startup, you need |
|
|
67 | # to provide a site file (shipped in ${FILESDIR}) which contains the |
|
|
68 | # startup code (have a look in the documentation of your software). |
|
|
69 | # Normally this would look like this: |
|
|
70 | # |
|
|
71 | # (add-to-list 'load-path "@SITELISP@") |
|
|
72 | # (add-to-list 'auto-mode-alist '("\\.csv\\'" . csv-mode)) |
|
|
73 | # (autoload 'csv-mode "csv-mode" "Major mode for csv files." t) |
|
|
74 | # |
|
|
75 | # If your XEmacs support files are installed in a subdirectory of |
|
|
76 | # /usr/share/xemacs/site-packages/ (which is strongly recommended), you need |
|
|
77 | # to extend XEmacs' load-path as shown in the first non-comment line. |
|
|
78 | # The xemacs-elisp-site-file-install() function of this eclass will replace |
|
|
79 | # "@SITELISP@" by the actual path. |
|
|
80 | # |
|
|
81 | # The next line tells XEmacs to load the mode opening a file ending |
|
|
82 | # with ".csv" and load functions depending on the context and needed |
|
|
83 | # features. Be careful though. Commands as "load-library" or "require" |
|
|
84 | # bloat the editor as they are loaded on every startup. When having |
|
|
85 | # many XEmacs support files, users may be annoyed by the start-up time. |
|
|
86 | # Also avoid keybindings as they might interfere with the user's |
|
|
87 | # settings. Give a hint in pkg_postinst(), which should be enough. |
|
|
88 | # |
|
|
89 | # The naming scheme for this site-init file matches the shell pattern |
|
|
90 | # "[1-8][0-9]*-gentoo*.el", where the two digits at the beginning define |
|
|
91 | # the loading order (numbers below 10 or above 89 are reserved for |
|
|
92 | # internal use). So if your initialisation depends on another XEmacs |
|
|
93 | # package, your site file's number must be higher! If there are no such |
|
|
94 | # interdependencies then the number should be 50. Otherwise, numbers |
|
|
95 | # divisible by 10 are preferred. |
|
|
96 | # |
|
|
97 | # Best practice is to define a SITEFILE variable in the global scope of |
|
|
98 | # your ebuild (e.g., right after S or RDEPEND): |
|
|
99 | # |
|
|
100 | # SITEFILE="50${PN}-gentoo.el" |
|
|
101 | # |
|
|
102 | # Which is then installed by |
|
|
103 | # |
|
|
104 | # xemacs-elisp-site-file-install "${FILESDIR}/${SITEFILE}" || die |
|
|
105 | # |
|
|
106 | # in src_install(). Any characters after the "-gentoo" part and before |
|
|
107 | # the extension will be stripped from the destination file's name. |
|
|
108 | # For example, a file "50${PN}-gentoo-${PV}.el" will be installed as |
|
|
109 | # "50${PN}-gentoo.el". If your subdirectory is not named ${PN}, give |
|
|
110 | # the differing name as second argument. |
| 66 | |
111 | |
|
|
112 | # @ECLASS-VARIABLE: XEMACS_SITELISP |
|
|
113 | # @DESCRIPTION: |
|
|
114 | # Directory where packages install indivivual XEmacs Lisp files. |
|
|
115 | XEMACS_SITELISP=/usr/share/xemacs/site-lisp |
| 67 | |
116 | |
|
|
117 | # @ECLASS-VARIABLE: XEMACS_SITEPACKAGE |
|
|
118 | # @DESCRIPTION: |
|
|
119 | # Directory where packages install XEmacs Lisp packages. |
| 68 | SITEPACKAGE=/usr/lib/xemacs/site-packages |
120 | XEMACS_SITEPACKAGE=/usr/share/xemacs/site-packages |
|
|
121 | |
|
|
122 | # @ECLASS-VARIABLE: XEMACS |
|
|
123 | # @DESCRIPTION: |
|
|
124 | # Path of XEmacs executable. |
| 69 | XEMACS=/usr/bin/xemacs |
125 | XEMACS=/usr/bin/xemacs |
|
|
126 | |
|
|
127 | # @ECLASS-VARIABLE: XEMACS_BATCH_CLEAN |
|
|
128 | # @DESCRIPTION: |
|
|
129 | # Invocation of XEMACS in batch mode. |
| 70 | XEMACS_BATCH_CLEAN="${XEMACS} --batch --no-site-file --no-init-file" |
130 | XEMACS_BATCH_CLEAN="${XEMACS} --batch --no-site-file --no-init-file" |
| 71 | |
131 | |
| 72 | # @FUNCTION: xemacs-elisp-compile |
132 | # @FUNCTION: xemacs-elisp-compile |
| 73 | # @USAGE: <list of elisp files> |
133 | # @USAGE: <list of elisp files> |
| 74 | # @DESCRIPTION: |
134 | # @DESCRIPTION: |
| … | |
… | |
| 98 | |
158 | |
| 99 | xemacs-elisp-install () { |
159 | xemacs-elisp-install () { |
| 100 | local subdir="$1" |
160 | local subdir="$1" |
| 101 | shift |
161 | shift |
| 102 | ( # use sub-shell to avoid possible environment polution |
162 | ( # use sub-shell to avoid possible environment polution |
| 103 | dodir "${SITEPACKAGE}"/lisp/"${subdir}" |
163 | dodir "${XEMACS_SITEPACKAGE}"/lisp/"${subdir}" |
| 104 | insinto "${SITEPACKAGE}"/lisp/"${subdir}" |
164 | insinto "${XEMACS_SITEPACKAGE}"/lisp/"${subdir}" |
| 105 | doins "$@" |
165 | doins "$@" |
| 106 | ) || die "Installing lisp files failed" |
166 | ) || die "Installing lisp files failed" |
| 107 | } |
167 | } |
| 108 | |
168 | |
| 109 | # @FUNCTION: xemacs-elisp-comp |
169 | # @FUNCTION: xemacs-elisp-comp |
| … | |
… | |
| 142 | |
202 | |
| 143 | popd |
203 | popd |
| 144 | rm -fr ${tempdir} |
204 | rm -fr ${tempdir} |
| 145 | return ${ret} |
205 | return ${ret} |
| 146 | } |
206 | } |
|
|
207 | |
|
|
208 | # @FUNCTION: xemacs-elisp-site-file-install |
|
|
209 | # @USAGE: <site-init file> [subdirectory] |
|
|
210 | # @DESCRIPTION: |
|
|
211 | # Install XEmacs site-init file in XEMACS_SITELISP directory. |
|
|
212 | # Automatically inserts a standard comment header with the name of the |
|
|
213 | # package (unless it is already present). Token @SITELISP@ is replaced |
|
|
214 | # by the path to the package's subdirectory in XEMACS_SITELISP. |
|
|
215 | |
|
|
216 | xemacs-elisp-site-file-install() { |
|
|
217 | local sf="${1##*/}" my_pn="${2:-${PN}}" ret |
|
|
218 | local header=";;; ${PN} site-lisp configuration" |
|
|
219 | |
|
|
220 | [[ ${sf} == [0-9][0-9]*-gentoo*.el ]] \ |
|
|
221 | || ewarn "xemacs-elisp-site-file-install: bad name of site-init file" |
|
|
222 | sf="${T}/${sf/%-gentoo*.el/-gentoo.el}" |
|
|
223 | ebegin "Installing site initialisation file for XEmacs" |
|
|
224 | [[ $1 = "${sf}" ]] || cp "$1" "${sf}" |
|
|
225 | sed -i -e "1{:x;/^\$/{n;bx;};/^;.*${PN}/I!s:^:${header}\n\n:;1s:^:\n:;}" \ |
|
|
226 | -e "s:@SITELISP@:${EPREFIX}${XEMACS_SITELISP}/${my_pn}:g" "${sf}" |
|
|
227 | ( # subshell to avoid pollution of calling environment |
|
|
228 | insinto "${XEMACS_SITELISP}/site-gentoo.d" |
|
|
229 | doins "${sf}" |
|
|
230 | ) |
|
|
231 | ret=$? |
|
|
232 | rm -f "${sf}" |
|
|
233 | eend ${ret} "xemacs-elisp-site-file-install: doins failed" |
|
|
234 | } |
|
|
235 | |
|
|
236 | # @FUNCTION: xemacs-elisp-site-regen |
|
|
237 | # @DESCRIPTION: |
|
|
238 | # Regenerate the site-gentoo.el file, based on packages' site |
|
|
239 | # initialisation files in the /usr/share/xemacs/site-lisp/site-gentoo.d/ |
|
|
240 | # directory. |
|
|
241 | |
|
|
242 | xemacs-elisp-site-regen() { |
|
|
243 | local sitelisp=${ROOT}${EPREFIX}${XEMACS_SITELISP} |
|
|
244 | local sf i line null="" page=$'\f' |
|
|
245 | local -a sflist |
|
|
246 | |
|
|
247 | if [ ! -d "${sitelisp}" ]; then |
|
|
248 | eerror "xemacs-elisp-site-regen: Directory ${sitelisp} does not exist" |
|
|
249 | return 1 |
|
|
250 | fi |
|
|
251 | |
|
|
252 | if [ ! -d "${T}" ]; then |
|
|
253 | eerror "xemacs-elisp-site-regen: Temporary directory ${T} does not exist" |
|
|
254 | return 1 |
|
|
255 | fi |
|
|
256 | |
|
|
257 | einfon "Regenerating site-gentoo.el for XEmacs (${EBUILD_PHASE}) ..." |
|
|
258 | |
|
|
259 | for sf in "${sitelisp}"/site-gentoo.d/[0-9][0-9]*.el |
|
|
260 | do |
|
|
261 | [ -r "${sf}" ] || continue |
|
|
262 | # sort files by their basename. straight insertion sort. |
|
|
263 | for ((i=${#sflist[@]}; i>0; i--)); do |
|
|
264 | [[ ${sf##*/} < ${sflist[i-1]##*/} ]] || break |
|
|
265 | sflist[i]=${sflist[i-1]} |
|
|
266 | done |
|
|
267 | sflist[i]=${sf} |
|
|
268 | done |
|
|
269 | |
|
|
270 | cat <<-EOF >"${T}"/site-gentoo.el |
|
|
271 | ;;; site-gentoo.el --- site initialisation for Gentoo-installed packages |
|
|
272 | |
|
|
273 | ;;; Commentary: |
|
|
274 | ;; Automatically generated by xemacs-elisp-common.eclass |
|
|
275 | ;; DO NOT EDIT THIS FILE |
|
|
276 | |
|
|
277 | ;;; Code: |
|
|
278 | EOF |
|
|
279 | # Use sed instead of cat here, since files may miss a trailing newline. |
|
|
280 | sed '$q' "${sflist[@]}" </dev/null >>"${T}"/site-gentoo.el |
|
|
281 | cat <<-EOF >>"${T}"/site-gentoo.el |
|
|
282 | |
|
|
283 | ${page} |
|
|
284 | (provide 'site-gentoo) |
|
|
285 | |
|
|
286 | ;; Local ${null}Variables: |
|
|
287 | ;; no-byte-compile: t |
|
|
288 | ;; buffer-read-only: t |
|
|
289 | ;; End: |
|
|
290 | |
|
|
291 | ;;; site-gentoo.el ends here |
|
|
292 | EOF |
|
|
293 | |
|
|
294 | if cmp -s "${sitelisp}"/site-gentoo.el "${T}"/site-gentoo.el; then |
|
|
295 | # This prevents outputting unnecessary text when there |
|
|
296 | # was actually no change. |
|
|
297 | # A case is a remerge where we have doubled output. |
|
|
298 | rm -f "${T}"/site-gentoo.el |
|
|
299 | echo " no changes." |
|
|
300 | else |
|
|
301 | mv "${T}"/site-gentoo.el "${sitelisp}"/site-gentoo.el |
|
|
302 | echo |
|
|
303 | case ${#sflist[@]} in |
|
|
304 | 0) ewarn "... Huh? No site initialisation files found." ;; |
|
|
305 | 1) einfo "... ${#sflist[@]} site initialisation file included." ;; |
|
|
306 | *) einfo "... ${#sflist[@]} site initialisation files included." ;; |
|
|
307 | esac |
|
|
308 | fi |
|
|
309 | |
|
|
310 | return 0 |
|
|
311 | } |