diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2020-05-09 18:18:34 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2020-05-11 21:40:28 +0900 |
commit | b3cab292feff48a59b2bf6e37d77176e0dade711 (patch) | |
tree | 04721b49e57faa415ac36fb026b378076f25a65e | |
parent | 62eee7be681c74c6b6aa679acac9d27bf1b871e9 (diff) | |
download | buildstream-b3cab292feff48a59b2bf6e37d77176e0dade711.tar.gz |
_ostree.py: Fix call to remote_gpg_import() again
Last time we fixed this, we actually only adjusted it to work with
the new API but stopped supporting the old API, which is still widely
in use (debian 9, debian 10 and ubuntu 18 all still use ostree v2019.1).
This time, lets add an except block here and fallback to the older
API if the new API raises a TypeError.
-rw-r--r-- | buildstream/_ostree.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/buildstream/_ostree.py b/buildstream/_ostree.py index a0c056293..c3c849322 100644 --- a/buildstream/_ostree.py +++ b/buildstream/_ostree.py @@ -271,6 +271,20 @@ def configure_remote(repo, remote, url, key_url=None): try: gfile = Gio.File.new_for_uri(key_url) stream = gfile.read() - repo.remote_gpg_import(remote, stream, None, None) + + # In ostree commit `v2019.2-10-gaa5df899`, the python + # facing API was changed by way of modifying the + # instrospection annotations. + # + # This means we need to call this API in two different + # ways depending on which ostree version is installed. + # + try: + # New API + repo.remote_gpg_import(remote, stream, None, None) + except TypeError: + # Old API + repo.remote_gpg_import(remote, stream, None, 0, None) + except GLib.GError as e: raise OSTreeError("Failed to add gpg key from url '{}': {}".format(key_url, e.message)) from e |