me
/
guix
Archived
1
0
Fork 0

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.
master
Mathieu Othacehe 2020-04-28 14:16:33 +02:00
parent fd1351ab0a
commit 5990e95b60
No known key found for this signature in database
GPG Key ID: 8354763531769CA6
1 changed files with 13 additions and 3 deletions

View File

@ -51,9 +51,14 @@ that the fonts, background images, etc. referred to by BOOTCFG are not GC'd."
(copy-file bootcfg pivot) (copy-file bootcfg pivot)
(rename-file pivot target))) (rename-file pivot target)))
(define (evaluate-populate-directive directive target) (define* (evaluate-populate-directive directive target
#:key
(default-gid 0)
(default-uid 0))
"Evaluate DIRECTIVE, an sexp describing a file or directory to create under "Evaluate DIRECTIVE, an sexp describing a file or directory to create under
directory TARGET." directory TARGET. DEFAULT-UID and DEFAULT-GID are the default UID and GID in
the context of the caller. If the directive matches those defaults then,
'chown' won't be run."
(let loop ((directive directive)) (let loop ((directive directive))
(catch 'system-error (catch 'system-error
(lambda () (lambda ()
@ -63,7 +68,12 @@ directory TARGET."
(('directory name uid gid) (('directory name uid gid)
(let ((dir (string-append target name))) (let ((dir (string-append target name)))
(mkdir-p dir) (mkdir-p dir)
(chown dir uid gid))) ;; If called from a context without "root" permissions, "chown"
;; to root will fail. In that case, do not try to run "chown"
;; and assume that the file will be chowned elsewhere (when
;; interned in the store for instance).
(or (and (= uid default-uid) (= gid default-gid))
(chown dir uid gid))))
(('directory name uid gid mode) (('directory name uid gid mode)
(loop `(directory ,name ,uid ,gid)) (loop `(directory ,name ,uid ,gid))
(chmod (string-append target name) mode)) (chmod (string-append target name) mode))