Skip to content

Commit b1b49de

Browse files
committed
Add flatpak update plugin for system-wide flatpaks
improves: QubesOS/qubes-issues#2766 requires: QubesOS/qubes-core-agent-linux#604
1 parent b479add commit b1b49de

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# coding=utf-8
2+
#
3+
# The Qubes OS Project, http://www.qubes-os.org
4+
#
5+
# Copyright (C) 2025 Ali Mirjamali <[email protected]>
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License
9+
# as published by the Free Software Foundation; either version 2
10+
# of the License, or (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program; if not, write to the Free Software
19+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20+
# USA.
21+
22+
import subprocess
23+
24+
from pathlib import Path
25+
26+
def flatpak_updater(os_data, log, **kwargs):
27+
"""
28+
Distro agnostic plugin to update system-wide flatpaks
29+
"""
30+
31+
if not Path("/usr/bin/flatpak"):
32+
return
33+
34+
log.info("Flatpak is installed. Checking for flatpak updates.")
35+
proc = subprocess.Popen(
36+
["flatpak", "remotes", "--columns", "name"],
37+
stdout=subprocess.PIPE
38+
)
39+
flatpak_updates_available = False
40+
for remote in proc.stdout.read().decode().strip().split("\n"):
41+
if subprocess.Popen(
42+
["flatpak", "remote-ls", remote, "--system", "--updates"],
43+
stdout=subprocess.PIPE
44+
).stdout.read().decode().strip():
45+
flatpak_updates_available = True
46+
break
47+
if not flatpak_updates_available:
48+
log.info("No flatpak updates found.")
49+
return
50+
51+
log.info("Flatpak updates found. Updating flatpaks...")
52+
subprocess.run(
53+
["flatpak", "update", "--noninteractive", "-y"]
54+
)

0 commit comments

Comments
 (0)