Change workflow scheduled time to more "random" minute
[platform/core/system/upgrade-tools.git] / README
1 # Tizen System Update
2
3 This repository was previously known as platorm/core/system/tota-upg,
4 the "Tizen OTA Upgrade Package Generator".  From Tizen 8.0 upgrade is
5 handled by platform/core/system/upgrade-tools repository.
6
7
8 Tizen System Update is the one of Tizen feature. This implements
9 the functionality of firmware update base on OTA mechanism.
10
11 * Notice of Limitations
12  This functionality does NOT support official signing & validation method.
13 This means it requires proper mechanism for binary validation offered by each
14 manufacturers.
15
16
17 ## Docker environment
18
19 OS Upgrade tools have a dedicated Docker environment image, which can be used
20 for local OS Upgrade image creation, as well as for CI.
21
22 The image can be either built by executing `docker-build.sh` script or by
23 pulling the image from BART registry.
24
25 ### Using BART registry (recommended)
26
27 The Docker image is built in
28 [`docker-build`](./.github/workflows/docker-build.yml) workflow in this
29 repository. It is stored in BART Docker registry as
30 `tizen-system-upgrade-tools-docker-local.bart.sec.samsung.net/upgrade-tools`.
31
32 For the default branch (`tizen`), an image with tag `latest` is generated. In
33 case a PR on GitHub is submitted, Docker image with tag name derived from the
34 git branch name is pushed to the registry in order to test the delta image
35 generation by the new image. For example, for a PR from branch `ghactions`,
36 there will be image called
37 `tizen-system-upgrade-tools-docker-local.bart.sec.samsung.net/upgrade-tools:ghactions`.
38
39 You can pull the image by executing the following commands:
40
41 ```shell
42 # Needs to be executed only once:
43 $ docker login tizen-system-upgrade-tools-docker-local.bart.sec.samsung.net
44 Username: <BART ID>
45 Password: <BART Identity Key>
46 Login Succeeded
47 $ docker pull tizen-system-upgrade-tools-docker-local.bart.sec.samsung.net/upgrade-tools:<Docker tag>
48 ```
49
50 - BART ID – username used as BART login.
51 - BART Identity Key – identity key for your account which can be generated
52   [here](https://bart.sec.samsung.net/ui/user_profile).
53 - Docker tag – `latest` for the default image, or PR-specific tag name.
54
55 ### Local image build
56
57 First, ensure that you have the latest Docker with BuildKit enabled (version 23
58 and above), as the image requires some extensions which were enabled recently.
59 It is advised to use the [official Docker
60 CE](https://docs.docker.com/engine/install/). It is not requried to have the
61 *Docker Desktop* – `docker-ce` package is enough. Distro-provided Docker package
62 may or may not work, and this setup is not directly supported. BuildKit is
63 enabled by default from version 23 of Docker Engine, but [can be explicitly
64 enabled](https://docs.docker.com/build/buildkit/#getting-started) for some
65 older versions.
66
67 By default, the FROM image is taken from the official Docker Hub (i.e.,
68 `library` namespace). If you want to source it from BART, export
69 `FROM_IMAGE_NAMESPACE=docker-remote.bart.sec.samsung.net` as environment
70 variable before executing the build script.
71
72 To build the Docker image locally, execute:
73
74 ```shell
75 $ ./docker-build.sh
76 ```
77
78 ### Delta generation in Docker environment
79
80 Save input tar.gz images in `images/old` and `images/new`. Once you have the
81 Docker image pulled or built, you can execute delta image generation in the
82 following manner:
83
84 ```shell
85 $ TARGET=rpi4
86 $ docker run --privileged=true \
87     -v $(pwd)/images/old:/tota-upg/mk_delta/$TARGET/data/old_tar:ro \
88     -v $(pwd)/images/new:/tota-upg/mk_delta/$TARGET/data/new_tar:ro \
89     -v $(pwd)/images/result:/tota-upg/mk_delta/$TARGET/result \
90     tizen-system-upgrade-tools-docker-local.bart.sec.samsung.net/upgrade-tools \
91     /tota-upg/scripts/delta-generation.sh /tota-upg/ $TARGET
92 ```
93
94 Generated delta images will be stored in `images/result`.
95
96
97 ## GitHub Actions
98
99 ### `mk_delta` action
100
101 `mk_delta` action creates delta OS Upgrade image for two sets of source images
102 (old and new), and stores the result on BART.
103
104 Before executing the delta script, the action checks if the delta needs to be
105 built – if input image checksums match with the previous build the delta image
106 is not built, thus reducing run time of the action (about 15 seconds for cache
107 check). This in turn allows to run the action frequently to check if new input
108 images are available.
109
110 Example use case of the action can be found in this repository in
111 [test-image-build](./.github/workflows/test-image-build.yml) workflow. For
112 external repositories this action should be referenced as
113 `srpol-syskern/upgrade-tools/mk_delta@tizen`.
114
115 **The action does the following things:**
116
117 1. Install JFrog tool – used for BART interaction.
118 2. Prepare environment – generate environment variables and pull cached input
119    checksums from BART.
120 3. Download source images:
121     1. Download `SHA256SUM` files if available.
122     2. Check if new images need to be generated – **if not, no additional steps
123        are executed**.
124     3. Download input tar.gz images.
125 4. Log in to Docker registry.
126 5. Generate delta image – execute `delta-generation.sh` script in Docker
127    environment.
128 6. Upload to artifactory:
129     1. Compress resulting tar archive to `.tar.gz`.
130     2. Upload delta archive to BART.
131     3. Upload input file SHA256 checksums.
132 7. Add GitHub PR comment with links to generated delta image.
133
134 The tool uploads two copies of the archive to `${{ inputs.output_repository
135 }}`/`${{ inputs.output_directory }}` directory. One has a deterministic name,
136 which can be inferred from the upgraded system filesystem, and the second has
137 some additional information and is uploaded to `archive` subdirectory:
138
139 - deterministic name: `${device_type}--${model_name}--${image_type}--${arch}--${tz_build_date}@${{ inputs.docker_image_tag }}.tar.gz`,
140 - archival name: `archive/${device_type}--${model_name}--${image_type}--${arch}--${build_string.txt}--${delta_timestamp}.tar.gz`.
141
142 **Variables:**
143
144 - `device_type`, `model_name`, `tz_build_date` – taken from `update-info.ini`
145   delta file.
146 - `image_type`:
147   - `all` contains delta of all sub-images,
148   - `platform` doesn't contain boot delta.
149 - `build_string.txt` – contents of `build_string.txt` delta file.
150 - `delta_timestamp` – delta build timestamp in format `%Y%m%d_%H%M%S`.
151 - `arch` – `${{ inputs.arch }}` for now, until `tz_build_arch` from
152   `update-info.ini` is fixed.
153
154 In addition to the main `.tar.gz` archive, a `.sha256sums` file containing input
155 file checksums is uploaded along the delta files, and in `action_checksums/${{
156 inputs.run_name }}` directory.
157
158 **Example file tree on BART after a successful run:**
159
160 - `${{ inputs.output_repository }}`/`${{ inputs.output_directory }}/`
161   - `IoT_Headless--rpi4--all--aarch64--20240124_061003@latest.tar.gz` –
162     resulting delta archive after latest run on the main branch (`tizen`).
163   - `IoT_Headless--rpi4--all--aarch64--20240124_061003@latest.tar.gz.sha256sums`
164     – SHA256 checksums of input files for the run above.
165   - `archive/`
166     - `IoT_Headless--rpi4--all--aarch64--20240124_061003@20240123_164559--20240124_121048.tar.gz`
167       – resulting delta archive after run executed on 2024-01-24 at 12:10:48
168       UTC.
169     - `IoT_Headless--rpi4--all--aarch64--20240124_061003@20240123_164559--20240124_121048.sha256sums`
170       – SHA256 checksums of input files for the run above.
171   - `action_checksums/${{ inputs.run_name }}/`
172     - `latest.sha256sums` – copy of
173     `IoT_Headless--rpi4--all--aarch64--20240124_061003@latest.tar.gz.sha256sums`
174     (used for cache check in cache check in the second step).
175
176 #### Action inputs
177
178 For default values of some inputs please refer to [the action
179 file](./mk_delta/action.yml).
180
181 **Docker image configuration:**
182
183 For regular run it is not required to change these, but it can be useful for
184 checking if new images work properly.
185
186 - `docker_image_registry` – Docker image registry used for the delta build.
187 - `docker_image_name` – Docker image used for the delta build.
188 - `docker_image_tag` – Docker image tag used for the delta build.
189
190 **Secrets (BART and GitHub):**
191
192 It is advised to use GitHub secrets to store the BART credentials. Example on
193 how to use them, refer to the
194 [test-image-build](./.github/workflows/test-image-build.yml) workflow. It is the
195 safest to create service account especially for CI purpose and store the secrets
196 in GitHub repository (not organization-wide). You can access GitHub secrets in
197 project *Settings → Secrets and variables*.
198
199 - `bart_id` – user ID used for BART authentication.
200 - `bart_key` – BART Identity Token which can be generated
201   [here](https://bart.sec.samsung.net/ui/user_profile).
202 - `github_token` – GitHub Token used for API access to fetch the job ID. Can be
203   passed from `${{ secrets.GITHUB_TOKEN }}`.
204
205 **Delta tool configuration:**
206
207 Input image URL can be either directory or `tar.gz` file. Mind that previous
208 build detection doesn't currently work for `tar.gz` variant – only for
209 directories with `SHA256SUMS` file (as on https://download.tizen.org).
210
211 For multiple images, separate them with newline, e.g.:
212
213 ```yaml
214 - name: Build delta images
215   uses: srpol-syskern/upgrade-tools/mk_delta@tizen
216   with:
217     old_images: |
218       https://download.tizen.org/snapshots/TIZEN/Tizen/Tizen-Unified/latest/images/standard/tizen-boot-arm64-rpi4/
219       https://download.tizen.org/snapshots/TIZEN/Tizen/Tizen-Unified/latest/images/standard/tizen-headless-aarch64/
220 ```
221
222 - `old_images` – Old image URLs.
223 - `new_images` – New image URLs.
224 - `arch` – Build architecture. Used for artifact naming.
225 - `target` – `delta-generation.sh` script target.
226 - `image_type` – Name of the image type for given input images.
227
228 **Output configuration:**
229
230 - `run_name` – Delta generation run name. Used in artifact path and messages.
231 - `output_repository` – Output BART repository.
232 - `output_directory` – Output directory in BART repository.
233 - `output_gzip_flags` – Flags given to gzip command used to compress the final
234   delta tar.
235
236 #### Action outputs
237
238 - `artifact_path_latest` – Path to result delta image artifact in BART
239   repository with `latest` tag.
240 - `artifact_path_archvie` – Path to result delta image artifact in BART
241   repository with deterministic path.
242
243
244 ### `mk_delta/summarize` action
245
246 `mk_delta/summarize` action processes job state and presents it in a concise
247 GitHub PR message.
248
249 Example use case of the action can be found in this repository in
250 [test-image-build](./.github/workflows/test-image-build.yml) workflow. For
251 external repositories this action should be referenced as
252 `srpol-syskern/upgrade-tools/mk_delta/summarize@tizen`.
253
254 #### Action inputs
255
256 **BART secrets:** Same as in `mk_delta` action.
257
258 **Output configuration:** `output_repository` and `output_directory` same as in `mk_delta` action.
259
260 #### Example output
261
262 > Here is the list of all jobs in run [8394854](https://github.sec.samsung.net/srpol-syskern/upgrade-tools/actions/runs/8394854):
263 > - [Tizen-7.0_Tizen-8.0_headed_rpi4_all_aarch64](https://github.sec.samsung.net/srpol-syskern/upgrade-tools/actions/runs/8394854/job/21478842): ✔️ You can find the delta image [here](https://bart.sec.samsung.net/ui/repos/tree/General/tizen-system-upgrade-tools-generic-local/tests/Tizen7_Unified/archive/IoT_Headed--rpi4--all--aarch64--20240205_160201@20240205_160245--20240205_171010.tar.gz) ([direct](https://bart.sec.samsung.net/artifactory/tizen-system-upgrade-tools-generic-local/tests/Tizen7_Unified/archive/IoT_Headed--rpi4--all--aarch64--20240205_160201@20240205_160245--20240205_171010.tar.gz)).
264 > - [Tizen-7.0_Tizen-8.0_headed_rpi4_all_armv7hl](https://github.sec.samsung.net/srpol-syskern/upgrade-tools/actions/runs/8394854/job/21478838): ✔️ Inputs are not different from the last run. Not generating deltas.
265 > - [Tizen-7.0_Tizen-8.0_headed_rpi4_all_armv7l](https://github.sec.samsung.net/srpol-syskern/upgrade-tools/actions/runs/8394854/job/21478840): ✔️ Inputs are not different from the last run. Not generating deltas.
266 > - [Tizen-7.0_Tizen-8.0_headed_rpi4_platform_aarch64](https://github.sec.samsung.net/srpol-syskern/upgrade-tools/actions/runs/8394854/job/21478845): ✔️ You can find the delta image [here](https://bart.sec.samsung.net/ui/repos/tree/General/tizen-system-upgrade-tools-generic-local/tests/Tizen7_Unified/archive/IoT_Headed----platform--aarch64--20240205_160201@20240205_160245--20240205_171104.tar.gz) ([direct](https://bart.sec.samsung.net/artifactory/tizen-system-upgrade-tools-generic-local/tests/Tizen7_Unified/archive/IoT_Headed----platform--aarch64--20240205_160201@20240205_160245--20240205_171104.tar.gz)).
267 > - [Tizen-7.0_Tizen-8.0_headed_rpi4_platform_armv7hl](https://github.sec.samsung.net/srpol-syskern/upgrade-tools/actions/runs/8394854/job/21478839): ✔️ Inputs are not different from the last run. Not generating deltas.
268 > - [Tizen-7.0_Tizen-8.0_headed_rpi4_platform_armv7l](https://github.sec.samsung.net/srpol-syskern/upgrade-tools/actions/runs/8394854/job/21478841): ✔️ Inputs are not different from the last run. Not generating deltas.
269 > - [Tizen-7.0_Tizen-8.0_headless_rpi4_all_aarch64](https://github.sec.samsung.net/srpol-syskern/upgrade-tools/actions/runs/8394854/job/21478848): ✔️ Inputs are not different from the last run. Not generating deltas.
270 > - [Tizen-7.0_Tizen-8.0_headless_rpi4_all_armv7l](https://github.sec.samsung.net/srpol-syskern/upgrade-tools/actions/runs/8394854/job/21478846): ✔️ Inputs are not different from the last run. Not generating deltas.
271 > - [Tizen-7.0_Tizen-8.0_headless_rpi4_platform_aarch64](https://github.sec.samsung.net/srpol-syskern/upgrade-tools/actions/runs/8394854/job/21478849): ✔️ Inputs are not different from the last run. Not generating deltas.
272 > - [Tizen-7.0_Tizen-8.0_headless_rpi4_platform_armv7l](https://github.sec.samsung.net/srpol-syskern/upgrade-tools/actions/runs/8394854/job/21478847): ✔️ You can find the delta image [here](https://bart.sec.samsung.net/ui/repos/tree/General/tizen-system-upgrade-tools-generic-local/tests/Tizen7_Unified/archive/IoT_Headless----platform--armv7l--20240205_155803@20240205_155843--20240205_165500.tar.gz) ([direct](https://bart.sec.samsung.net/artifactory/tizen-system-upgrade-tools-generic-local/tests/Tizen7_Unified/archive/IoT_Headless----platform--armv7l--20240205_155803@20240205_155843--20240205_165500.tar.gz)).
273 > - [Tizen-8.0_Tizen_headed_rpi4_all_aarch64](https://github.sec.samsung.net/srpol-syskern/upgrade-tools/actions/runs/8394854/job/21478855): ✔️ You can find the delta image [here](https://bart.sec.samsung.net/ui/repos/tree/General/tizen-system-upgrade-tools-generic-local/tests/Tizen8.0_Unified/archive/IoT_Headed--rpi4--all--aarch64--20240205_160245@20240205_161650--20240205_170156.tar.gz) ([direct](https://bart.sec.samsung.net/artifactory/tizen-system-upgrade-tools-generic-local/tests/Tizen8.0_Unified/archive/IoT_Headed--rpi4--all--aarch64--20240205_160245@20240205_161650--20240205_170156.tar.gz)).
274 > - [Tizen-8.0_Tizen_headed_rpi4_all_armv7hl](https://github.sec.samsung.net/srpol-syskern/upgrade-tools/actions/runs/8394854/job/21478850): ✔️ You can find the delta image [here](https://bart.sec.samsung.net/ui/repos/tree/General/tizen-system-upgrade-tools-generic-local/tests/Tizen8.0_Unified/archive/IoT_Headed--rpi4--all--armv7hl--20240205_160219@20240205_161637--20240205_165902.tar.gz) ([direct](https://bart.sec.samsung.net/artifactory/tizen-system-upgrade-tools-generic-local/tests/Tizen8.0_Unified/archive/IoT_Headed--rpi4--all--armv7hl--20240205_160219@20240205_161637--20240205_165902.tar.gz)).
275 > - [Tizen-8.0_Tizen_headed_rpi4_all_armv7l](https://github.sec.samsung.net/srpol-syskern/upgrade-tools/actions/runs/8394854/job/21478853): ✔️ You can find the delta image [here](https://bart.sec.samsung.net/ui/repos/tree/General/tizen-system-upgrade-tools-generic-local/tests/Tizen8.0_Unified/archive/IoT_Headed--rpi4--all--armv7l--20240205_160233@20240205_161647--20240205_165952.tar.gz) ([direct](https://bart.sec.samsung.net/artifactory/tizen-system-upgrade-tools-generic-local/tests/Tizen8.0_Unified/archive/IoT_Headed--rpi4--all--armv7l--20240205_160233@20240205_161647--20240205_165952.tar.gz)).
276 > - [Tizen-8.0_Tizen_headed_rpi4_platform_aarch64](https://github.sec.samsung.net/srpol-syskern/upgrade-tools/actions/runs/8394854/job/21478856): ✔️ You can find the delta image [here](https://bart.sec.samsung.net/ui/repos/tree/General/tizen-system-upgrade-tools-generic-local/tests/Tizen8.0_Unified/archive/IoT_Headed----platform--aarch64--20240205_160245@20240205_161650--20240205_170306.tar.gz) ([direct](https://bart.sec.samsung.net/artifactory/tizen-system-upgrade-tools-generic-local/tests/Tizen8.0_Unified/archive/IoT_Headed----platform--aarch64--20240205_160245@20240205_161650--20240205_170306.tar.gz)).
277 > - [Tizen-8.0_Tizen_headed_rpi4_platform_armv7hl](https://github.sec.samsung.net/srpol-syskern/upgrade-tools/actions/runs/8394854/job/21478851): ✔️ You can find the delta image [here](https://bart.sec.samsung.net/ui/repos/tree/General/tizen-system-upgrade-tools-generic-local/tests/Tizen8.0_Unified/archive/IoT_Headed----platform--armv7hl--20240205_160219@20240205_161637--20240205_170102.tar.gz) ([direct](https://bart.sec.samsung.net/artifactory/tizen-system-upgrade-tools-generic-local/tests/Tizen8.0_Unified/archive/IoT_Headed----platform--armv7hl--20240205_160219@20240205_161637--20240205_170102.tar.gz)).
278 > - [Tizen-8.0_Tizen_headed_rpi4_platform_armv7l](https://github.sec.samsung.net/srpol-syskern/upgrade-tools/actions/runs/8394854/job/21478854): ✔️ You can find the delta image [here](https://bart.sec.samsung.net/ui/repos/tree/General/tizen-system-upgrade-tools-generic-local/tests/Tizen8.0_Unified/archive/IoT_Headed----platform--armv7l--20240205_160233@20240205_161647--20240205_165955.tar.gz) ([direct](https://bart.sec.samsung.net/artifactory/tizen-system-upgrade-tools-generic-local/tests/Tizen8.0_Unified/archive/IoT_Headed----platform--armv7l--20240205_160233@20240205_161647--20240205_165955.tar.gz)).
279 > - [Tizen-8.0_Tizen_headless_rpi4_all_aarch64](https://github.sec.samsung.net/srpol-syskern/upgrade-tools/actions/runs/8394854/job/21478859): ✔️ You can find the delta image [here](https://bart.sec.samsung.net/ui/repos/tree/General/tizen-system-upgrade-tools-generic-local/tests/Tizen8.0_Unified/archive/IoT_Headless--rpi4--all--aarch64--20240205_155854@20240205_161251--20240205_165319.tar.gz) ([direct](https://bart.sec.samsung.net/artifactory/tizen-system-upgrade-tools-generic-local/tests/Tizen8.0_Unified/archive/IoT_Headless--rpi4--all--aarch64--20240205_155854@20240205_161251--20240205_165319.tar.gz)).
280 > - [Tizen-8.0_Tizen_headless_rpi4_all_armv7l](https://github.sec.samsung.net/srpol-syskern/upgrade-tools/actions/runs/8394854/job/21478857): ✔️ You can find the delta image [here](https://bart.sec.samsung.net/ui/repos/tree/General/tizen-system-upgrade-tools-generic-local/tests/Tizen8.0_Unified/archive/IoT_Headless--rpi4--all--armv7l--20240205_155843@20240205_161300--20240205_165430.tar.gz) ([direct](https://bart.sec.samsung.net/artifactory/tizen-system-upgrade-tools-generic-local/tests/Tizen8.0_Unified/archive/IoT_Headless--rpi4--all--armv7l--20240205_155843@20240205_161300--20240205_165430.tar.gz)).
281 > - [Tizen-8.0_Tizen_headless_rpi4_platform_aarch64](https://github.sec.samsung.net/srpol-syskern/upgrade-tools/actions/runs/8394854/job/21478860): ✔️ You can find the delta image [here](https://bart.sec.samsung.net/ui/repos/tree/General/tizen-system-upgrade-tools-generic-local/tests/Tizen8.0_Unified/archive/IoT_Headless----platform--aarch64--20240205_155854@20240205_161251--20240205_165319.tar.gz) ([direct](https://bart.sec.samsung.net/artifactory/tizen-system-upgrade-tools-generic-local/tests/Tizen8.0_Unified/archive/IoT_Headless----platform--aarch64--20240205_155854@20240205_161251--20240205_165319.tar.gz)).
282 > - [Tizen-8.0_Tizen_headless_rpi4_platform_armv7l](https://github.sec.samsung.net/srpol-syskern/upgrade-tools/actions/runs/8394854/job/21478858): ✔️ You can find the delta image [here](https://bart.sec.samsung.net/ui/repos/tree/General/tizen-system-upgrade-tools-generic-local/tests/Tizen8.0_Unified/archive/IoT_Headless----platform--armv7l--20240205_155843@20240205_161300--20240205_165224.tar.gz) ([direct](https://bart.sec.samsung.net/artifactory/tizen-system-upgrade-tools-generic-local/tests/Tizen8.0_Unified/archive/IoT_Headless----platform--armv7l--20240205_155843@20240205_161300--20240205_165224.tar.gz)).