fixer.scm 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. (define-module (fiasco fixer)
  2. #:use-module (fiasco finder)
  3. #:use-module (guix base32)
  4. #:use-module (guix upstream)
  5. #:export (fix-packages-hash))
  6. ;;; Commentary:
  7. ;;;
  8. ;;; Repair the packages whose hash can be safely updated, as found by
  9. ;;; the finder script. This should be run from a checkout of the Guix
  10. ;;; source tree, e.g. as "./pre-inst-guix guile ~/src/guile-hacks/fiasco/run.scm
  11. (define (result-needs-checking? result)
  12. (and (not (result-hash-ok? result))
  13. (not (result-safe-to-update? result))))
  14. (define* (fix-packages-hash #:optional (file (results-file)))
  15. "Correct the packages whose hash can be safely updated, based on
  16. data in FILE."
  17. (let* ((results (results-file->results file))
  18. (results-to-check (filter result-needs-checking? results))
  19. (actionable-results (filter result-safe-to-update? results)))
  20. (define (update-package-hash result)
  21. (when (not (null? (result->package result)))
  22. (let* ((package (result->package result))
  23. (name (result-package-name result))
  24. (version (result-package-version result))
  25. (old-hash (result-guix-hash result))
  26. (new-hash (result-upstream-hash result))
  27. (new-hash-bv (nix-base32-string->bytevector new-hash)))
  28. (format #t "~a: updating hash from ~s to ~s..." name old-hash new-hash)
  29. (if (update-package-source package version new-hash-bv)
  30. (format #t " success~%")
  31. (format #t " failed~%")))))
  32. (format #t "The following packages require manual verification:~%")
  33. (for-each (lambda (r)
  34. (format #t "~a version ~a~%"
  35. (result-package-name r)
  36. (result-package-version r)))
  37. results-to-check)
  38. (display "\n")
  39. (format #t "Attempting to repair the hashes of ~a packages...~%"
  40. (length actionable-results))
  41. (for-each update-package-hash actionable-results)))