Commit e46328a5 authored by Alexandru Băluț's avatar Alexandru Băluț Committed by Thibault Saunier

flatpak: Pass only the flatpakrepo URL for remotes

Clarifies a bit what the add() method does.
parent 3b845509
Pipeline #10022 failed with stage
in 2 minutes and 26 seconds
......@@ -194,14 +194,16 @@ class FlatpakRepos(FlatpakObject):
def __init__(self, user=True):
FlatpakObject.__init__(self, user=user)
# The remote repositories, name -> FlatpakRepo
self.repos = {}
def update(self):
self.repos = {}
repo_defs = [rd for rd in
self.flatpak("remote-list", "-d").split("\n") if rd]
for repo in repo_defs:
remotes = [row
for row in self.flatpak("remote-list", "-d").split("\n")
if row]
for repo in remotes:
for components in [repo.split(" "), repo.split("\t")]:
if len(components) == 1:
components = repo.split("\t")
......@@ -227,65 +229,55 @@ class FlatpakRepos(FlatpakObject):
Console.message("No valid URI found for: %s", repo)
self.repos[name] = FlatpakRepo(name, desc, url, repos=self)
self.repos[name] = FlatpakRepo(name, url, desc, repos=self)
self.packages = FlatpakPackages(self)
def add(self, repo, override=True):
def add(self, name, flatpakrepo_url, override=True):
flatpakrepo = tempfile.NamedTemporaryFile(mode="w")
repo = configparser.ConfigParser()
url = repo["Flatpak Repo"]["Url"]
same_name = None
for name, tmprepo in self.repos.items():
if repo.url == tmprepo.url:
for tmpname, tmprepo in self.repos.items():
if url == tmprepo.url:
return tmprepo
if == name:
if name == tmpname:
same_name = tmprepo
if same_name:
Console.message("Flatpak remote with the same name already exists: %s", same_name)
if not override:
Console.message("%sNote the URL is %s, not %s%s",
Colors.WARNING, same_name.url, url, Colors.ENDC)
return None
self.flatpak("remote-modify",, "--url=" + repo.url,
Console.message("The URL is different. Overriding.")
self.flatpak("remote-modify", name, "--url=" + url,
comment="Setting repo %s URL from %s to %s"
% (, same_name.url, repo.url))
same_name.url = repo.url
% (name, same_name.url, url))
same_name.url = url
return same_name
self.flatpak("remote-add", "--if-not-exists",, "--from",,
comment="Adding repo %s" %
repo.repos = self
return repo
self.flatpak("remote-add", "--if-not-exists", name,
"--from", flatpakrepo_url,
comment="Adding repo %s" % name)
return self.repos[name]
class FlatpakRepo(FlatpakObject): # pylint: disable=too-few-public-methods
def __init__(self, name, desc=None, url=None, # pylint: disable=too-many-arguments
repo_file=None, user=True, repos=None):
def __init__(self, name, url, desc=None, user=True, repos=None): # pylint: disable=too-many-arguments
FlatpakObject.__init__(self, user=user) = name
self.url = url
assert name
self.desc = desc
self.repo_file_name = repo_file
self._repo_file = None
self.repos = repos
assert name
if repo_file and not url:
repo = configparser.ConfigParser()
self.url = repo["Flatpak Repo"]["Url"]
assert url
def repo_file(self):
if self._repo_file:
return self._repo_file
assert self.repo_file_name
self._repo_file = tempfile.NamedTemporaryFile(mode="w")
return self._repo_file
self.url = url
class FlatpakPackage(FlatpakObject):
......@@ -417,10 +409,8 @@ class PitiviFlatpak: # pylint: disable=too-many-instance-attributes
repos = FlatpakRepos()
self.sdk_repo = repos.add(
self.sdk_repo = repos.add("gnome",
sdk_branch = SDK_BRANCH[self.branch]
self.runtime = FlatpakPackage(
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment