summaryrefslogtreecommitdiff
path: root/gnu/build
diff options
context:
space:
mode:
authorMathieu Othacehe <m.othacehe@gmail.com>2020-04-28 14:16:33 +0200
committerMathieu Othacehe <m.othacehe@gmail.com>2020-05-05 16:08:32 +0200
commit5990e95b607b888edd862a2ccb5ca69dcd17d801 (patch)
tree4b948ab42900768ca46770400a8c0a858fc8057a /gnu/build
parentfd1351ab0a209fb2cd3bd4de04fb9e2a515dea31 (diff)
build: install: Ignore chown exceptions.
Changing ownership may require root permissions. As image can now be generated without root permissions (no VM involved), ignore those exceptions. * gnu/build/install.scm (evaluate-populate-directive): Ignore chown exceptions.
Diffstat (limited to 'gnu/build')
-rw-r--r--gnu/build/install.scm16
1 files changed, 13 insertions, 3 deletions
diff --git a/gnu/build/install.scm b/gnu/build/install.scm
index c0d4d44091f..9753792216a 100644
--- a/gnu/build/install.scm
+++ b/gnu/build/install.scm
@@ -51,9 +51,14 @@ that the fonts, background images, etc. referred to by BOOTCFG are not GC'd."
51 (copy-file bootcfg pivot) 51 (copy-file bootcfg pivot)
52 (rename-file pivot target))) 52 (rename-file pivot target)))
53 53
54(define (evaluate-populate-directive directive target) 54(define* (evaluate-populate-directive directive target
55 #:key
56 (default-gid 0)
57 (default-uid 0))
55 "Evaluate DIRECTIVE, an sexp describing a file or directory to create under 58 "Evaluate DIRECTIVE, an sexp describing a file or directory to create under
56directory TARGET." 59directory TARGET. DEFAULT-UID and DEFAULT-GID are the default UID and GID in
60the context of the caller. If the directive matches those defaults then,
61'chown' won't be run."
57 (let loop ((directive directive)) 62 (let loop ((directive directive))
58 (catch 'system-error 63 (catch 'system-error
59 (lambda () 64 (lambda ()
@@ -63,7 +68,12 @@ directory TARGET."
63 (('directory name uid gid) 68 (('directory name uid gid)
64 (let ((dir (string-append target name))) 69 (let ((dir (string-append target name)))
65 (mkdir-p dir) 70 (mkdir-p dir)
66 (chown dir uid gid))) 71 ;; If called from a context without "root" permissions, "chown"
72 ;; to root will fail. In that case, do not try to run "chown"
73 ;; and assume that the file will be chowned elsewhere (when
74 ;; interned in the store for instance).
75 (or (and (= uid default-uid) (= gid default-gid))
76 (chown dir uid gid))))
67 (('directory name uid gid mode) 77 (('directory name uid gid mode)
68 (loop `(directory ,name ,uid ,gid)) 78 (loop `(directory ,name ,uid ,gid))
69 (chmod (string-append target name) mode)) 79 (chmod (string-append target name) mode))