Gentoo Archives: gentoo-commits

From: Pacho Ramos <pacho@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-power/switcheroo-control/, sys-power/switcheroo-control/files/
Date: Thu, 29 Dec 2022 10:44:40
Message-Id: 1672310665.05c2d14051f6814adc367615b155dd58c46fcc36.pacho@gentoo
1 commit: 05c2d14051f6814adc367615b155dd58c46fcc36
2 Author: Pacho Ramos <pacho <AT> gentoo <DOT> org>
3 AuthorDate: Thu Dec 29 10:40:10 2022 +0000
4 Commit: Pacho Ramos <pacho <AT> gentoo <DOT> org>
5 CommitDate: Thu Dec 29 10:44:25 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=05c2d140
7
8 sys-power/switcheroo-control: Support openRC too
9
10 It seems switcheroo-control can also run on openRC systems with an init.d
11 service. Install service files for both unconditionally following current
12 policy of not relying on USE flags to control single-files installation.
13
14 Thanks-to: Jan Henke
15 Thanks-to: GDH-gentoo
16 Thanks-to: fedeliallalinea
17 Closes: https://bugs.gentoo.org/888199
18 Signed-off-by: Pacho Ramos <pacho <AT> gentoo.org>
19
20 .../files/switcheroo-control-init.d | 12 +++++
21 .../switcheroo-control-2.6-r1.ebuild | 63 ++++++++++++++++++++++
22 2 files changed, 75 insertions(+)
23
24 diff --git a/sys-power/switcheroo-control/files/switcheroo-control-init.d b/sys-power/switcheroo-control/files/switcheroo-control-init.d
25 new file mode 100644
26 index 000000000000..e6ca92908715
27 --- /dev/null
28 +++ b/sys-power/switcheroo-control/files/switcheroo-control-init.d
29 @@ -0,0 +1,12 @@
30 +#!/sbin/openrc-run
31 +
32 +description="Switcheroo Control Proxy service"
33 +
34 +command=/usr/libexec/switcheroo-control
35 +command_background=yes
36 +pidfile=/run/switcheroo-control.pid
37 +
38 +depend() {
39 + need dbus
40 + before alsasound display-manager
41 +}
42
43 diff --git a/sys-power/switcheroo-control/switcheroo-control-2.6-r1.ebuild b/sys-power/switcheroo-control/switcheroo-control-2.6-r1.ebuild
44 new file mode 100644
45 index 000000000000..c44f0662b570
46 --- /dev/null
47 +++ b/sys-power/switcheroo-control/switcheroo-control-2.6-r1.ebuild
48 @@ -0,0 +1,63 @@
49 +# Copyright 2021-2022 Gentoo Authors
50 +# Distributed under the terms of the GNU General Public License v2
51 +
52 +EAPI=8
53 +PYTHON_COMPAT=( python3_{8..11} )
54 +
55 +inherit meson python-any-r1 systemd
56 +
57 +DESCRIPTION="D-Bus service to check the availability of dual-GPU"
58 +HOMEPAGE="https://gitlab.freedesktop.org/hadess/switcheroo-control/"
59 +SRC_URI="https://gitlab.freedesktop.org/hadess/switcheroo-control/uploads/86ea54ac7ddb901b6bf6e915209151f8/${P}.tar.xz"
60 +
61 +LICENSE="GPL-3"
62 +SLOT="0"
63 +IUSE="gtk-doc test"
64 +
65 +KEYWORDS="~amd64"
66 +
67 +RDEPEND="
68 + >=dev-libs/glib-2.56.0:2
69 + >=dev-libs/libgudev-232:=
70 +"
71 +DEPEND="${RDEPEND}"
72 +BDEPEND="
73 + gtk-doc? ( dev-util/gtk-doc )
74 + test? (
75 + $(python_gen_any_dep 'dev-python/python-dbusmock[${PYTHON_USEDEP}]')
76 + dev-util/umockdev
77 + )
78 +"
79 +
80 +RESTRICT="!test? ( test )"
81 +
82 +python_check_deps() {
83 + use test || return 0
84 + python_has_version "dev-python/python-dbusmock[${PYTHON_USEDEP}]"
85 +}
86 +
87 +src_configure() {
88 + local emesonargs=(
89 + -Dsystemdsystemunitdir="$(systemd_get_systemunitdir)"
90 + $(meson_use gtk-doc gtk_doc)
91 + $(meson_use test tests)
92 + )
93 + meson_src_configure
94 +}
95 +
96 +src_install() {
97 + meson_src_install
98 + python_fix_shebang "${D}"/usr/bin/switcherooctl
99 + newinitd "${FILESDIR}"/${PN}-init.d ${PN}
100 +}
101 +
102 +pkg_postinst() {
103 + if [[ -z "${REPLACING_VERSIONS}" ]]; then
104 + elog "You to enable the service:"
105 + if systemd_is_booted; then
106 + elog "# systemctl enable switcheroo-control"
107 + else
108 + elog "# rc-update add ${PN} default"
109 + fi
110 + fi
111 +}