From f22cc8899acecc3717b41e4d219d0be0af97e090ba687884611efc928fddcf5e Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Sun, 21 Nov 2021 11:00:22 +0000 Subject: [PATCH] Accepting request 932557 from home:iznogood:branches:Base:System Add upstream patch and tweak OBS-URL: https://build.opensuse.org/request/show/932557 OBS-URL: https://build.opensuse.org/package/show/Base:System/power-profiles-daemon?expand=0&rev=8 --- ...64dfe26f13f8c8cd7b44483cd872dfdede36.patch | 146 ++++++++++++++++++ power-profiles-daemon.changes | 8 + power-profiles-daemon.spec | 4 +- 3 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 fd1664dfe26f13f8c8cd7b44483cd872dfdede36.patch diff --git a/fd1664dfe26f13f8c8cd7b44483cd872dfdede36.patch b/fd1664dfe26f13f8c8cd7b44483cd872dfdede36.patch new file mode 100644 index 0000000..d27532b --- /dev/null +++ b/fd1664dfe26f13f8c8cd7b44483cd872dfdede36.patch @@ -0,0 +1,146 @@ +From fd1664dfe26f13f8c8cd7b44483cd872dfdede36 Mon Sep 17 00:00:00 2001 +From: Bastien Nocera +Date: Mon, 8 Nov 2021 15:39:07 +0100 +Subject: [PATCH] main: Error out on D-Bus communication errors + +The bug reporting tool in Fedora, in its infinite wisdom, considers +innocuous exceptions that occur when system daemons aren't running +to be bug report worthy. + +Catch all the D-Bus communication errors, print an error message +detailing the problem and exit with a return value of 1 when they occur +instead of printing an exception. + +See: +https://bugzilla.redhat.com/show_bug.cgi?id=2019536 +https://bugzilla.redhat.com/show_bug.cgi?id=2020251 +https://bugzilla.redhat.com/show_bug.cgi?id=2020941 +--- + meson.build | 2 +- + src/powerprofilesctl.in | 44 +++++++++++++++++++++++++++++------------ + 2 files changed, 32 insertions(+), 14 deletions(-) + +diff --git a/meson.build b/meson.build +index d7b5a8c..84e67c6 100644 +--- a/meson.build ++++ b/meson.build +@@ -44,7 +44,7 @@ add_global_arguments(common_cflags, language: 'c') + + if get_option('pylint') + pylint = find_program('pylint-3', 'pylint3', 'pylint', required: true) +- pylint_flags = ['-d', 'C0116', '-d', 'C0114', '-d', 'W0707'] ++ pylint_flags = ['-d', 'C0116', '-d', 'C0114', '-d', 'W0707', '-d', 'W0706' ] + endif + xmllint = find_program('xmllint', required: false) + +diff --git a/src/powerprofilesctl.in b/src/powerprofilesctl.in +index 9b5e201..1461e3a 100755 +--- a/src/powerprofilesctl.in ++++ b/src/powerprofilesctl.in +@@ -98,7 +98,7 @@ def get_proxy(): + '/net/hadess/PowerProfiles', + 'org.freedesktop.DBus.Properties', None) + except: +- raise SystemError ++ raise + return proxy + + def _get(): +@@ -117,13 +117,13 @@ def get_profiles_property(prop): + try: + proxy = get_proxy() + except: +- raise SystemError ++ raise + + profiles = None + try: + profiles = proxy.Get('(ss)', 'net.hadess.PowerProfiles', prop) + except: +- raise ReferenceError ++ raise + else: + return profiles + +@@ -134,8 +134,7 @@ def _list(): + degraded = (reason != '') + active = get_proxy().Get('(ss)', 'net.hadess.PowerProfiles', 'ActiveProfile') + except: +- print("Couldn\'t get Profiles: ", sys.exc_info()[0]) +- raise SystemError ++ raise + else: + index = 0 + for profile in reversed(profiles): +@@ -152,8 +151,7 @@ def _list_holds(): + try: + holds = get_profiles_property('ActiveProfileHolds') + except: +- # print("Couldn\'t get ActiveProfileHolds: ", sys.exc_info()[0]) +- raise SystemError ++ raise + else: + index = 0 + for hold in holds: +@@ -173,7 +171,7 @@ def _launch(args, profile, appid, reason): + '/net/hadess/PowerProfiles', + 'net.hadess.PowerProfiles', None) + except: +- raise SystemError ++ raise + + cookie = proxy.HoldProfile('(sss)', profile, reason, appid) + +@@ -208,16 +206,32 @@ def main(): # pylint: disable=too-many-branches, disable=too-many-statements + elif command == 'version': + version() + elif command == 'get': +- _get() ++ try: ++ _get() ++ except GLib.Error as error: ++ sys.stderr.write(f'Failed to communicate with power-profiles-daemon: {format(error)}\n') ++ sys.exit(1) + elif command == 'set': + if len(args) != 1: + usage_set() + sys.exit(1) +- _set(args[0]) ++ try: ++ _set(args[0]) ++ except GLib.Error as error: ++ sys.stderr.write(f'Failed to communicate with power-profiles-daemon: {format(error)}\n') ++ sys.exit(1) + elif command == 'list': +- _list() ++ try: ++ _list() ++ except GLib.Error as error: ++ sys.stderr.write(f'Failed to communicate with power-profiles-daemon: {format(error)}\n') ++ sys.exit(1) + elif command == 'list-holds': +- _list_holds() ++ try: ++ _list_holds() ++ except GLib.Error as error: ++ sys.stderr.write(f'Failed to communicate with power-profiles-daemon: {format(error)}\n') ++ sys.exit(1) + elif command == 'launch': + if len(args) == 0: + sys.exit(0) +@@ -256,7 +270,11 @@ def main(): # pylint: disable=too-many-branches, disable=too-many-statements + reason = 'Running ' + appid + if not profile: + profile = 'performance' +- _launch(args, profile, appid, reason) ++ try: ++ _launch(args, profile, appid, reason) ++ except GLib.Error as error: ++ sys.stderr.write(f'Failed to communicate with power-profiles-daemon: {format(error)}\n') ++ sys.exit(1) + + if __name__ == '__main__': + main() +-- +GitLab + diff --git a/power-profiles-daemon.changes b/power-profiles-daemon.changes index 8b90d18..478b033 100644 --- a/power-profiles-daemon.changes +++ b/power-profiles-daemon.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Fri Nov 19 15:29:11 UTC 2021 - Bjørn Lie + +- Add fd1664dfe26f13f8c8cd7b44483cd872dfdede36.patch: main: Error + out on D-Bus communication errors (rh#2019536). +- Bump pkgconfig(polkit-gobject-1) BuildRequires version to 0.114. + It's required for the g_autoptr() support we use. + ------------------------------------------------------------------- Fri Nov 5 18:35:24 UTC 2021 - Atri Bhattacharya diff --git a/power-profiles-daemon.spec b/power-profiles-daemon.spec index 67fca13..23223d2 100644 --- a/power-profiles-daemon.spec +++ b/power-profiles-daemon.spec @@ -25,6 +25,8 @@ URL: https://gitlab.freedesktop.org/hadess/power-profiles-daemon Source: %{url}/-/archive/%{version}/%{name}-%{version}.tar.bz2 # PATCH-FEATURE-OPENSUSE hold-profile-hardening.patch boo#1189900 -- Hardening of HoldProfile D-Bus method Patch0: hold-profile-hardening.patch +# PATCH-FIX-UPSTREAM fd1664dfe26f13f8c8cd7b44483cd872dfdede36.patch -- main: Error out on D-Bus communication errors +Patch1: https://gitlab.freedesktop.org/hadess/power-profiles-daemon/-/commit/fd1664dfe26f13f8c8cd7b44483cd872dfdede36.patch BuildRequires: c_compiler BuildRequires: gtk-doc @@ -33,7 +35,7 @@ BuildRequires: pkgconfig BuildRequires: python3-dbusmock BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(gudev-1.0) -BuildRequires: pkgconfig(polkit-gobject-1) +BuildRequires: pkgconfig(polkit-gobject-1) >= 0.114 BuildRequires: pkgconfig(systemd) BuildRequires: pkgconfig(udev) BuildRequires: pkgconfig(umockdev-1.0)