pack.scm 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2017 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. (define-module (test-pack)
  19. #:use-module (guix scripts pack)
  20. #:use-module (guix store)
  21. #:use-module (guix derivations)
  22. #:use-module (guix profiles)
  23. #:use-module (guix monads)
  24. #:use-module (guix grafts)
  25. #:use-module (guix tests)
  26. #:use-module (guix gexp)
  27. #:use-module (gnu packages bootstrap)
  28. #:use-module (srfi srfi-64))
  29. (define %store
  30. (open-connection-for-tests))
  31. ;; Globally disable grafts because they can trigger early builds.
  32. (%graft? #f)
  33. (define-syntax-rule (test-assertm name exp)
  34. (test-assert name
  35. (run-with-store %store exp
  36. #:guile-for-build (%guile-for-build))))
  37. (define %gzip-compressor
  38. ;; Compressor that uses the bootstrap 'gzip'.
  39. ((@ (guix scripts pack) compressor) "gzip"
  40. "gz"
  41. #~(#+(file-append %bootstrap-coreutils&co "/bin/gzip") "-6n")))
  42. (define %tar-bootstrap %bootstrap-coreutils&co)
  43. (test-begin "pack")
  44. (unless (network-reachable?) (test-skip 1))
  45. (test-assertm "self-contained-tarball"
  46. (mlet* %store-monad
  47. ((profile (profile-derivation (packages->manifest
  48. (list %bootstrap-guile))
  49. #:hooks '()
  50. #:locales? #f))
  51. (tarball (self-contained-tarball "pack" profile
  52. #:symlinks '(("/bin/Guile"
  53. -> "bin/guile"))
  54. #:compressor %gzip-compressor
  55. #:tar %tar-bootstrap))
  56. (check (gexp->derivation
  57. "check-tarball"
  58. #~(let ((guile (string-append "." #$profile "/bin")))
  59. (setenv "PATH"
  60. (string-append #$%tar-bootstrap "/bin"))
  61. (system* "tar" "xvf" #$tarball)
  62. (mkdir #$output)
  63. (exit
  64. (and (file-exists? (string-append guile "/guile"))
  65. (string=? (string-append #$%bootstrap-guile "/bin")
  66. (readlink guile))
  67. (string=? (string-append (string-drop guile 1)
  68. "/guile")
  69. (readlink "bin/Guile"))))))))
  70. (built-derivations (list check))))
  71. (test-end)