source-manifest.scm 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
  3. ;;;
  4. ;;; This file is part of GNU Guix.
  5. ;;;
  6. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  7. ;;; under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation; either version 3 of the License, or (at
  9. ;;; your option) any later version.
  10. ;;;
  11. ;;; GNU Guix is distributed in the hope that it will be useful, but
  12. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;;; GNU General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  18. ;;; This file returns a manifest containing origins of all the packages. The
  19. ;;; main purpose is to allow continuous integration services to keep upstream
  20. ;;; source code around. It can also be passed to 'guix weather -m'.
  21. (use-modules (srfi srfi-1) (srfi srfi-26)
  22. (ice-9 match) (ice-9 vlist)
  23. (guix packages) (guix profiles)
  24. (gnu packages))
  25. (define (all-packages)
  26. "Return the list of all the packages, public or private, omitting only
  27. superseded packages."
  28. (fold-packages (lambda (package lst)
  29. (match (package-replacement package)
  30. (#f (cons package lst))
  31. (replacement
  32. (append (list replacement package) lst))))
  33. '()
  34. #:select? (negate package-superseded)))
  35. (define (upstream-origin source)
  36. "Return SOURCE without any patches or snippet."
  37. (origin (inherit source)
  38. (snippet #f) (patches '())))
  39. (define (all-origins)
  40. "Return the list of origins referred to by all the packages."
  41. (let loop ((packages (all-packages))
  42. (origins '())
  43. (visited vlist-null))
  44. (match packages
  45. ((head . tail)
  46. (let ((new (remove (cut vhash-assq <> visited)
  47. (package-direct-sources head))))
  48. (loop tail (append new origins)
  49. (fold (cut vhash-consq <> #t <>)
  50. visited new))))
  51. (()
  52. origins))))
  53. ;; Return a manifest containing all the origins.
  54. (manifest (map (lambda (origin)
  55. (manifest-entry
  56. (name (or (origin-actual-file-name origin)
  57. "origin"))
  58. (version "0")
  59. (item (upstream-origin origin))))
  60. (all-origins)))