-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_raspberry_extras.sls
143 lines (116 loc) · 3.92 KB
/
build_raspberry_extras.sls
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
{# Raspberry PI Extras
- support for rasberry 4
- limited support for 3 and 5
- outputs
- raspberry/eeprom_rpi4
- eeprom update for rpi4
- raspberry/uboot
- uboot bios boot for rpi4
- raspberry/uefi_rpi[345]
- uefi bios boot for rpi[345]
#}
{% import_yaml "build_defaults.yml" as defaults %}
{% set settings=salt['grains.filter_by']({'default': defaults},
grain='default', default= 'default', merge= salt['pillar.get']('build', {})) %}
{% set tmp_dir= grains["tmp_dir"] %}
{% set download_dir= tmp_dir ~ "/download" %}
create_tmp_dir:
file.directory:
- name: {{ tmp_dir }}
- makedirs: True
create_download_dir:
file.directory:
- name: {{ download_dir }}
- makedirs: True
{# ### eeprom for rpi4 #}
{% set dest_dir = tmp_dir ~ "/eeprom_rpi4" %}
rpi_eeprom_rpi4_download:
file.managed:
- name: {{ download_dir ~ "/rpi-boot-eeprom-recovery-sd.zip" }}
- source: {{ settings.raspberry.eeprom_rpi4.fileurl.format(
VERSION=settings.raspberry.eeprom_rpi4.version) }}
- source_hash: {{ settings.raspberry.eeprom_rpi4.sha256sum }}
- makedirs: True
- require:
- file: create_download_dir
rpi_eeprom_rpi4_dir:
file.directory:
- name: {{ dest_dir }}
- makedirs: True
rpi_eeprom_rpi4_extracted:
archive.extracted:
- name: {{ dest_dir }}/build
- source: {{ download_dir ~ "/rpi-boot-eeprom-recovery-sd.zip" }}
- source_hash: {{ settings.raspberry.eeprom_rpi4.sha256sum }}
- extract_perms: False
- enforce_toplevel: False
- require:
- file: rpi_eeprom_rpi4_download
- file: rpi_eeprom_rpi4_dir
{# ### uboot bios for rpi4 #}
{% set dest_dir = tmp_dir ~ "/uboot" %}
rpi_fcos_uboot_download:
file.managed:
- name: {{ download_dir ~ "/uboot-images-armv8.rpm" }}
- source: {{ settings.raspberry.uboot.fileurl.format(
VERSION=settings.raspberry.uboot.version) }}
- source_hash: {{ settings.raspberry.uboot.sha256sum }}
- makedirs: True
- require:
- file: create_download_dir
rpi_fcos_uboot_extracted_dir:
file.directory:
- name: {{ download_dir ~ "/uboot_extracted" }}
- makedirs: True
rpi_fcos_uboot_extracted:
cmd.run:
- name: |
bsdtar -xf {{ download_dir ~ "/uboot-images-armv8.rpm" }} \
-C {{ download_dir ~ "/uboot_extracted" }} \
usr/share/uboot/rpi_arm64/u-boot.bin
- creates:
- {{ download_dir ~ "/uboot_extracted" }}/usr/share/uboot/rpi_arm64/u-boot.bin
- onchanges:
- file: rpi_fcos_uboot_download
- requires:
- file: rpi_fcos_uboot_download
- file: rpi_fcos_uboot_extracted_dir
rpi_fcos_uboot_dir:
file.directory:
- name: {{ dest_dir }}/boot/efi
- makedirs: True
rpi_fcos_uboot_copy_rpi4_bin:
file.copy:
- name: {{ dest_dir }}/boot/efi/u-boot.bin
- source: {{ download_dir ~ "/uboot_extracted" }}/usr/share/uboot/rpi_arm64/u-boot.bin
- force: true
- requires:
- file: rpi_fcos_uboot_dir
- file: rpi_fcos_uboot_extracted
{% endfor %}
{# ### uefi bios for rpi3, rpi4 and rpi5 #}
{% for uefi_rpi in ["uefi_rpi3", "uefi_rpi4", "uefi_rpi5"] %}
{% set dest_dir = tmp_dir ~ "/" ~ uefi_rpi %}
rpi_fcos_{{ uefi_rpi }}_dir:
file.directory:
- name: {{ dest_dir }}
- makedirs: True
rpi_fcos_{{ uefi_rpi }}_download:
file.managed:
- name: {{ download_dir ~ "/" ~ uefi_rpi ~ "_firmware.zip" }}
- source: {{ settings.raspberry[uefi_rpi].fileurl.format(
VERSION=settings.raspberry[uefi_rpi].version) }}
- source_hash: {{ settings.raspberry[uefi_rpi].sha256sum }}
- makedirs: True
- require:
- file: rpi_fcos_{{ uefi_rpi }}_dir
rpi_fcos_uefi_{{ uefi_rpi }}_extracted:
archive.extracted:
- name: {{ dest_dir }}
- source: {{ download_dir ~ "/" ~ uefi_rpi ~ "_firmware.zip" }}
- source_hash: {{ settings.raspberry[uefi_rpi].sha256sum }}
- extract_perms: False
- enforce_toplevel: False
- require:
- file: rpi_fcos_{{ uefi_rpi }}_download
{% endfor %}