-
Notifications
You must be signed in to change notification settings - Fork 512
Expand file tree
/
Copy pathsnapcraft.yaml
More file actions
263 lines (238 loc) · 8.55 KB
/
snapcraft.yaml
File metadata and controls
263 lines (238 loc) · 8.55 KB
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
name: snapcraft
title: Snapcraft
base: core24
summary: Package, distribute, and update any app for Linux and IoT.
description: |
Snapcraft is the command-line build tool for packaging and distributing software and apps in the snap container format.
The tool packages apps across many supported languages, build tools, and frameworks, such as Python, C and C++, Rust, Node, and GNOME. Snaps can be tested, debugged, and locally shared before being published to the global Snap Store and private stores. It uses simple commands to manage and monitor releases at a granular level.
It solves the problems of dependency management and architecture support by bundling all of a software’s libraries into the container itself, and provides a way to package any app, program, toolkit, or library for all major Linux distributions and IoT devices.
Snapcraft is for developers, package maintainers, fleet administrators, and hobbyists who are interested in publishing snaps for Linux and IoT devices.
adopt-info: snapcraft
confinement: classic
license: GPL-3.0
assumes:
- snapd2.43
issues:
- https://github.com/canonical/snapcraft/issues
source-code:
- https://github.com/canonical/snapcraft
website:
- https://documentation.ubuntu.com/snapcraft
# https://github.com/canonical/snapcraft/issues/4187
environment:
PATH: "$SNAP/libexec/snapcraft:/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# cryptography>=42.0 cannot load legacy algorithms on
# Ubuntu 20.04 for armhf, ppc64el, riscv64, and s390x
CRYPTOGRAPHY_OPENSSL_NO_LEGACY: "1"
apps:
snapcraft:
environment:
# https://github.com/lxc/pylxd/pull/361
PYLXD_WARNINGS: "none"
command: bin/python $SNAP/bin/snapcraft
completer: completion.sh
build-packages:
- cargo
- build-essential
- intltool
- libapt-pkg-dev
- libffi-dev
- libssl-dev
- libsodium-dev
- liblzma-dev
- libxml2-dev
- libxslt1-dev
- libyaml-dev
- patch
- pkg-config
- python3-dev
- rustc
- sed
parts:
snapcraft-scripts:
source: snap/local
plugin: dump
organize:
craft.git: libexec/snapcraft/craft.git
# Put sitecustomize in site-packages
sitecustomize.py: lib/python3.12/site-packages/sitecustomize.py
stage:
- "libexec/"
- "lib/"
git:
plugin: nil
stage-packages: [git]
build-attributes:
- enable-patchelf
prime:
- "-usr/bin"
- "-usr/share/doc"
- "-usr/share/man"
# perl is part of the core22 / core24
- "-usr/share/perl"
- "-usr/lib/x86_64-linux-gnu/perl"
- "-usr/lib/x86_64-linux-gnu/libperl*"
- "-usr/lib/x86_64-linux-gnu/libgdbm*"
patchelf:
plugin: autotools
source: https://github.com/canonical/patchelf
source-type: git
source-branch: "0.9+snapcraft"
autotools-configure-parameters:
- --prefix=/
build-attributes:
- enable-patchelf
build-packages:
- g++
- git
- make
override-pull: |
${SNAP}/libexec/snapcraft/craftctl default
if [ "${CRAFT_TARGET_ARCH}" = "riscv64" ]; then
git am "${CRAFT_PROJECT_DIR}/snap/local/patches/patchelf/0001-Always-use-the-ET_DYN-codepath-avoiding-shifting-loa.patch"
git am "${CRAFT_PROJECT_DIR}/snap/local/patches/patchelf/0002-Fix-rewriteSectionsLibrary-to-not-assume-the-base-ad.patch"
fi
override-build: |
${SNAP}/libexec/snapcraft/craftctl default
make check
prime:
- bin/patchelf
snapcraft-libs:
plugin: nil
stage-packages:
- apt
- apt-transport-https
- apt-utils
- binutils
- execstack
- gpg
- gpgv
- libsodium23
- libxml2
- libxslt1.1
- libpython3-stdlib
- libpython3.12-stdlib
- libpython3.12-minimal
- python3-pip
- python3-setuptools
- python3-wheel
- python3-venv
- python3-minimal
- python3.12-minimal
- squashfs-tools
- xdelta3
build-attributes:
- enable-patchelf
override-build: |
${SNAP}/libexec/snapcraft/craftctl default
echo "Create libsodium symlink..."
TRIPLET_PATH="$SNAPCRAFT_PART_INSTALL/usr/lib/$(gcc -print-multiarch)"
LIBSODIUM="$(readlink -n "$TRIPLET_PATH/libsodium.so.23")"
# Remove so the link can be recreated on re-builds
rm -f "$TRIPLET_PATH/libsodium.so"
ln -s "$LIBSODIUM" "$TRIPLET_PATH/libsodium.so"
# Restore patched files
PYTHON_PACKAGE_PATH="${SNAPCRAFT_PART_INSTALL}/usr/lib/python3.12/"
CTYPES_INIT="ctypes/__init__.py"
CTYPES_INIT_ORIG="patched/${CTYPES_INIT}.orig"
[ -f "${CTYPES_INIT_ORIG}" ] && mv "${CTYPES_INIT_ORIG}" "${PYTHON_PACKAGE_PATH}/${CTYPES_INIT}"
# Apply patches
echo "Patching ctypes..."
patch -s -b "${PYTHON_PACKAGE_PATH}/${CTYPES_INIT}" "${SNAPCRAFT_PROJECT_DIR}/snap/local/patches/python/ctypes_init.diff"
# Save patches to allow rebuilding
mkdir -p patched/ctypes
if [ -f "${PYTHON_PACKAGE_PATH}/${CTYPES_INIT}.orig" ]; then
mv "${PYTHON_PACKAGE_PATH}/${CTYPES_INIT}.orig" patched/ctypes
fi
# Disable site packages
sed -i "${SNAPCRAFT_PART_INSTALL}/usr/lib/python3.12/site.py" \
-e 's/^ENABLE_USER_SITE = None$/ENABLE_USER_SITE = False/'
prime:
# dist-packages
- -usr/lib/python3
- -usr/share/python-wheels
libgit2:
source: https://github.com/libgit2/libgit2/archive/refs/tags/v1.7.2.tar.gz
source-checksum: sha256/de384e29d7efc9330c6cdb126ebf88342b5025d920dcb7c645defad85195ea7f
plugin: cmake
cmake-parameters:
- -DCMAKE_INSTALL_PREFIX=/usr
- -DCMAKE_BUILD_TYPE=RelWithDebInfo
build-attributes:
- enable-patchelf
prime:
- -usr/include
snapcraft:
source: .
plugin: python
python-packages:
- wheel
- pip
python-requirements:
- uv-requirements.txt
- requirements-noble.txt
organize:
# Put snapcraftctl and craftctl into its own directory that can be included in the PATH
# without including other binaries.
bin/craftctl: libexec/snapcraft/craftctl
bin/snapcraftctl: bin/scriptlet-bin/snapcraftctl
# Also install the compatibility wrapper for core22+.
bin/snapcraftctl-compat: libexec/snapcraft/snapcraftctl
# Include general data in the share directory
"**/site-packages/extensions": share/snapcraft/extensions
"**/site-packages/keyrings": share/snapcraft/keyrings
"**/site-packages/schema": share/snapcraft/schema
build-attributes:
- enable-patchelf
build-environment:
# Build PyNaCl from source since the wheel files interact
# strangely with classic snaps. Well, build it all from source.
- "PIP_NO_BINARY": ":all:"
# Use base image's libsodium for PyNaCl.
- "SODIUM_INSTALL": "system"
- "CFLAGS": "$(pkg-config python-3.12 yaml-0.1 --cflags)"
- "UV_FROZEN": "1" # Never update the uv lockfile - fail build if we can't succeed.
build-snaps:
- astral-uv
override-build: |
uv export --no-dev --no-emit-workspace --output-file uv-requirements.txt
${SNAP}/libexec/snapcraft/craftctl default
version=$(PYTHONPATH=$CRAFT_PART_INSTALL/lib/python3.12/site-packages python3 -c "import snapcraft;print(snapcraft.__version__)")
${SNAP}/libexec/snapcraft/craftctl set version="$version"
[ -n "$(echo $version | grep "post")" ] && grade=devel || grade=stable
${SNAP}/libexec/snapcraft/craftctl set grade="$grade"
sed -i -e '1 s|^#!/.*|#!/snap/snapcraft/current/bin/python -E|' $SNAPCRAFT_PART_INSTALL/bin/craftctl
# The new implementation still requires this.
ln -sf ../usr/bin/python3.12 $SNAPCRAFT_PART_INSTALL/bin/python3
after: [snapcraft-libs, libgit2]
chisel:
plugin: nil
stage-snaps:
- chisel/latest/candidate
organize:
bin/chisel: libexec/snapcraft/chisel
stage:
- libexec/snapcraft/chisel
completion-script:
after: [snapcraft]
plugin: nil
build-environment:
- PYTHONPATH: $CRAFT_STAGE/lib/python3.12/site-packages
override-build: |
python3 -m craft_cli.completion $CRAFT_PROJECT_NAME snapcraft.application:get_app_info \
> $CRAFT_PART_INSTALL/completion.sh
spread:
plugin: go
source: https://github.com/canonical/spread.git
source-commit: d6447c43754c8ca0741901e9db73d5fdb4d21c93 # 'main' as of 28-March-2025
build-snaps:
- go
build-attributes:
- enable-patchelf
build-environment:
- CGO_ENABLED: 0
- GOFLAGS: -trimpath -ldflags=-w -ldflags=-s
organize:
bin/spread: libexec/snapcraft/craft.spread
stage:
- libexec/snapcraft/