Browse Source

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.
wip-gnome3.36
Ludovic Courtès 2 years ago
parent
commit
a322e9d16b
No known key found for this signature in database GPG Key ID: 90B11993D9AEBB5
  1. 17
      gnu/services.scm

17
gnu/services.scm

@ -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…
Cancel
Save