GNU bug report logs - #75550
smartd fails to send an email

Previous Next

Package: guix-patches;

Reported by: Tomas Volf <~@wolfsden.cz>

Date: Tue, 14 Jan 2025 01:37:01 UTC

Severity: normal

Done: Hilton Chain <hako <at> ultrarare.space>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 75550 in the body.
You can then email your comments to 75550 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#75550; Package guix. (Tue, 14 Jan 2025 01:37:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tomas Volf <~@wolfsden.cz>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Tue, 14 Jan 2025 01:37:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Tomas Volf <~@wolfsden.cz>
To: bug-guix <at> gnu.org
Subject: smartd fails to send an email
Date: Tue, 14 Jan 2025 02:36:21 +0100
Hi,

I have tried to write a service type for smartd from smartmontools,
however the bundled script fails.

When the test (-m root -M test) is executed, some programs seem to be
missing in the $PATH:

--8<---------------cut here---------------start------------->8---
Jan 14 01:34:19 localhost smartd[3138]: Executing test of <mail> to root ... 
Jan 14 01:34:19 localhost smartd[3138]: Test of <mail> to root produced unexpected output (118 bytes) to STDOUT/STDERR:  
Jan 14 01:34:19 localhost smartd[3138]: /gnu/store/ks6lnp8hssm9zkka47ysa4qp9xd9f8bv-smartmontools-7.4/etc/smartd_warning.sh: line 132: sed: command not found 
Jan 14 01:34:19 localhost smartd[3138]: Test of <mail> to root: failed (32-bit/8-bit exit status: 32512/127) 
--8<---------------cut here---------------end--------------->8---

At the start of the script I see:

--8<---------------cut here---------------start------------->8---
export PATH="/usr/local/bin:/usr/bin:/bin"
--8<---------------cut here---------------end--------------->8---

That does not look correct.  I am not sure if any wrapping is necessary.

Have a nice day,
Tomas

-- 
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.




Information forwarded to bug-guix <at> gnu.org:
bug#75550; Package guix. (Tue, 14 Jan 2025 05:31:02 GMT) Full text and rfc822 format available.

Message #8 received at 75550 <at> debbugs.gnu.org (full text, mbox):

From: 45mg <45mg.writes <at> gmail.com>
To: Tomas Volf <~@wolfsden.cz>, 75550 <at> debbugs.gnu.org
Subject: Re: bug#75550: smartd fails to send an email
Date: Tue, 14 Jan 2025 05:30:47 +0000
Hi Tomas,

Tomas Volf <~@wolfsden.cz> writes:

> Hi,
>
> I have tried to write a service type for smartd from smartmontools,
> however the bundled script fails.
>
> When the test (-m root -M test) is executed, some programs seem to be
> missing in the $PATH:
>
> --8<---------------cut here---------------start------------->8---
> Jan 14 01:34:19 localhost smartd[3138]: Executing test of <mail> to root ... 
> Jan 14 01:34:19 localhost smartd[3138]: Test of <mail> to root produced unexpected output (118 bytes) to STDOUT/STDERR:  
> Jan 14 01:34:19 localhost smartd[3138]: /gnu/store/ks6lnp8hssm9zkka47ysa4qp9xd9f8bv-smartmontools-7.4/etc/smartd_warning.sh: line 132: sed: command not found 
> Jan 14 01:34:19 localhost smartd[3138]: Test of <mail> to root: failed (32-bit/8-bit exit status: 32512/127) 
> --8<---------------cut here---------------end--------------->8---

I've seen other package definitions deal with this problem by using
`substitute*` to replace executables specified in scripts, etc. (like
sed here) with the corresponding store paths. See 'light' in (gnu
packages linux) for an example.




Information forwarded to sharlatanus <at> gmail.com, bug-guix <at> gnu.org:
bug#75550; Package guix. (Tue, 14 Jan 2025 23:41:03 GMT) Full text and rfc822 format available.

Message #11 received at 75550 <at> debbugs.gnu.org (full text, mbox):

From: Tomas Volf <~@wolfsden.cz>
To: 75550 <at> debbugs.gnu.org,
	guix-patches <at> gnu.org
Cc: Tomas Volf <~@wolfsden.cz>
Subject: [PATCH] gnu: smartmontools: Fix PATH in smartd_warning.sh.
Date: Wed, 15 Jan 2025 00:40:19 +0100
The script started with reset of the $PATH to a value not suitable to Guix.
In addition, the script requires coreutils and sed, so add those into the
$PATH.

* gnu/packages/admin.scm (smartmontools)[arguments]<#:phases>: Add 'fix-path.

Change-Id: Ide97f572e6f369fe24337f945474dc7a65584eda
---
 gnu/packages/admin.scm | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index 7f50d5f4e9..098e21ff8a 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -2921,8 +2921,19 @@ (define-public smartmontools
                 "0gcrzcb4g7f994n6nws26g6x15yjija1gyzd359sjv7r3xj1z9p9"))))
     (build-system gnu-build-system)
     (arguments
-     (list #:make-flags
-           #~(list "BUILD_INFO=\"(Guix)\"")))
+     (list
+      #:make-flags
+      #~(list "BUILD_INFO=\"(Guix)\"")
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'install 'fix-path
+            (lambda _
+              (substitute* (string-append #$output "/etc/smartd_warning.sh")
+                (("export PATH=.*$" all)
+                 (string-append "PATH="
+                                #$(file-append sed "/bin") ":"
+                                #$(file-append coreutils "/bin") ":"
+                                "$PATH\n"))))))))
     (inputs (list libcap-ng))
     (home-page "https://www.smartmontools.org/")
     (synopsis "S.M.A.R.T. harddisk control and monitoring tools")
-- 
2.47.1





bug reassigned from package 'guix' to 'guix-patches'. Request was from Tomas Volf <~@wolfsden.cz> to control <at> debbugs.gnu.org. (Tue, 14 Jan 2025 23:43:02 GMT) Full text and rfc822 format available.

Information forwarded to guix-patches <at> gnu.org:
bug#75550; Package guix-patches. (Wed, 15 Jan 2025 02:54:01 GMT) Full text and rfc822 format available.

Message #16 received at 75550 <at> debbugs.gnu.org (full text, mbox):

From: Hilton Chain <hako <at> ultrarare.space>
To: Tomas Volf <~@wolfsden.cz>
Cc: 75550 <at> debbugs.gnu.org, Sharlatan Hellseher <sharlatanus <at> gmail.com>
Subject: Re: bug#75550: [PATCH] gnu: smartmontools: Fix PATH in
 smartd_warning.sh.
Date: Wed, 15 Jan 2025 10:50:35 +0800
Hi Tomas,

On Wed, 15 Jan 2025 07:40:19 +0800,
Tomas Volf wrote:
>
> The script started with reset of the $PATH to a value not suitable to Guix.
> In addition, the script requires coreutils and sed, so add those into the
> $PATH.
>
> * gnu/packages/admin.scm (smartmontools)[arguments]<#:phases>: Add 'fix-path.
>
> Change-Id: Ide97f572e6f369fe24337f945474dc7a65584eda
> ---
>  gnu/packages/admin.scm | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
> index 7f50d5f4e9..098e21ff8a 100644
> --- a/gnu/packages/admin.scm
> +++ b/gnu/packages/admin.scm
> @@ -2921,8 +2921,19 @@ (define-public smartmontools
>                  "0gcrzcb4g7f994n6nws26g6x15yjija1gyzd359sjv7r3xj1z9p9"))))
>      (build-system gnu-build-system)
>      (arguments
> -     (list #:make-flags
> -           #~(list "BUILD_INFO=\"(Guix)\"")))
> +     (list
> +      #:make-flags
> +      #~(list "BUILD_INFO=\"(Guix)\"")
> +      #:phases
> +      #~(modify-phases %standard-phases
> +          (add-after 'install 'fix-path
> +            (lambda _
> +              (substitute* (string-append #$output "/etc/smartd_warning.sh")
> +                (("export PATH=.*$" all)
> +                 (string-append "PATH="
> +                                #$(file-append sed "/bin") ":"
> +                                #$(file-append coreutils "/bin") ":"
> +                                "$PATH\n"))))))))

Please add sed and coreutils-minimal to inputs and use search-input-file or
this-package-input instead.

For smartmontools the proper way is to set --with-scriptpath='...' configure
flag, which is documented in its INSTALL file.  (It can be disabled with a 'no'
value as well.)

>      (inputs (list libcap-ng))
>      (home-page "https://www.smartmontools.org/")
>      (synopsis "S.M.A.R.T. harddisk control and monitoring tools")
> --
> 2.47.1

Thanks




Information forwarded to guix-patches <at> gnu.org:
bug#75550; Package guix-patches. (Fri, 24 Jan 2025 15:33:02 GMT) Full text and rfc822 format available.

Message #19 received at 75550 <at> debbugs.gnu.org (full text, mbox):

From: Tomas Volf <~@wolfsden.cz>
To: Hilton Chain <hako <at> ultrarare.space>
Cc: 75550 <at> debbugs.gnu.org, Sharlatan Hellseher <sharlatanus <at> gmail.com>
Subject: Re: bug#75550: [PATCH] gnu: smartmontools: Fix PATH in
 smartd_warning.sh.
Date: Fri, 24 Jan 2025 16:31:56 +0100
[Message part 1 (text/plain, inline)]
Thank you for the review, responses below.

Hilton Chain <hako <at> ultrarare.space> writes:

> Hi Tomas,
>
> On Wed, 15 Jan 2025 07:40:19 +0800,
> Tomas Volf wrote:
>>
>> The script started with reset of the $PATH to a value not suitable to Guix.
>> In addition, the script requires coreutils and sed, so add those into the
>> $PATH.
>>
>> * gnu/packages/admin.scm (smartmontools)[arguments]<#:phases>: Add 'fix-path.
>>
>> Change-Id: Ide97f572e6f369fe24337f945474dc7a65584eda
>> ---
>>  gnu/packages/admin.scm | 15 +++++++++++++--
>>  1 file changed, 13 insertions(+), 2 deletions(-)
>>
>> diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
>> index 7f50d5f4e9..098e21ff8a 100644
>> --- a/gnu/packages/admin.scm
>> +++ b/gnu/packages/admin.scm
>> @@ -2921,8 +2921,19 @@ (define-public smartmontools
>>                  "0gcrzcb4g7f994n6nws26g6x15yjija1gyzd359sjv7r3xj1z9p9"))))
>>      (build-system gnu-build-system)
>>      (arguments
>> -     (list #:make-flags
>> -           #~(list "BUILD_INFO=\"(Guix)\"")))
>> +     (list
>> +      #:make-flags
>> +      #~(list "BUILD_INFO=\"(Guix)\"")
>> +      #:phases
>> +      #~(modify-phases %standard-phases
>> +          (add-after 'install 'fix-path
>> +            (lambda _
>> +              (substitute* (string-append #$output "/etc/smartd_warning.sh")
>> +                (("export PATH=.*$" all)
>> +                 (string-append "PATH="
>> +                                #$(file-append sed "/bin") ":"
>> +                                #$(file-append coreutils "/bin") ":"
>> +                                "$PATH\n"))))))))
>
> Please add sed and coreutils-minimal to inputs and use search-input-file or
> this-package-input instead.

Why?  I will of course do so, but would first like to understand why.
The current way seems to work and keeps all the references in just one
place.  If I switch to the suggested approach, both `sed' and
`coreutils' will be referenced in two places (once in the `inputs' and
once here) and those will need to be kept in sync.  So, uh, why do it?

>
> For smartmontools the proper way is to set --with-scriptpath='...' configure
> flag, which is documented in its INSTALL file.  (It can be disabled with a 'no'
> value as well.)

This does indeed seem to be more elegant approach, will use it for v2.

>
>>      (inputs (list libcap-ng))
>>      (home-page "https://www.smartmontools.org/")
>>      (synopsis "S.M.A.R.T. harddisk control and monitoring tools")
>> --
>> 2.47.1
>
> Thanks

Tomas

-- 
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#75550; Package guix-patches. (Fri, 24 Jan 2025 16:20:01 GMT) Full text and rfc822 format available.

Message #22 received at 75550 <at> debbugs.gnu.org (full text, mbox):

From: Hilton Chain <hako <at> ultrarare.space>
To: Tomas Volf <~@wolfsden.cz>
Cc: 75550 <at> debbugs.gnu.org, Sharlatan Hellseher <sharlatanus <at> gmail.com>
Subject: Re: bug#75550: [PATCH] gnu: smartmontools: Fix PATH in
 smartd_warning.sh.
Date: Sat, 25 Jan 2025 00:19:06 +0800
On Fri, 24 Jan 2025 23:31:56 +0800,
Tomas Volf wrote:
> [...]
> >> +                 (string-append "PATH="
> >> +                                #$(file-append sed "/bin") ":"
> >> +                                #$(file-append coreutils "/bin") ":"
> >> +                                "$PATH\n"))))))))
> >
> > Please add sed and coreutils-minimal to inputs and use search-input-file or
> > this-package-input instead.
>
> Why?  I will of course do so, but would first like to understand why.
> The current way seems to work and keeps all the references in just one
> place.  If I switch to the suggested approach, both `sed' and
> `coreutils' will be referenced in two places (once in the `inputs' and
> once here) and those will need to be kept in sync.  So, uh, why do it?

The reason is to record dependency information at <package> level, since this is
where the UI and most of the tools work.  (`guix show', `guix refresh', package
transformation etc.)

For referencing dependencies from inputs in arguments, the benefit is mainly for
transformations.  Maybe it doesn't make much sense in this case (sed and
coreutils), but it's a good practice to follow.




Information forwarded to guix-patches <at> gnu.org:
bug#75550; Package guix-patches. (Tue, 28 Jan 2025 22:12:01 GMT) Full text and rfc822 format available.

Message #25 received at 75550 <at> debbugs.gnu.org (full text, mbox):

From: Tomas Volf <~@wolfsden.cz>
To: Hilton Chain <hako <at> ultrarare.space>
Cc: 75550 <at> debbugs.gnu.org, Sharlatan Hellseher <sharlatanus <at> gmail.com>
Subject: Re: bug#75550: [PATCH] gnu: smartmontools: Fix PATH in
 smartd_warning.sh.
Date: Tue, 28 Jan 2025 23:11:48 +0100
[Message part 1 (text/plain, inline)]
Hilton Chain <hako <at> ultrarare.space> writes:

> On Fri, 24 Jan 2025 23:31:56 +0800,
> Tomas Volf wrote:
>> [...]
>> >> +                 (string-append "PATH="
>> >> +                                #$(file-append sed "/bin") ":"
>> >> +                                #$(file-append coreutils "/bin") ":"
>> >> +                                "$PATH\n"))))))))
>> >
>> > Please add sed and coreutils-minimal to inputs and use search-input-file or
>> > this-package-input instead.
>>
>> Why?  I will of course do so, but would first like to understand why.
>> The current way seems to work and keeps all the references in just one
>> place.  If I switch to the suggested approach, both `sed' and
>> `coreutils' will be referenced in two places (once in the `inputs' and
>> once here) and those will need to be kept in sync.  So, uh, why do it?
>
> The reason is to record dependency information at <package> level, since this is
> where the UI and most of the tools work.  (`guix show', `guix refresh', package
> transformation etc.)

Is there a technical reason it cannot inspect the gexps used or is it
just matter of "no one wrote the code yet"?

>
> For referencing dependencies from inputs in arguments, the benefit is mainly for
> transformations.  Maybe it doesn't make much sense in this case (sed and
> coreutils), but it's a good practice to follow.

I did not realize this at all.  That is very good to know.

Tomas

-- 
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to sharlatanus <at> gmail.com, guix-patches <at> gnu.org:
bug#75550; Package guix-patches. (Tue, 28 Jan 2025 23:01:01 GMT) Full text and rfc822 format available.

Message #28 received at 75550 <at> debbugs.gnu.org (full text, mbox):

From: Tomas Volf <~@wolfsden.cz>
To: 75550 <at> debbugs.gnu.org
Cc: Tomas Volf <~@wolfsden.cz>
Subject: [PATCH v2] gnu: smartmontools: Fix PATH in smartd_warning.sh.
Date: Wed, 29 Jan 2025 00:00:15 +0100
The script started with reset of the $PATH to a value not suitable to Guix.
In addition, the script requires coreutils and sed, so add those into the
$PATH.

* gnu/packages/admin.scm (smartmontools)[inputs]: Add sed, coreutils-minimal.
[arguments]<#:configure-flags>: Pass --with-scriptpath=.

Change-Id: Ide97f572e6f369fe24337f945474dc7a65584eda
---
 gnu/packages/admin.scm | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index fd5d67ec50..e21f3f6e19 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -3051,9 +3051,16 @@ (define-public smartmontools
                 "0gcrzcb4g7f994n6nws26g6x15yjija1gyzd359sjv7r3xj1z9p9"))))
     (build-system gnu-build-system)
     (arguments
-     (list #:make-flags
-           #~(list "BUILD_INFO=\"(Guix)\"")))
-    (inputs (list libcap-ng))
+     (list
+      #:make-flags
+      #~(list "BUILD_INFO=\"(Guix)\"")
+      #:configure-flags
+      #~(list (format #f "--with-scriptpath=~a:~a:$PATH"
+                      (dirname (search-input-file %build-inputs "bin/sed"))
+                      (dirname (search-input-file %build-inputs "bin/true"))))))
+    (inputs (list coreutils-minimal
+                  libcap-ng
+                  sed))
     (home-page "https://www.smartmontools.org/")
     (synopsis "S.M.A.R.T. harddisk control and monitoring tools")
     (description
-- 
2.47.1





Information forwarded to guix-patches <at> gnu.org:
bug#75550; Package guix-patches. (Tue, 28 Jan 2025 23:03:01 GMT) Full text and rfc822 format available.

Message #31 received at 75550 <at> debbugs.gnu.org (full text, mbox):

From: Tomas Volf <~@wolfsden.cz>
To: Hilton Chain <hako <at> ultrarare.space>
Cc: 75550 <at> debbugs.gnu.org, Sharlatan Hellseher <sharlatanus <at> gmail.com>
Subject: Re: bug#75550: [PATCH] gnu: smartmontools: Fix PATH in
 smartd_warning.sh.
Date: Wed, 29 Jan 2025 00:02:04 +0100
[Message part 1 (text/plain, inline)]
Hilton Chain <hako <at> ultrarare.space> writes:

>
> Please add sed and coreutils-minimal to inputs and use search-input-file or
> this-package-input instead.
>
> For smartmontools the proper way is to set --with-scriptpath='...' configure
> flag, which is documented in its INSTALL file.  (It can be disabled with a 'no'
> value as well.)

Thank you for the review, I have sent v2 that hopefully incorporates
your feedback.

Tomas

-- 
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
[signature.asc (application/pgp-signature, inline)]

Reply sent to Hilton Chain <hako <at> ultrarare.space>:
You have taken responsibility. (Thu, 30 Jan 2025 12:31:02 GMT) Full text and rfc822 format available.

Notification sent to Tomas Volf <~@wolfsden.cz>:
bug acknowledged by developer. (Thu, 30 Jan 2025 12:31:02 GMT) Full text and rfc822 format available.

Message #36 received at 75550-done <at> debbugs.gnu.org (full text, mbox):

From: Hilton Chain <hako <at> ultrarare.space>
To: Tomas Volf <~@wolfsden.cz>
Cc: 75550-done <at> debbugs.gnu.org, Sharlatan Hellseher <sharlatanus <at> gmail.com>
Subject: Re: [bug#75550] [PATCH v2] gnu: smartmontools: Fix PATH in
 smartd_warning.sh.
Date: Thu, 30 Jan 2025 20:29:15 +0800
On Wed, 29 Jan 2025 07:00:15 +0800,
Tomas Volf wrote:
>
> The script started with reset of the $PATH to a value not suitable to Guix.
> In addition, the script requires coreutils and sed, so add those into the
> $PATH.
>
> * gnu/packages/admin.scm (smartmontools)[inputs]: Add sed, coreutils-minimal.
> [arguments]<#:configure-flags>: Pass --with-scriptpath=.
>
> Change-Id: Ide97f572e6f369fe24337f945474dc7a65584eda
> ---
>  gnu/packages/admin.scm | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
> index fd5d67ec50..e21f3f6e19 100644
> --- a/gnu/packages/admin.scm
> +++ b/gnu/packages/admin.scm
> @@ -3051,9 +3051,16 @@ (define-public smartmontools
>                  "0gcrzcb4g7f994n6nws26g6x15yjija1gyzd359sjv7r3xj1z9p9"))))
>      (build-system gnu-build-system)
>      (arguments
> -     (list #:make-flags
> -           #~(list "BUILD_INFO=\"(Guix)\"")))
> -    (inputs (list libcap-ng))
> +     (list
> +      #:make-flags
> +      #~(list "BUILD_INFO=\"(Guix)\"")
> +      #:configure-flags
> +      #~(list (format #f "--with-scriptpath=~a:~a:$PATH"
> +                      (dirname (search-input-file %build-inputs "bin/sed"))
> +                      (dirname (search-input-file %build-inputs "bin/true"))))))

I have modified #:configure-flags to use `this-package-input', to have proper
cross build support:
--8<---------------cut here---------------start------------->8---
#~(list (format #f "--with-scriptpath=~{~a:~}$PATH"
                (map (lambda (pkg)
                       (in-vicinity pkg "bin"))
                     '#$(list (this-package-input "coreutils-minimal")
                              (this-package-input "sed")))))
--8<---------------cut here---------------end--------------->8---

Thinking of the limitation of %build-inputs, it might be convenient to define
`inputs' and `native-inputs' directly in builder's environment.  🤔

Anyway, applied as f7fc4caf7da8f1d7cc76b3bc6ac0c4e643507454 with above change.

> +    (inputs (list coreutils-minimal
> +                  libcap-ng
> +                  sed))
>      (home-page "https://www.smartmontools.org/")
>      (synopsis "S.M.A.R.T. harddisk control and monitoring tools")
>      (description
> --
> 2.47.1

Thanks




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 28 Feb 2025 12:24:16 GMT) Full text and rfc822 format available.

This bug report was last modified 113 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.