-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathsnapcraft.yaml
More file actions
608 lines (597 loc) · 18.4 KB
/
snapcraft.yaml
File metadata and controls
608 lines (597 loc) · 18.4 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
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
name: octavia-diskimage-retrofit
icon: src/icon.svg
adopt-info: retrofit
grade: stable
license: AGPL-3.0-only OR Apache-2.0 OR GPL-2.0 OR LGPL-2.1
summary: Turn stock cloud image into Octavia Amphora image
description: |
The purpose of this tool is to take a stock Ubuntu Cloud Image,
apply OpenStack Diskimage-builder elements from OpenStack Octavia,
to retrofit the image so that it is suitable for use as Octavia HAProxy
amphora.
Example Usage:
sudo snap install --classic octavia-diskimage-retrofit
cd /var/snap/octavia-diskimage-retrofit/common/tmp
wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
sudo octavia-diskimage-retrofit \
jammy-server-cloudimg-amd64.img \
ubuntu-amphora-haproxy-amd64.qcow2
**NOTE** The tool will use KVM acceleration when available.
confinement: classic
base: core22
architectures:
- build-on: amd64
- build-on: arm64
- build-on: ppc64el
- build-on: s390x
environment:
# To enable execution of binaries from snap, and the host operating system,
# we patch all ELF binaries shipped with the snap in the 'patchelf' part
# instead of using the LD_LIBRARY_PATH environment variable.
#
# This is required because both libc and other standard libraries hard code
# the path to /bin/sh, and uses that to execute other binaries. The path to
# /bin/sh is part of POSIX, so we can't really blame them. Any attempt to
# execute /bin/sh from host operating system with LD_LIBRARY_PATH pointing
# to the snap will make the execution abort or fault.
#
# In addition to that the diskimage builder elements in multiple parts of
# this snap contain shell code which may try to execute host binaries.
LD_LIBRARY_PATH: ""
PATH: $SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin
LIBGUESTFS_PATH: $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/guestfs/appliance
TMPDIR: $SNAP_COMMON/tmp
PYTHONHOME: $SNAP
PYTHONPATH: $SNAP/usr/lib/python3/dist-packages:$SNAP/usr/lib/python3.10/site-packages:$SNAP/usr/lib/python3.10:$SNAP/usr/lib/python3.10/lib-dynload
apps:
octavia-diskimage-retrofit:
command: bin/retrofit.sh
parts:
retrofit:
plugin: dump
source: src/retrofit
override-stage: |
craftctl default
craftctl set version=$(git -C $CRAFT_PROJECT_DIR describe --always --dirty --tags | sed -e 's/-/+git/;y/-/./' | sed -s 's/^v//')
organize:
retrofit.sh: bin/retrofit.sh
local-elements:
plugin: dump
source: src
organize:
elements/*: usr/local/lib/elements/
octavia-elements:
plugin: dump
source: https://git.launchpad.net/~ubuntu-openstack-dev/ubuntu/+source/octavia
source-type: git
source-branch: stable/yoga
organize:
elements/*: usr/local/lib/elements/
stage:
# The Ubuntu Jammy Octavia package does not have a binary package for
# the new prometheus-proxy daemon (LP: #1982969).
- -usr/local/lib/elements/amphora-agent/post-install.d/12-enable-prometheus-proxy-systemd
diskimage-builder:
# We do not use the Python plugin because in a classic snap we install a
# complete Python environment and not just a venv.
plugin: dump
source: https://git.launchpad.net/~ubuntu-openstack-dev/ubuntu/+source/python-diskimage-builder
source-type: git
source-branch: stable/yoga
build-environment:
- PATH: $CRAFT_PART_INSTALL/usr/bin:$PATH
- PYTHONHOME: $CRAFT_PART_INSTALL
- PYTHONPATH: $CRAFT_PART_INSTALL/usr/lib/python3/dist-packages:$CRAFT_PART_INSTALL/usr/lib/python3.10/site-packages:$CRAFT_PART_INSTALL/usr/lib/python3.10:$CRAFT_PART_INSTALL/usr/lib/python3.10/lib-dynload
override-build: |
patch -p1 < $CRAFT_PROJECT_DIR/patch/patch-diskimage-builder-manifests-fix-chown.patch
python3 setup.py build
python3 setup.py install --prefix $CRAFT_PART_INSTALL/usr
# No need to run the dump plugins default build step
override-stage: |
find $CRAFT_PART_INSTALL -type f -print0 | xargs -0 sed -i '1 s/^#\!.*python$/#\!\/usr\/bin\/env python3/'
find $CRAFT_PART_INSTALL -type f -print0 | xargs -0 sed -i '1 s/^#\!.*python3$/#\!\/usr\/bin\/env python3/'
craftctl default
stage-packages:
- libpython3.10
- libpython3.10-minimal
- libpython3.10-stdlib
- python3-minimal
- python3.10-minimal
- python3-pip
- python3-setuptools
- python3-distutils
- python3-pkg-resources
- python3-py
- python3-babel
- python3-networkx
- python3-pbr
- python3-yaml
- python3-flake8
- python3-six
- python3-stevedore
qemu:
source: https://git.launchpad.net/ubuntu/+source/qemu
source-type: git
source-branch: ubuntu/jammy-updates
plugin: autotools
build-attributes:
- enable-patchelf
override-build: |
dpkg-source --before-build .
rm -rf build && mkdir build && cd build
../configure \
--extra-cflags='-g -O2 -fdebug-prefix-map=/home/ubuntu/qemu-2.11+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -DVENDOR_UBUNTU' \
--extra-ldflags='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed -Wl,-rpath=/snap/core22/current/lib/$CRAFT_ARCH_TRIPLET' \
--prefix=/snap/$CRAFT_PROJECT_NAME/current/usr \
--bindir=bin \
--libdir=lib/$CRAFT_ARCH_TRIPLET \
--libexecdir=lib/qemu \
--datadir=share/qemu \
--sysconfdir=/var/snap/$CRAFT_PROJECT_NAME/common \
--localstatedir=/var/snap/$CRAFT_PROJECT_NAME/common \
--interp-prefix=/var/snap/$CRAFT_PROJECT_NAME/common/etc/qemu-binfmt/%M \
--firmwarepath="/snap/$CRAFT_PROJECT_NAME/current/usr/share/qemu:/snap/$CRAFT_PROJECT_NAME/current/usr/share/seabios:/snap/$CRAFT_PROJECT_NAME/current/usr/lib/ipxe/qemu" \
--disable-blobs \
--disable-strip \
--disable-user \
--enable-modules \
--enable-linux-aio \
--enable-attr \
--enable-virtfs \
--enable-cap-ng \
--enable-curl \
--enable-fdt \
--enable-gnutls \
--disable-gtk \
--disable-vte \
--disable-sdl \
--disable-vnc \
--disable-vnc-sasl \
--disable-vnc-jpeg \
--disable-vnc-png \
--disable-spice \
--disable-curses \
--disable-xen \
--enable-seccomp \
--enable-xfsctl \
--enable-kvm \
--enable-vhost-net \
--target-list="aarch64-softmmu ppc64-softmmu riscv64-softmmu s390x-softmmu x86_64-softmmu" \
--with-git-submodules=ignore
make -j${CRAFT_PARALLEL_BUILD_COUNT}
make install DESTDIR=${CRAFT_PART_INSTALL}
override-prime: |
patchelf \
--force-rpath \
--set-rpath '$ORIGIN/../lib/$SNAPCRAFT_ARCH_TRIPLET:$ORIGIN/../../lib/$SNAPCRAFT_ARCH_TRIPLET:/snap/core22/current/lib/$SNAPCRAFT_ARCH_TRIPLET' \
$CRAFT_PART_INSTALL/usr/bin/qemu-img
patchelf \
--set-interpreter /snap/core22/current/lib/ld-linux-$(echo $SNAPCRAFT_ARCH_TRIPLET | cut -d'-' -f1 | sed s/_/-/g).so.1 \
$CRAFT_PART_INSTALL/usr/bin/qemu-img
# for ITEM in $(ls /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libpcre.so.3* /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libp11-kit.so.0* /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libidn2.so.0* /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libunistring.so.2* /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libtasn1.so.6* /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libnettle.so.8* /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libhogweed.so.6 libgmp.so.10* /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libffi.so.8*); do
# cp -P $ITEM usr/lib/$SNAPCRAFT_ARCH_TRIPLET/
# done
craftctl default
build-packages:
- patchelf
- libaio-dev
- acpica-tools
- libattr1-dev
- libcap-dev
- libcap-ng-dev
- libnuma-dev
- zlib1g-dev
- uuid-dev
- device-tree-compiler
- texinfo
- libfdt-dev
- gnutls-dev
- libseccomp-dev
- xfslibs-dev
- libcapstone-dev
- pkg-config
- libpixman-1-dev
- python-all-dev
- libglib2.0-dev
- glusterfs-common
- gnutls-dev
- libaio-dev
- libasound2-dev
- libbrlapi-dev
- libcacard-dev
- libcap-ng-dev
- libcurl4-gnutls-dev
- libdrm-dev
- libepoxy-dev
- libfdt-dev
- libffi-dev
- libfuse3-dev
- libgbm-dev
- libglusterfs-dev
- libgmp-dev
- libgtk-3-dev
- libibumad-dev
- libibverbs-dev
- libidn2-dev
- libiscsi-dev
- libjack-dev
- libjpeg-dev
- libncurses-dev
- libnuma-dev
- libp11-kit-dev
- libpcre2-dev
- libpixman-1-dev
- libpng-dev
- libpulse-dev
- librbd-dev
- librdmacm-dev
- libsasl2-dev
- libsdl2-dev
- libseccomp-dev
- libslirp-dev
- libssh-dev
- libudev-dev
- liburing-dev
- libunistring-dev
- libtasn1-6-dev
- libusb-1.0-0-dev
- libusbredirparser-dev
- libvirglrenderer-dev
- libvte-2.91-dev
- libzstd-dev
- meson
- nettle-dev
- ninja-build
- python3
- python3-sphinx
- python3-sphinx-rtd-theme
- texinfo
- uuid-dev
- xfslibs-dev
- zlib1g-dev
- device-tree-compiler
- fcode-utils
- xsltproc
- on amd64:
- libpmem-dev
- on arm64:
- libpmem-dev
- on ppc64el:
- libpmem-dev
stage-packages:
# Note that some stage-packages are omitted here because of collissions
# with libguestfs part.
- seabios
- ipxe-qemu
- libnuma1
- libaio1
- libcapstone4
- libfdt1
- libffi8
- libgmp10
- libhogweed6
- libidn2-0
- libnettle8
- libpixman-1-0
- libslang2
- libunistring2
- liburing2
- libp11-kit0
- libpcre3
- librdmacm1
- libpixman-1-0
- libcapstone4
- libfdt1
- libibverbs1
- libslirp0
- libtasn1-6
- qemu-system-data
- on amd64:
- libpmem1
- on arm64:
- libpmem1
- on ppc64el:
- libpmem1
organize:
snap/$CRAFT_PROJECT_NAME/current/: /
libguestfs:
after: [qemu]
source: https://git.launchpad.net/ubuntu/+source/libguestfs
source-type: git
source-tag: ubuntu/jammy
plugin: autotools
build-attributes:
- enable-patchelf
build-environment:
- PYTHON: /snap/$CRAFT_PROJECT_NAME/current/usr/bin/python3
- QEMU_CPU: "$(dpkg-architecture -qDEB_HOST_GNU_CPU | sed -r -e 's,i[456]86,i386,' -e 's,sparc.*,sparc64,' -e 's,powerpc(64.*)?,ppc64,' -e 's,arm.*,arm,')"
- QEMU: /snap/$CRAFT_PROJECT_NAME/current/usr/bin/qemu-system-$QEMU_CPU
override-build: |
rm -rf /snap/$CRAFT_PROJECT_NAME
mkdir -p /snap/$CRAFT_PROJECT_NAME
ln -sf $CRAFT_STAGE /snap/$CRAFT_PROJECT_NAME/current
if [ ! -d /snap/$CRAFT_PROJECT_NAME/current/bin ]; then
mkdir /snap/$CRAFT_PROJECT_NAME/current/bin
fi
dpkg-source --before-build .
if echo $CRAFT_TARGET_ARCH | grep -q ^arm; then
patch -p1 < $CRAFT_PROJECT_DIR/patch/patch-libguestfs-appliance-init-chrony.patch
fi
patch -p1 < $CRAFT_PROJECT_DIR/patch/patch-libguestfs-appliance-init-link-up.patch
autoreconf
craftctl default
rm -f /snap/$CRAFT_PROJECT_NAME/current
rmdir /snap/$CRAFT_PROJECT_NAME
override-prime: |
# appliance
mkdir -p usr/lib/$CRAFT_ARCH_TRIPLET/guestfs/appliance
mkdir -p /snap/$CRAFT_PROJECT_NAME
ln -sf $CRAFT_STAGE /snap/$CRAFT_PROJECT_NAME/current
env -i LIBGUESTFS_PATH=$CRAFT_STAGE/usr/lib/guestfs LD_LIBRARY_PATH=$CRAFT_STAGE/lib:$CRAFT_STAGE/lib/$CRAFT_ARCH_TRIPLET:$CRAFT_STAGE/usr/lib:$CRAFT_STAGE/usr/lib/$CRAFT_ARCH_TRIPLET PATH=$CRAFT_STAGE/usr/sbin:$CRAFT_STAGE/usr/bin:$CRAFT_STAGE/sbin:$CRAFT_STAGE/bin:/usr/sbin:/usr/bin:/sbin:/bin LIBGUESTFS_DEBUG=1 LIBGUESTFS_TRACE=1 libguestfs-make-fixed-appliance usr/lib/$CRAFT_ARCH_TRIPLET/guestfs/appliance
rm -f /snap/$CRAFT_PROJECT_NAME/current
rmdir /snap/$CRAFT_PROJECT_NAME
chmod 0644 usr/lib/$CRAFT_ARCH_TRIPLET/guestfs/appliance/kernel
ln -sf gawk usr/bin/awk
# perform snapcraft default prime steps
craftctl default
organize:
root/stage/: /
autotools-configure-parameters:
- --disable-silent-rules
- --disable-gnulib-tests
- --with-readline
- --disable-haskell
- --disable-java
- --disable-golang
- --disable-python
- --disable-perl
- --disable-php
- --disable-gobject
- --disable-lua
- --disable-erlang
- --disable-ruby
- --without-libvirt
- --with-extra-packages="chrony"
- --prefix=/usr
build-packages:
# The build process for the guestfs appliance involves copying binaries
# from packages installed on the build machine. As a consequence this
# part has many system management packages listed as build packages.
- genisoimage
- acl
- attr
- autoconf
- automake
- bash-completion
- binutils
- bison
- bsdextrautils
- bsdmainutils
- btrfs-progs
- bzip2
- cpio
- cryptsetup-bin
- curl
- db-util
- debootstrap
- default-jdk
- dh-lua
- dh-php
- dh-python
- dosfstools
- e2fsprogs
- exfatprogs
- f2fs-tools
- fdisk
- file
- flex
- libfuse2
- libfuse-dev
- gawk
- gdisk
- gem2deb
- gfs2-utils
- gjs
- gobject-introspection
- golang-go
- gperf
- hfsplus
- icoutils
- iproute2
- iputils-arping
- iputils-ping
- iputils-tracepath
- jfsutils
- kmod
- kpartx
- ldmtool
- less
- libacl1-dev
- libaugeas-dev
- libc-dev-bin
- libcap-dev
- libconfig-dev
- libdbus-1-dev
- libextutils-command-perl
- libgirepository1.0-dev
- libglib2.0-dev
- libgtk-3-dev
- libintl-perl
- libjs-jquery
- liblzma-dev
- libmagic-dev
- libmodule-build-perl
- libncurses5-dev
- libncursesw5-dev
- libpcre2-dev
- libreadline-dev
- librpm-dev
- libselinux1-dev
- libstring-shellquote-perl
- libsys-virt-perl
- libsystemd-dev
- libtest-pod-coverage-perl
- libtest-pod-perl
- libtool
- libtsk-dev
- libxml2-dev
- libxml2-utils
- libyajl-dev
- libhivex-dev
- python3-all-dev
- libjansson-dev
- libyara-dev
- lsof
- lsscsi
- lvm2
- lzop
- mdadm
- kmod
- mount
- mtools
- netpbm
- nilfs-tools
- openssh-client
- parted
- pciutils
- php-all-dev
- pkg-config
- po-debconf
- po4a
- procps
- psmisc
- python3-all-dev
- rake
- reiserfsprogs
- rsync
- scrub
- sleuthkit
- sqlite3
- squashfs-tools
- strace
- supermin
- systemd-sysv
- systemtap-sdt-dev
- udev
- uuid-runtime
- vim-tiny
- xfsprogs
- xorriso
- xz-utils
- zerofree
- libgettext-ocaml-dev
- libhivex-ocaml-dev
- libounit-ocaml-dev
- libvirt-ocaml-dev
- ocaml-findlib
- ocaml-nox
- chrony
- on amd64:
- linux-image-virtual
- syslinux
- extlinux
- on arm64:
- linux-image-virtual
- on ppc64el:
- linux-image-virtual
- on s390x:
- linux-image-virtual
stage-packages:
- genisoimage
- libmagic1
- uuid-runtime
- libjansson4
- libfuse2
- libfuse3-3
- fuse3
- libffi8
- libgmp10
- libhogweed6
- libidn2-0
- libnettle8
- libunistring2
- libp11-kit0
- libtasn1-6
stage:
- -lib64
guestfs-tools:
after: [libguestfs]
source: https://salsa.debian.org/libvirt-team/guestfs-tools.git
source-type: git
source-tag: debian/1.46.1-4
plugin: autotools
build-attributes:
- enable-patchelf
build-environment:
- OCAMLPATH: $CRAFT_STAGE/usr/lib/ocaml
- PYTHON: /snap/$CRAFT_PROJECT_NAME/current/usr/bin/python3
- QEMU_CPU: "$(dpkg-architecture -qDEB_HOST_GNU_CPU | sed -r -e 's,i[456]86,i386,' -e 's,sparc.*,sparc64,' -e 's,powerpc(64.*)?,ppc64,' -e 's,arm.*,arm,')"
- QEMU: /snap/$CRAFT_PROJECT_NAME/current/usr/bin/qemu-system-$QEMU_CPU
override-build: |
patch -p1 < $CRAFT_PROJECT_DIR/patch/patch-libguestfs-dib-feature-modify-image.patch
patch -p1 < $CRAFT_PROJECT_DIR/patch/disable-ocaml-warning-6-completely.patch
rm -rf /snap/$CRAFT_PROJECT_NAME
mkdir -p /snap/$CRAFT_PROJECT_NAME
ln -sf $CRAFT_STAGE /snap/$CRAFT_PROJECT_NAME/current
dpkg-source --before-build .
autoreconf
patch -p1 < $CRAFT_PROJECT_DIR/patch/patch-guestfs-tools-dib-fake-sudo-env.patch
craftctl default
rm -f /snap/$CRAFT_PROJECT_NAME/current
rmdir /snap/$CRAFT_PROJECT_NAME
autotools-configure-parameters:
- --disable-silent-rules
- --disable-gnulib-tests
- --with-readline
- --disable-haskell
- --disable-java
- --disable-golang
- --disable-python
- --disable-perl
- --disable-php
- --disable-gobject
- --disable-lua
- --disable-erlang
- --disable-ruby
- --without-libvirt
- --prefix=/usr
build-packages:
- bash-completion
- bison
- flex
- gettext
- guestfish
- ipxe-qemu
- libintl-perl
- libjansson-dev
- liblzma-dev
- libmodule-build-perl
- libpcre2-dev
- libtinfo-dev
- libxml2-dev
- libxml2-utils
- pkg-config
- po4a
- sqlite3
- xorriso
- xz-utils
stage-packages:
# For use by the virt-dib command. Diskimage-builder elements will be
# executing these tools while processing the image.
#
# These binaries are shipped with the base snap, but we can't use those
# because we need to do without the LD_LIBRARY_PATH. See full explanation
# in the `environment` section.
- bash
- coreutils
- tar
- gawk
- gzip
- findutils
- grep
- util-linux
- libicu70
- libxml2
- libc-bin
- lsb-release
- libpcre3