aboutsummaryrefslogtreecommitdiffstats
path: root/community/emacs/APKBUILD
blob: 17c7d13209810e58077c51140a29f877001c1e73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
# Contributor: Timo Teräs <timo.teras@iki.fi>
pkgname=emacs
pkgver=29.1
pkgrel=3
pkgdesc="Extensible, customizable, self-documenting real-time display editor (common files)"
arch="all"
url="https://www.gnu.org/software/emacs/emacs.html"
license="GPL-3.0-or-later"
makedepends="
	!libexecinfo-dev
	alsa-lib-dev
	autoconf
	automake
	fontconfig-dev
	gawk
	giflib-dev
	glib-dev
	gmp-dev
	gnutls-dev
	gtk+3.0-dev
	harfbuzz-dev
	jansson-dev
	libgccjit-dev
	libjpeg-turbo-dev
	libpng-dev
	librsvg-dev
	libwebp-dev
	libxaw-dev
	libxml2-dev
	libxpm-dev
	linux-headers
	ncurses-dev
	pango-dev
	sqlite-dev
	tiff-dev
	tree-sitter-dev
	"
subpackages="
	$pkgname-doc
	$pkgname-nox
	$pkgname-gtk3
	$pkgname-gtk3-nativecomp:gtk3_nativecomp
	$pkgname-pgtk
	$pkgname-pgtk-nativecomp:pgtk_nativecomp
	$pkgname-x11
	$pkgname-x11-nativecomp:x11_nativecomp
	"
source="https://ftp.gnu.org/gnu/emacs/emacs-$pkgver.tar.xz
	no-git-repo.patch
	"

# secfixes:
#   28.2-r6:
#     - CVE-2023-27986
#   28.2-r5:
#     - CVE-2023-27985
#   28.2-r3:
#     - CVE-2022-45939

prepare() {
	default_prepare
	./autogen.sh
	rm etc/emacs.service # systemd unit

	mkdir -p nox
	mv ./* nox || true

	cp -a nox x11
	cp -a nox x11-nativecomp
	cp -a nox gtk3
	cp -a nox gtk3-nativecomp
	cp -a nox pgtk
	cp -a nox pgtk-nativecomp
}

_build_variant() {
	cd "$builddir/$1"
	shift
	CFLAGS="$CFLAGS -O2 -flto=auto" \
	CXXFLAGS="$CXXFLAGS -O2 -flto=auto" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--libexecdir=/usr/lib \
		--localstatedir=/var \
		--with-gameuser=:games \
		--with-gpm \
		--with-harfbuzz \
		--with-json \
		"${@}"

	make
}

_build_x11() {
	_build_variant x11 \
		--with-x-toolkit=athena \
		--without-toolkit-scroll-bars \
		--without-dbus \
		--with-xft \
		--with-jpeg=yes \
		--with-tiff=yes
}

_build_x11_nativecomp() {
	_build_variant x11-nativecomp \
		--with-x-toolkit=athena \
		--without-toolkit-scroll-bars \
		--without-dbus \
		--with-xft \
		--with-jpeg=yes \
		--with-tiff=yes \
		--with-native-compilation=aot \
		--without-compress-install
}

_build_gtk3() {
	 _build_variant gtk3 \
		--with-x-toolkit=gtk3 \
		--with-xft \
		--with-jpeg=yes \
		--with-tiff=no
}

_build_gtk3_nativecomp() {
	 _build_variant gtk3-nativecomp \
		--with-x-toolkit=gtk3 \
		--with-xft \
		--with-jpeg=yes \
		--with-tiff=no \
		--with-native-compilation=aot
}

_build_pgtk() {
	_build_variant pgtk \
		       --with-x-toolkit=gtk3 \
		       --with-pgtk \
		       --with-xft \
		       --with-jpeg=yes \
		       --with-tiff=no
}

_build_pgtk_nativecomp() {
	_build_variant pgtk-nativecomp \
		       --with-x-toolkit=gtk3 \
		       --with-pgtk \
		       --with-xft \
		       --with-jpeg=yes \
		       --with-tiff=no \
		       --with-native-compilation=aot
}

_build_nox() {
	_build_variant nox \
		--without-sound \
		--without-x \
		--without-file-notification
}

build() {
	_build_nox
	_build_x11
	_build_x11_nativecomp
	_build_gtk3
	_build_gtk3_nativecomp
	_build_pgtk
	_build_pgtk_nativecomp
}

package() {
	make DESTDIR="$pkgdir" install -C gtk3

	cd "$pkgdir"
	# resolve conflict with ctags package
	mv usr/bin/ctags \
		usr/bin/ctags.emacs
	mv usr/share/man/man1/ctags.1.gz \
		usr/share/man/man1/ctags.emacs.1.gz

	# remove things that are per-subpackage and not common
	rm -r \
		usr/bin/emacs \
		usr/bin/emacsclient \
		usr/bin/emacs-$pkgver \
		usr/lib/emacs/$pkgver/*/emacs*.pdmp \
		usr/lib/systemd \
		usr/share/emacs/$pkgver/lisp \
		usr/share/emacs/$pkgver/site-lisp

	# fix perms on /var/games
	chmod 775 var/games
	chmod 775 var/games/emacs
	chmod 664 var/games/emacs/*
	chown -R root:games var/games

	# fix user/root permissions on usr/share files
	find usr/share/emacs/ -exec chown root:root {} \;
	find usr/lib -perm -g+s,g+x ! -type d -exec chmod g-s {} \;
}

_subpackage() {
	cd "$builddir/$1"
	make DESTDIR="$subpkgdir" install

	cd "$subpkgdir"

	# remove things that are in -common
	rm -rf \
		usr/bin/ctags \
		usr/bin/ebrowse \
		usr/bin/etags \
		usr/include \
		usr/lib/emacs/$pkgver/*/hexl \
		usr/lib/emacs/$pkgver/*/movemail \
		usr/lib/emacs/$pkgver/*/rcs2log \
		usr/lib/emacs/$pkgver/*/update-game-score \
		usr/lib/systemd \
		usr/share/applications \
		usr/share/emacs/$pkgver/etc \
		usr/share/icons \
		usr/share/info \
		usr/share/man \
		usr/share/metainfo \
		var/games

	# fix user/root permissions on usr/share files
	find usr/share/emacs/ -exec chown root:root {} \;
	find usr/lib -perm -g+s,g+x ! -type d -exec chmod g-s {} \;
}

nox() {
	pkgdesc="$pkgdesc - non-graphical"
	depends="
		$pkgname=$pkgver-r$pkgrel
		!emacs-gtk3
		!emacs-gtk3-nativecomp
		!emacs-pgtk
		!emacs-pgtk-nativecomp
		!emacs-x11
		!emacs-x11-nativecomp
		"
	_subpackage nox
}

x11() {
	pkgdesc="$pkgdesc - with X11"
	depends="
		$pkgname=$pkgver-r$pkgrel
		!emacs-gtk3
		!emacs-gtk3-nativecomp
		!emacs-pgtk
		!emacs-pgtk-nativecomp
		!emacs-nox
		!emacs-x11-nativecomp
		desktop-file-utils
		hicolor-icon-theme
		"
	_subpackage x11
}

x11_nativecomp() {
	pkgdesc="$pkgdesc - with X11 and native compilation"
	depends="
		$pkgname=$pkgver-r$pkgrel
		!emacs-gtk3
		!emacs-gtk3-nativecomp
		!emacs-pgtk
		!emacs-pgtk-nativecomp
		!emacs-nox
		!emacs-x11
		desktop-file-utils
		hicolor-icon-theme
		"
	_subpackage x11-nativecomp
}

gtk3() {
	pkgdesc="$pkgdesc - with GTK3"
	depends="
		$pkgname=$pkgver-r$pkgrel
		!emacs-gtk3-nativecomp
		!emacs-pgtk
		!emacs-pgtk-nativecomp
		!emacs-nox
		!emacs-x11
		!emacs-x11-nativecomp
		desktop-file-utils
		hicolor-icon-theme
		"
	_subpackage gtk3
}

gtk3_nativecomp() {
	pkgdesc="$pkgdesc - with GTK3 and native compilation"
	depends="
		$pkgname=$pkgver-r$pkgrel
		!emacs-gtk3
		!emacs-pgtk
		!emacs-pgtk-nativecomp
		!emacs-nox
		!emacs-x11
		!emacs-x11-nativecomp
		desktop-file-utils
		hicolor-icon-theme
		"
	_subpackage gtk3-nativecomp
}

pgtk() {
	pkgdesc="$pkgdesc - with pure GTK"
	depends="
		$pkgname=$pkgver-r$pkgrel
		!emacs-gtk3
		!emacs-gtk3-nativecomp
		!emacs-pgtk-nativecomp
		!emacs-nox
		!emacs-x11
		!emacs-x11-nativecomp
		desktop-file-utils
		hicolor-icon-theme
		"
	_subpackage pgtk
}

pgtk_nativecomp() {
	pkgdesc="$pkgdesc - with pure GTK and native compilation"
	depends="
		$pkgname=$pkgver-r$pkgrel
		!emacs-gtk3
		!emacs-gtk3-nativecomp
		!emacs-pgtk
		!emacs-nox
		!emacs-x11
		!emacs-x11-nativecomp
		desktop-file-utils
		hicolor-icon-theme
		"
	_subpackage pgtk-nativecomp
}

sha512sums="
de10f2af462682019af680e6a82fd33feb05ce6d995bedf5756264fa06e29d90cab02c5884b0aeade1c5ab39cf064e0fb6ff9f78d9eedbd162f0a985945b9ec2  emacs-29.1.tar.xz
5a2d1d10d66fd335b16d9f2d6d1e45e093067db87f8ef2d14a8c921cc94b3e226310c7cc691d19eb91eaf16de9ae4f20ff8be3596a4906b0514fa5f098328d97  no-git-repo.patch
"