forked from canonical/pc-gadget
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsnapcraft.yaml
More file actions
97 lines (87 loc) · 3.3 KB
/
Copy pathsnapcraft.yaml
File metadata and controls
97 lines (87 loc) · 3.3 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
name: pc
version: '22-0.4'
type: gadget
base: core22
summary: PC gadget for generic devices
description: |
This gadget enables generic pc devices to work with Ubuntu Frame
confinement: strict
grade: stable
icon: icon.png
package-repositories:
- type: apt
ppa: ucdev/uc-staging-ppa
priority: always
hooks:
prepare-device:
environment:
# If you are forking and building your own gadget:
# define your model's API key here
# See https://ubuntu.com/core/services/guide/serial-vault-overview
# for instructions on how to generate an API key
# DO NOT check this API key into a publicly accessible VCS
MODEL_APIKEY: ""
# Min version to support shim 15.7 and min-size
assumes:
- snapd2.60.1
parts:
mbr:
source: legacy-bios
plugin: make
override-build: |
if [ "$CRAFT_TARGET_ARCH" != amd64 ]; then
exit
fi
craftctl default
boot-assets:
plugin: nil
build-packages:
- sbsigntool
stage-packages:
- grub-efi-$CRAFT_TARGET_ARCH-signed
- shim-signed
override-build: |
set -x
# Set some variables that depend on the architecture
grub_target=x86_64
grub_bin=grubx64.efi.signed
shim_bin=shimx64.efi.dualsigned
if [ "$CRAFT_TARGET_ARCH" = arm64 ]; then
grub_target=arm64
grub_bin=grubaa64.efi.signed
shim_bin=shimaa64.efi.dualsigned
fi
# Make sure we have signatures from the UC certificates
shim_path="$CRAFT_PART_INSTALL"/usr/lib/shim/$shim_bin
grub_path="$CRAFT_PART_INSTALL"/usr/lib/grub/"$grub_target"-efi-signed/$grub_bin
sbverify --list "$shim_path" | grep -E 'Canonical Ltd. Secure Boot Signing \(Ubuntu Core'
sbverify --list "$grub_path" | grep -E 'Canonical Ltd. Secure Boot Signing \(Ubuntu Core'
# Move shim/grub to the expected path
install -m 644 "$shim_path" "$CRAFT_PART_INSTALL"/shim.efi.signed
install -m 644 "$grub_path" "$CRAFT_PART_INSTALL"/${grub_bin%.signed}
# Remove all the bits we do not need, keeping changelogs and copyrights
# (using organize/prime is not possible due to different names per arch - x64/aa64)
find "$CRAFT_PART_INSTALL"/ -type f,l \
-not -path "$SNAPCRAFT_PART_INSTALL"/shim.efi.signed \
-not -path "$SNAPCRAFT_PART_INSTALL"/${grub_bin%.signed} \
-not -path "$SNAPCRAFT_PART_INSTALL"/usr/share/doc/grub-efi-$CRAFT_TARGET_ARCH-signed/'*' \
-and -not -path "$SNAPCRAFT_PART_INSTALL"/'usr/share/doc/shim-signed/*' \
-delete
find "$SNAPCRAFT_PART_INSTALL"/ -type d -empty -delete
# grub.conf lets snapd identify grub as the bootloader on boot
install -m 644 /dev/null "$CRAFT_PART_INSTALL"/grub.conf
gadget:
plugin: nil
source: gadget
override-build:
# We need to install directly in the project dir as snapcraft checks there
# for gadget.yaml instead of looking first at the prime folder.
install -m 644 gadget-"$CRAFT_TARGET_ARCH".yaml "$CRAFT_PROJECT_DIR"/gadget.yaml
# Dump contents of the `extra` folder into the snap
#
# cloud.conf and cmdline.extra are special:
# https://ubuntu.com/core/docs/gadget-snaps#heading--setup
# https://ubuntu.com/core/docs/modify-kernel-options#heading--cmdline
extra:
plugin: dump
source: extra