services: etc: Detect and report duplicate entries.
Fixes <https://bugs.gnu.org/40729>. Reported by Christopher Baines <mail@cbaines.net>. * gnu/services.scm (files->etc-directory)[assert-no-duplicates]: New procedure. Use it.
This commit is contained in:
parent
b25ecfa2e0
commit
a322e9d16b
@ -632,6 +632,23 @@ and FILE could be \"/usr/bin/env\"."
|
||||
(files->etc-directory (service-value service)))
|
||||
|
||||
(define (files->etc-directory files)
|
||||
(define (assert-no-duplicates files)
|
||||
(let loop ((files files)
|
||||
(seen (set)))
|
||||
(match files
|
||||
(() #t)
|
||||
(((file _) rest ...)
|
||||
(when (set-contains? seen file)
|
||||
(raise (condition
|
||||
(&message
|
||||
(message (format #f (G_ "duplicate '~a' entry for /etc")
|
||||
file))))))
|
||||
(loop rest (set-insert file seen))))))
|
||||
|
||||
;; Detect duplicates early instead of letting them through, eventually
|
||||
;; leading to a build failure of "etc.drv".
|
||||
(assert-no-duplicates files)
|
||||
|
||||
(file-union "etc" files))
|
||||
|
||||
(define (etc-entry files)
|
||||
|
Loading…
Reference in New Issue
Block a user