Skip to content

Add flatpak remote support #1348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 3.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions pyinfra/operations/flatpak.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
@operation()
def packages(
packages: str | list[str] | None = None,
remote: str | None = None,
present=True,
):
"""
Install/remove a flatpak package

+ packages: List of packages
+ remote: Source to install the application or runtime from
+ present: whether the package should be installed

**Examples:**
Expand All @@ -30,6 +32,13 @@ def packages(
packages="org.videolan.VLC",
)

# Install vlc flatpak from flathub
flatpak.package(
name="Install vlc",
packages="org.videolan.VLC",
remote="flathub",
)

# Install multiple flatpaks
flatpak.package(
name="Install vlc and kodi",
Expand All @@ -55,6 +64,12 @@ def packages(
install_packages = []
remove_packages = []

if remote is None:
remote = ""
else:
# ensure we have a space between the remote and packages
remote = remote.strip() + " "

for package in packages:
# it's installed
if package in flatpak_packages:
Expand All @@ -73,7 +88,7 @@ def packages(
host.noop(f"flatpak package {package} is not installed")

if install_packages:
yield " ".join(["flatpak", "install", "--noninteractive"] + install_packages)
yield f"flatpak install --noninteractive {remote}{' '.join(install_packages)}"

if remove_packages:
yield " ".join(["flatpak", "uninstall", "--noninteractive"] + remove_packages)
yield f"flatpak uninstall --noninteractive {' '.join(remove_packages)}"