GNU bug report logs - #77037
[PATCH] services: `file-database-mcron-jobs' search updatedb in package field

Previous Next

Package: guix-patches;

Reported by: Sergio Pastor Pérez <sergio.pastorperez <at> gmail.com>

Date: Sat, 15 Mar 2025 14:20:03 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Sergio Pastor Pérez <sergio.pastorperez <at> gmail.com>
To: 77037 <at> debbugs.gnu.org
Cc: Sergio Pastor Pérez <sergio.pastorperez <at> gmail.com>
Subject: [bug#77037] [PATCH] services: `file-database-mcron-jobs' search updatedb in package field
Date: Sat, 15 Mar 2025 15:18:30 +0100
`file-database-service-type' appends 'bin/updatedb' path to the `package'
field provided by `file-database-configuration'. This prevents users from
using alternate packages which also provide 'updatedb' but in a different
location.

For example, the `plocate' package installs 'updatedb' it in 'sbin/updatedb'.

Use `find-files' to locate the binary within the user configured package.

* gnu/services/admin.scm (file-database-mcron-jobs): locate 'updatedb' binary.

Change-Id: Id35b26cbe41261a0ac3add53757d240b003aa26e
---
 gnu/services/admin.scm | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm
index 2a11a4f4f10..19b0d64f2c2 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -37,13 +37,16 @@ (define-module (gnu services admin)
   #:use-module (gnu services shepherd)
   #:use-module (gnu system accounts)
   #:use-module ((gnu system shadow) #:select (account-service-type))
-  #:use-module ((guix store) #:select (%store-prefix))
+  #:use-module ((guix store) #:select (%store-prefix
+                                       open-connection))
   #:use-module (guix deprecation)
   #:use-module (guix gexp)
   #:use-module (guix modules)
   #:use-module (guix packages)
   #:use-module (guix records)
+  #:use-module (guix build utils)
   #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-26)
   #:use-module (ice-9 match)
   #:use-module (ice-9 vlist)
   #:export (log-rotation-configuration
@@ -473,17 +476,21 @@ (define (file-database-mcron-jobs configuration)
                      #~(begin
                          ;; 'updatedb' is a shell script that expects various
                          ;; commands in $PATH.
-                         (setenv "PATH"
-                                 (string-append #$package "/bin:"
-                                                #$(canonical-package coreutils)
-                                                "/bin:"
-                                                #$(canonical-package sed)
-                                                "/bin"))
-                         (execl #$(file-append package "/bin/updatedb")
-                                "updatedb"
-                                #$(string-append "--prunepaths="
-                                                 (string-join
-                                                  excluded-directories)))))))
+                         (let ((updatedb-bin #$(find (cut executable-file? <>)
+                                                     (find-files (package-output (open-connection)
+                                                                                 package)
+                                                                 "^updatedb$"))))
+                           (setenv "PATH"
+                                   (string-append (dirname updatedb-bin) ":"
+                                                  #$(canonical-package coreutils)
+                                                  "/bin:"
+                                                  #$(canonical-package sed)
+                                                  "/bin"))
+                           (execl updatedb-bin
+                                  "updatedb"
+                                  #$(string-append "--prunepaths="
+                                                   (string-join
+                                                    excluded-directories))))))))
       (list #~(job #$schedule #$updatedb)))))
 
 (define file-database-service-type

base-commit: 412f411d4f8780e6b60b448caae17f01c09be0eb
-- 
2.48.1





This bug report was last modified 109 days ago.

Previous Next


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