From e25675de04b42c55ce3d6a69c2f560b1a1bd25bd Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Thu, 20 Sep 2018 10:12:02 -0500 Subject: [PATCH] trivial: standalone: If missing flatpak dependencies, download them Most distros don't enable flathub by default, so enable it when running the tool if the deps are missing and pull the Gnome SDK from there. --- contrib/standalone-installer/assets/header.py | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/contrib/standalone-installer/assets/header.py b/contrib/standalone-installer/assets/header.py index e77e84941..c70ecc4a2 100644 --- a/contrib/standalone-installer/assets/header.py +++ b/contrib/standalone-installer/assets/header.py @@ -122,12 +122,43 @@ def install_flatpak (directory, verbose, uninstall): app = 'org.freedesktop.fwupd' common = '%s/.var/app/%s' % (os.getenv ('HOME'), app) - #check existing installed - cmd = ['flatpak', 'info', app] with open(os.devnull, 'w') as devnull: + if not verbose: + output = devnull + else: + output = None + #look for dependencies + dep = 'org.gnome.Platform/x86_64/3.28' + repo = 'flathub' + repo_url = 'https://flathub.org/repo/flathub.flatpakrepo' + cmd = ['flatpak', 'info', dep] if verbose: print(cmd) - ret = subprocess.run (cmd, stdout=devnull, stderr=devnull) + ret = subprocess.run (cmd, stdout=output, stderr=output) + #not installed + if ret.returncode != 0: + #look for remotes + cmd = ['flatpak', 'remote-info', repo, dep] + if verbose: + print(cmd) + ret = subprocess.run (cmd, stdout=output, stderr=output) + #not enabled, enable it + if ret.returncode != 0: + cmd = ['flatpak', 'remote-add', repo, repo_url] + if verbose: + print(cmd) + ret = subprocess.run (cmd, stderr=output) + # install dep + cmd = ['flatpak', 'install', repo, dep] + if verbose: + print(cmd) + ret = subprocess.run (cmd) + + #check existing installed + cmd = ['flatpak', 'info', app] + if verbose: + print(cmd) + ret = subprocess.run (cmd, stdout=output, stderr=output) if ret.returncode == 0: cmd = ['flatpak', 'remove', app] if verbose: