-
Notifications
You must be signed in to change notification settings - Fork 13
/
snapcraft.yaml
386 lines (374 loc) · 11.3 KB
/
snapcraft.yaml
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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
name: emacs
title: GNU Emacs
version: "29.4"
summary: GNU Emacs is the extensible self-documenting text editor
description: |
Emacs is the extensible, customizable, self-documenting real-time
display editor.
Features include:
* Content-aware editing modes, including syntax coloring, for many file types.
* Complete built-in documentation, including a tutorial for new users.
* Full Unicode support for nearly all human scripts.
* Highly customizable, using Emacs Lisp code or a graphical interface.
* An entire ecosystem of functionality beyond text editing, including a project
planner, mail and news reader, debugger interface, calendar, and more.
* A packaging system for downloading and installing extensions.
This snap is built via the build.snapcraft.io service from the
snapcraft.yaml definition at https://github.com/alexmurray/emacs-snap to
ensure source and build transparency.
base: core24
grade: stable
confinement: classic
license: GPL-3.0+
compression: lzo
apps:
emacs:
command-chain:
- setup-env
command: emacs
desktop: usr/share/applications/emacs.desktop
emacsclient:
command: emacsclient
desktop: usr/share/applications/emacsclient.desktop
ctags:
command: usr/bin/ctags
ebrowse:
command: usr/bin/ebrowse
etags:
command: usr/bin/etags
parts:
tree-sitter:
plugin: make
build-attributes:
- enable-patchelf
source: https://github.com/tree-sitter/tree-sitter.git
source-tag: v0.24.4
build-environment:
- PREFIX: "/usr"
emacs:
after: [tree-sitter]
plugin: nil
build-attributes:
- enable-patchelf
source: https://mirrors.ocf.berkeley.edu/gnu/emacs/emacs-29.4.tar.xz
source-checksum: sha256/ba897946f94c36600a7e7bb3501d27aa4112d791bfe1445c61ed28550daca235
organize:
snap/emacs/current/usr: usr
build-packages:
- autoconf
- automake
- autopoint
- bsd-mailx
- dbus-x11
- debhelper
- dpkg-dev
- gawk
- gcc-14
- g++-14
- libacl1-dev
- libasound2-dev
- libdbus-1-dev
- libgccjit-14-dev
- libgif-dev
- libgnutls28-dev
- libgpm-dev
- libgtk-3-dev
- libharfbuzz-dev
- libjansson-dev
- libjpeg-dev
- liblcms2-dev
- liblockfile-dev
- libm17n-dev
- libncurses-dev
- liboss4-salsa2
- libotf-dev
- libpng-dev
- librsvg2-dev
- libselinux1-dev
- libsqlite3-dev
- libsystemd-dev
- libtiff-dev
- libtool
- libxi-dev
- libxml2-dev
- libxpm-dev
- libxt-dev
- procps
- quilt
- sharutils
- texinfo
- zlib1g-dev
stage-packages:
- gsettings-desktop-schemas
- gcc-14 # for tree-sitter
- g++-14 # for tree-sitter
- gvfs
- gvfs-libs
- ibus-gtk3
- libacl1
- libattr1
- libasound2t64
- libaspell15
- libasyncns0
- libatk-bridge2.0-0t64
- libatk1.0-0t64
- libatspi2.0-0t64
- libblkid1
- libbrotli1
- libbsd0
- libc6 # required for native-comp
- libc6-dev # required for native-comp
- libcairo-gobject2
- libcairo2
- libcanberra-gtk3-0t64
- libcanberra-gtk3-module
- libcanberra0t64
- libdatrie1
- libdb5.3t64
- libdrm2
- libdevmapper1.02.1
- libegl1
- libenchant-2-2
- libenchant-2-dev # for https://github.com/alexmurray/emacs-snap/issues/71
- libepoxy0
- libexpat1
- libffi8
- libflac12t64
- libfontconfig1
- libfreetype6
- libgbm1
- libgccjit0
- libgccjit-14-dev
- libgcc-s1
- libgcrypt20
- libgd3
- libgdk-pixbuf2.0-0
- libgif7
- libgl1
- libglib2.0-0t64
- libglib2.0-bin
- libglvnd0
- libglx0
- libgmp10
- libgnutls30t64
- libhogweed6t64
- libidn2-0
- liblz4-1
- libmd0
- libnettle8t64
- libsystemd0
- libtasn1-6
- libunistring5
- libzstd1
- libgpg-error0
- libgpm2
- libgraphite2-3
- libgstreamer-gl1.0-0
- libgstreamer-plugins-base1.0-0
- libgstreamer1.0-0
- libgtk-3-0t64
- libgudev-1.0-0
- libharfbuzz-icu0
- libharfbuzz0b
- libhyphen0
- libibus-1.0-5
- libice6
- libicu74
- libisl23
- libjansson4
- libjbig0
- libjpeg-turbo8
- libcom-err2
- liblcms2-2
- liblockfile1
- libltdl7
- libm17n-0
- libmount1
- libmpc3
- libmpfr6
- libnotify4
- libnss-mdns
- libnss-myhostname
- libnss-sss
- libnss-systemd
- libogg0
- libedit2
- libelf1t64
- libreadline8t64
- libncursesw6
- libkeyutils1
- libtinfo6
- libbz2-1.0
- libdbus-1-3
- liblzma5
- libcap2
- liborc-0.4-0t64
- liboss4-salsa2
- libotf1
- libp11-kit0
- libpango-1.0-0
- libpangocairo-1.0-0
- libpangoft2-1.0-0
- libpixman-1-0
- libpng16-16t64
- libpulse0
- librsvg2-2
- libsasl2-2
- libsecret-1-0
- libselinux1
- libsm6
- libsndfile1
- libsoup2.4-common
- libsqlite3-0
- libssl3t64
- libsss-nss-idmap0
- libstdc++6
- libtdb1
- libthai0
- libtiff6
- libuuid1
- libvorbis0a
- libvorbisenc2
- libvorbisfile3
- libwayland-client0
- libwayland-cursor0
- libwayland-egl1
- libwayland-server0
- libwebp7
- libwebpdecoder3
- libwebpdemux2
- libwoff1
- libxml2
- libxpm4
- libxslt1.1
- libyajl2
- libx11-6
- libx11-xcb1
- libxau6
- libxapian30
- libxapian-dev # https://github.com/alexmurray/emacs-snap/issues/92
- libxcb-render0
- libxcb-shm0
- libxcb1
- libxcomposite1
- libxcursor1
- libxdamage1
- libxdmcp6
- libxext6
- libxfixes3
- libxi6
- libxinerama1
- libxkbcommon0
- libxrandr2
- libxrender1
- zlib1g
stage:
- -usr/share/emacs/site-lisp
build-environment:
- CC: "gcc-14"
- CXX: "g++-14"
- CFLAGS: "${CFLAGS:+$CFLAGS} -O2"
- NATIVE_FULL_AOT: "1"
- LD_LIBRARY_PATH: "$SNAPCRAFT_STAGE/usr/lib"
override-pull: |
craftctl default
# ensure we hard-code our copy of gcc-14 and g++14 for tree-sitter
# otherwise it will use the system installed ones which will have a
# different libc version and we will fail to load them
patch -p1 < $SNAPCRAFT_PROJECT_DIR/treesit.patch
# also hard-code the default x resource name to emacs rather than using
# the invocation name (which is emacs-gtk or similar)
patch -p1 < $SNAPCRAFT_PROJECT_DIR/emacs-x-resource-name.patch
override-build: |
# build with pgtk for wayland
env NOCONFIGURE=1 ./autogen.sh
./configure \
--prefix=/snap/emacs/current/usr \
--with-x-toolkit=gtk3 \
--without-xaw3d \
--with-modules \
--with-cairo \
--with-native-compilation=aot \
--with-pgtk \
--with-xinput2 \
--with-tree-sitter \
--with-json
env NATIVE_FULL_AOT=1 make -j"${SNAPCRAFT_PARALLEL_BUILD_COUNT}"
cp src/emacs src/emacs-wayland
cp lib-src/emacsclient lib-src/emacsclient-wayland
cp src/emacs.pdmp src/emacs-wayland.pdmp
# then build without pgtk as well
env NOCONFIGURE=1 ./autogen.sh
make distclean
./configure \
--prefix=/snap/emacs/current/usr \
--with-x-toolkit=gtk3 \
--without-xaw3d \
--with-modules \
--with-cairo \
--with-native-compilation=aot \
--without-pgtk \
--with-xinput2 \
--with-tree-sitter \
--with-json
env NATIVE_FULL_AOT=1 make -j"${SNAPCRAFT_PARALLEL_BUILD_COUNT}"
cp src/emacs src/emacs-gtk
cp lib-src/emacsclient lib-src/emacsclient-gtk
cp src/emacs.pdmp src/emacs-gtk.pdmp
make install DESTDIR="${SNAPCRAFT_PART_INSTALL}"
for backend in gtk wayland; do
install -m 0755 src/emacs-$backend $SNAPCRAFT_PART_INSTALL/usr/bin/
install -m 0755 lib-src/emacsclient-$backend $SNAPCRAFT_PART_INSTALL/usr/bin/
# cheat by using the already installed pdmp file from above as a template
pdmp_dir=$(dirname $(ls -1 $SNAPCRAFT_PART_INSTALL/snap/emacs/current/usr/libexec/emacs/*/*/emacs-*.pdmp | head -n1))
install -m 0644 "src/emacs-$backend.pdmp" "${pdmp_dir}"
ln -sf "emacs-$backend.pdmp" "${pdmp_dir}/emacs-$backend-$(src/emacs-$backend --fingerprint).pdmp"
done
override-stage: |
set -eu
craftctl default
glib-compile-schemas $SNAPCRAFT_STAGE/usr/share/glib-2.0/schemas/
# Fix-up application icon lookup
sed -i -e 's|^Icon=.*|Icon=usr/share/icons/hicolor/scalable/apps/emacs.svg|g' usr/share/applications/emacs*.desktop
# also fixup emacsclient.desktop file since snapd replaces the Exec= line
sed -i 's|Exec=.*|Exec=emacsclient %F|' usr/share/applications/emacsclient.desktop
# ensure we hard-code the necessary arguments for
# native-comp-driver-options in the build to try and avoid
# https://github.com/alexmurray/emacs-snap/issues/35 - we can't do
# this before we compile otherwise these options get used for doing
# the AOT compile as well - so set them afterwards just inside the
# snap
VERSION=$(ls -1 usr/share/emacs/*/lisp/emacs-lisp/comp.el* | head -n1 | cut -d / -f 4)
rm -f "usr/share/emacs/${VERSION}/lisp/emacs-lisp/comp.elc"
[ -f "usr/share/emacs/${VERSION}/lisp/emacs-lisp/comp.el.gz" ] && gunzip -f usr/share/emacs/*/lisp/emacs-lisp/comp.el.gz
# check if patched first so we can run prime stage multiple times when
# iterating on changes
grep -q SNAP "usr/share/emacs/${VERSION}/lisp/emacs-lisp/comp.el" || sed "s/@@VERSION@@/${VERSION}/g" $SNAPCRAFT_PROJECT_DIR/native-comp.patch | sed "s/@@MULTIARCH@@/$CRAFT_ARCH_TRIPLET_BUILD_FOR/g" | patch -p1
../parts/emacs/build/src/emacs -batch -f batch-byte+native-compile "usr/share/emacs/${VERSION}/lisp/emacs-lisp/comp.el"
# compiled eln files get put back in the build directory - copy them over
# manually
VERSION_HASH=$(basename ../parts/emacs/build/native-lisp/*)
cp "../parts/emacs/build/native-lisp/${VERSION_HASH}"/comp-*.eln "usr/lib/emacs/${VERSION}/native-lisp/${VERSION_HASH}/"
gzip usr/share/emacs/*/lisp/emacs-lisp/comp.el
# fix up paths in the various pkg-config files that we ship
find $SNAPCRAFT_STAGE -name *.pc -exec sed -i "s|prefix=$SNAPCRAFT_STAGE|prefix=/snap/emacs/current|" {} \;
# finally fixup linker script to use our libc_nonshared.a
sed -i "s| /usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libc_nonshared.a| /snap/emacs/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libc_nonshared.a|" usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libc.so
site-lisp:
source: site-lisp
plugin: dump
organize:
"*.el": usr/share/emacs/site-lisp/
setup-env:
source: setup-env
plugin: make
build-attributes:
- enable-patchelf
stage:
- setup-env
scripts:
source: .
plugin: dump
stage:
- emacsclient
- emacs