Add Network UPS Tools

  • Open
  • quality assurance status badge
Details
3 participants
  • Nicolò Balzarotti
  • Marius Bakke
  • Bruno Victal
Owner
unassigned
Submitted by
Nicolò Balzarotti
Severity
normal
N
N
Nicolò Balzarotti wrote on 27 Oct 2020 17:12
(address . guix-patches@gnu.org)
87lffrmyvp.fsf@guixSD.i-did-not-set--mail-host-address--so-tickle-me
Hi guix!
This patch adds Network UPS Tools (nut).

I could test that binaries run, but could not connect to a real UPS (I
need to replace my UPSs as they are currently dead).

Let me know if any of you can try!

Thanks, Nicolò
From 0e3a16eb19bc481d38edbe36c241ec4631cbdd33 Mon Sep 17 00:00:00 2001
From: nixo <nicolo@nixo.xyz>
Date: Tue, 27 Oct 2020 10:56:35 +0100
Subject: [PATCH] gnu: Add nut.

* gnu/packages/admin.scm (nut): New variable.
---
gnu/packages/admin.scm | 64 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)

Toggle diff (105 lines)
diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index 8dcf8afd84..02dccd8021 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -35,6 +35,7 @@
;;; Copyright © 2020 Michael Rohleder <mike@rohleder.de>
;;; Copyright © 2020 Vincent Legoll <vincent.legoll@gmail.com>
;;; Copyright © 2020 Morgan Smith <Morgan.J.Smith@outlook.com>
+;;; Copyright © 2020 Nicolò Balzarotti <nicolo@nixo.xyz>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -70,6 +71,7 @@
#:use-module (gnu packages algebra)
#:use-module (gnu packages autogen)
#:use-module (gnu packages autotools)
+ #:use-module (gnu packages avahi)
#:use-module (gnu packages base)
#:use-module (gnu packages bash)
#:use-module (gnu packages bison)
@@ -85,6 +87,7 @@
#:use-module (gnu packages elf)
#:use-module (gnu packages file)
#:use-module (gnu packages flex)
+ #:use-module (gnu packages freeipmi)
#:use-module (gnu packages gawk)
#:use-module (gnu packages gettext)
#:use-module (gnu packages gl)
@@ -110,6 +113,7 @@
#:use-module (gnu packages mcrypt)
#:use-module (gnu packages mpi)
#:use-module (gnu packages ncurses)
+ #:use-module (gnu packages networking)
#:use-module (gnu packages openldap)
#:use-module (gnu packages patchutils)
#:use-module (gnu packages pciutils)
@@ -880,6 +884,66 @@ IPv6, proxies, and Unix sockets.")
(license (list license:bsd-3
license:bsd-2)))) ; atomicio.*, socks.c
+(define-public nut
+ (package
+ (name "nut")
+ (version "2.7.4")
+ (source
+ (origin
+ (method url-fetch)
+ (uri "https://networkupstools.org/source/2.7/nut-2.7.4.tar.gz")
+ (sha256
+ (base32
+ "19r5dm07sfz495ckcgbfy0pasx0zy3faa0q7bih69lsjij8q43lq"))
+ (patches
+ (list
+ ;; OpenSSL 1.1 support
+ (origin
+ (method url-fetch)
+ (uri (string-append "https://patch-diff.githubusercontent.com/raw/"
+ "networkupstools/nut/pull/504.patch"))
+ (sha256
+ (base32 "1dabbzlmb886qy39xjx6nxlfrzfkm99n48la1ip32zm3baal6qph"))
+ (file-name (string-append name "-openssl1.1")))))))
+ (build-system gnu-build-system)
+ (arguments
+ `(#:configure-flags '("--with-all"
+ "--with-openssl"
+ ;; powerman is required (where is it hosted?)
+ "--without-powerman"
+ ;; cgi requires libgd
+ "--without-cgi")
+ #:phases
+ (modify-phases %standard-phases
+ (add-before 'configure 'update-configure
+ ;; required to apply the patch to the ./configure script
+ (lambda _
+ (invoke "autoconf"))))))
+ (native-inputs `(("autoconf" ,autoconf)
+ ("cppunit" ,cppunit)
+ ("pkg-config" ,pkg-config)))
+ (inputs `(("avahi" ,avahi)
+ ("libusb" ,libusb-compat)
+ ("libltdl" ,libltdl)
+ ("freeipmi" ,freeipmi)
+ ("neon" ,neon)
+ ("openssl" ,openssl)
+ ("net-snmp" ,net-snmp)))
+ (home-page "https://networkupstools.org")
+ (license
+ (list
+ ;; - most files under gpl2+
+ license:gpl2+
+ ;; - scripts/python/ under gpl3+
+ license:gpl3+
+ ;; - scripts/perl/Nut.pm same as perl (either gpl1+ or artistic)
+ license:gpl1+ license:artistic2.0))
+ (synopsis "Collection of programs for monitoring and administering UPS")
+ (description "Network UPS Tools is a collection of programs which provide
+a common interface for monitoring and administering UPS, PDU and SCD hardware.
+It uses a layered approach to connect all of the parts. Drivers are provided
+for a wide assortment of equipment.")))
+
(define-public sipcalc
(package
(name "sipcalc")
--
2.28.0
M
M
Marius Bakke wrote on 10 Nov 2020 20:55
87h7pxdm10.fsf@gnu.org
Nicolò Balzarotti <anothersms@gmail.com> writes:

Toggle quote (3 lines)
> Hi guix!
> This patch adds Network UPS Tools (nut).

Cool!

[...]

Toggle quote (7 lines)
>>From 0e3a16eb19bc481d38edbe36c241ec4631cbdd33 Mon Sep 17 00:00:00 2001
> From: nixo <nicolo@nixo.xyz>
> Date: Tue, 27 Oct 2020 10:56:35 +0100
> Subject: [PATCH] gnu: Add nut.
>
> * gnu/packages/admin.scm (nut): New variable.

[...]
Toggle quote (9 lines)
> +(define-public nut
> + (package
> + (name "nut")
> + (version "2.7.4")
> + (source
> + (origin
> + (method url-fetch)
> + (uri "https://networkupstools.org/source/2.7/nut-2.7.4.tar.gz")

Avoid hard-coding versions in URLs. You can use the version-major+minor
procedure to create that "2.7" URL component.

Toggle quote (11 lines)
> + (patches
> + (list
> + ;; OpenSSL 1.1 support
> + (origin
> + (method url-fetch)
> + (uri (string-append "https://patch-diff.githubusercontent.com/raw/"
> + "networkupstools/nut/pull/504.patch"))
> + (sha256
> + (base32 "1dabbzlmb886qy39xjx6nxlfrzfkm99n48la1ip32zm3baal6qph"))
> + (file-name (string-append name "-openssl1.1")))))))

This got merged in 2017, and still not released!

Looking at the pull request[0], this URL is a squashed version of 7
commits. While convenient, this trick has failed before due to subtle
changes in GitHub machinery, eventually leading to a hash mismatch[1].

Taking 7 patches directly is no fun either, so I wonder if we can just
stick with OpenSSL 1.0 for now?

[1] commit 7670efefe4fb4aca12cb19ea5d89ff37c48e3ea6

Toggle quote (7 lines)
> + (build-system gnu-build-system)
> + (arguments
> + `(#:configure-flags '("--with-all"
> + "--with-openssl"
> + ;; powerman is required (where is it hosted?)
> + "--without-powerman"

Can you elaborate on powerman being required? Is the package not usable
without it?

Toggle quote (3 lines)
> + ;; cgi requires libgd
> + "--without-cgi")

We do have libgd (in the 'gd' package).

Toggle quote (7 lines)
> + #:phases
> + (modify-phases %standard-phases
> + (add-before 'configure 'update-configure
> + ;; required to apply the patch to the ./configure script
> + (lambda _
> + (invoke "autoconf"))))))

This may not be necessary due to the 'bootstrap' phase (but I haven't
verified).

Toggle quote (11 lines)
> + (native-inputs `(("autoconf" ,autoconf)
> + ("cppunit" ,cppunit)
> + ("pkg-config" ,pkg-config)))
> + (inputs `(("avahi" ,avahi)
> + ("libusb" ,libusb-compat)
> + ("libltdl" ,libltdl)
> + ("freeipmi" ,freeipmi)
> + ("neon" ,neon)
> + ("openssl" ,openssl)
> + ("net-snmp" ,net-snmp)))

The indentation of these are a bit weird. :-)

Toggle quote (10 lines)
> + (home-page "https://networkupstools.org")
> + (license
> + (list
> + ;; - most files under gpl2+
> + license:gpl2+
> + ;; - scripts/python/ under gpl3+
> + license:gpl3+
> + ;; - scripts/perl/Nut.pm same as perl (either gpl1+ or artistic)
> + license:gpl1+ license:artistic2.0))

Great job at listing licenses!

Toggle quote (6 lines)
> + (synopsis "Collection of programs for monitoring and administering UPS")
> + (description "Network UPS Tools is a collection of programs which provide
> +a common interface for monitoring and administering UPS, PDU and SCD hardware.
> +It uses a layered approach to connect all of the parts. Drivers are provided
> +for a wide assortment of equipment.")))

Maybe add @acronym{UPS, Uninterruptible Power Supply},
@acronym{PDU, ...} etc, but no strong opinion.

Can you send an updated patch?
-----BEGIN PGP SIGNATURE-----

iQFDBAEBCgAtFiEEu7At3yzq9qgNHeZDoqBt8qM6VPoFAl+q8DsPHG1hcml1c0Bn
bnUub3JnAAoJEKKgbfKjOlT6UtYH/AtjrjHebyz5YlGQhv4giwVK3illSb0fYfY+
nvzsdm/KqnbH6IORxCOosKDOz6RIZJXpeIjO/Y1d2xC3KalAcXXCis16zSo+cgu/
yaTwmez8QUXqcWZuBBrcW44W1xIIP1/4AYRtPi3YOdHdlmUCTJW45Jb4nSWuvHIc
gKMUamvqVrxSJ691tEL21I/gSqLynmUsgoMgCeHkkET3pZLVlmRrmNCWipUUYfIU
jWEEGz7Uoe7Jbd8scZU1iAcfEhrhXxikKf8hhUq5t30vRtlTzbc3MVqo+JBRUz0/
tFpMTVTKgB/agGtxNXMdJ4D2ifeVTdjGWiqxCLnBX1LUBuNrOy0=
=mfMe
-----END PGP SIGNATURE-----

N
N
Nicolò Balzarotti wrote on 14 Nov 2020 17:45
87sg9b99bc.fsf@guixSD.i-did-not-set--mail-host-address--so-tickle-me
Hi, thanks for the reply.

Marius Bakke <marius@gnu.org> writes:

Toggle quote (4 lines)
>
> Avoid hard-coding versions in URLs. You can use the version-major+minor
> procedure to create that "2.7" URL component.

Done!

Toggle quote (9 lines)
> This got merged in 2017, and still not released!
>
> Looking at the pull request[0], this URL is a squashed version of 7
> commits. While convenient, this trick has failed before due to subtle
> changes in GitHub machinery, eventually leading to a hash mismatch[1].
>
> Taking 7 patches directly is no fun either, so I wonder if we can just
> stick with OpenSSL 1.0 for now?
>
Fine! Using openssl-1.0 now.

Toggle quote (6 lines)
>> + ;; powerman is required (where is it hosted?)
>> + "--without-powerman"
>
> Can you elaborate on powerman being required? Is the package not usable
> without it?
>
Expanded a bit, following nut readme.

Toggle quote (5 lines)
>> + ;; cgi requires libgd
>> + "--without-cgi")
>
> We do have libgd (in the 'gd' package).
>
Oh, I don't know how I missed it. Added! Now cgi is working (output is
in folder /cgi-bin, is this correct for guix?)

Since nut release is really old, it used to use gdlib-config. It has
been removed and replaced by pkg-config. However, the patch [1] does
not apply. So I had to do the "terrible" fix of calling pkg-config
myself (in the new "fix-ligdb-check" phase). Terrible because I wanted
to call it in guile and save the output to the file, but the only way I
know of is with popen (and I could not find another package doing this
(while some package like python-libmpsse are just inserting the call
like I did here).

Toggle quote (10 lines)
>> + #:phases
>> + (modify-phases %standard-phases
>> + (add-before 'configure 'update-configure
>> + ;; required to apply the patch to the ./configure script
>> + (lambda _
>> + (invoke "autoconf"))))))
>
> This may not be necessary due to the 'bootstrap' phase (but I haven't
> verified).
>
Well, now that I switched to openssl-1.0 it sure is not needed anymore.
But previously I remember without the autoreconf call, it was not working.

Toggle quote (13 lines)
>> + (native-inputs `(("autoconf" ,autoconf)n
>> + ("cppunit" ,cppunit)
>> + ("pkg-config" ,pkg-config)))
>> + (inputs `(("avahi" ,avahi)
>> + ("libusb" ,libusb-compat)
>> + ("libltdl" ,libltdl)
>> + ("freeipmi" ,freeipmi)
>> + ("neon" ,neon)
>> + ("openssl" ,openssl)
>> + ("net-snmp" ,net-snmp)))
>
> The indentation of these are a bit weird. :-)
>
ops :)

Toggle quote (21 lines)
>> + (home-page "https://networkupstools.org")
>> + (license
>> + (list
>> + ;; - most files under gpl2+
>> + license:gpl2+
>> + ;; - scripts/python/ under gpl3+
>> + license:gpl3+
>> + ;; - scripts/perl/Nut.pm same as perl (either gpl1+ or artistic)
>> + license:gpl1+ license:artistic2.0))
>
> Great job at listing licenses!
>
>> + (synopsis "Collection of programs for monitoring and administering UPS")
>> + (description "Network UPS Tools is a collection of programs which provide
>> +a common interface for monitoring and administering UPS, PDU and SCD hardware.
>> +It uses a layered approach to connect all of the parts. Drivers are provided
>> +for a wide assortment of equipment.")))
>
> Maybe add @acronym{UPS, Uninterruptible Power Supply},
> @acronym{PDU, ...} etc, but no strong opinion.
>
Sure!

Toggle quote (2 lines)
> Can you send an updated patch?

I also added the phase "fix-search-paths" which fixes nut-scanner.
nut scanner now finds my ups device (but I still could not get it to
work, not sure if the problem is in my config or in this package. I'd
wait to merge this until someone can try.

Thanks again,
Nicolò
B
B
Bruno Victal wrote on 31 Mar 2023 01:00
control-msg
(name . control)(address . control@debbugs.gnu.org)
74912071-f536-c8bc-4711-db295b4da0e6@makinata.eu
# done with 5c131aff691fa1cb0fafe71b5f2795902ae056a7
close 55819

# control fail?
close 45449

# no longer relevant
close 33078

# tags
tags 62551 patch
tags 62503 patch
tags 62461 patch
tags 62443 patch
tags 62428 patch
tags 61226 patch
tags 59893 patch
tags 59852 patch
tags 49451 patch
tags 49207 patch
tags 44258 patch


quit
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 44258@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 44258
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch