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.
This commit is contained in:
Kalev Lember 2019-04-03 14:45:49 +02:00
parent 5ffa114899
commit 527512aa12
2 changed files with 45 additions and 1 deletions

View File

@ -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

View File

@ -3,12 +3,14 @@
Name: flatpak Name: flatpak
Version: 1.3.1 Version: 1.3.1
Release: 1%{?dist} Release: 2%{?dist}
Summary: Application deployment framework for desktop apps Summary: Application deployment framework for desktop apps
License: LGPLv2+ License: LGPLv2+
URL: http://flatpak.org/ URL: http://flatpak.org/
Source0: https://github.com/flatpak/flatpak/releases/download/%{version}/%{name}-%{version}.tar.xz 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(appstream-glib)
BuildRequires: pkgconfig(dconf) BuildRequires: pkgconfig(dconf)
@ -36,6 +38,13 @@ BuildRequires: /usr/bin/xdg-dbus-proxy
BuildRequires: /usr/bin/xmlto BuildRequires: /usr/bin/xmlto
BuildRequires: /usr/bin/xsltproc 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: bubblewrap >= %{bubblewrap_version}
Requires: librsvg2%{?_isa} Requires: librsvg2%{?_isa}
Requires: ostree-libs%{?_isa} >= %{ostree_version} 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. # The system repo is not installed by the flatpak build system.
install -d %{buildroot}%{_localstatedir}/lib/flatpak install -d %{buildroot}%{_localstatedir}/lib/flatpak
install -d %{buildroot}%{_sysconfdir}/flatpak/remotes.d install -d %{buildroot}%{_sysconfdir}/flatpak/remotes.d
install -D -t %{buildroot}%{_unitdir} %{SOURCE1}
rm -f %{buildroot}%{_libdir}/libflatpak.la rm -f %{buildroot}%{_libdir}/libflatpak.la
%find_lang %{name} %find_lang %{name}
@ -117,6 +127,22 @@ rm -f %{buildroot}%{_libdir}/libflatpak.la
# Create an (empty) system-wide repo. # Create an (empty) system-wide repo.
flatpak remote-list --system &> /dev/null || : 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 %ldconfig_scriptlets libs
@ -155,6 +181,7 @@ flatpak remote-list --system &> /dev/null || :
%{_sysconfdir}/dbus-1/system.d/org.freedesktop.Flatpak.SystemHelper.conf %{_sysconfdir}/dbus-1/system.d/org.freedesktop.Flatpak.SystemHelper.conf
%{_sysconfdir}/flatpak/remotes.d %{_sysconfdir}/flatpak/remotes.d
%{_sysconfdir}/profile.d/flatpak.sh %{_sysconfdir}/profile.d/flatpak.sh
%{_unitdir}/flatpak-add-fedora-repos.service
%{_unitdir}/flatpak-system-helper.service %{_unitdir}/flatpak-system-helper.service
%{_userunitdir}/flatpak-portal.service %{_userunitdir}/flatpak-portal.service
%{_userunitdir}/flatpak-session-helper.service %{_userunitdir}/flatpak-session-helper.service
@ -178,6 +205,9 @@ flatpak remote-list --system &> /dev/null || :
%changelog %changelog
* Wed Apr 03 2019 Kalev Lember <klember@redhat.com> - 1.3.1-2
- Add a oneshot systemd service to add Fedora flatpak repos
* Wed Mar 27 2019 David King <amigadave@amigadave.com> - 1.3.1-1 * Wed Mar 27 2019 David King <amigadave@amigadave.com> - 1.3.1-1
- Update to 1.3.1 (#1693207) - Update to 1.3.1 (#1693207)