forked from erfanoabdi/rootfs-builder-debos-android9
-
Notifications
You must be signed in to change notification settings - Fork 0
/
systemimage-builder.yaml
167 lines (134 loc) · 4.86 KB
/
systemimage-builder.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
{{- $architecture := or .architecture "arm64" -}}
{{- $image := or .image "ubuntu-touch-system-image.img" -}}
{{- $device := or .device "device unset in systemimage-builder" -}}
{{- $channel := or .channel "channel unset in systemimage-builder" -}}
# Creates a prebuilt system-image capable image
# Looking at this recipe, you may be asking yourself "why is this even a debos
# recipe?"
# That is a very good question.
architecture: {{ $architecture }}
actions:
- action: run
description: Mount tmpfs as '/' as far as debos is concerned
command: mkdir mnt && mount -t tmpfs tmpfs mnt/
- action: image-partition
description: Creating image
imagename: {{ $image }}
imagesize: 14.6GiB
partitiontype: gpt
mountpoints:
- mountpoint: /cache
partition: cache
- mountpoint: /data
partition: userdata
partitions:
- name: loader
fs: none
start: 131072B
end: 2097K
- name: scr
fs: none
start: 2098K
end: 3146K
flags: [ legacy_boot ]
- name: persist
fs: ext2
start: 3147K
end: 11.5M
- name: boot_a
fs: none
start: 11.6M
end: 78.6M
- name: boot_b
fs: none
start: 78.7M
end: 146M
- name: recovery_a
fs: none
start: 146M
end: 213M
- name: recovery_b
fs: none
start: 213M
end: 280M
# Future second system partition
- name: cache
fs: ext2
start: 280M
end: 2840M
- name: system
fs: ext4
start: 2840M
end: 5400M
features:
- "^metadata_csum"
- name: userdata
fs: ext4
start: 5400M
end: 100%
features:
- "^metadata_csum"
- action: run
description: Manually set resolver in the container
chroot: false
command: mv /etc/resolv.conf /etc/resolv2.conf && echo "nameserver 8.8.8.8" > /etc/resolv.conf
- action: run
description: create directory to store ubuntu_command file and installable tarballs
chroot: false
command: mkdir mnt/cache/recovery/
- action: run
description: Fetches and prepares system image install
script: scripts/fetch-and-prepare-latest-ota.sh '{{ $channel }}' '{{ $device }}' 'mnt/cache/recovery/'
- action: run
description: extract device tarball partitions for writing
chroot: false
command: busybox unxz -c mnt/cache/recovery/device-*.tar.xz | tar -xC . partitions/ -f -
# filesystem is a predefined origin, $scratchdir/root. $filesystem/.. is
# $scratchdir, where we download files above.
# It's not pretty, but it works.
- action: raw
description: Install recovery partition
origin: filesystem
source: ../partitions/recovery.img
offset: 0
partition: recovery_a
- action: run
description: Mount needed partitions for preinstall
command: mkdir mnt/recovery && mkdir mnt/system && mount /dev/vda9 mnt/system && mount /dev/vda6 mnt/recovery
- action: run
description: Extract initramfs to new root
command: zcat mnt/recovery/initrd.img | cpio -idmvD mnt/
- action: run
description: Place a fake /proc/cmdline
command: mkdir mnt/proc && echo 'systempart=' > mnt/proc/cmdline
- action: run
description: Place a fake /proc/mounts
command: echo '/dev/vda10 /data nonsensestring' > mnt/proc/mounts
- action: run
description: Set up temporary root
command: mkdir mnt/sbin && mkdir -p mnt/usr/bin && mkdir mnt/dev && mount --bind /dev mnt/dev && chroot mnt/ /bin/busybox --install -s
- action: run
description: Place a fake mkfs.ext4
command: echo '#!/bin/sh\nmke2fs -t ext4 $@' > mnt/bin/mkfs.ext4 && chmod +x mnt/bin/mkfs.ext4
- action: run
description: Place a fake mount
command: rm mnt/bin/mount && echo '#!/bin/sh\nbusybox mount -t ext4 $@' > mnt/bin/mount && chmod +x mnt/bin/mount
- action: run
description: Place an fstab
command: echo '/dev/vda1 /loader none defaults \n/dev/vda2 /scr none defaults \n/dev/vda4 /boot ext2 defaults \n/dev/vda6 /recovery ext2 defaults \n/dev/vda9 /system ext4 defaults' > mnt/etc/recovery.fstab
- action: run
description: system-image installation
command: chroot mnt/ /bin/sh /system-image-upgrader /cache/recovery/ubuntu_command
- action: run
description: Unmount all filesystems
command: umount mnt/*; umount mnt/
- action: run
description: zerofill empty space on the system partition to reduce final size
command: zerofree -v `blkid --match-token PARTLABEL=system --output device`
- action: run
description: zerofill empty space on the cache partition to reduce final size
command: zerofree -v `blkid --match-token PARTLABEL=cache --output device`
- action: run
description: Create bmap file
postprocess: true
command: bmaptool create {{ $image }} > {{ $image }}.bmap