Andrew Geissler | 0ec686b | 2019-01-18 10:01:53 -0600 | [diff] [blame] | 1 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" |
Tom Joseph | 6c09f7a | 2018-09-24 07:34:14 -0500 | [diff] [blame] | 2 | |
| 3 | # Calculate the auxiliary firmware revision to be updated in the dev_id.json |
| 4 | # file. It is calculated from the VERSION_ID field which currently has two |
| 5 | # formats. The revision field is 4 bytes, the first two bytes represent the |
| 6 | # count of commits from the tagging and next two bytes represent the version. |
| 7 | # Both fields are represented in BCD encoded format, so 9999 is the maximum |
| 8 | # value both fields can take. With the format "v2.1-216-ga78ace8", Petitboot |
| 9 | # would display the firmware revision as "Firmware version: 2.01.02160000", |
| 10 | # "0216" is count and the revision is "0000". With the format |
| 11 | # "ibm-v2.0-10-r41-0-gd0c319e" Petitboot would display the firmware revision |
| 12 | # as "Firmware version: 2.00.00100041", "0010" is count and the revision |
| 13 | # is "0041". |
| 14 | inherit image_version |
| 15 | |
| 16 | unset do_patch[noexec] |
| 17 | do_patch[depends] = "os-release:do_populate_sysroot" |
| 18 | |
Brad Bishop | a29c2d5 | 2019-07-17 17:35:55 -0400 | [diff] [blame] | 19 | python do_patch_ibm-ac-server() { |
Tom Joseph | 6c09f7a | 2018-09-24 07:34:14 -0500 | [diff] [blame] | 20 | import json |
| 21 | import re |
| 22 | from shutil import copyfile |
| 23 | version_id = do_get_version(d) |
| 24 | |
Adriana Kobylak | 49054bc | 2021-01-14 15:37:48 -0600 | [diff] [blame] | 25 | # count from the commit version, minimum of one digit |
Tom Joseph | 6c09f7a | 2018-09-24 07:34:14 -0500 | [diff] [blame] | 26 | count = re.findall("-(\d{1,4})-", version_id) |
Adriana Kobylak | 49054bc | 2021-01-14 15:37:48 -0600 | [diff] [blame] | 27 | if count: |
| 28 | commit = count[0] |
| 29 | else: |
| 30 | commit = "0" |
Tom Joseph | 6c09f7a | 2018-09-24 07:34:14 -0500 | [diff] [blame] | 31 | |
| 32 | release = re.findall("-r(\d{1,4})", version_id) |
| 33 | if release: |
Adriana Kobylak | 49054bc | 2021-01-14 15:37:48 -0600 | [diff] [blame] | 34 | auxVer = commit + "{0:0>4}".format(release[0]) |
Tom Joseph | 6c09f7a | 2018-09-24 07:34:14 -0500 | [diff] [blame] | 35 | else: |
Adriana Kobylak | 49054bc | 2021-01-14 15:37:48 -0600 | [diff] [blame] | 36 | auxVer = commit + "0000" |
Tom Joseph | 6c09f7a | 2018-09-24 07:34:14 -0500 | [diff] [blame] | 37 | |
| 38 | workdir = d.getVar('WORKDIR', True) |
| 39 | file = os.path.join(workdir, 'dev_id.json') |
| 40 | |
| 41 | # Update dev_id.json with the auxiliary firmware revision |
| 42 | with open(file, "r+") as jsonFile: |
| 43 | data = json.load(jsonFile) |
| 44 | jsonFile.seek(0) |
| 45 | jsonFile.truncate() |
| 46 | data["aux"] = int(auxVer, 16) |
| 47 | json.dump(data, jsonFile) |
| 48 | } |