1 |
commit: ce73c25b148e24f7fe94ca6c888820d35c5b0de1 |
2 |
Author: Felix Janda <felix.janda <AT> posteo <DOT> de> |
3 |
AuthorDate: Thu Feb 5 17:45:54 2015 +0000 |
4 |
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Feb 7 18:58:50 2015 +0000 |
6 |
URL: http://sources.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=commit;h=ce73c25b |
7 |
|
8 |
app-editors/emacs: LD_PRELOAD hack from Rich Felker |
9 |
|
10 |
--- |
11 |
app-editors/emacs/emacs-24.4-r99.ebuild | 348 +++++++++++++++++++++ |
12 |
.../files/emacs-24.3-alloc-invalid-frees.patch | 58 ++++ |
13 |
app-editors/emacs/files/emacs-24.3-stderr.patch | 11 + |
14 |
app-editors/emacs/files/emacs-24.4-configure.patch | 10 + |
15 |
app-editors/emacs/files/emacs-24.4-lisp.patch | 10 + |
16 |
.../emacs/files/emacs-24.4-preload-hack.patch | 11 + |
17 |
app-editors/emacs/files/preload.c | 88 ++++++ |
18 |
app-editors/emacs/metadata.xml | 46 +++ |
19 |
8 files changed, 582 insertions(+) |
20 |
|
21 |
diff --git a/app-editors/emacs/emacs-24.4-r99.ebuild b/app-editors/emacs/emacs-24.4-r99.ebuild |
22 |
new file mode 100644 |
23 |
index 0000000..385d930 |
24 |
--- /dev/null |
25 |
+++ b/app-editors/emacs/emacs-24.4-r99.ebuild |
26 |
@@ -0,0 +1,348 @@ |
27 |
+# Copyright 1999-2015 Gentoo Foundation |
28 |
+# Distributed under the terms of the GNU General Public License v2 |
29 |
+# $Header: /var/cvsroot/gentoo-x86/app-editors/emacs/emacs-24.4-r2.ebuild,v 1.1 2015/01/23 20:38:44 ulm Exp $ |
30 |
+ |
31 |
+EAPI=5 |
32 |
+ |
33 |
+inherit elisp-common eutils flag-o-matic multilib readme.gentoo |
34 |
+ |
35 |
+DESCRIPTION="The extensible, customizable, self-documenting real-time display editor" |
36 |
+HOMEPAGE="http://www.gnu.org/software/emacs/" |
37 |
+SRC_URI="mirror://gnu/emacs/${P}.tar.xz |
38 |
+ http://dev.gentoo.org/~ulm/emacs/${P}-patches-3.tar.xz" |
39 |
+ |
40 |
+LICENSE="GPL-3+ FDL-1.3+ BSD HPND MIT W3C unicode PSF-2" |
41 |
+SLOT="24" |
42 |
+KEYWORDS="amd64 ~arm ~mips ~ppc ~x86" |
43 |
+IUSE="acl alsa aqua athena dbus games gconf gfile gif gnutls gpm gsettings gtk +gtk3 gzip-el hesiod imagemagick +inotify jpeg kerberos libxml2 livecd m17n-lib motif pax_kernel png selinux sound source svg tiff toolkit-scroll-bars wide-int X Xaw3d xft +xpm zlib" |
44 |
+REQUIRED_USE="?? ( aqua X )" |
45 |
+ |
46 |
+RDEPEND="sys-libs/ncurses |
47 |
+ >=app-admin/eselect-emacs-1.16 |
48 |
+ >=app-emacs/emacs-common-gentoo-1.4-r1[games?,X?] |
49 |
+ net-libs/liblockfile |
50 |
+ acl? ( virtual/acl ) |
51 |
+ alsa? ( media-libs/alsa-lib ) |
52 |
+ dbus? ( sys-apps/dbus ) |
53 |
+ gfile? ( >=dev-libs/glib-2.28.6 ) |
54 |
+ gnutls? ( net-libs/gnutls ) |
55 |
+ gpm? ( sys-libs/gpm ) |
56 |
+ hesiod? ( net-dns/hesiod ) |
57 |
+ kerberos? ( virtual/krb5 ) |
58 |
+ libxml2? ( >=dev-libs/libxml2-2.2.0 ) |
59 |
+ selinux? ( sys-libs/libselinux ) |
60 |
+ zlib? ( sys-libs/zlib ) |
61 |
+ X? ( |
62 |
+ x11-libs/libXmu |
63 |
+ x11-libs/libXt |
64 |
+ x11-misc/xbitmaps |
65 |
+ gconf? ( >=gnome-base/gconf-2.26.2 ) |
66 |
+ gsettings? ( >=dev-libs/glib-2.28.6 ) |
67 |
+ gif? ( media-libs/giflib ) |
68 |
+ jpeg? ( virtual/jpeg:0= ) |
69 |
+ png? ( >=media-libs/libpng-1.4:0= ) |
70 |
+ svg? ( >=gnome-base/librsvg-2.0 ) |
71 |
+ tiff? ( media-libs/tiff ) |
72 |
+ xpm? ( x11-libs/libXpm ) |
73 |
+ imagemagick? ( >=media-gfx/imagemagick-6.6.2 ) |
74 |
+ xft? ( |
75 |
+ media-libs/fontconfig |
76 |
+ media-libs/freetype |
77 |
+ x11-libs/libXft |
78 |
+ m17n-lib? ( |
79 |
+ >=dev-libs/libotf-0.9.4 |
80 |
+ >=dev-libs/m17n-lib-1.5.1 |
81 |
+ ) |
82 |
+ ) |
83 |
+ gtk? ( |
84 |
+ gtk3? ( x11-libs/gtk+:3 ) |
85 |
+ !gtk3? ( x11-libs/gtk+:2 ) |
86 |
+ ) |
87 |
+ !gtk? ( |
88 |
+ motif? ( >=x11-libs/motif-2.3:0 ) |
89 |
+ !motif? ( |
90 |
+ Xaw3d? ( x11-libs/libXaw3d ) |
91 |
+ !Xaw3d? ( athena? ( x11-libs/libXaw ) ) |
92 |
+ ) |
93 |
+ ) |
94 |
+ )" |
95 |
+ |
96 |
+DEPEND="${RDEPEND} |
97 |
+ virtual/pkgconfig |
98 |
+ gzip-el? ( app-arch/gzip ) |
99 |
+ pax_kernel? ( |
100 |
+ sys-apps/attr |
101 |
+ sys-apps/paxctl |
102 |
+ )" |
103 |
+ |
104 |
+RDEPEND="${RDEPEND} |
105 |
+ !<app-editors/emacs-vcs-${PV}" |
106 |
+ |
107 |
+EMACS_SUFFIX="${PN/emacs/emacs-${SLOT}}" |
108 |
+SITEFILE="20${PN}-${SLOT}-gentoo.el" |
109 |
+# FULL_VERSION keeps the full version number, which is needed in |
110 |
+# order to determine some path information correctly for copy/move |
111 |
+# operations later on |
112 |
+FULL_VERSION="${PV%%_*}" |
113 |
+S="${WORKDIR}/emacs-${FULL_VERSION}" |
114 |
+ |
115 |
+src_prepare() { |
116 |
+ EPATCH_SUFFIX=patch epatch |
117 |
+ |
118 |
+ epatch "${FILESDIR}/${PN}-24.3-stderr.patch" |
119 |
+ epatch "${FILESDIR}/${PN}-24.3-alloc-invalid-frees.patch" |
120 |
+ epatch "${FILESDIR}/${PN}-24.4-configure.patch" |
121 |
+ epatch "${FILESDIR}/${PN}-24.4-preload-hack.patch" |
122 |
+ epatch "${FILESDIR}/${PN}-24.4-lisp.patch" |
123 |
+ |
124 |
+ epatch_user |
125 |
+ |
126 |
+ # Fix filename reference in redirected man page |
127 |
+ sed -i -e "/^\\.so/s/etags/&-${EMACS_SUFFIX}/" doc/man/ctags.1 \ |
128 |
+ || die "unable to sed ctags.1" |
129 |
+ |
130 |
+ #AT_M4DIR=m4 eautoreconf |
131 |
+} |
132 |
+ |
133 |
+src_configure() { |
134 |
+ strip-flags |
135 |
+ filter-flags -pie #526948 |
136 |
+ |
137 |
+ if use sh; then |
138 |
+ replace-flags "-O[1-9]" -O0 #262359 |
139 |
+ elif use ia64; then |
140 |
+ replace-flags "-O[2-9]" -O1 #325373 |
141 |
+ else |
142 |
+ replace-flags "-O[3-9]" -O2 |
143 |
+ fi |
144 |
+ |
145 |
+ local myconf |
146 |
+ |
147 |
+ if use alsa; then |
148 |
+ use sound || ewarn \ |
149 |
+ "USE flag \"alsa\" overrides \"-sound\"; enabling sound support." |
150 |
+ myconf+=" --with-sound=alsa" |
151 |
+ else |
152 |
+ myconf+=" --with-sound=$(usex sound oss)" |
153 |
+ fi |
154 |
+ |
155 |
+ if use X; then |
156 |
+ myconf+=" --with-x --without-ns" |
157 |
+ myconf+=" $(use_with gconf)" |
158 |
+ myconf+=" $(use_with gsettings)" |
159 |
+ myconf+=" $(use_with toolkit-scroll-bars)" |
160 |
+ myconf+=" $(use_with gif)" |
161 |
+ myconf+=" $(use_with jpeg)" |
162 |
+ myconf+=" $(use_with png)" |
163 |
+ myconf+=" $(use_with svg rsvg)" |
164 |
+ myconf+=" $(use_with tiff)" |
165 |
+ myconf+=" $(use_with xpm)" |
166 |
+ myconf+=" $(use_with imagemagick)" |
167 |
+ |
168 |
+ if use xft; then |
169 |
+ myconf+=" --with-xft" |
170 |
+ myconf+=" $(use_with m17n-lib libotf)" |
171 |
+ myconf+=" $(use_with m17n-lib m17n-flt)" |
172 |
+ else |
173 |
+ myconf+=" --without-xft" |
174 |
+ myconf+=" --without-libotf --without-m17n-flt" |
175 |
+ use m17n-lib && ewarn \ |
176 |
+ "USE flag \"m17n-lib\" has no effect if \"xft\" is not set." |
177 |
+ fi |
178 |
+ |
179 |
+ local f |
180 |
+ if use gtk; then |
181 |
+ einfo "Configuring to build with GIMP Toolkit (GTK+)" |
182 |
+ myconf+=" --with-x-toolkit=$(usex gtk3 gtk3 gtk2)" |
183 |
+ for f in motif Xaw3d athena; do |
184 |
+ use ${f} && ewarn \ |
185 |
+ "USE flag \"${f}\" has no effect if \"gtk\" is set." |
186 |
+ done |
187 |
+ elif use motif; then |
188 |
+ einfo "Configuring to build with Motif toolkit" |
189 |
+ myconf+=" --with-x-toolkit=motif" |
190 |
+ for f in Xaw3d athena; do |
191 |
+ use ${f} && ewarn \ |
192 |
+ "USE flag \"${f}\" has no effect if \"motif\" is set." |
193 |
+ done |
194 |
+ elif use athena || use Xaw3d; then |
195 |
+ einfo "Configuring to build with Athena/Lucid toolkit" |
196 |
+ myconf+=" --with-x-toolkit=lucid $(use_with Xaw3d xaw3d)" |
197 |
+ else |
198 |
+ einfo "Configuring to build with no toolkit" |
199 |
+ myconf+=" --with-x-toolkit=no" |
200 |
+ fi |
201 |
+ elif use aqua; then |
202 |
+ einfo "Configuring to build with Nextstep (Cocoa) support" |
203 |
+ myconf+=" --with-ns --disable-ns-self-contained" |
204 |
+ myconf+=" --without-x" |
205 |
+ else |
206 |
+ myconf+=" --without-x --without-ns" |
207 |
+ fi |
208 |
+ |
209 |
+ # Save version information in the Emacs binary. It will be available |
210 |
+ # in variable "system-configuration-options". |
211 |
+ myconf+=" GENTOO_PACKAGE=${CATEGORY}/${PF}" |
212 |
+ |
213 |
+ econf \ |
214 |
+ --program-suffix="-${EMACS_SUFFIX}" \ |
215 |
+ --infodir="${EPREFIX}"/usr/share/info/${EMACS_SUFFIX} \ |
216 |
+ --localstatedir="${EPREFIX}"/var \ |
217 |
+ --enable-locallisppath="${EPREFIX}/etc/emacs:${EPREFIX}${SITELISP}" \ |
218 |
+ --with-gameuser="${GAMES_USER_DED:-games}" \ |
219 |
+ --without-compress-install \ |
220 |
+ --with-file-notification=$(usev gfile || usev inotify || echo no) \ |
221 |
+ $(use_enable acl) \ |
222 |
+ $(use_with dbus) \ |
223 |
+ $(use_with gnutls) \ |
224 |
+ $(use_with gpm) \ |
225 |
+ $(use_with hesiod) \ |
226 |
+ $(use_with kerberos) $(use_with kerberos kerberos5) \ |
227 |
+ $(use_with libxml2 xml2) \ |
228 |
+ $(use_with selinux) \ |
229 |
+ $(use_with wide-int) \ |
230 |
+ $(use_with zlib) \ |
231 |
+ ${myconf} |
232 |
+} |
233 |
+ |
234 |
+src_compile() { |
235 |
+ echo $S |
236 |
+ $(tc-getCC) -shared -fPIC -o preload.so "${FILESDIR}/preload.c" || die |
237 |
+ |
238 |
+ export SANDBOX_ON=0 # for the unbelievers, see Bug #131505 |
239 |
+ emake |
240 |
+} |
241 |
+ |
242 |
+src_install () { |
243 |
+ emake DESTDIR="${D}" NO_BIN_LINK=t install |
244 |
+ |
245 |
+ mv "${ED}"/usr/bin/{emacs-${FULL_VERSION}-,}${EMACS_SUFFIX} \ |
246 |
+ || die "moving emacs executable failed" |
247 |
+ mv "${ED}"/usr/share/man/man1/{emacs-,}${EMACS_SUFFIX}.1 \ |
248 |
+ || die "moving emacs man page failed" |
249 |
+ |
250 |
+ # move info dir to avoid collisions with the dir file generated by portage |
251 |
+ mv "${ED}"/usr/share/info/${EMACS_SUFFIX}/dir{,.orig} \ |
252 |
+ || die "moving info dir failed" |
253 |
+ touch "${ED}"/usr/share/info/${EMACS_SUFFIX}/.keepinfodir |
254 |
+ docompress -x /usr/share/info/${EMACS_SUFFIX}/dir.orig |
255 |
+ |
256 |
+ # avoid collision between slots, see bug #169033 e.g. |
257 |
+ rm "${ED}"/usr/share/emacs/site-lisp/subdirs.el |
258 |
+ rm -rf "${ED}"/usr/share/{applications,icons} |
259 |
+ rm -rf "${ED}"/var |
260 |
+ |
261 |
+ # remove unused <version>/site-lisp dir |
262 |
+ rm -rf "${ED}"/usr/share/emacs/${FULL_VERSION}/site-lisp |
263 |
+ |
264 |
+ # remove COPYING file (except for etc/COPYING used by describe-copying) |
265 |
+ rm "${ED}"/usr/share/emacs/${FULL_VERSION}/lisp/COPYING |
266 |
+ |
267 |
+ if use gzip-el; then |
268 |
+ # compress .el files when a corresponding .elc exists |
269 |
+ find "${ED}"/usr/share/emacs/${FULL_VERSION}/lisp -type f \ |
270 |
+ -name "*.elc" -print | sed 's/\.elc$/.el/' | xargs gzip -9n |
271 |
+ assert "gzip .el failed" |
272 |
+ fi |
273 |
+ |
274 |
+ local cdir |
275 |
+ if use source; then |
276 |
+ cdir="/usr/share/emacs/${FULL_VERSION}/src" |
277 |
+ insinto "${cdir}" |
278 |
+ # This is not meant to install all the source -- just the |
279 |
+ # C source you might find via find-function |
280 |
+ doins src/*.{c,h,m} |
281 |
+ elif has installsources ${FEATURES}; then |
282 |
+ cdir="/usr/src/debug/${CATEGORY}/${PF}/${S#"${WORKDIR}/"}/src" |
283 |
+ fi |
284 |
+ |
285 |
+ sed -e "${cdir:+#}/^Y/d" -e "s/^[XY]//" >"${T}/${SITEFILE}" <<-EOF |
286 |
+ X |
287 |
+ ;;; ${PN}-${SLOT} site-lisp configuration |
288 |
+ X |
289 |
+ (when (string-match "\\\\\`${FULL_VERSION//./\\\\.}\\\\>" emacs-version) |
290 |
+ Y (setq find-function-C-source-directory |
291 |
+ Y "${EPREFIX}${cdir}") |
292 |
+ X (let ((path (getenv "INFOPATH")) |
293 |
+ X (dir "${EPREFIX}/usr/share/info/${EMACS_SUFFIX}") |
294 |
+ X (re "\\\\\`${EPREFIX}/usr/share/info\\\\>")) |
295 |
+ X (and path |
296 |
+ X ;; move Emacs Info dir before anything else in /usr/share/info |
297 |
+ X (let* ((p (cons nil (split-string path ":" t))) (q p)) |
298 |
+ X (while (and (cdr q) (not (string-match re (cadr q)))) |
299 |
+ X (setq q (cdr q))) |
300 |
+ X (setcdr q (cons dir (delete dir (cdr q)))) |
301 |
+ X (setq Info-directory-list (prune-directory-list (cdr p))))))) |
302 |
+ EOF |
303 |
+ elisp-site-file-install "${T}/${SITEFILE}" || die |
304 |
+ |
305 |
+ dodoc README BUGS |
306 |
+ |
307 |
+ if use aqua; then |
308 |
+ dodir /Applications/Gentoo |
309 |
+ rm -rf "${ED}"/Applications/Gentoo/Emacs${EMACS_SUFFIX#emacs}.app |
310 |
+ mv nextstep/Emacs.app \ |
311 |
+ "${ED}"/Applications/Gentoo/Emacs${EMACS_SUFFIX#emacs}.app || die |
312 |
+ fi |
313 |
+ |
314 |
+ DOC_CONTENTS="You can set the version to be started by /usr/bin/emacs |
315 |
+ through the Emacs eselect module, which also redirects man and info |
316 |
+ pages. Therefore, several Emacs versions can be installed at the |
317 |
+ same time. \"man emacs.eselect\" for details. |
318 |
+ \\n\\nIf you upgrade from Emacs version 24.2 or earlier, then it is |
319 |
+ strongly recommended that you use app-admin/emacs-updater to rebuild |
320 |
+ all byte-compiled elisp files of the installed Emacs packages." |
321 |
+ use X && DOC_CONTENTS+="\\n\\nYou need to install some fonts for Emacs. |
322 |
+ Installing media-fonts/font-adobe-{75,100}dpi on the X server's |
323 |
+ machine would satisfy basic Emacs requirements under X11. |
324 |
+ See also https://wiki.gentoo.org/wiki/Xft_support_for_GNU_Emacs |
325 |
+ for how to enable anti-aliased fonts." |
326 |
+ use aqua && DOC_CONTENTS+="\\n\\nEmacs${EMACS_SUFFIX#emacs}.app is in |
327 |
+ \"${EPREFIX}/Applications/Gentoo\". You may want to copy or symlink |
328 |
+ it into /Applications by yourself." |
329 |
+ readme.gentoo_create_doc |
330 |
+} |
331 |
+ |
332 |
+pkg_preinst() { |
333 |
+ # move Info dir file to correct name |
334 |
+ local infodir=/usr/share/info/${EMACS_SUFFIX} f |
335 |
+ if [[ -f ${ED}${infodir}/dir.orig ]]; then |
336 |
+ mv "${ED}"${infodir}/dir{.orig,} || die "moving info dir failed" |
337 |
+ elif [[ -d "${ED}"${infodir} ]]; then |
338 |
+ # this should not happen in EAPI 4 |
339 |
+ ewarn "Regenerating Info directory index in ${infodir} ..." |
340 |
+ rm -f "${ED}"${infodir}/dir{,.*} |
341 |
+ for f in "${ED}"${infodir}/*; do |
342 |
+ if [[ ${f##*/} != *-[0-9]* && -e ${f} ]]; then |
343 |
+ install-info --info-dir="${ED}"${infodir} "${f}" \ |
344 |
+ || die "install-info failed" |
345 |
+ fi |
346 |
+ done |
347 |
+ fi |
348 |
+} |
349 |
+ |
350 |
+pkg_postinst() { |
351 |
+ elisp-site-regen |
352 |
+ |
353 |
+ local pvr |
354 |
+ for pvr in ${REPLACING_VERSIONS}; do |
355 |
+ [[ ${pvr%%[-_]*} = 24.[12] ]] && FORCE_PRINT_ELOG=1 |
356 |
+ done |
357 |
+ readme.gentoo_print_elog |
358 |
+ |
359 |
+ if use livecd; then |
360 |
+ # force an update of the emacs symlink for the livecd/dvd, |
361 |
+ # because some microemacs packages set it with USE=livecd |
362 |
+ eselect emacs update |
363 |
+ elif [[ $(readlink "${EROOT}"/usr/bin/emacs) = ${EMACS_SUFFIX} ]]; then |
364 |
+ # refresh symlinks in case any installed files have changed |
365 |
+ eselect emacs set ${EMACS_SUFFIX} |
366 |
+ else |
367 |
+ eselect emacs update ifunset |
368 |
+ fi |
369 |
+} |
370 |
+ |
371 |
+pkg_postrm() { |
372 |
+ elisp-site-regen |
373 |
+ eselect emacs update ifunset |
374 |
+} |
375 |
|
376 |
diff --git a/app-editors/emacs/files/emacs-24.3-alloc-invalid-frees.patch b/app-editors/emacs/files/emacs-24.3-alloc-invalid-frees.patch |
377 |
new file mode 100644 |
378 |
index 0000000..1638e5f |
379 |
--- /dev/null |
380 |
+++ b/app-editors/emacs/files/emacs-24.3-alloc-invalid-frees.patch |
381 |
@@ -0,0 +1,58 @@ |
382 |
+From http://www.openwall.com/lists/musl/2015/02/03/1 |
383 |
+ |
384 |
+--- emacs-24.3.orig/src/alloc.c |
385 |
++++ emacs-24.3/src/alloc.c |
386 |
+@@ -47,6 +47,13 @@ |
387 |
+ |
388 |
+ #include <verify.h> |
389 |
+ |
390 |
++static void *initial_brk; |
391 |
++__attribute__((__constructor__)) |
392 |
++static void init() |
393 |
++{ |
394 |
++ initial_brk = sbrk(0); |
395 |
++} |
396 |
++ |
397 |
+ /* GC_CHECK_MARKED_OBJECTS means do sanity checks on allocated objects. |
398 |
+ Doable only if GC_MARK_STACK. */ |
399 |
+ #if ! GC_MARK_STACK |
400 |
+@@ -699,6 +706,14 @@ |
401 |
+ { |
402 |
+ void *val; |
403 |
+ |
404 |
++ if (block && block < initial_brk) { |
405 |
++ size_t len = (char *)initial_brk - (char *)block; |
406 |
++ if (len > size) len = size; |
407 |
++ void *p = xmalloc(size); |
408 |
++ memcpy(p, block, len); |
409 |
++ return p; |
410 |
++ } |
411 |
++ |
412 |
+ MALLOC_BLOCK_INPUT; |
413 |
+ /* We must call malloc explicitly when BLOCK is 0, since some |
414 |
+ reallocs don't do this. */ |
415 |
+@@ -720,6 +735,7 @@ |
416 |
+ void |
417 |
+ xfree (void *block) |
418 |
+ { |
419 |
++ if (block < initial_brk) return; |
420 |
+ if (!block) |
421 |
+ return; |
422 |
+ MALLOC_BLOCK_INPUT; |
423 |
+@@ -910,6 +926,7 @@ |
424 |
+ static void |
425 |
+ lisp_free (void *block) |
426 |
+ { |
427 |
++ if (block < initial_brk) return; |
428 |
+ MALLOC_BLOCK_INPUT; |
429 |
+ free (block); |
430 |
+ #if GC_MARK_STACK && !defined GC_MALLOC_CHECK |
431 |
+@@ -1117,6 +1134,8 @@ |
432 |
+ { |
433 |
+ struct ablock *ablock = block; |
434 |
+ struct ablocks *abase = ABLOCK_ABASE (ablock); |
435 |
++ |
436 |
++ if (block < initial_brk) return; |
437 |
+ |
438 |
+ MALLOC_BLOCK_INPUT; |
439 |
+ #if GC_MARK_STACK && !defined GC_MALLOC_CHECK |
440 |
|
441 |
diff --git a/app-editors/emacs/files/emacs-24.3-stderr.patch b/app-editors/emacs/files/emacs-24.3-stderr.patch |
442 |
new file mode 100644 |
443 |
index 0000000..a3beb9f |
444 |
--- /dev/null |
445 |
+++ b/app-editors/emacs/files/emacs-24.3-stderr.patch |
446 |
@@ -0,0 +1,11 @@ |
447 |
+--- a/emacs-24.3/src/print.c |
448 |
++++ b/emacs-24.3/src/print.c |
449 |
+@@ -733,7 +733,7 @@ |
450 |
+ print_output_debug_flag = x; |
451 |
+ } |
452 |
+ |
453 |
+-#if defined (GNU_LINUX) |
454 |
++#if 0 |
455 |
+ |
456 |
+ /* This functionality is not vitally important in general, so we rely on |
457 |
+ non-portable ability to use stderr as lvalue. */ |
458 |
|
459 |
diff --git a/app-editors/emacs/files/emacs-24.4-configure.patch b/app-editors/emacs/files/emacs-24.4-configure.patch |
460 |
new file mode 100644 |
461 |
index 0000000..8c63009 |
462 |
--- /dev/null |
463 |
+++ b/app-editors/emacs/files/emacs-24.4-configure.patch |
464 |
@@ -0,0 +1,10 @@ |
465 |
+--- a/configure.ac 2015-02-03 20:27:53.649248696 -0100 |
466 |
++++ b/configure.ac 2015-02-03 20:29:40.708910266 -0100 |
467 |
+@@ -2004,6 +2004,7 @@ |
468 |
+ ## darwin ld insists on the use of malloc routines in the System framework. |
469 |
+ darwin|sol2-10) system_malloc=yes ;; |
470 |
+ esac |
471 |
++system_malloc=yes |
472 |
+ |
473 |
+ GMALLOC_OBJ= |
474 |
+ if test "${system_malloc}" = "yes"; then |
475 |
|
476 |
diff --git a/app-editors/emacs/files/emacs-24.4-lisp.patch b/app-editors/emacs/files/emacs-24.4-lisp.patch |
477 |
new file mode 100644 |
478 |
index 0000000..bc8a3f7 |
479 |
--- /dev/null |
480 |
+++ b/app-editors/emacs/files/emacs-24.4-lisp.patch |
481 |
@@ -0,0 +1,10 @@ |
482 |
+--- a/src/lisp.h 2015-02-03 20:42:39.233177373 -0100 |
483 |
++++ b/src/lisp.h 2015-02-03 20:44:01.780145394 -0100 |
484 |
+@@ -270,6 +270,7 @@ |
485 |
+ This can be used in #if, e.g., '#if VAL_MAX < UINTPTR_MAX' below. */ |
486 |
+ #define VAL_MAX (EMACS_INT_MAX >> (GCTYPEBITS - 1)) |
487 |
+ |
488 |
++#define USE_LSB_TAG 1 |
489 |
+ /* Unless otherwise specified, use USE_LSB_TAG on systems where: */ |
490 |
+ #ifndef USE_LSB_TAG |
491 |
+ /* 1. We know malloc returns a multiple of 8. */ |
492 |
|
493 |
diff --git a/app-editors/emacs/files/emacs-24.4-preload-hack.patch b/app-editors/emacs/files/emacs-24.4-preload-hack.patch |
494 |
new file mode 100644 |
495 |
index 0000000..8bed0bd |
496 |
--- /dev/null |
497 |
+++ b/app-editors/emacs/files/emacs-24.4-preload-hack.patch |
498 |
@@ -0,0 +1,11 @@ |
499 |
+--- a/src/Makefile.in 2014-05-26 16:50:55.000000000 -0100 |
500 |
++++ b/src/Makefile.in 2015-02-03 20:25:11.915270649 -0100 |
501 |
+@@ -292,7 +292,7 @@ |
502 |
+ |
503 |
+ GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ |
504 |
+ |
505 |
+-RUN_TEMACS = ./temacs |
506 |
++RUN_TEMACS = LD_PRELOAD=../preload.so ./temacs |
507 |
+ |
508 |
+ ## Invoke ../nt/addsection for MinGW, ":" elsewhere. |
509 |
+ TEMACS_POST_LINK = @TEMACS_POST_LINK@ |
510 |
|
511 |
diff --git a/app-editors/emacs/files/preload.c b/app-editors/emacs/files/preload.c |
512 |
new file mode 100644 |
513 |
index 0000000..65cdcef |
514 |
--- /dev/null |
515 |
+++ b/app-editors/emacs/files/preload.c |
516 |
@@ -0,0 +1,88 @@ |
517 |
+// http://www.openwall.com/lists/musl/2015/02/03/1 |
518 |
+#include <pthread.h> |
519 |
+#include <stdint.h> |
520 |
+#include <stdlib.h> |
521 |
+#include <string.h> |
522 |
+#include <dlfcn.h> |
523 |
+#include <unistd.h> |
524 |
+#include <stdio.h> |
525 |
+ |
526 |
+static void *(*real_malloc)(size_t); |
527 |
+static void *initial_brk; |
528 |
+ |
529 |
+static pthread_once_t once_control[1]; |
530 |
+static void once_func() |
531 |
+{ |
532 |
+ real_malloc = dlsym(RTLD_NEXT, "malloc"); |
533 |
+ initial_brk = sbrk(0); |
534 |
+} |
535 |
+ |
536 |
+static int cmp(const void *a, const void *b) |
537 |
+{ |
538 |
+ void *aa = *(void **)a, *bb = *(void **)b; |
539 |
+ return aa < bb ? -1 : aa > bb ? 1 : 0; |
540 |
+} |
541 |
+ |
542 |
+void *malloc(size_t n) |
543 |
+{ |
544 |
+ size_t i, j, k; |
545 |
+ pthread_once(once_control, once_func); |
546 |
+ if (n < 100000 || n > (size_t)-1/2) { |
547 |
+ void *p; |
548 |
+ do p = real_malloc(n); |
549 |
+ while (p > sbrk(0) || (p && p < initial_brk)); |
550 |
+ return p; |
551 |
+ } |
552 |
+ size_t cnt = n/16384; |
553 |
+ void **list = real_malloc(sizeof *list * cnt); |
554 |
+ if (!list) return 0; |
555 |
+ for (i=0; i<cnt; i++) list[i] = 0; |
556 |
+ for (i=0; i<cnt; i++) { |
557 |
+ list[i] = real_malloc(65536 - 2*sizeof(size_t)); |
558 |
+ if (!list[i]) goto fail; |
559 |
+ if (i<cnt/4) continue; |
560 |
+ size_t base = 0; |
561 |
+ qsort(list, i+1, sizeof(void *), cmp); |
562 |
+ for (j=0; j<i; j++) { |
563 |
+ char *p = list[base]; |
564 |
+ char *s = list[j]; |
565 |
+ char *z = list[j+1]; |
566 |
+ if (z-s > 65536) { |
567 |
+ base = j+1; |
568 |
+ continue; |
569 |
+ } |
570 |
+ if (z-p < n+64) { |
571 |
+ continue; |
572 |
+ } |
573 |
+ for (k=0; k<base; k++) free(list[k]); |
574 |
+ *(size_t *)(p-sizeof(size_t)) = z-p | 1; |
575 |
+ *(size_t *)(z-2*sizeof(size_t)) = z-p | 1; |
576 |
+ for (k=j+1; k<i+1; k++) free(list[k]); |
577 |
+ free(list); |
578 |
+ return p; |
579 |
+ } |
580 |
+ } |
581 |
+fail: |
582 |
+ for (i=0; i<cnt; i++) free(list[i]); |
583 |
+ free(list); |
584 |
+ return 0; |
585 |
+} |
586 |
+ |
587 |
+void *calloc(size_t n, size_t m) |
588 |
+{ |
589 |
+ if ((size_t)-1/n <= m) n *= m; |
590 |
+ else n = (size_t)-1; |
591 |
+ void *p = malloc(n); |
592 |
+ if (p) memset(p, 0, n); |
593 |
+ return p; |
594 |
+} |
595 |
+ |
596 |
+void *realloc(void *p, size_t n) |
597 |
+{ |
598 |
+ void *q = malloc(n); |
599 |
+ if (!q) return 0; |
600 |
+ size_t l = *(size_t *)((char *)p - sizeof(size_t)) & -8; |
601 |
+ memcpy(q, p, l<n ? l : n); |
602 |
+ free(p); |
603 |
+ return q; |
604 |
+} |
605 |
|
606 |
diff --git a/app-editors/emacs/metadata.xml b/app-editors/emacs/metadata.xml |
607 |
new file mode 100644 |
608 |
index 0000000..88ecff5 |
609 |
--- /dev/null |
610 |
+++ b/app-editors/emacs/metadata.xml |
611 |
@@ -0,0 +1,46 @@ |
612 |
+<?xml version="1.0" encoding="UTF-8"?> |
613 |
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> |
614 |
+<pkgmetadata> |
615 |
+<herd>emacs</herd> |
616 |
+<longdescription> |
617 |
+ GNU Emacs is an extensible, customizable text editor - and more. At its core |
618 |
+ is an interpreter for Emacs Lisp, a dialect of the Lisp programming language |
619 |
+ with extensions to support text editing. The features of GNU Emacs include: |
620 |
+ * Content-sensitive editing modes, including syntax coloring, for a variety |
621 |
+ of file types including plain text, source code, and HTML. |
622 |
+ * Complete built-in documentation, including a tutorial for new users. |
623 |
+ * Full Unicode support for nearly all human languages and their scripts. |
624 |
+ * Highly customizable, using Emacs Lisp code or a graphical interface. |
625 |
+ * A large number of extensions that add other functionality, including a |
626 |
+ project planner, mail and news reader, debugger interface, calendar, and |
627 |
+ more. Many of these extensions are distributed with GNU Emacs; others are |
628 |
+ available separately. |
629 |
+</longdescription> |
630 |
+<use> |
631 |
+ <flag name='athena'>Enable the MIT Athena widget set |
632 |
+ (<pkg>x11-libs/libXaw</pkg>)</flag> |
633 |
+ <flag name='games'>Support shared score files for games</flag> |
634 |
+ <flag name='gconf'>Use <pkg>gnome-base/gconf</pkg> to read the system |
635 |
+ font name</flag> |
636 |
+ <flag name='gfile'>Use gfile (<pkg>dev-libs/glib</pkg>) for file |
637 |
+ notification</flag> |
638 |
+ <flag name='gsettings'>Use gsettings (<pkg>dev-libs/glib</pkg>) to read the |
639 |
+ system font name</flag> |
640 |
+ <flag name='gtk3'>Link against version 3 of the GIMP Toolkit instead of |
641 |
+ version 2 (<pkg>x11-libs/gtk+</pkg>)</flag> |
642 |
+ <flag name='gzip-el'>Compress bundled Emacs Lisp source</flag> |
643 |
+ <flag name='hesiod'>Enable support for <pkg>net-dns/hesiod</pkg></flag> |
644 |
+ <flag name='imagemagick'>Use <pkg>media-gfx/imagemagick</pkg> for image |
645 |
+ processing</flag> |
646 |
+ <flag name='libxml2'>Use <pkg>dev-libs/libxml2</pkg> to parse XML instead |
647 |
+ of the internal Lisp implementations</flag> |
648 |
+ <flag name='pax_kernel'>Enable building under a PaX enabled kernel</flag> |
649 |
+ <flag name='source'>Install C source files and make them available for |
650 |
+ find-function</flag> |
651 |
+ <flag name='toolkit-scroll-bars'>Use the selected toolkit's scrollbars in |
652 |
+ preference to Emacs' own scrollbars</flag> |
653 |
+ <flag name='wide-int'>Prefer wide Emacs integers (typically 62-bit). |
654 |
+ This option has an effect only on architectures where "long" and |
655 |
+ "long long" types have different size.</flag> |
656 |
+</use> |
657 |
+</pkgmetadata> |