packages: Add printer for <origin>.

* guix/packages.scm (print-origin): New procedure.
  (<origin>): Add it as record type printer.
This commit is contained in:
Ludovic Courtès 2014-07-11 13:59:54 +02:00
parent 42e1394b11
commit f109696473
1 changed files with 11 additions and 0 deletions

View File

@ -125,6 +125,17 @@
(patch-guile origin-patch-guile ; package or #f
(default #f)))
(define (print-origin origin port)
"Write a concise representation of ORIGIN to PORT."
(match origin
(($ <origin> uri method sha256 file-name patches)
(simple-format port "#<origin ~s ~a ~s ~a>"
uri (bytevector->base32-string sha256)
patches
(number->string (object-address origin) 16)))))
(set-record-type-printer! <origin> print-origin)
(define-syntax base32
(lambda (s)
"Return the bytevector corresponding to the given Nix-base32