Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

Commit

Permalink
feat: sanity check Flathub's existence on all systems and all users
Browse files Browse the repository at this point in the history
This is super important. Without these checks, the system can end up in a broken state where certain users or even the system itself lacks the "flathub" remote, which then breaks yafti's ability to install software, and also breaks consistency between multi-user accounts.

Before these fixes, we only installed "flathub" for the current user on multi-user systems, and then never again, since our installation of Flathub was dependent on the removal of Fedora's own repositories, and never happened again after that.

We now sanity-check both the system and the user-account on every yafti run.

If someone doesn't want "flathub" at the user-level, they're welcome to make their own image which removes that check. But as a "starting point" template, we should strive to provide a robust example that the largest amount of people will be happy with, which means ensuring that Flathub exists for all users on the system!

Most people run a single-user system, and will never even see these screens, since they'll see the initial screen which removes Fedora's repos and takes care of adding Flathub at the same time. These "system repair" screens will only be seen by people on multi-user systems or on various messed up systems.

PS: The strange "run" condition is required since yafti demands that the return code of a command should be "0" to show a conditional screen, but "grep" by itself returns "1" when nothing matches. Negation operators such as `!` don't work in the run-conditions either, so this workaround does the job perfectly instead. It robustly checks for the exact number "0", meaning that the Flathub remote wasn't found.
  • Loading branch information
Arcitec authored and xynydev committed May 14, 2023
1 parent 475a3c9 commit aa157c2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions usr/share/ublue-os/firstboot/yafti.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@ screens:
- run: flatpak remove --system --noninteractive --all
- run: flatpak remote-add --if-not-exists --system flathub https://flathub.org/repo/flathub.flatpakrepo
- run: flatpak remote-add --if-not-exists --user flathub https://flathub.org/repo/flathub.flatpakrepo
check-system-flathub:
source: yafti.screen.consent
values:
title: Missing Flathub Repository (System)
condition:
run: flatpak remotes --system --columns=name | grep flathub | wc -l | grep '^0$'
description: |
We have detected that you don't have Flathub's repository on your system. We will now add that repository to your system-wide list.
actions:
- run: flatpak remote-add --if-not-exists --system flathub https://flathub.org/repo/flathub.flatpakrepo
check-user-flathub:
source: yafti.screen.consent
values:
title: Missing Flathub Repository (User)
condition:
run: flatpak remotes --user --columns=name | grep flathub | wc -l | grep '^0$'
description: |
We have detected that you don't have Flathub's repository on your current user account. We will now add that repository to your account.
actions:
- run: flatpak remote-add --if-not-exists --user flathub https://flathub.org/repo/flathub.flatpakrepo
applications:
source: yafti.screen.package
values:
Expand Down

0 comments on commit aa157c2

Please sign in to comment.