From 527512aa128630815fcb7055dd6cb856fff6b04d Mon Sep 17 00:00:00 2001 From: Kalev Lember Date: Wed, 3 Apr 2019 14:45:49 +0200 Subject: [PATCH] Add a oneshot systemd service to add Fedora flatpak repos This adds a systemd service that is type=oneshot and adds fedora and fedora-testing (disabled by default) flatpak repos. Various bugs around /etc/flatpak/remotes.d/ handling make it difficult to use right now, which would otherwise have been a much saner alternative. See https://github.com/flatpak/flatpak/issues/2508 and https://github.com/flatpak/flatpak/issues/1665 for the remotes.d issues. --- flatpak-add-fedora-repos.service | 14 ++++++++++++++ flatpak.spec | 32 +++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 flatpak-add-fedora-repos.service diff --git a/flatpak-add-fedora-repos.service b/flatpak-add-fedora-repos.service new file mode 100644 index 0000000..94616a1 --- /dev/null +++ b/flatpak-add-fedora-repos.service @@ -0,0 +1,14 @@ +[Unit] +Description=Add Fedora flatpak repositories +ConditionPathExists=!/var/lib/flatpak/.fedora-initialized +Before=flatpak-system-helper.service + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/bin/flatpak remote-add --system --if-not-exists --title "Fedora" fedora oci+https://registry.fedoraproject.org +ExecStart=/usr/bin/flatpak remote-add --system --if-not-exists --disable --title "Fedora (testing)" fedora-testing oci+https://registry.fedoraproject.org#testing +ExecStartPost=/usr/bin/touch /var/lib/flatpak/.fedora-initialized + +[Install] +WantedBy=multi-user.target diff --git a/flatpak.spec b/flatpak.spec index ba9a75f..ad168f5 100644 --- a/flatpak.spec +++ b/flatpak.spec @@ -3,12 +3,14 @@ Name: flatpak Version: 1.3.1 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Application deployment framework for desktop apps License: LGPLv2+ URL: http://flatpak.org/ Source0: https://github.com/flatpak/flatpak/releases/download/%{version}/%{name}-%{version}.tar.xz +# Add Fedora flatpak repositories +Source1: flatpak-add-fedora-repos.service BuildRequires: pkgconfig(appstream-glib) BuildRequires: pkgconfig(dconf) @@ -36,6 +38,13 @@ BuildRequires: /usr/bin/xdg-dbus-proxy BuildRequires: /usr/bin/xmlto BuildRequires: /usr/bin/xsltproc +%{?systemd_requires} + +# Require the version of system-release that adds +# flatpak-add-fedora-repos.service preset. +# Should be fine to drop in F32. +Requires(post): system-release >= 30-0.25 + Requires: bubblewrap >= %{bubblewrap_version} Requires: librsvg2%{?_isa} Requires: ostree-libs%{?_isa} >= %{ostree_version} @@ -109,6 +118,7 @@ install -pm 644 NEWS README.md %{buildroot}/%{_pkgdocdir} # The system repo is not installed by the flatpak build system. install -d %{buildroot}%{_localstatedir}/lib/flatpak install -d %{buildroot}%{_sysconfdir}/flatpak/remotes.d +install -D -t %{buildroot}%{_unitdir} %{SOURCE1} rm -f %{buildroot}%{_libdir}/libflatpak.la %find_lang %{name} @@ -117,6 +127,22 @@ rm -f %{buildroot}%{_libdir}/libflatpak.la # Create an (empty) system-wide repo. flatpak remote-list --system &> /dev/null || : +%systemd_post flatpak-add-fedora-repos.service + +if [ $1 -gt 1 ] ; then + # Apply the preset also on package updates to support F29->F31 upgrade + # path. systemd_post macro only handles initial installs and not the + # case when a new .service file appears on a package update. + # Should be fine to drop in F32. + systemctl --no-reload preset flatpak-add-fedora-repos.service >/dev/null 2>&1 || : +fi + +%preun +%systemd_preun flatpak-add-fedora-repos.service + +%postun +%systemd_postun_with_restart flatpak-add-fedora-repos.service + %ldconfig_scriptlets libs @@ -155,6 +181,7 @@ flatpak remote-list --system &> /dev/null || : %{_sysconfdir}/dbus-1/system.d/org.freedesktop.Flatpak.SystemHelper.conf %{_sysconfdir}/flatpak/remotes.d %{_sysconfdir}/profile.d/flatpak.sh +%{_unitdir}/flatpak-add-fedora-repos.service %{_unitdir}/flatpak-system-helper.service %{_userunitdir}/flatpak-portal.service %{_userunitdir}/flatpak-session-helper.service @@ -178,6 +205,9 @@ flatpak remote-list --system &> /dev/null || : %changelog +* Wed Apr 03 2019 Kalev Lember - 1.3.1-2 +- Add a oneshot systemd service to add Fedora flatpak repos + * Wed Mar 27 2019 David King - 1.3.1-1 - Update to 1.3.1 (#1693207)