From patchwork Wed Mar 23 18:48:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: M X-Patchwork-Id: 38029 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 1283E27BBE9; Wed, 23 Mar 2022 18:50:44 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 00D8227BBEC for ; Wed, 23 Mar 2022 18:50:42 +0000 (GMT) Received: from localhost ([::1]:56280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nX649-0005W8-3T for patchwork@mira.cbaines.net; Wed, 23 Mar 2022 14:50:41 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nX63Z-0005V7-CI for guix-patches@gnu.org; Wed, 23 Mar 2022 14:50:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:52128) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nX63Y-0003ED-Qo for guix-patches@gnu.org; Wed, 23 Mar 2022 14:50:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nX63Y-0001GJ-P5 for guix-patches@gnu.org; Wed, 23 Mar 2022 14:50:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54539] [PATCH 3/6] gnu: tlp: Move tlp and friends to new module to break cycles. Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 23 Mar 2022 18:50:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54539 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 54539@debbugs.gnu.org Cc: Maxime Devos Received: via spool by 54539-submit@debbugs.gnu.org id=B54539.16480613624732 (code B ref 54539); Wed, 23 Mar 2022 18:50:04 +0000 Received: (at 54539) by debbugs.gnu.org; 23 Mar 2022 18:49:22 +0000 Received: from localhost ([127.0.0.1]:46014 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nX62n-0001EB-3E for submit@debbugs.gnu.org; Wed, 23 Mar 2022 14:49:22 -0400 Received: from baptiste.telenet-ops.be ([195.130.132.51]:33972) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nX62Z-0001Cj-Jy for 54539@debbugs.gnu.org; Wed, 23 Mar 2022 14:49:08 -0400 Received: from localhost.localdomain ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a]) by baptiste.telenet-ops.be with bizsmtp id 9up12700i4UW6Th01up2o9; Wed, 23 Mar 2022 19:49:02 +0100 From: Maxime Devos Date: Wed, 23 Mar 2022 18:48:52 +0000 Message-Id: <20220323184855.25241-3-maximedevos@telenet.be> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220323184855.25241-1-maximedevos@telenet.be> References: <20220323184855.25241-1-maximedevos@telenet.be> MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22; t=1648061342; bh=+k2smBwbQdMTo7r9Yjnd0YVnA19ENKGaQNZlaeMoxiw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=URYGGc39csoQfNQ8izL6n5dLw5uHot5S2xLsbEshQ8OhTtm+FsLAZFF4QEKK8lBP9 YwqkyNGX5gjRdIInWnql/y7sOxWN8+Iunl12G2eS9iuRu800YE7oTNnlG/mwSr5tsd gBJOVZiH0TiSWxWY5r7lfivsd+xAPfnDl40LTko1+3NuLQhsgAoET7NtwY9josEDAl YQ0mwk80wrtMB8l63Rbzu0p1hPMnZ02VyPLjbNSgBq386z4iZFE0x/q/35eN+Nn/Ez js/6xSWK3IGtKV0fgkg5TIGG4xAk85HwLjPHTayV6yxzkws/lTEcN5yh2PBxKLTH9a WlH7qB4OTRkTQ== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches This partially breaks a cycle between (gnu packages linux) and (gnu packages gtk). It is not sufficient though, see next patch. * gnu/packages/linux.scm (tlp,tlpui): Move to ... * gnu/packages/tlp.scm: ... this new module. * gnu/local.mk (GNU_SYSTEM_MODULES): Register new module. --- gnu/local.mk | 1 + gnu/packages/linux.scm | 192 +--------------------------------- gnu/packages/tlp.scm | 228 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 231 insertions(+), 190 deletions(-) create mode 100644 gnu/packages/tlp.scm diff --git a/gnu/local.mk b/gnu/local.mk index aab22d32d4..ad24234ae5 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -582,6 +582,7 @@ GNU_SYSTEM_MODULES = \ %D%/packages/textutils.scm \ %D%/packages/text-editors.scm \ %D%/packages/time.scm \ + %D%/packages/tlp.scm \ %D%/packages/tls.scm \ %D%/packages/tmux.scm \ %D%/packages/toolkits.scm \ diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index dc4f91d48f..6ce640ddf2 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -113,8 +113,8 @@ #:use-module (gnu packages golang) #:use-module (gnu packages gperf) #:use-module (gnu packages gstreamer) - #:use-module (gnu packages gtk) - #:use-module (gnu packages haskell-apps) + ;; Don't import that module here, otherwise a cycle would result. + ;; #:use-module (gnu packages gtk) #:use-module (gnu packages haskell-xyz) #:use-module (gnu packages libunwind) #:use-module (gnu packages libusb) @@ -6897,194 +6897,6 @@ The appropriate permissions must be set on the backlight or LED control interface in sysfs, which can be accomplished with the included udev rules.") (license license:expat))) -(define-public tlp - (package - (name "tlp") - (version "1.5.0") - (source - (origin - (method git-fetch) - (uri (git-reference - (url "https://github.com/linrunner/TLP") - (commit version))) - (file-name (git-file-name name version)) - (sha256 - (base32 "0cssclk2brhwvn9dm7h5snm2svwy0c8cfr4z2cgkdkac2pfaaxw4")))) - (native-inputs - (list shellcheck)) - (inputs - `(("bash" ,bash) - ("dbus" ,dbus) - ("ethtool" ,ethtool) - ("eudev" ,eudev) - ("grep" ,grep) - ("hdparm" ,hdparm) - ("inetutils" ,inetutils) - ("iw" ,iw) - ("kmod" ,kmod) - ("pciutils" ,pciutils) - ("perl" ,perl) - ("rfkill" ,rfkill) - ("sed" ,sed) - ("usbutils" ,usbutils) - ("util-linux" ,util-linux) - ("wireless-tools" ,wireless-tools) - ,@(if (let ((system (or (%current-target-system) - (%current-system)))) - (or (string-prefix? "i686-" system) - (string-prefix? "x86_64-" system))) - `(("x86-energy-perf-policy" ,x86-energy-perf-policy)) - '()))) - (build-system gnu-build-system) - (arguments - ;; XXX: The full test suite is run with "checkall" but it requires - ;; "checkbashisms" and "perlcritic", not yet packaged in Guix. - `(#:test-target "shellcheck" - #:modules ((guix build gnu-build-system) - (guix build utils) - (srfi srfi-1)) - #:phases - (modify-phases %standard-phases - (delete 'configure) ; no configure script - (add-before 'build 'setenv - (lambda* (#:key outputs #:allow-other-keys) - (let ((out (assoc-ref outputs "out"))) - (setenv "TLP_WITH_SYSTEMD" "0") - (setenv "TLP_NO_INIT" "1") - (setenv "TLP_NO_PMUTILS" "1") - (setenv "TLP_SBIN" (string-append out "/bin")) - (setenv "TLP_BATD" (string-append out "/share/tlp/bat.d")) - (setenv "TLP_BIN" (string-append out "/bin")) - (setenv "TLP_TLIB" (string-append out "/share/tlp")) - (setenv "TLP_FLIB" (string-append out "/share/tlp/func.d")) - (setenv "TLP_ULIB" (string-append out "/lib/udev")) - (setenv "TLP_CONFDEF" - (string-append out "/share/tlp/defaults.conf")) - (setenv "TLP_CONFDIR" (string-append out "/etc/tlp.d")) - (setenv "TLP_CONFREN" - (string-append out "/share/tlp/rename.conf")) - (setenv "TLP_ELOD" - (string-append out "/lib/elogind/system-sleep")) - (setenv "TLP_SHCPL" - (string-append out "/share/bash-completion/completions")) - (setenv "TLP_MAN" (string-append out "/share/man")) - (setenv "TLP_META" (string-append out "/share/metainfo"))))) - (add-before 'install 'fix-installation - (lambda _ - ;; Stop the Makefile from trying to create system directories. - (substitute* "Makefile" - (("\\[ -f \\$\\(_CONFUSR\\) \\]") "#") - (("install -d -m 755 \\$\\(_VAR\\)") "#")))) - (replace 'install - (lambda _ (invoke "make" "install-tlp" "install-man-tlp"))) - (add-after 'install 'wrap - (lambda* (#:key inputs outputs #:allow-other-keys) - (let* ((bin (string-append (assoc-ref outputs "out") "/bin")) - (bin-files (find-files bin ".*"))) - (define (bin-directory input-name) - (let ((p (assoc-ref inputs input-name))) - (and p (string-append p "/bin")))) - (define (sbin-directory input-name) - (string-append (assoc-ref inputs input-name) "/sbin")) - (for-each (lambda (program) - (wrap-program program - `("PATH" ":" prefix - ,(append - (filter-map bin-directory - '("bash" - "coreutils" - "dbus" - "eudev" - "grep" - "inetutils" - "kmod" - "perl" - "sed" - "usbutils" - "util-linux" - "x86-energy-perf-policy")) - (filter-map sbin-directory - '("ethtool" - "hdparm" - "iw" - "pciutils" - "rfkill" - "wireless-tools")))))) - bin-files))))))) - (home-page "https://linrunner.de/en/tlp/tlp.html") - (synopsis "Power management tool for Linux") - (description "TLP is a power management tool for Linux. It comes with -a default configuration already optimized for battery life. Nevertheless, -TLP is customizable to fulfil system requirements. TLP settings are applied -every time the power supply source is changed.") - ;; 'COPYING' is a custom version that says that one file is GPLv3+ and the - ;; rest is GPLv2+. - (license (list license:gpl2+ license:gpl3+)))) - -(define-public tlpui - (package - (name "tlpui") - (version "1.5.0") - (source - (origin - (method git-fetch) - (uri (git-reference - (url "https://github.com/d4nj1/TLPUI") - (commit (string-append "tlpui-" version)))) - (file-name (git-file-name name version)) - (sha256 - (base32 "0ca18hazxksx516nkh28f6rd0l1039nkn7mszqfy68c461061q1h")))) - (build-system python-build-system) - (arguments - `(#:phases - (modify-phases %standard-phases - (add-after 'unpack 'patch-setup.py - ;; Install data_files to $out/share instead of /usr/share. - (lambda _ - (substitute* "setup.py" - (("/usr/") "")))) - (add-after 'unpack 'use-tlp-input - ;; Hard-code tlp-stat filename to avoid propagating "tlp". - (lambda* (#:key inputs #:allow-other-keys) - (let ((tlp-stat (search-input-file inputs "/bin/tlp-stat"))) - (with-directory-excursion "tlpui" - (substitute* '("file.py" "settingshelper.py" "statui.py") - (("which\\(\"tlp-stat\"\\)") - (string-append "'" tlp-stat "'")) - (("\"tlp-stat\"") - (string-append "'" tlp-stat "'"))))))) - (add-before 'check 'fix-home-directory - (lambda _ - ;; Tests fail with "Permission denied: - ;; '/homeless-shelter'". - (setenv "HOME" "/tmp"))) - ;; `sanity-check' phase errors out with the following - ;; messages: "Unable to init server: Could not connect: - ;; Connection refused" and "Error: cannot read user - ;; configuration from /etc/tlp.conf or /etc/default/tlp". - (delete 'sanity-check) - (replace 'check - (lambda _ - (invoke "python" "-m" "discover"))) - (add-after 'install 'wrap-gi-python - (lambda* (#:key outputs #:allow-other-keys) - (let ((out (assoc-ref outputs "out")) - (gi-typelib-path (getenv "GI_TYPELIB_PATH"))) - (wrap-program (string-append out "/bin/tlpui") - `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-path))))))))) - (native-inputs - (list `(,glib "bin") gobject-introspection python-discover)) - (inputs - (list gtk+ python-pygobject tlp)) - (home-page "https://github.com/d4nj1/TLPUI") - (synopsis "User interface for TLP written in Python") - (description - "The Python scripts in this project generate a GTK-UI to change -TLP configuration files easily. It aims to protect users from setting -bad configuration and to deliver a basic overview of all the valid -configuration values.") - (license license:gpl2+))) - (define-public lshw (package (name "lshw") diff --git a/gnu/packages/tlp.scm b/gnu/packages/tlp.scm new file mode 100644 index 0000000000..dfe7d3616b --- /dev/null +++ b/gnu/packages/tlp.scm @@ -0,0 +1,228 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2021 Brice Waegeneire +;;; Copyright © 2018-2022 Nicolas Goaziou +;;; Copyright © 2019 Stefan Stefanović +;;; Copyright © 2019 Ludovic Courtès +;;; Copyright © 2017 Tobias Geerinckx-Rice +;;; Copyright © 2017 Mathieu Othacehe +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu packages tlp) + #:use-module (guix packages) + #:use-module (guix build-system gnu) + #:use-module (guix build-system python) + #:use-module (guix git-download) + #:use-module (gnu packages admin) ;inetutils + #:use-module (gnu packages base) ;grep + #:use-module (gnu packages bash) + #:use-module (gnu packages check) ;python-discover + #:use-module (gnu packages glib) ;dbus + #:use-module (gnu packages haskell-apps) ;shellcheck + #:use-module (gnu packages gtk) + #:use-module (gnu packages linux) ;eudev + #:use-module (gnu packages networking) ;ethtool + #:use-module (gnu packages pciutils) + #:use-module (gnu packages perl) ;ethtool + #:use-module ((guix licenses) #:prefix license:)) + +(define-public tlp + (package + (name "tlp") + (version "1.5.0") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/linrunner/TLP") + (commit version))) + (file-name (git-file-name name version)) + (sha256 + (base32 "0cssclk2brhwvn9dm7h5snm2svwy0c8cfr4z2cgkdkac2pfaaxw4")))) + (native-inputs + (list shellcheck)) + (inputs + `(("bash" ,bash) + ("dbus" ,dbus) + ("ethtool" ,ethtool) + ("eudev" ,eudev) + ("grep" ,grep) + ("hdparm" ,hdparm) + ("inetutils" ,inetutils) + ("iw" ,iw) + ("kmod" ,kmod) + ("pciutils" ,pciutils) + ("perl" ,perl) + ("rfkill" ,rfkill) + ("sed" ,sed) + ("usbutils" ,usbutils) + ("util-linux" ,util-linux) + ("wireless-tools" ,wireless-tools) + ,@(if (let ((system (or (%current-target-system) + (%current-system)))) + (or (string-prefix? "i686-" system) + (string-prefix? "x86_64-" system))) + `(("x86-energy-perf-policy" ,x86-energy-perf-policy)) + '()))) + (build-system gnu-build-system) + (arguments + ;; XXX: The full test suite is run with "checkall" but it requires + ;; "checkbashisms" and "perlcritic", not yet packaged in Guix. + `(#:test-target "shellcheck" + #:modules ((guix build gnu-build-system) + (guix build utils) + (srfi srfi-1)) + #:phases + (modify-phases %standard-phases + (delete 'configure) ; no configure script + (add-before 'build 'setenv + (lambda* (#:key outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "out"))) + (setenv "TLP_WITH_SYSTEMD" "0") + (setenv "TLP_NO_INIT" "1") + (setenv "TLP_NO_PMUTILS" "1") + (setenv "TLP_SBIN" (string-append out "/bin")) + (setenv "TLP_BATD" (string-append out "/share/tlp/bat.d")) + (setenv "TLP_BIN" (string-append out "/bin")) + (setenv "TLP_TLIB" (string-append out "/share/tlp")) + (setenv "TLP_FLIB" (string-append out "/share/tlp/func.d")) + (setenv "TLP_ULIB" (string-append out "/lib/udev")) + (setenv "TLP_CONFDEF" + (string-append out "/share/tlp/defaults.conf")) + (setenv "TLP_CONFDIR" (string-append out "/etc/tlp.d")) + (setenv "TLP_CONFREN" + (string-append out "/share/tlp/rename.conf")) + (setenv "TLP_ELOD" + (string-append out "/lib/elogind/system-sleep")) + (setenv "TLP_SHCPL" + (string-append out "/share/bash-completion/completions")) + (setenv "TLP_MAN" (string-append out "/share/man")) + (setenv "TLP_META" (string-append out "/share/metainfo"))))) + (add-before 'install 'fix-installation + (lambda _ + ;; Stop the Makefile from trying to create system directories. + (substitute* "Makefile" + (("\\[ -f \\$\\(_CONFUSR\\) \\]") "#") + (("install -d -m 755 \\$\\(_VAR\\)") "#")))) + (replace 'install + (lambda _ (invoke "make" "install-tlp" "install-man-tlp"))) + (add-after 'install 'wrap + (lambda* (#:key inputs outputs #:allow-other-keys) + (let* ((bin (string-append (assoc-ref outputs "out") "/bin")) + (bin-files (find-files bin ".*"))) + (define (bin-directory input-name) + (let ((p (assoc-ref inputs input-name))) + (and p (string-append p "/bin")))) + (define (sbin-directory input-name) + (string-append (assoc-ref inputs input-name) "/sbin")) + (for-each (lambda (program) + (wrap-program program + `("PATH" ":" prefix + ,(append + (filter-map bin-directory + '("bash" + "coreutils" + "dbus" + "eudev" + "grep" + "inetutils" + "kmod" + "perl" + "sed" + "usbutils" + "util-linux" + "x86-energy-perf-policy")) + (filter-map sbin-directory + '("ethtool" + "hdparm" + "iw" + "pciutils" + "rfkill" + "wireless-tools")))))) + bin-files))))))) + (home-page "https://linrunner.de/en/tlp/tlp.html") + (synopsis "Power management tool for Linux") + (description "TLP is a power management tool for Linux. It comes with +a default configuration already optimized for battery life. Nevertheless, +TLP is customizable to fulfil system requirements. TLP settings are applied +every time the power supply source is changed.") + ;; 'COPYING' is a custom version that says that one file is GPLv3+ and the + ;; rest is GPLv2+. + (license (list license:gpl2+ license:gpl3+)))) + +(define-public tlpui + (package + (name "tlpui") + (version "1.5.0") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/d4nj1/TLPUI") + (commit (string-append "tlpui-" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 "0ca18hazxksx516nkh28f6rd0l1039nkn7mszqfy68c461061q1h")))) + (build-system python-build-system) + (arguments + `(#:phases + (modify-phases %standard-phases + (add-after 'unpack 'patch-setup.py + ;; Install data_files to $out/share instead of /usr/share. + (lambda _ + (substitute* "setup.py" + (("/usr/") "")))) + (add-after 'unpack 'use-tlp-input + ;; Hard-code tlp-stat filename to avoid propagating "tlp". + (lambda* (#:key inputs #:allow-other-keys) + (let ((tlp-stat (search-input-file inputs "/bin/tlp-stat"))) + (with-directory-excursion "tlpui" + (substitute* '("file.py" "settingshelper.py" "statui.py") + (("which\\(\"tlp-stat\"\\)") + (string-append "'" tlp-stat "'")) + (("\"tlp-stat\"") + (string-append "'" tlp-stat "'"))))))) + (add-before 'check 'fix-home-directory + (lambda _ + ;; Tests fail with "Permission denied: + ;; '/homeless-shelter'". + (setenv "HOME" "/tmp"))) + ;; `sanity-check' phase errors out with the following + ;; messages: "Unable to init server: Could not connect: + ;; Connection refused" and "Error: cannot read user + ;; configuration from /etc/tlp.conf or /etc/default/tlp". + (delete 'sanity-check) + (replace 'check + (lambda _ + (invoke "python" "-m" "discover"))) + (add-after 'install 'wrap-gi-python + (lambda* (#:key outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "out")) + (gi-typelib-path (getenv "GI_TYPELIB_PATH"))) + (wrap-program (string-append out "/bin/tlpui") + `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-path))))))))) + (native-inputs + (list `(,glib "bin") gobject-introspection python-discover)) + (inputs + (list gtk+ python-pygobject tlp)) + (home-page "https://github.com/d4nj1/TLPUI") + (synopsis "User interface for TLP written in Python") + (description + "The Python scripts in this project generate a GTK-UI to change +TLP configuration files easily. It aims to protect users from setting +bad configuration and to deliver a basic overview of all the valid +configuration values.") + (license license:gpl2+)))