diff options
Diffstat (limited to 'recipes-sota/aktualizr/garage-sign-version.inc')
| -rw-r--r-- | recipes-sota/aktualizr/garage-sign-version.inc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/recipes-sota/aktualizr/garage-sign-version.inc b/recipes-sota/aktualizr/garage-sign-version.inc new file mode 100644 index 0000000..66e3ffd --- /dev/null +++ b/recipes-sota/aktualizr/garage-sign-version.inc | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | |||
| 2 | python () { | ||
| 3 | if d.getVar("GARAGE_SIGN_VERSION", True) or not d.getVar("SOTA_PACKED_CREDENTIALS", True): | ||
| 4 | return | ||
| 5 | import json | ||
| 6 | import urllib.request | ||
| 7 | import zipfile | ||
| 8 | with zipfile.ZipFile(d.getVar("SOTA_PACKED_CREDENTIALS", True), 'r') as zip_ref: | ||
| 9 | try: | ||
| 10 | with zip_ref.open('tufrepo.url', mode='r') as url_file: | ||
| 11 | url = url_file.read().decode() + '/health/version' | ||
| 12 | except (KeyError, ValueError, RuntimeError): | ||
| 13 | return | ||
| 14 | r = urllib.request.urlopen(url) | ||
| 15 | if r.code != 200: | ||
| 16 | return | ||
| 17 | resp = r.read().decode('utf-8') | ||
| 18 | j = json.loads(resp) | ||
| 19 | version = 'cli-' + j['version'] + '.tgz' | ||
| 20 | d.setVar("GARAGE_SIGN_VERSION", version) | ||
| 21 | } | ||
| 22 | |||
| 23 | # vim:set ts=4 sw=4 sts=4 expandtab: | ||
