-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathsnapcraft.yaml
More file actions
368 lines (339 loc) · 11.6 KB
/
Copy pathsnapcraft.yaml
File metadata and controls
368 lines (339 loc) · 11.6 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
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
name: core26
adopt-info: hooks
summary: Runtime environment based on Ubuntu 26.04
description: |
The base snap based on the Ubuntu 26.04 release.
confinement: strict
type: base
build-base: core26
grade: stable
assumes:
- snapd2.55.5
# This is uncommented in our github builds for riscv64
## - isa-riscv64-rva23
parts:
# TODO: rewrite this once all slices are upstreamed to use chisel slices
# directly from canonical, instead of our own chisel-releases repo.
chisel-libs:
plugin: nil
build-packages:
- golang
- file
source: https://github.com/canonical/chisel-ubuntu-core.git
source-type: git
source-branch: '26.04'
override-build: |
# We use a file with env vars in $CRAFT_PROJECT_DIR to decide whether to
# include cloud-init or not. This file can be manually created for local
# builds, or created here if we are running from a launchpad recipe with
# suffix -cloud-init. This is detected by looking at the
# SNAPCRAFT_IMAGE_INFO env var injected in LP, which tells us the build
# url and has a form like:
#
# {
# "build-request-id": "lp-<id>",
# "build-request-timestamp": "<time>",
# "build_url": "https://launchpad.net/~ubuntu-core-service/+snap/core26-cloud-init/+build/<build_id>"
# }
#
# (although in one line).
(
cd "$CRAFT_PROJECT_DIR"
touch build-env
if printf "$SNAPCRAFT_IMAGE_INFO" | grep -q -- "-cloud-init/+build"
then echo "SNAP_BUILD_VARIANT=cloud-init" > build-env
fi
)
go install github.com/canonical/chisel/cmd/chisel@latest
# Define the system utilities that we want to include in the base
# These are the ones where we can probably slim down the number of binaries
# later on, but for now we include them all to ensure maximum compatibility.
UTILS=(
apparmor_bins
bash_bins
bzip2_scripts
coreutils-from-uutils_bins
diffutils_bins
dosfstools_bins
debianutils_which
debianutils_ischroot
debianutils_run-parts
file_bins
gdbserver_bins
gnu-coreutils_bins
gnutls-bin_bins
gpgv_bins
grep_bins
gzip_scripts
hostname_bins
iptables_bins
iputils-ping_bins
less_bins
login_bins
mawk_bins
ncurses-bin_bins
polkitd_bins
rfkill_bins
sed_bins
sudo-rs_bins
sysvinit-utils_scripts
squashfs-tools_bins
tar_bins
util-linux_bins
util-linux-extra_hardware
util-linux-extra_process
util-linux-extra_login
vim-tiny_bins
)
# Define the system libraries and services that we want to include in the base
#
SLICES=(
apparmor_systemd
base-files_motd
base-files_release-info
base-files_root-defaults
bash-completion_config
bash-completion_completions
ca-certificates_data-with-certs
cracklib-runtime_bins
cryptsetup_bins
cryptsetup-bin_bins
dbus_services
dbus-user-session_services
dhcpcd-base_standard
distro-info-data_data
dmsetup_rules
e2fsprogs_services
e2fsprogs_standard
fdisk_bins
fonts-ubuntu_all
fonts-ubuntu_config
finalrd_services
iproute2_bins
kmod_bins
kmod_config
libc6_config
libc6_gconv
libc-bin_iconv
libc-bin_nsswitch
libc-bin_ldconfig
libc-bin_locale
libc-bin_getconf
libc-bin_getent
libpam-modules_config
libpam-modules_pam-config
libpam-pwquality_pam-config
libpam-modules-bin_standard
libpam-modules-bin_extrausers
libpam-modules-bin_namespace
libpam-modules-bin_timestamp
libpam-systemd_libs
libengine-pkcs11-openssl_libs
libgnutls30t64_config
libopts25_libs
libp11-3t64_libs
libnss-mdns_mdns4-minimal
libnss-extrausers_libs
libpam-pwquality_libs
libpciaccess0_libs
libwrap0_host-files
libx11-data_xerrordb
locales_standard
netcat-openbsd_bins
netplan.io_bins
ncurses-base_terminfo
openssh-client_config
openssh-client_services
openssh-server_bins
openssh-server_config
openssh-server_services
openssl_bins
opensc_bins
p11-kit_bins
passwd_pam-config
polkitd_services
procps_bins
plymouth_bins
plymouth-label-ft_libs
procps_config
udev_services
util-linux_services
systemd_bash-completions
systemd_extras
systemd_run0
systemd_kernel-parameters
systemd_udev-rules
systemd_tpm2
systemd_standard
systemd_user-services
systemd-bootchart_services
systemd-coredump_bins
systemd-cryptsetup_bins
systemd-cryptsetup_services
systemd-resolved_bins
systemd-sysv_bins
systemd-timesyncd_services
systemd-zram-generator_services
tzdata_zoneinfo
wpasupplicant_services
)
. "$CRAFT_PROJECT_DIR"/build-env
SNAP_BUILD_VARIANT=${SNAP_BUILD_VARIANT:-}
if [ "$SNAP_BUILD_VARIANT" = cloud-init ]; then
SLICES+=(cloud-init_bins)
fi
# TODO: not sure about FIPS yet, this will have to come later, chisel has builtin
# support for ESM, meaning it's something we can request chisel to do for us.
# if [[ ${SNAP_FIPS_BUILD+x} ]]; then
# # Ensure vital crypt packages are refreshed / downgraded and downloaded
# # from the FIPS ppa. This should also contain openssh-server, but we already
# # have that one listed above.
# SLICES+=(libgcrypt20 libgnutls30t64 openssl-fips-module-3 ssh)
# fi
# add architecture specific slices
case "$(dpkg --print-architecture)" in
amd64|arm64)
SLICES+=(secureboot-db_services nvidia-kernel-common-595_bins nvidia-kernel-common-595_modprobe-d-kms)
;;
i386)
SLICES+=(secureboot-db_services)
;;
riscv64)
SLICES+=(gdbserver_bins systemd-bootchart_services)
;;
esac
# create the rootfs directory we install slices into
mkdir -p "${CRAFT_PART_INSTALL}"/base
# Cut the initial slices into the rootfs
chisel cut \
--release="${CRAFT_PART_SRC}" \
--root "${CRAFT_PART_INSTALL}"/base \
"${SLICES[@]}" "${UTILS[@]}" \
base-files_chisel
# Cut foreign libraries we also need
case "$(dpkg --print-architecture)" in
amd64)
chisel cut \
--arch=i386 \
--release="${CRAFT_PART_SRC}" \
--root "${CRAFT_PART_INSTALL}"/base \
libnss-mdns_mdns4-minimal libc6_libs libc6_gconv libc6_config libgcc-s1_libs
;;
esac
# https://documentation.ubuntu.com/chisel/en/latest/reference/manifest/
# chisel automatically generates a manifest for the cut slices here:
# $rootfs/var/lib/chisel/manifest.wall
# this is zstd compressed, and must therefor be uncompressed
# unzstd ./manifest.wall -o manifest.json
override-prime: |
# No files from this step in prime
snapd-files:
plugin: nil
source: .
build-packages:
- snapd
after:
- chisel-libs
override-build: |
mkdir -p "${CRAFT_PART_INSTALL}"/base/usr/lib/systemd/system-generators
cp /usr/lib/systemd/system-generators/snapd-generator "${CRAFT_PART_INSTALL}"/base/usr/lib/systemd/system-generators/snapd-generator
mkdir -p "${CRAFT_PART_INSTALL}"/base/usr/lib/tmpfiles.d
cp /usr/lib/tmpfiles.d/snapd.conf "${CRAFT_PART_INSTALL}"/base/usr/lib/tmpfiles.d/snapd.conf
override-prime: |
# No files from this step in prime
generators:
plugin: nil
source: generators/
build-packages:
- cargo
- rustc
override-build: |
cd "${CRAFT_PART_SRC}"
cargo build --release
strip target/release/ubuntu-core-generator
mkdir -p "${CRAFT_PART_INSTALL}/usr/lib/core"
install -m 755 target/release/ubuntu-core-generator \
"${CRAFT_PART_INSTALL}/usr/lib/core/ubuntu-core-generator"
splash-theme:
plugin: dump
source: https://github.com/snapcore/plymouth-theme-ubuntu-core.git
source-type: git
organize:
ubuntu-core: usr/share/plymouth/themes/ubuntu-core
copyright: usr/share/doc/plymouth-theme-ubuntu-core/copyright
stage:
- -README.md
hooks:
after:
- chisel-libs
- snapd-files
- splash-theme
plugin: make
source: .
build-packages:
- shellcheck
- distro-info
override-pull: |
craftctl default
date_tag=$(./get-version.sh)
# detect whether we are doing a fips build on LP
if git remote get-url origin | grep "fips"; then
craftctl set version="$date_tag"+fips
echo "SNAP_BUILD_VARIANT=fips" > build-env
echo "SNAP_BUILD_NAME=core26-fips" >> build-env
else
craftctl set version=$date_tag
rm -f build-env
fi
override-prime: |
craftctl default
# ensure build-in tests are run
make -C ${CRAFT_PART_SRC} test TESTDIR=${CRAFT_PRIME}
generate-changelog:
after:
- hooks
plugin: make
# Use the root to be able to detect the git repo, as we need to be able
# to get the current commit
source: .
build-packages:
- python3-debian
- python3-requests
- python3-yaml
# to generate changelogs, it's own snap need to be present
# TODO: maybe we can override pull and just copy the files we need into
# the source dir.
build-snaps:
- core26/beta
override-build: |
cd ${CRAFT_PART_SRC}
# Generate the dpkg.yaml for compatability purposes. Scanning tools still expect
# this file to be present, and they move slowly in terms of support for the new chisel format.
mkdir -p "${CRAFT_PART_INSTALL}/usr/share/snappy"
python3 ./tools/wall2dpkg.py "${CRAFT_STAGE}/var/lib/chisel/manifest.wall" "${CRAFT_PART_INSTALL}/usr/share/snappy/dpkg.yaml"
# When building through spread there is no .git, which means we cannot
# generate the changelog in this case, ensure that the current folder is
# a git repository, additionally check that the snap we are building a changelog
# against has the dpkg.yaml.
if git rev-parse HEAD && [ -e "/snap/core26/current/usr/share/snappy/dpkg.yaml" ]; then
CHG_PARAMS=
if [ -e /build/core26 ]; then
CHG_PARAMS=--launchpad
fi
mkdir -p "${CRAFT_PART_INSTALL}/usr/share/doc"
./tools/generate-changelog.py "/snap/core26/current" "${CRAFT_PART_INSTALL}" core26 $CHG_PARAMS
else
echo "WARNING: changelog will not be generated for this build"
fi
publish-artifacts-lp:
after:
- generate-changelog
plugin: nil
override-prime: |
# copy dpkg.yaml, chisel manifest and changelog files for lp build
if [ -e /build/core26 ]; then
DATEFMT="$(date +%Y%m%d%H%M)"
/bin/cp ${CRAFT_PRIME}/usr/share/snappy/dpkg.yaml /build/core26/core26-$(DATEFMT)_${CRAFT_ARCH_BUILD_FOR}.dpkg.yaml
/bin/cp ${CRAFT_PRIME}/var/lib/chisel/manifest.wall /build/core26/core26-$(DATEFMT)_${CRAFT_ARCH_BUILD_FOR}.manifest.wall
/bin/cp ${CRAFT_PRIME}/usr/share/doc/ChangeLog /build/core26/core26-$(DATEFMT)_${CRAFT_ARCH_BUILD_FOR}.ChangeLog
fi