OSTree plugin fails with: `TypeError: OSTree.Repo.remote_gpg_import() takes exactly 5 arguments (6 given)`
Summary
OSTree/GObject seem to have changed and now cause BuildStream 1.4's OSTree plugin to fail when importing gpg keys.
Steps to reproduce
- Build any old project with an ostree source plugin
- Fail
What is the current bug behavior?
A BUG message as pasted below.
What is the expected correct behavior?
A nice and comfortable build
Relevant logs and/or screenshots
An unhandled exception occured:
Traceback (most recent call last):
File "/home/tlater/Documents/Work/buildstream/buildstream-1/buildstream/_scheduler/jobs/job.py", line 413, in _child_action
result = self.child_process()
File "/home/tlater/Documents/Work/buildstream/buildstream-1/buildstream/_scheduler/jobs/elementjob.py", line 94, in child_process
return self._action_cb(self._element)
File "/home/tlater/Documents/Work/buildstream/buildstream-1/buildstream/_scheduler/queues/fetchqueue.py", line 46, in process
source._fetch(previous_sources)
File "/home/tlater/Documents/Work/buildstream/buildstream-1/buildstream/source.py", line 695, in _fetch
self.__do_fetch()
File "/home/tlater/Documents/Work/buildstream/buildstream-1/buildstream/source.py", line 1014, in __do_fetch
self.fetch(**kwargs)
File "/home/tlater/Documents/Work/buildstream/buildstream-1/buildstream/plugins/sources/ostree.py", line 126, in fetch
remote_name = self.ensure_remote(self.url)
File "/home/tlater/Documents/Work/buildstream/buildstream-1/buildstream/plugins/sources/ostree.py", line 194, in ensure_remote
_ostree.configure_remote(self.repo, remote_name, url, key_url=gpg_key)
File "/home/tlater/Documents/Work/buildstream/buildstream-1/buildstream/_ostree.py", line 274, in configure_remote
repo.remote_gpg_import(remote, stream, None, 0, None)
TypeError: OSTree.Repo.remote_gpg_import() takes exactly 5 arguments (6 given)
Possible fixes
The following diff does the trick:
diff --git a/buildstream/_ostree.py b/buildstream/_ostree.py
index 5a4039f2..a0c05629 100644
--- a/buildstream/_ostree.py
+++ b/buildstream/_ostree.py
@@ -271,6 +271,6 @@ 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, 0, None)
+ repo.remote_gpg_import(remote, stream, None, None)
except GLib.GError as e:
raise OSTreeError("Failed to add gpg key from url '{}': {}".format(key_url, e.message)) from e
Unfortunately it isn't quite so simple, because this will probably break with old ostree/gobject combos. Having done some sleuthing, it seems like this function never changed on the OSTree side, so I suspect this is a GObject change, but I don't have the time to dig into this further right now.
Other relevant information
- BuildStream version affected: /milestone %BuildStream_v1.2 /milestone %BuildStream_v1.4 /milestone %BuildStream_v1.6