channels.scm 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2018-2023 Ludovic Courtès <ludo@gnu.org>
  3. ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
  4. ;;; Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  5. ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
  6. ;;;
  7. ;;; This file is part of GNU Guix.
  8. ;;;
  9. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  10. ;;; under the terms of the GNU General Public License as published by
  11. ;;; the Free Software Foundation; either version 3 of the License, or (at
  12. ;;; your option) any later version.
  13. ;;;
  14. ;;; GNU Guix is distributed in the hope that it will be useful, but
  15. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ;;; GNU General Public License for more details.
  18. ;;;
  19. ;;; You should have received a copy of the GNU General Public License
  20. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  21. (define-module (guix channels)
  22. #:use-module (git)
  23. #:use-module (guix git)
  24. #:use-module (guix git-authenticate)
  25. #:use-module ((guix openpgp)
  26. #:select (openpgp-public-key-fingerprint
  27. openpgp-format-fingerprint))
  28. #:use-module (guix base16)
  29. #:use-module (guix records)
  30. #:use-module (guix gexp)
  31. #:use-module (guix monads)
  32. #:use-module (guix profiles)
  33. #:use-module (guix packages)
  34. #:use-module (guix progress)
  35. #:use-module (guix derivations)
  36. #:use-module (guix combinators)
  37. #:use-module (guix diagnostics)
  38. #:use-module (guix sets)
  39. #:use-module (guix store)
  40. #:use-module (guix i18n)
  41. #:use-module (srfi srfi-1)
  42. #:use-module (srfi srfi-2)
  43. #:use-module (srfi srfi-9)
  44. #:use-module (srfi srfi-11)
  45. #:use-module (srfi srfi-26)
  46. #:use-module (srfi srfi-34)
  47. #:use-module (srfi srfi-35)
  48. #:autoload (guix describe) (current-channels) ;XXX: circular dep
  49. #:autoload (guix self) (whole-package make-config.scm)
  50. #:autoload (guix inferior) (gexp->derivation-in-inferior) ;FIXME: circular dep
  51. #:autoload (guix quirks) (%quirks %patches applicable-patch? apply-patch)
  52. #:use-module (ice-9 format)
  53. #:use-module (ice-9 match)
  54. #:use-module (ice-9 vlist)
  55. #:export (channel
  56. channel?
  57. channel-name
  58. channel-url
  59. channel-branch
  60. channel-commit
  61. channel-introduction
  62. channel-location
  63. channel-introduction?
  64. make-channel-introduction
  65. channel-introduction-first-signed-commit
  66. channel-introduction-first-commit-signer
  67. openpgp-fingerprint->bytevector
  68. openpgp-fingerprint
  69. %default-guix-channel
  70. %default-channels
  71. guix-channel?
  72. repository->guix-channel
  73. channel-instance?
  74. channel-instance-channel
  75. channel-instance-commit
  76. channel-instance-checkout
  77. authenticate-channel
  78. latest-channel-instances
  79. checkout->channel-instance
  80. latest-channel-derivation
  81. channel-instance->sexp
  82. channel-instances->manifest
  83. %channel-profile-hooks
  84. channel-instances->derivation
  85. ensure-forward-channel-update
  86. profile-channels
  87. manifest-entry-channel
  88. sexp->channel
  89. channel->code
  90. channel-news-entry?
  91. channel-news-entry-commit
  92. channel-news-entry-tag
  93. channel-news-entry-title
  94. channel-news-entry-body
  95. channel-news-for-commit))
  96. ;;; Commentary:
  97. ;;;
  98. ;;; This module implements "channels." A channel is usually a source of
  99. ;;; package definitions. There's a special channel, the 'guix' channel, that
  100. ;;; provides all of Guix, including its commands and its documentation.
  101. ;;; User-defined channels are expected to typically provide a bunch of .scm
  102. ;;; files meant to be added to the '%package-search-path'.
  103. ;;;
  104. ;;; This module provides tools to fetch and update channels from a Git
  105. ;;; repository and to build them.
  106. ;;;
  107. ;;; Code:
  108. (define-record-type* <channel> channel make-channel
  109. channel?
  110. (name channel-name)
  111. (url channel-url)
  112. (branch channel-branch (default "master"))
  113. (commit channel-commit (default #f))
  114. (introduction channel-introduction (default #f))
  115. (location channel-location
  116. (default (current-source-location)) (innate)))
  117. ;; Channel introductions. A "channel introduction" provides a commit/signer
  118. ;; pair that specifies the first commit of the authentication process as well
  119. ;; as its signer's fingerprint. Introductions are used to bootstrap trust in
  120. ;; a channel.
  121. (define-record-type <channel-introduction>
  122. (%make-channel-introduction first-signed-commit first-commit-signer)
  123. channel-introduction?
  124. (first-signed-commit channel-introduction-first-signed-commit) ;hex string
  125. (first-commit-signer channel-introduction-first-commit-signer)) ;bytevector
  126. (define (make-channel-introduction commit signer)
  127. "Return a new channel introduction: COMMIT is the introductory where
  128. authentication starts, and SIGNER is the OpenPGP fingerprint (a bytevector) of
  129. the signer of that commit."
  130. (%make-channel-introduction commit signer))
  131. (define (openpgp-fingerprint->bytevector str)
  132. "Convert STR, an OpenPGP fingerprint (hexadecimal string with whitespace),
  133. to the corresponding bytevector."
  134. (base16-string->bytevector
  135. (string-downcase (string-filter char-set:hex-digit str))))
  136. (define-syntax openpgp-fingerprint
  137. (lambda (s)
  138. "Convert STR, an OpenPGP fingerprint (hexadecimal string with whitespace),
  139. to the corresponding bytevector."
  140. (syntax-case s ()
  141. ((_ str)
  142. (string? (syntax->datum #'str))
  143. (openpgp-fingerprint->bytevector (syntax->datum #'str)))
  144. ((_ str)
  145. #'(openpgp-fingerprint->bytevector str)))))
  146. (define %guix-channel-introduction
  147. ;; Introduction of the official 'guix channel. The chosen commit is the
  148. ;; first one that introduces '.guix-authorizations' on the 'staging'
  149. ;; branch that was eventually merged in 'master'. Any branch starting
  150. ;; before that commit cannot be merged or it will be rejected by 'guix pull'
  151. ;; & co.
  152. (make-channel-introduction
  153. "9edb3f66fd807b096b48283debdcddccfea34bad" ;2020-05-26
  154. (openpgp-fingerprint ;mbakke
  155. "BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA")))
  156. (define %default-channel-url
  157. ;; URL of the default 'guix' channel.
  158. "https://git.savannah.gnu.org/git/guix.git")
  159. (define %default-guix-channel
  160. (channel
  161. (name 'guix)
  162. (branch "master")
  163. (url %default-channel-url)
  164. (introduction %guix-channel-introduction)))
  165. (define %default-channels
  166. ;; Default list of channels.
  167. (list %default-guix-channel))
  168. (define (guix-channel? channel)
  169. "Return true if CHANNEL is the 'guix' channel."
  170. (eq? 'guix (channel-name channel)))
  171. (define (ensure-default-introduction chan)
  172. "If CHAN represents the \"official\" 'guix' channel and lacks an
  173. introduction, add it."
  174. (if (and (guix-channel? chan)
  175. (not (channel-introduction chan))
  176. (string=? (channel-url chan) %default-channel-url))
  177. (channel (inherit chan)
  178. (introduction %guix-channel-introduction))
  179. chan))
  180. (define* (repository->guix-channel directory
  181. #:key
  182. (introduction %guix-channel-introduction))
  183. "Look for a Git repository in DIRECTORY or its ancestors and return a
  184. channel that uses that repository and the commit HEAD currently points to; use
  185. INTRODUCTION as the channel's introduction. Return #f if no Git repository
  186. could be found at DIRECTORY or one of its ancestors."
  187. (catch 'git-error
  188. (lambda ()
  189. (with-repository (repository-discover directory) repository
  190. (let* ((head (repository-head repository))
  191. (commit (oid->string (reference-target head))))
  192. (channel
  193. (inherit %default-guix-channel)
  194. (url (repository-working-directory repository))
  195. (commit commit)
  196. (branch (reference-shorthand head))
  197. (introduction introduction)))))
  198. (const #f)))
  199. (define-record-type <channel-instance>
  200. (channel-instance channel commit checkout)
  201. channel-instance?
  202. (channel channel-instance-channel)
  203. (commit channel-instance-commit)
  204. (checkout channel-instance-checkout))
  205. (define-record-type <channel-metadata>
  206. (channel-metadata directory dependencies news-file keyring-reference url)
  207. channel-metadata?
  208. (directory channel-metadata-directory) ;string with leading slash
  209. (dependencies channel-metadata-dependencies) ;list of <channel>
  210. (news-file channel-metadata-news-file) ;string | #f
  211. (keyring-reference channel-metadata-keyring-reference) ;string
  212. (url channel-metadata-url)) ;string | #f
  213. (define %default-keyring-reference
  214. ;; Default value of the 'keyring-reference' field.
  215. "keyring")
  216. (define (channel-reference channel)
  217. "Return the \"reference\" for CHANNEL, an sexp suitable for
  218. 'latest-repository-commit'."
  219. (match (channel-commit channel)
  220. (#f `(branch . ,(channel-branch channel)))
  221. (commit `(tag-or-commit . ,(channel-commit channel)))))
  222. (define sexp->channel-introduction
  223. (match-lambda
  224. (('channel-introduction ('version 0)
  225. ('commit commit) ('signer signer)
  226. _ ...)
  227. (make-channel-introduction commit (openpgp-fingerprint signer)))
  228. (x (raise (condition
  229. (&message
  230. (message (format #f (G_ "channel dependency has an invalid\
  231. introduction field"))))
  232. (&error-location
  233. (location
  234. (source-properties->location
  235. (source-properties x)))))))))
  236. (define (read-channel-metadata port)
  237. "Read from PORT channel metadata in the format expected for the
  238. '.guix-channel' file. Return a <channel-metadata> record, or raise an error
  239. if valid metadata could not be read from PORT."
  240. (match (read port)
  241. (('channel ('version 0) properties ...)
  242. (let ((directory (and=> (assoc-ref properties 'directory) first))
  243. (dependencies (or (assoc-ref properties 'dependencies) '()))
  244. (news-file (and=> (assoc-ref properties 'news-file) first))
  245. (url (and=> (assoc-ref properties 'url) first))
  246. (keyring-reference
  247. (or (and=> (assoc-ref properties 'keyring-reference) first)
  248. %default-keyring-reference)))
  249. (channel-metadata
  250. (cond ((not directory) "/") ;directory
  251. ((string-prefix? "/" directory) directory)
  252. (else (string-append "/" directory)))
  253. (map (lambda (item) ;dependencies
  254. (let ((get (lambda* (key #:optional default)
  255. (or (and=> (assoc-ref item key) first) default))))
  256. (and-let* ((name (get 'name))
  257. (url (get 'url))
  258. (branch (get 'branch "master")))
  259. (channel
  260. (name name)
  261. (branch branch)
  262. (url url)
  263. (commit (get 'commit))
  264. (introduction (and=> (get 'introduction)
  265. sexp->channel-introduction))))))
  266. dependencies)
  267. news-file
  268. keyring-reference
  269. url)))
  270. ((and ('channel ('version version) _ ...) sexp)
  271. (raise (condition
  272. (&message (message "unsupported '.guix-channel' version"))
  273. (&error-location
  274. (location (source-properties->location
  275. (source-properties sexp)))))))
  276. (sexp
  277. (raise (condition
  278. (&message (message "invalid '.guix-channel' file"))
  279. (&error-location
  280. (location (source-properties->location
  281. (source-properties sexp)))))))))
  282. (define (read-channel-metadata-from-source source)
  283. "Return a channel-metadata record read from channel's SOURCE/.guix-channel
  284. description file, or return the default channel-metadata record if that file
  285. doesn't exist."
  286. (catch 'system-error
  287. (lambda ()
  288. (call-with-input-file (string-append source "/.guix-channel")
  289. read-channel-metadata))
  290. (lambda args
  291. (if (= ENOENT (system-error-errno args))
  292. (channel-metadata "/" '() #f %default-keyring-reference #f)
  293. (apply throw args)))))
  294. (define (channel-instance-metadata instance)
  295. "Return a channel-metadata record read from the channel INSTANCE's
  296. description file or its default value."
  297. (read-channel-metadata-from-source (channel-instance-checkout instance)))
  298. (define (channel-instance-dependencies instance)
  299. "Return the list of channels that are declared as dependencies for the given
  300. channel INSTANCE."
  301. (channel-metadata-dependencies (channel-instance-metadata instance)))
  302. (define (apply-patches checkout commit patches)
  303. "Apply the matching PATCHES to CHECKOUT, modifying files in place. The
  304. result is unspecified."
  305. (let loop ((patches patches))
  306. (match patches
  307. (() #t)
  308. ((patch rest ...)
  309. (when (applicable-patch? patch checkout commit)
  310. (apply-patch patch checkout))
  311. (loop rest)))))
  312. (define commit-short-id
  313. (compose (cut string-take <> 7) oid->string commit-id))
  314. (define* (authenticate-channel channel checkout commit
  315. #:key (keyring-reference-prefix "origin/"))
  316. "Authenticate the given COMMIT of CHANNEL, available at CHECKOUT, a
  317. directory containing a CHANNEL checkout. Raise an error if authentication
  318. fails."
  319. (define intro
  320. (channel-introduction channel))
  321. (define cache-key
  322. (string-append "channels/" (symbol->string (channel-name channel))))
  323. (define keyring-reference
  324. (channel-metadata-keyring-reference
  325. (read-channel-metadata-from-source checkout)))
  326. (define (make-reporter start-commit end-commit commits)
  327. (format (current-error-port)
  328. (G_ "Authenticating channel '~a', commits ~a to ~a (~h new \
  329. commits)...~%")
  330. (channel-name channel)
  331. (commit-short-id start-commit)
  332. (commit-short-id end-commit)
  333. (length commits))
  334. (progress-reporter/bar (length commits)))
  335. (define authentic-commits
  336. ;; Consider the currently-used commit of CHANNEL as authentic so
  337. ;; authentication can skip it and all its closure.
  338. (match (find (lambda (candidate)
  339. (eq? (channel-name candidate) (channel-name channel)))
  340. (current-channels))
  341. (#f '())
  342. (channel
  343. (if (channel-commit channel)
  344. (list (channel-commit channel))
  345. '()))))
  346. ;; XXX: Too bad we need to re-open CHECKOUT.
  347. (with-repository checkout repository
  348. (authenticate-repository repository
  349. (string->oid
  350. (channel-introduction-first-signed-commit intro))
  351. (channel-introduction-first-commit-signer intro)
  352. #:end (string->oid commit)
  353. #:keyring-reference
  354. (string-append keyring-reference-prefix
  355. keyring-reference)
  356. #:authentic-commits authentic-commits
  357. #:make-reporter make-reporter
  358. #:cache-key cache-key)))
  359. (define* (latest-channel-instance store channel
  360. #:key (patches %patches)
  361. starting-commit
  362. (authenticate? #f)
  363. (validate-pull
  364. ensure-forward-channel-update))
  365. "Return the latest channel instance for CHANNEL. When STARTING-COMMIT is
  366. true, call VALIDATE-PULL with CHANNEL, STARTING-COMMIT, the target commit, and
  367. their relation. When AUTHENTICATE? is false, CHANNEL is not authenticated."
  368. (define (dot-git? file stat)
  369. (and (string=? (basename file) ".git")
  370. (eq? 'directory (stat:type stat))))
  371. (let-values (((channel)
  372. (ensure-default-introduction channel))
  373. ((checkout commit relation)
  374. (update-cached-checkout (channel-url channel)
  375. #:ref (channel-reference channel)
  376. #:starting-commit starting-commit)))
  377. (when relation
  378. (validate-pull channel starting-commit commit relation))
  379. (if authenticate?
  380. (if (channel-introduction channel)
  381. (authenticate-channel channel checkout commit)
  382. (begin
  383. (when (file-exists?
  384. (string-append checkout "/.guix-authorizations"))
  385. (warning (and=> (channel-location channel)
  386. source-properties->location)
  387. (G_ "channel '~a' lacks 'introduction' field but \
  388. '.guix-authorizations' found\n")
  389. (channel-name channel)))
  390. ;; TODO: Warn for all the channels once the authentication interface
  391. ;; is public.
  392. (when (guix-channel? channel)
  393. (raise (make-compound-condition
  394. (formatted-message (G_ "channel '~a' lacks an \
  395. introduction and cannot be authenticated~%")
  396. (channel-name channel))
  397. (condition
  398. (&fix-hint
  399. (hint (G_ "Add the missing introduction to your
  400. channels file to address the issue. Alternatively, you can pass
  401. @option{--disable-authentication}, at the risk of running unauthenticated and
  402. thus potentially malicious code.")))))))))
  403. (warning (G_ "channel authentication disabled~%")))
  404. (when (guix-channel? channel)
  405. ;; Apply the relevant subset of PATCHES directly in CHECKOUT. This is
  406. ;; safe to do because 'switch-to-ref' eventually does a hard reset.
  407. (apply-patches checkout commit patches))
  408. (let* ((name (url+commit->name (channel-url channel) commit))
  409. (checkout (add-to-store store name #t "sha256" checkout
  410. #:select? (negate dot-git?))))
  411. (channel-instance channel commit checkout))))
  412. (define (ensure-forward-channel-update channel start commit relation)
  413. "Raise an error if RELATION is not 'ancestor, meaning that START is not an
  414. ancestor of COMMIT, unless CHANNEL specifies a commit.
  415. This procedure implements a channel update policy meant to be used as a
  416. #:validate-pull argument."
  417. (match relation
  418. ('ancestor #t)
  419. ('self #t)
  420. (_
  421. (raise (make-compound-condition
  422. (condition
  423. (&message (message
  424. (format #f (G_ "\
  425. aborting update of channel '~a' to commit ~a, which is not a descendant of ~a")
  426. (channel-name channel)
  427. commit start))))
  428. ;; If the user asked for a specific commit, they might want
  429. ;; that to happen nevertheless, so tell them about the
  430. ;; relevant 'guix pull' option.
  431. (if (channel-commit channel)
  432. (condition
  433. (&fix-hint
  434. (hint (G_ "Use @option{--allow-downgrades} to force
  435. this downgrade."))))
  436. (condition
  437. (&fix-hint
  438. (hint (G_ "This could indicate that the channel has
  439. been tampered with and is trying to force a roll-back, preventing you from
  440. getting the latest updates. If you think this is not the case, explicitly
  441. allow non-forward updates."))))))))))
  442. (define (channel-instance-primary-url instance)
  443. "Return the primary URL advertised for INSTANCE, or #f if there is no such
  444. information."
  445. (channel-metadata-url (channel-instance-metadata instance)))
  446. (define* (latest-channel-instances store channels
  447. #:key
  448. (current-channels '())
  449. (authenticate? #t)
  450. (validate-pull
  451. ensure-forward-channel-update))
  452. "Return a list of channel instances corresponding to the latest checkouts of
  453. CHANNELS and the channels on which they depend.
  454. When AUTHENTICATE? is true, authenticate the subset of CHANNELS that has a
  455. \"channel introduction\".
  456. CURRENT-CHANNELS is the list of currently used channels. It is compared
  457. against the newly-fetched instances of CHANNELS, and VALIDATE-PULL is called
  458. for each channel update and can choose to emit warnings or raise an error,
  459. depending on the policy it implements."
  460. ;; Only process channels that are unique, or that are more specific than a
  461. ;; previous channel specification.
  462. (define (ignore? channel others)
  463. (member channel others
  464. (lambda (a b)
  465. (and (eq? (channel-name a) (channel-name b))
  466. (or (channel-commit b)
  467. (not (or (channel-commit a)
  468. (channel-commit b))))))))
  469. (define (current-commit name)
  470. ;; Return the current commit for channel NAME.
  471. (any (lambda (channel)
  472. (and (eq? (channel-name channel) name)
  473. (channel-commit channel)))
  474. current-channels))
  475. (let loop ((channels channels)
  476. (previous-channels '()))
  477. ;; Accumulate a list of instances. A list of processed channels is also
  478. ;; accumulated to decide on duplicate channel specifications.
  479. (define-values (resulting-channels instances)
  480. (fold2 (lambda (channel previous-channels instances)
  481. (if (ignore? channel previous-channels)
  482. (values previous-channels instances)
  483. (begin
  484. (format (current-error-port)
  485. (G_ "Updating channel '~a' from Git repository at '~a'...~%")
  486. (channel-name channel)
  487. (channel-url channel))
  488. (let* ((current (current-commit (channel-name channel)))
  489. (instance
  490. (latest-channel-instance store channel
  491. #:authenticate?
  492. authenticate?
  493. #:validate-pull
  494. validate-pull
  495. #:starting-commit
  496. current)))
  497. (when authenticate?
  498. ;; CHANNEL is authenticated so we can trust the
  499. ;; primary URL advertised in its metadata and warn
  500. ;; about possibly stale mirrors.
  501. (let ((primary-url (channel-instance-primary-url
  502. instance)))
  503. (unless (or (not primary-url)
  504. (channel-commit channel)
  505. (string=? primary-url (channel-url channel)))
  506. (warning (G_ "pulled channel '~a' from a mirror \
  507. of ~a, which might be stale~%")
  508. (channel-name channel)
  509. primary-url))))
  510. (let-values (((new-instances new-channels)
  511. (loop (channel-instance-dependencies instance)
  512. previous-channels)))
  513. (values (append (cons channel new-channels)
  514. previous-channels)
  515. (append (cons instance new-instances)
  516. instances)))))))
  517. previous-channels
  518. '() ;instances
  519. channels))
  520. (let ((instance-name (compose channel-name channel-instance-channel)))
  521. ;; Remove all earlier channel specifications if they are followed by a
  522. ;; more specific one.
  523. (values (delete-duplicates instances
  524. (lambda (a b)
  525. (eq? (instance-name a) (instance-name b))))
  526. resulting-channels))))
  527. (define* (checkout->channel-instance checkout
  528. #:key commit
  529. (url checkout) (name 'guix))
  530. "Return a channel instance for CHECKOUT, which is assumed to be a checkout
  531. of COMMIT at URL. Use NAME as the channel name."
  532. (let* ((commit (or commit (make-string 40 #\0)))
  533. (channel (channel (name name)
  534. (commit commit)
  535. (url url))))
  536. (channel-instance channel commit checkout)))
  537. (define %self-build-file
  538. ;; The file containing code to build Guix. This serves the same purpose as
  539. ;; a makefile, and, similarly, is intended to always keep this name.
  540. "build-aux/build-self.scm")
  541. (define %pull-version
  542. ;; This is the version of the 'guix pull' protocol. It specifies what's
  543. ;; expected from %SELF-BUILD-FILE. The initial version ("0") was when we'd
  544. ;; place a set of compiled Guile modules in ~/.config/guix/latest.
  545. 1)
  546. (define (standard-module-derivation name source core dependencies)
  547. "Return a derivation that builds with CORE, a Guix instance, the Scheme
  548. modules in SOURCE and that depend on DEPENDENCIES, a list of lowerable
  549. objects. The assumption is that SOURCE contains package modules to be added
  550. to '%package-module-path'."
  551. (let* ((metadata (read-channel-metadata-from-source source))
  552. (directory (channel-metadata-directory metadata)))
  553. (define build
  554. ;; This is code that we'll run in CORE, a Guix instance, with its own
  555. ;; modules and so on. That way, we make sure these modules are built for
  556. ;; the right Guile version, with the right dependencies, and that they get
  557. ;; to see the right (gnu packages …) modules.
  558. (with-extensions dependencies
  559. #~(begin
  560. (use-modules (guix build compile)
  561. (guix build utils)
  562. (srfi srfi-26))
  563. (define go
  564. (string-append #$output "/lib/guile/" (effective-version)
  565. "/site-ccache"))
  566. (define scm
  567. (string-append #$output "/share/guile/site/"
  568. (effective-version)))
  569. (define optimizations-for-level
  570. ;; Guile 3.0 provides this procedure but Guile 2.2 didn't.
  571. ;; Since this code may be executed by either version, we can't
  572. ;; rely on its availability.
  573. (or (and=> (false-if-exception
  574. (resolve-interface '(system base optimize)))
  575. (lambda (iface)
  576. (module-ref iface 'optimizations-for-level)))
  577. (const '())))
  578. (define -O1
  579. ;; Optimize for package module compilation speed.
  580. (optimizations-for-level 1))
  581. (let* ((subdir #$directory)
  582. (source (string-append #$source subdir)))
  583. (compile-files source go (find-files source "\\.scm$")
  584. #:optimization-options (const -O1))
  585. (mkdir-p (dirname scm))
  586. (symlink (string-append #$source subdir) scm))
  587. scm)))
  588. (gexp->derivation-in-inferior name build core)))
  589. (define* (guile-for-source source #:optional (quirks %quirks))
  590. "Return the Guile package to use when building SOURCE or #f if the default
  591. '%guile-for-build' should be good enough."
  592. (let loop ((quirks quirks))
  593. (match quirks
  594. (()
  595. #f)
  596. (((predicate . guile) rest ...)
  597. (if (predicate source) (guile) (loop rest))))))
  598. (define (call-with-guile guile thunk)
  599. (lambda (store)
  600. (values (parameterize ((%guile-for-build
  601. (if guile
  602. (package-derivation store guile)
  603. (%guile-for-build))))
  604. (run-with-store store (thunk)))
  605. store)))
  606. (define-syntax-rule (with-guile guile exp ...)
  607. "Set GUILE as the '%guile-for-build' parameter for the dynamic extent of
  608. EXP, a series of monadic expressions."
  609. (call-with-guile guile (lambda ()
  610. (mbegin %store-monad exp ...))))
  611. (define (with-trivial-build-handler mvalue)
  612. "Run MVALUE, a monadic value, with a \"trivial\" build handler installed
  613. that unconditionally resumes the continuation."
  614. (lambda (store)
  615. (with-build-handler (lambda (continue . _)
  616. (continue #t))
  617. (values (run-with-store store mvalue)
  618. store))))
  619. (define* (build-from-source instance
  620. #:key core verbose? (dependencies '()) system)
  621. "Return a derivation to build Guix from INSTANCE, using the self-build
  622. script contained therein. When CORE is true, build package modules under
  623. SOURCE using CORE, an instance of Guix. By default, build for the current
  624. system, or SYSTEM if specified."
  625. (define name
  626. (symbol->string
  627. (channel-name (channel-instance-channel instance))))
  628. (define source
  629. (channel-instance-checkout instance))
  630. (define commit
  631. (channel-instance-commit instance))
  632. ;; Running the self-build script makes it easier to update the build
  633. ;; procedure: the self-build script of the Guix-to-be-installed contains the
  634. ;; right dependencies, build procedure, etc., which the Guix-in-use may not
  635. ;; know.
  636. (define script
  637. (string-append source "/" %self-build-file))
  638. (if (file-exists? script)
  639. (let ((build (save-module-excursion
  640. (lambda ()
  641. ;; Disable deprecation warnings; it's OK for SCRIPT to
  642. ;; use deprecated APIs and the user doesn't have to know
  643. ;; about it.
  644. (parameterize ((guix-warning-port
  645. (%make-void-port "w")))
  646. (primitive-load script)))))
  647. (guile (guile-for-source source)))
  648. ;; BUILD must be a monadic procedure of at least one argument: the
  649. ;; source tree.
  650. ;;
  651. ;; Note: BUILD can return #f if it does not support %PULL-VERSION. In
  652. ;; the future we'll fall back to a previous version of the protocol
  653. ;; when that happens.
  654. (with-guile guile
  655. ;; BUILD is usually quite costly. Install a "trivial" build handler
  656. ;; so we don't bounce an outer build-accumulator handler that could
  657. ;; cause us to redo half of the BUILD computation several times just
  658. ;; to realize it gives the same result.
  659. (with-trivial-build-handler
  660. (build source
  661. #:verbose? verbose? #:version commit
  662. #:system system
  663. #:channel-metadata (channel-instance->sexp instance)
  664. #:pull-version %pull-version))))
  665. ;; Build a set of modules that extend Guix using the standard method.
  666. (standard-module-derivation name source core dependencies)))
  667. (define* (build-channel-instance instance system
  668. #:optional core (dependencies '()))
  669. "Return, as a monadic value, the derivation for INSTANCE, a channel
  670. instance, for SYSTEM. DEPENDENCIES is a list of extensions providing Guile
  671. modules that INSTANCE depends on."
  672. (build-from-source instance
  673. #:core core
  674. #:dependencies dependencies
  675. #:system system))
  676. (define (resolve-dependencies instances)
  677. "Return a procedure that, given one of the elements of INSTANCES, returns
  678. list of instances it depends on."
  679. (define channel-instance-name
  680. (compose channel-name channel-instance-channel))
  681. (define table ;map a name to an instance
  682. (fold (lambda (instance table)
  683. (vhash-consq (channel-instance-name instance)
  684. instance table))
  685. vlist-null
  686. instances))
  687. (define edges
  688. (fold (lambda (instance edges)
  689. (fold (lambda (channel edges)
  690. (let ((name (channel-name channel)))
  691. (match (vhash-assq name table)
  692. ((_ . target)
  693. (vhash-consq instance target edges)))))
  694. edges
  695. (channel-instance-dependencies instance)))
  696. vlist-null
  697. instances))
  698. (lambda (instance)
  699. (vhash-foldq* cons '() instance edges)))
  700. (define* (channel-instance-derivations instances #:key system)
  701. "Return the list of derivations to build INSTANCES, in the same order as
  702. INSTANCES. Build for the current system by default, or SYSTEM if specified."
  703. (define core-instance
  704. ;; The 'guix' channel is treated specially: it's an implicit dependency of
  705. ;; all the other channels.
  706. (find (lambda (instance)
  707. (guix-channel? (channel-instance-channel instance)))
  708. instances))
  709. (define edges
  710. (resolve-dependencies instances))
  711. (define (instance->derivation instance)
  712. (mlet %store-monad ((system (if system (return system) (current-system))))
  713. (mcached (if (eq? instance core-instance)
  714. (build-channel-instance instance system)
  715. (mlet %store-monad ((core (instance->derivation core-instance))
  716. (deps (mapm %store-monad instance->derivation
  717. (edges instance))))
  718. (build-channel-instance instance system core deps)))
  719. instance
  720. system)))
  721. (unless core-instance
  722. (let ((loc (and=> (any (compose channel-location channel-instance-channel)
  723. instances)
  724. source-properties->location)))
  725. (raise (apply make-compound-condition
  726. (condition
  727. (&message (message "'guix' channel is lacking")))
  728. (condition
  729. (&fix-hint (hint (G_ "Make sure your list of channels
  730. contains one channel named @code{guix} providing the core of Guix."))))
  731. (if loc
  732. (list (condition (&error-location (location loc))))
  733. '())))))
  734. (mapm %store-monad instance->derivation instances))
  735. (define (whole-package-for-legacy name modules)
  736. "Return a full-blown Guix package for MODULES, a derivation that builds Guix
  737. modules in the old ~/.config/guix/latest style."
  738. (define packages
  739. (resolve-interface '(gnu packages guile)))
  740. (define modules+compiled
  741. ;; Since MODULES contains both .scm and .go files at its root, re-bundle
  742. ;; it so that it has share/guile/site and lib/guile, which is what
  743. ;; 'whole-package' expects.
  744. (computed-file (derivation-name modules)
  745. (with-imported-modules '((guix build utils))
  746. #~(begin
  747. (use-modules (guix build utils))
  748. (define version
  749. (effective-version))
  750. (define share
  751. (string-append #$output "/share/guile/site"))
  752. (define lib
  753. (string-append #$output "/lib/guile/" version))
  754. (mkdir-p share) (mkdir-p lib)
  755. (symlink #$modules (string-append share "/" version))
  756. (symlink #$modules (string-append lib "/site-ccache"))))))
  757. (letrec-syntax ((list (syntax-rules (->)
  758. ((_)
  759. '())
  760. ((_ (module -> variable) rest ...)
  761. (cons (module-ref (resolve-interface
  762. '(gnu packages module))
  763. 'variable)
  764. (list rest ...)))
  765. ((_ variable rest ...)
  766. (cons (module-ref packages 'variable)
  767. (list rest ...))))))
  768. (whole-package name modules+compiled
  769. ;; In the "old style", %SELF-BUILD-FILE would simply return a
  770. ;; derivation that builds modules. We have to infer what the
  771. ;; dependencies of these modules were.
  772. (list guile-json-3 guile-git guile-bytestructures
  773. (ssh -> guile-ssh) (tls -> gnutls))
  774. #:guile (default-guile))))
  775. (define (old-style-guix? drv)
  776. "Return true if DRV corresponds to a ~/.config/guix/latest style of
  777. derivation."
  778. ;; Here we rely on a gross historical fact: that derivations produced by the
  779. ;; "old style" (before commit 8a0d9bc8a3f153159d9e239a151c0fa98f1e12d8,
  780. ;; dated May 30, 2018) did not depend on "guix-command.drv".
  781. (not (find (lambda (input)
  782. (string=? "guix-command"
  783. (derivation-name
  784. (derivation-input-derivation input))))
  785. (derivation-inputs drv))))
  786. (define (channel-instance->sexp instance)
  787. "Return an sexp representation of INSTANCE, a channel instance."
  788. (let* ((commit (channel-instance-commit instance))
  789. (channel (channel-instance-channel instance))
  790. (intro (channel-introduction channel)))
  791. `(repository
  792. (version 0)
  793. (url ,(channel-url channel))
  794. (branch ,(channel-branch channel))
  795. (commit ,commit)
  796. (name ,(channel-name channel))
  797. ,@(if intro
  798. `((introduction
  799. (channel-introduction
  800. (version 0)
  801. (commit
  802. ,(channel-introduction-first-signed-commit
  803. intro))
  804. (signer
  805. ,(openpgp-format-fingerprint
  806. (channel-introduction-first-commit-signer
  807. intro))))))
  808. '()))))
  809. (define* (channel-instances->manifest instances #:key system)
  810. "Return a profile manifest with entries for all of INSTANCES, a list of
  811. channel instances. By default, build for the current system, or SYSTEM if
  812. specified."
  813. (define (instance->entry instance drv)
  814. (let ((commit (channel-instance-commit instance))
  815. (channel (channel-instance-channel instance)))
  816. (manifest-entry
  817. (name (symbol->string (channel-name channel)))
  818. (version (string-take commit 7))
  819. (item (if (guix-channel? channel)
  820. (if (old-style-guix? drv)
  821. (whole-package-for-legacy (string-append name "-" version)
  822. drv)
  823. drv)
  824. drv))
  825. (properties
  826. `((source ,(channel-instance->sexp instance)))))))
  827. (mlet* %store-monad ((derivations (channel-instance-derivations instances
  828. #:system system))
  829. (entries -> (map instance->entry instances derivations)))
  830. (return (manifest entries))))
  831. (define (package-cache-file manifest)
  832. "Build a package cache file for the instance in MANIFEST. This is meant to
  833. be used as a profile hook."
  834. ;; Note: Emit a profile in format version 3, which was introduced in 2017
  835. ;; and is readable by Guix since before version 1.0. This ensures that the
  836. ;; Guix in MANIFEST is able to read the manifest file created for its own
  837. ;; profile below. See <https://issues.guix.gnu.org/56441>.
  838. (let ((profile (profile (content manifest) (hooks '())
  839. (format-version 3))))
  840. (define build
  841. #~(begin
  842. (use-modules (gnu packages))
  843. (if (defined? 'generate-package-cache)
  844. (begin
  845. ;; Delegate package cache generation to the inferior.
  846. (format (current-error-port)
  847. "Generating package cache for '~a'...~%"
  848. #$profile)
  849. ;; This script runs through (primitive-load), which by default
  850. ;; doesn't print backtraces when it encounters an exception,
  851. ;; so manually do it. Use with-throw-handler because it is
  852. ;; supported by all Guile versions.
  853. (with-throw-handler #t
  854. (lambda () (generate-package-cache #$output))
  855. (lambda (key . args)
  856. (backtrace))))
  857. (mkdir #$output))))
  858. (define channels
  859. (map (compose string->symbol manifest-entry-name)
  860. (manifest-entries manifest)))
  861. (gexp->derivation-in-inferior "guix-package-cache" build
  862. profile
  863. ;; If the Guix in PROFILE is too old and
  864. ;; lacks 'guix repl', don't build the cache
  865. ;; instead of failing.
  866. #:silent-failure? #t
  867. #:properties `((type . profile-hook)
  868. (hook . package-cache)
  869. (channels . ,channels))
  870. #:local-build? #t)))
  871. (define %channel-profile-hooks
  872. ;; The default channel profile hooks.
  873. (cons package-cache-file %default-profile-hooks))
  874. (define (channel-instances->derivation instances)
  875. "Return the derivation of the profile containing INSTANCES, a list of
  876. channel instances."
  877. (mlet %store-monad ((manifest (channel-instances->manifest instances)))
  878. ;; Emit a profile in format version so that, if INSTANCES denotes an old
  879. ;; Guix, it can still read that profile, for instance for the purposes of
  880. ;; 'guix describe'.
  881. (profile-derivation manifest
  882. #:hooks %channel-profile-hooks
  883. #:format-version 3)))
  884. (define latest-channel-instances*
  885. (store-lift latest-channel-instances))
  886. (define* (latest-channel-derivation #:optional (channels %default-channels)
  887. #:key
  888. (current-channels '())
  889. (validate-pull
  890. ensure-forward-channel-update))
  891. "Return as a monadic value the derivation that builds the profile for the
  892. latest instances of CHANNELS. CURRENT-CHANNELS and VALIDATE-PULL are passed
  893. to 'latest-channel-instances'."
  894. (mlet %store-monad ((instances
  895. (latest-channel-instances* channels
  896. #:current-channels
  897. current-channels
  898. #:validate-pull
  899. validate-pull)))
  900. (channel-instances->derivation instances)))
  901. (define* (sexp->channel sexp #:optional (name 'channel))
  902. "Read SEXP, a provenance sexp as created by 'channel-instance->sexp'; use
  903. NAME as the channel name if SEXP does not specify it. Return #f if the sexp
  904. does not have the expected structure."
  905. (match sexp
  906. (('repository ('version 0)
  907. ('url url)
  908. ('branch branch)
  909. ('commit commit)
  910. rest ...)
  911. ;; Historically channel sexps did not include the channel name. It's OK
  912. ;; for channels created by 'channel-instances->manifest' because the
  913. ;; entry name is the channel name, but it was missing for entries created
  914. ;; by 'manifest-entry-with-provenance'.
  915. (channel (name (match (assq 'name rest)
  916. (#f name)
  917. (('name name) name)))
  918. (url url)
  919. (branch branch)
  920. (commit commit)
  921. (introduction
  922. (match (assq 'introduction rest)
  923. (#f #f)
  924. (('introduction intro)
  925. (sexp->channel-introduction intro))))))
  926. (_ #f)))
  927. (define (manifest-entry-channel entry)
  928. "Return the channel ENTRY corresponds to, or #f if that information is
  929. missing or unreadable. ENTRY must be an entry created by
  930. 'channel-instances->manifest', with the 'source' property."
  931. (let ((name (string->symbol (manifest-entry-name entry))))
  932. (match (assq-ref (manifest-entry-properties entry) 'source)
  933. ((sexp)
  934. (sexp->channel sexp name))
  935. (_
  936. ;; No channel information for this manifest entry.
  937. ;; XXX: Pre-0.15.0 Guix did not provide that information,
  938. ;; but there's not much we can do in that case.
  939. #f))))
  940. (define (profile-channels profile)
  941. "Return the list of channels corresponding to entries in PROFILE. If
  942. PROFILE is not a profile created by 'guix pull', return the empty list."
  943. (filter-map manifest-entry-channel
  944. ;; Show most recently installed packages last.
  945. (reverse
  946. (manifest-entries (profile-manifest profile)))))
  947. (define* (channel->code channel #:key (include-introduction? #t))
  948. "Return code (an sexp) to build CHANNEL. When INCLUDE-INTRODUCTION? is
  949. true, include its introduction, if any."
  950. (let ((intro (and include-introduction?
  951. (channel-introduction channel))))
  952. `(channel
  953. (name ',(channel-name channel))
  954. (url ,(channel-url channel))
  955. (branch ,(channel-branch channel))
  956. ,@(if (channel-commit channel)
  957. `((commit ,(channel-commit channel)))
  958. '())
  959. ,@(if intro
  960. `((introduction (make-channel-introduction
  961. ,(channel-introduction-first-signed-commit intro)
  962. (openpgp-fingerprint
  963. ,(openpgp-format-fingerprint
  964. (channel-introduction-first-commit-signer
  965. intro))))))
  966. '()))))
  967. ;;;
  968. ;;; News.
  969. ;;;
  970. ;; Channel news.
  971. (define-record-type <channel-news>
  972. (channel-news entries)
  973. channel-news?
  974. (entries channel-news-entries)) ;list of <channel-news-entry>
  975. ;; News entry, associated with a specific commit of the channel.
  976. (define-record-type <channel-news-entry>
  977. (channel-news-entry commit tag title body)
  978. channel-news-entry?
  979. (commit channel-news-entry-commit) ;hex string | #f
  980. (tag channel-news-entry-tag) ;#f | string
  981. (title channel-news-entry-title) ;list of language tag/string pairs
  982. (body channel-news-entry-body)) ;list of language tag/string pairs
  983. (define (sexp->channel-news-entry entry)
  984. "Return the <channel-news-entry> record corresponding to ENTRY, an sexp."
  985. (define (pair language message)
  986. (cons (symbol->string language) message))
  987. (match entry
  988. (('entry ((and (or 'commit 'tag) type) commit-or-tag)
  989. ('title ((? symbol? title-tags) (? string? titles)) ...)
  990. ('body ((? symbol? body-tags) (? string? bodies)) ...)
  991. _ ...)
  992. (channel-news-entry (and (eq? type 'commit) commit-or-tag)
  993. (and (eq? type 'tag) commit-or-tag)
  994. (map pair title-tags titles)
  995. (map pair body-tags bodies)))
  996. (_
  997. (raise (condition
  998. (&message (message "invalid channel news entry"))
  999. (&error-location
  1000. (location (source-properties->location
  1001. (source-properties entry)))))))))
  1002. (define (read-channel-news port)
  1003. "Read a channel news feed from PORT and return it as a <channel-news>
  1004. record."
  1005. (match (false-if-exception (read port))
  1006. (('channel-news ('version 0) entries ...)
  1007. (channel-news (map sexp->channel-news-entry entries)))
  1008. (('channel-news ('version version) _ ...)
  1009. ;; This is an unsupported version from the future. There's nothing wrong
  1010. ;; with that (the user may simply need to upgrade the 'guix' channel to
  1011. ;; be able to read it), so silently ignore it.
  1012. (channel-news '()))
  1013. (#f
  1014. (raise (condition
  1015. (&message (message "syntactically invalid channel news file")))))
  1016. (sexp
  1017. (raise (condition
  1018. (&message (message "invalid channel news file"))
  1019. (&error-location
  1020. (location (source-properties->location
  1021. (source-properties sexp)))))))))
  1022. (define (resolve-channel-news-entry-tag repository entry)
  1023. "If ENTRY has its 'commit' field set, return ENTRY. Otherwise, lookup
  1024. ENTRY's 'tag' in REPOSITORY and return ENTRY with its 'commit' field set to
  1025. the field its 'tag' refers to. A 'git-error' exception is raised if the tag
  1026. cannot be found."
  1027. (if (channel-news-entry-commit entry)
  1028. entry
  1029. (let* ((tag (channel-news-entry-tag entry))
  1030. (reference (reference-lookup repository
  1031. (string-append "refs/tags/" tag)))
  1032. (target (reference-target reference))
  1033. (oid (let ((obj (object-lookup repository target)))
  1034. (if (= OBJ-TAG (object-type obj)) ;annotated tag?
  1035. (tag-target-id (tag-lookup repository target))
  1036. target))))
  1037. (channel-news-entry (oid->string oid) tag
  1038. (channel-news-entry-title entry)
  1039. (channel-news-entry-body entry)))))
  1040. (define* (channel-news-for-commit channel new #:optional old)
  1041. "Return a list of <channel-news-entry> for CHANNEL between commits OLD and
  1042. NEW. When OLD is omitted or is #f, return all the news entries of CHANNEL."
  1043. (catch 'git-error
  1044. (lambda ()
  1045. (let* ((checkout (update-cached-checkout (channel-url channel)
  1046. #:ref `(commit . ,new)))
  1047. (metadata (read-channel-metadata-from-source checkout))
  1048. (news-file (channel-metadata-news-file metadata))
  1049. (news-file (and news-file
  1050. (string-append checkout "/" news-file))))
  1051. (if (and news-file (file-exists? news-file))
  1052. (with-repository checkout repository
  1053. (let* ((news (call-with-input-file news-file
  1054. (lambda (port)
  1055. (set-port-encoding! port
  1056. (or (file-encoding port)
  1057. "UTF-8"))
  1058. (read-channel-news port))))
  1059. (entries (map (lambda (entry)
  1060. (resolve-channel-news-entry-tag repository
  1061. entry))
  1062. (channel-news-entries news))))
  1063. (if old
  1064. (let* ((new (commit-lookup repository (string->oid new)))
  1065. (old (commit-lookup repository (string->oid old)))
  1066. (commits (list->set
  1067. (map (compose oid->string commit-id)
  1068. (commit-difference new old)))))
  1069. (filter (lambda (entry)
  1070. (set-contains? commits
  1071. (channel-news-entry-commit entry)))
  1072. entries))
  1073. entries)))
  1074. '())))
  1075. (lambda (key error . rest)
  1076. ;; If commit NEW or commit OLD cannot be found, then something must be
  1077. ;; wrong (for example, the history of CHANNEL was rewritten and these
  1078. ;; commits no longer exist upstream), so quietly return the empty list.
  1079. (if (= GIT_ENOTFOUND (git-error-code error))
  1080. '()
  1081. (apply throw key error rest)))))
  1082. ;;; Local Variables:
  1083. ;;; eval: (put 'with-guile 'scheme-indent-function 1)
  1084. ;;; End: