[neon/neon/settings/Neon/release-lts] /: rejigger flathub setup to anchor on sddm

Harald Sitter null at kde.org
Fri Oct 9 10:47:43 BST 2020


Git commit 6a9866159150372b3c1db21a69338e307c265c21 by Harald Sitter.
Committed on 09/10/2020 at 09:47.
Pushed by sitter into branch 'Neon/release-lts'.

rejigger flathub setup to anchor on sddm

this appears to have broken in 20.04 bc of changes to the critical
service chain.
instead start the setup along with sddm and handle that the network is
conceivably not up. since we have no control over which network manager
the user uses we'll assume it's nm but then proceed to try anyway in
case it is not.

this is a bit unfortunate as sddm is actually a bad service to start
with but there's not really any better options on a system level as far
as I can tell

BUG: 427459

M  +2    -3    debian/neon-settings-2.neon-flathub.service
M  +13   -5    usr/lib/neon_update/neon_flathub.rb

https://invent.kde.org/neon/neon/settings/commit/6a9866159150372b3c1db21a69338e307c265c21

diff --git a/debian/neon-settings-2.neon-flathub.service b/debian/neon-settings-2.neon-flathub.service
index 65c8ffc..99ca700 100644
--- a/debian/neon-settings-2.neon-flathub.service
+++ b/debian/neon-settings-2.neon-flathub.service
@@ -1,10 +1,9 @@
 # SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
-# SPDX-FileCopyrightText: 2018-2019 Harald Sitter <sitter at kde.org>
+# SPDX-FileCopyrightText: 2018-2020 Harald Sitter <sitter at kde.org>
 
 [Unit]
 Description=Automatically configures the flathub.org flatpak repository
 After=network-online.target network.target dbus.service NetworkManager-wait-online.service
-Wants=network-online.target
 ConditionPathExists=!/var/lib/neon/flathub-set-up
 
 [Service]
@@ -12,4 +11,4 @@ Type=simple
 ExecStart=/usr/lib/neon_update/neon_flathub.rb
 
 [Install]
-WantedBy=network-online.target
+WantedBy=sddm.service
diff --git a/usr/lib/neon_update/neon_flathub.rb b/usr/lib/neon_update/neon_flathub.rb
index fe5961f..9b6b213 100755
--- a/usr/lib/neon_update/neon_flathub.rb
+++ b/usr/lib/neon_update/neon_flathub.rb
@@ -1,6 +1,8 @@
 #!/usr/bin/env ruby
+# frozen_string_literal: true
+
 # SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
-# SPDX-FileCopyrightText: 2019 Harald Sitter <sitter at kde.org>
+# SPDX-FileCopyrightText: 2019-2020 Harald Sitter <sitter at kde.org>
 
 require 'fileutils'
 
@@ -8,20 +10,26 @@ bin = '/usr/bin/flatpak'
 
 exit 0 unless File.executable?(bin)
 
+# in seconds
 def wait_time
   @wait_times ||= [1, 5]
   @wait_times.pop || 30
 end
 
-loop do
+# After 10 iterations we'll assume network isn't going to come online and give
+# up. We'll try again next boot.
+10.times do
+  # wait for actual network; we ignore the return value. either this succeeded
+  # and we have network or we'll try again after a bit.
+  system('nm-online', '--timeout=60')
+
   if system(bin, 'remote-add', '--system', '--if-not-exists',
             'flathub', 'https://flathub.org/repo/flathub.flatpakrepo')
+    FileUtils.mkpath('/var/lib/neon/')
+    FileUtils.touch('/var/lib/neon/flathub-set-up')
     break
   end
 
   puts 'Failed to add flathub. Trying again in a bit.'
   sleep wait_time
 end
-
-FileUtils.mkpath('/var/lib/neon/')
-FileUtils.touch('/var/lib/neon/flathub-set-up')


More information about the Neon-commits mailing list