channels: Warn about missing introductions.

* guix/channels.scm (latest-channel-instance): Warn when CHANNEL has no
introduction and CHECKOUT contains '.guix-authorizations'.
This commit is contained in:
Ludovic Courtès 2022-10-04 09:28:01 +02:00
parent ae1af5d787
commit 5bc4b8e8e3
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -419,19 +419,28 @@ (define (dot-git? file stat)
(if authenticate? (if authenticate?
(if (channel-introduction channel) (if (channel-introduction channel)
(authenticate-channel channel checkout commit) (authenticate-channel channel checkout commit)
;; TODO: Warn for all the channels once the authentication interface (begin
;; is public. (when (file-exists?
(when (guix-channel? channel) (string-append checkout "/.guix-authorizations"))
(raise (make-compound-condition (warning (and=> (channel-location channel)
(formatted-message (G_ "channel '~a' lacks an \ source-properties->location)
(G_ "channel '~a' lacks 'introduction' field but \
'.guix-authorizations' found\n")
(channel-name channel)))
;; TODO: Warn for all the channels once the authentication interface
;; is public.
(when (guix-channel? channel)
(raise (make-compound-condition
(formatted-message (G_ "channel '~a' lacks an \
introduction and cannot be authenticated~%") introduction and cannot be authenticated~%")
(channel-name channel)) (channel-name channel))
(condition (condition
(&fix-hint (&fix-hint
(hint (G_ "Add the missing introduction to your (hint (G_ "Add the missing introduction to your
channels file to address the issue. Alternatively, you can pass channels file to address the issue. Alternatively, you can pass
@option{--disable-authentication}, at the risk of running unauthenticated and @option{--disable-authentication}, at the risk of running unauthenticated and
thus potentially malicious code.")))))))) thus potentially malicious code.")))))))))
(warning (G_ "channel authentication disabled~%"))) (warning (G_ "channel authentication disabled~%")))
(when (guix-channel? channel) (when (guix-channel? channel)