feat(default-flatpaks): Better handle multiple uses of module (#74)
* fix(default-flatpaks): Always enable systemd services Ensures that the module always removes Fedora Flatpaks, even if a system-wide flatpak remote isn't configured for the module. * chore(default-flatpaks): Add output for result of repo config * fix(default-flatpaks): Better handle multiple uses of module * chore(default-flatpaks): Add label to output of existing config * docs(default-flatpaks): Mention that Flatpak remote can be re-configured * docs(default-flatpaks): Add second example to README * docs(default-flatpaks): Clarify repo config in second example
This commit is contained in:
parent
30ecc4cefd
commit
f0c0192e10
2 changed files with 69 additions and 22 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# `default-flatpaks` module for startingpoint
|
||||
|
||||
The `default-flatpaks` module can be used to install flatpaks from a configurable remote on first boot. This module first removes the Fedora Flatpaks remote and Flatpaks that come pre-installed in Fedora. A Flatpak remote is configured the first time the module is used, and subsequent usages of the module will install flatpaks to the same remote. If no Flatpak remote is specified, the module will default to using Flathub.
|
||||
The `default-flatpaks` module can be used to install flatpaks from a configurable remote on first boot. This module first removes the Fedora Flatpaks remote and Flatpaks that come pre-installed in Fedora. A Flatpak remote is configured the first time the module is used, but it can be re-configured in subsequent usages of the module. If no Flatpak remote is specified, the module will default to using Flathub.
|
||||
|
||||
Flatpaks can either be installed system-wide or per-user, though per-user flatpaks will be installed for every user on a system. Previously-installed flatpaks can also be removed.
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ Flatpak setup can be run again by removing `/etc/ublue-os/system-flatpak-configu
|
|||
|
||||
This module stores the Flatpak remote configuration and Flatpak install/remove lists in `/etc/flatpak/`. There are two subdirectories, `user` and `system` corresponding with the install level of the Flatpaks and repositories. Each directory has text files containing the IDs of flatpaks to `install` and `remove`, plus a `repo-info.yml` containing the details of the Flatpak repository.
|
||||
|
||||
## Example configuration
|
||||
## Example configurations
|
||||
|
||||
```yaml
|
||||
type: default-flatpaks
|
||||
|
|
@ -38,3 +38,18 @@ system:
|
|||
user:
|
||||
repo-name: flathub
|
||||
```
|
||||
|
||||
```yaml
|
||||
# Assuming that the above example is called first in a recipe,
|
||||
# a subsequent usage might look like this:
|
||||
type: default-flatpaks
|
||||
system:
|
||||
# If the repo-* fields are omitted, the configured repo will
|
||||
# use the previous configuration. Otherwise, it defaults to Flathub.
|
||||
install:
|
||||
- org.kde.kdenlive
|
||||
user:
|
||||
# repo-name will overwrite the previously-configured repo-name for the user remote
|
||||
repo-name: flathub-user
|
||||
repo-title: "Flathub (User)
|
||||
```
|
||||
|
|
|
|||
|
|
@ -14,33 +14,65 @@ configure_flatpak_repo () {
|
|||
CONFIG_FILE=$1
|
||||
INSTALL_LEVEL=$2
|
||||
REPO_INFO="/usr/etc/flatpak/$INSTALL_LEVEL/repo-info.yml"
|
||||
# If REPO_INFO already exists, don't re-create it
|
||||
if [[ ! -f $REPO_INFO ]]; then
|
||||
echo "Configuring $INSTALL_LEVEL repo in $REPO_INFO"
|
||||
REPO_URL=$(echo "$CONFIG_FILE" | yq -I=0 ".$INSTALL_LEVEL.repo-url")
|
||||
REPO_NAME=$(echo "$CONFIG_FILE" | yq -I=0 ".$INSTALL_LEVEL.repo-name")
|
||||
REPO_TITLE=$(echo "$CONFIG_FILE" | yq -I=0 ".$INSTALL_LEVEL.repo-title")
|
||||
get_yaml_array INSTALL ".$INSTALL_LEVEL.install[]" "$CONFIG_FILE"
|
||||
|
||||
# Use Flathub as default repo
|
||||
if [[ $REPO_URL == "null" ]]; then
|
||||
REPO_URL=https://dl.flathub.org/repo/flathub.flatpakrepo
|
||||
fi
|
||||
|
||||
# If repo-name isn't configured, use flathub as fallback
|
||||
# Checked separately from URL to allow custom naming
|
||||
if [[ $REPO_NAME == "null" ]]; then
|
||||
# Checks pre-configured repo info, if exists
|
||||
if [[ -f $REPO_INFO ]]; then
|
||||
echo "Existing $INSTALL_LEVEL configuration found:"
|
||||
cat $REPO_INFO
|
||||
CONFIG_URL=$(yq ".repo-url" "$REPO_INFO")
|
||||
CONFIG_NAME=$(yq ".repo-name" "$REPO_INFO")
|
||||
CONFIG_TITLE=$(yq ".repo-title" "$REPO_INFO")
|
||||
else
|
||||
CONFIG_URL="null"
|
||||
CONFIG_NAME="null"
|
||||
CONFIG_TITLE="null"
|
||||
fi
|
||||
|
||||
echo "Configuring $INSTALL_LEVEL repo in $REPO_INFO"
|
||||
REPO_URL=$(echo "$CONFIG_FILE" | yq -I=0 ".$INSTALL_LEVEL.repo-url")
|
||||
REPO_NAME=$(echo "$CONFIG_FILE" | yq -I=0 ".$INSTALL_LEVEL.repo-name")
|
||||
REPO_TITLE=$(echo "$CONFIG_FILE" | yq -I=0 ".$INSTALL_LEVEL.repo-title")
|
||||
|
||||
# If repo-name isn't configured, use flathub as fallback
|
||||
# Checked separately from URL to allow custom naming
|
||||
if [[ $REPO_NAME == "null" && $CONFIG_NAME == "null" ]]; then
|
||||
if [[ ${#INSTALL[@]} -gt 0 ]]; then
|
||||
REPO_NAME="flathub"
|
||||
fi
|
||||
# Re-use existing config, if no new configuration was added
|
||||
elif [[ $REPO_NAME == "null" && ! $CONFIG_NAME == "null" ]]; then
|
||||
REPO_NAME=$CONFIG_NAME
|
||||
fi
|
||||
|
||||
touch $REPO_INFO
|
||||
# EOF breaks if the contents are indented,
|
||||
# so the below lines are intentionally un-indented
|
||||
cat > $REPO_INFO <<EOF
|
||||
# Re-use existing config, if no new configuration was added
|
||||
if [[ $REPO_TITLE == "null" && ! $CONFIG_TITLE == "null" ]]; then
|
||||
REPO_TITLE=$CONFIG_TITLE
|
||||
fi
|
||||
|
||||
if [[ $REPO_URL == "null" && $CONFIG_URL == "null" ]]; then
|
||||
# If repo name is configured, or if there are Flatpaks to be installed,
|
||||
# set Flathub as repo URL
|
||||
if [[ ! $REPO_NAME == "null" || ${#INSTALL[@]} -gt 0 ]]; then
|
||||
REPO_URL=https://dl.flathub.org/repo/flathub.flatpakrepo
|
||||
fi
|
||||
# Re-use existing config, if no new configuration was added
|
||||
elif [[ $REPO_URL == "null" && ! $CONFIG_URL == "null" ]]; then
|
||||
REPO_URL=$CONFIG_URL
|
||||
fi
|
||||
|
||||
touch $REPO_INFO
|
||||
# EOF breaks if the contents are indented,
|
||||
# so the below lines are intentionally un-indented
|
||||
cat > $REPO_INFO <<EOF
|
||||
repo-url: "$REPO_URL"
|
||||
repo-name: "$REPO_NAME"
|
||||
repo-title: "$REPO_TITLE"
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Show results of repo configuration
|
||||
cat $REPO_INFO
|
||||
}
|
||||
|
||||
configure_lists () {
|
||||
|
|
@ -72,17 +104,17 @@ configure_lists () {
|
|||
|
||||
echo "Enabling flatpaks module"
|
||||
mkdir -p /usr/etc/flatpak/{system,user}
|
||||
systemctl enable -f system-flatpak-setup.service
|
||||
systemctl enable -f --global user-flatpak-setup.service
|
||||
|
||||
# Check that `system` is present before configuring
|
||||
if [[ ! $(echo "$1" | yq -I=0 ".system") == "null" ]]; then
|
||||
systemctl enable -f system-flatpak-setup.service
|
||||
configure_flatpak_repo "$1" "system"
|
||||
configure_lists "$1" "system"
|
||||
fi
|
||||
|
||||
# Check that `user` is present before configuring
|
||||
if [[ ! $(echo "$1" | yq -I=0 ".user") == "null" ]]; then
|
||||
systemctl enable -f --global user-flatpak-setup.service
|
||||
configure_flatpak_repo "$1" "user"
|
||||
configure_lists "$1" "user"
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue