diff options
Diffstat (limited to 'recipes-sota/aktualizr/garage-sign-version.inc')
| -rw-r--r-- | recipes-sota/aktualizr/garage-sign-version.inc | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/recipes-sota/aktualizr/garage-sign-version.inc b/recipes-sota/aktualizr/garage-sign-version.inc deleted file mode 100644 index 2cea6c9..0000000 --- a/recipes-sota/aktualizr/garage-sign-version.inc +++ /dev/null | |||
| @@ -1,36 +0,0 @@ | |||
| 1 | |||
| 2 | python () { | ||
| 3 | if d.getVar("GARAGE_SIGN_VERSION") or not d.getVar("SOTA_PACKED_CREDENTIALS"): | ||
| 4 | return | ||
| 5 | import json | ||
| 6 | import urllib.request | ||
| 7 | import zipfile | ||
| 8 | with zipfile.ZipFile(d.getVar("SOTA_PACKED_CREDENTIALS"), 'r') as zip_ref: | ||
| 9 | try: | ||
| 10 | with zip_ref.open('tufrepo.url', mode='r') as url_file: | ||
| 11 | url = url_file.read().decode().strip(' \t\n') + '/health/version' | ||
| 12 | except (KeyError, ValueError, RuntimeError): | ||
| 13 | return | ||
| 14 | connected = False | ||
| 15 | tries = 3 | ||
| 16 | for i in range(tries): | ||
| 17 | try: | ||
| 18 | r = urllib.request.urlopen(url) | ||
| 19 | if r.code == 200: | ||
| 20 | connected = True | ||
| 21 | break | ||
| 22 | else: | ||
| 23 | print('Bad return code from server ' + url + ': ' + str(r.code) + | ||
| 24 | ' (attempt ' + str(i + 1) + ' of ' + str(tries) + ')') | ||
| 25 | except urllib.error.URLError as e: | ||
| 26 | print('Error connecting to server ' + url + ': ' + str(e) + | ||
| 27 | ' (attempt ' + str(i + 1) + ' of ' + str(tries) + ')') | ||
| 28 | if not connected: | ||
| 29 | return | ||
| 30 | resp = r.read().decode('utf-8') | ||
| 31 | j = json.loads(resp) | ||
| 32 | version = 'cli-' + j['version'] + '.tgz' | ||
| 33 | d.setVar("GARAGE_SIGN_VERSION", version) | ||
| 34 | } | ||
| 35 | |||
| 36 | # vim:set ts=4 sw=4 sts=4 expandtab: | ||
