summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-04-20 22:31:38 +0200
committerLudovic Courtès <ludo@gnu.org>2020-04-21 00:06:40 +0200
commita322e9d16b227484ce04721fee0f99618cb1007e (patch)
tree5ea8a61cf9d7ebc3d6ca360e10d1899862fad382
parentb25ecfa2e0ab6642dc35f7f68a24117e33f5795f (diff)
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.
-rw-r--r--gnu/services.scm17
1 files changed, 17 insertions, 0 deletions
diff --git a/gnu/services.scm b/gnu/services.scm
index 832d6984d8..126e0814eb 100644
--- a/gnu/services.scm
+++ b/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)