summaryrefslogtreecommitdiff
path: root/tests/pack.scm
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2023-03-03 21:09:33 -0500
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2023-07-18 16:56:06 -0400
commitd5f8b50365533f2713596f59519c48019f6b1f19 (patch)
tree1c0d6483fd4b6f7338befc8554e1aed51fe0ffcf /tests/pack.scm
parent772eaa69f31457aa19ca4dc4ce755c791d722054 (diff)
pack: Move common build code to (guix build pack).
The rationale is to reduce the number of derivations built per pack to ideally one, to minimize storage requirements. The number of derivations had gone up with 68380db4 ("pack: Extract populate-profile-root from self-contained-tarball/builder.") as a side effect to improving code reuse. * guix/scripts/pack.scm (guix): Add commentary comment. (populate-profile-root, self-contained-tarball/builder): Extract to... * guix/build/pack.scm (populate-profile-root): ... this, and... (build-self-contained-tarball): ... that, adjusting for use on the build side. (assert-utf8-locale): New procedure. (self-contained-tarball, debian-archive, rpm-archive): Adjust accordingly. Reviewed-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'tests/pack.scm')
-rw-r--r--tests/pack.scm106
1 files changed, 53 insertions, 53 deletions
diff --git a/tests/pack.scm b/tests/pack.scm
index ce5a2f8a53c..0864a4b78a7 100644
--- a/tests/pack.scm
+++ b/tests/pack.scm
@@ -76,66 +76,66 @@
76 76
77(test-begin "pack") 77(test-begin "pack")
78 78
79(unless (network-reachable?) (test-skip 1))
80(test-assertm "self-contained-tarball" %store
81 (mlet* %store-monad
82 ((profile -> (profile
83 (content (packages->manifest (list %bootstrap-guile)))
84 (hooks '())
85 (locales? #f)))
86 (tarball (self-contained-tarball "pack" profile
87 #:symlinks '(("/bin/Guile"
88 -> "bin/guile"))
89 #:compressor %gzip-compressor
90 #:archiver %tar-bootstrap))
91 (check (gexp->derivation
92 "check-tarball"
93 (with-imported-modules '((guix build utils))
94 #~(begin
95 (use-modules (guix build utils)
96 (srfi srfi-1))
97
98 (define store
99 ;; The unpacked store.
100 (string-append "." (%store-directory) "/"))
101
102 (define (canonical? file)
103 ;; Return #t if FILE is read-only and its mtime is 1.
104 (let ((st (lstat file)))
105 (or (not (string-prefix? store file))
106 (eq? 'symlink (stat:type st))
107 (and (= 1 (stat:mtime st))
108 (zero? (logand #o222
109 (stat:mode st)))))))
110
111 (define bin
112 (string-append "." #$profile "/bin"))
113
114 (setenv "PATH"
115 (string-append #$%tar-bootstrap "/bin"))
116 (system* "tar" "xvf" #$tarball)
117 (mkdir #$output)
118 (exit
119 (and (file-exists? (string-append bin "/guile"))
120 (file-exists? store)
121 (every canonical?
122 (find-files "." (const #t)
123 #:directories? #t))
124 (string=? (string-append #$%bootstrap-guile "/bin")
125 (readlink bin))
126 (string=? (string-append ".." #$profile
127 "/bin/guile")
128 (readlink "bin/Guile")))))))))
129 (built-derivations (list check))))
130
131;; The following test needs guile-sqlite3, libgcrypt, etc. as a consequence of 79;; The following test needs guile-sqlite3, libgcrypt, etc. as a consequence of
132;; commit c45477d2a1a651485feede20fe0f3d15aec48b39 and related changes. Thus, 80;; commit c45477d2a1a651485feede20fe0f3d15aec48b39 and related changes. Thus,
133;; run it on the user's store, if it's available, on the grounds that these 81;; run it on the user's store, if it's available, on the grounds that these
134;; dependencies may be already there, or we can get substitutes or build them 82;; dependencies may be already there, or we can get substitutes or build them
135;; quite inexpensively; see <https://bugs.gnu.org/32184>. 83;; quite inexpensively; see <https://bugs.gnu.org/32184>.
136
137(with-external-store store 84(with-external-store store
138 (unless store (test-skip 1)) 85 (unless store (test-skip 1))
86 (test-assertm "self-contained-tarball" store
87 (mlet* %store-monad
88 ((guile (set-guile-for-build (default-guile)))
89 (profile -> (profile
90 (content (packages->manifest (list %bootstrap-guile)))
91 (hooks '())
92 (locales? #f)))
93 (tarball (self-contained-tarball "pack" profile
94 #:symlinks '(("/bin/Guile"
95 -> "bin/guile"))
96 #:compressor %gzip-compressor
97 #:archiver %tar-bootstrap))
98 (check (gexp->derivation
99 "check-tarball"
100 (with-imported-modules '((guix build utils))
101 #~(begin
102 (use-modules (guix build utils)
103 (srfi srfi-1))
104
105 (define store
106 ;; The unpacked store.
107 (string-append "." (%store-directory) "/"))
108
109 (define (canonical? file)
110 ;; Return #t if FILE is read-only and its mtime is 1.
111 (let ((st (lstat file)))
112 (or (not (string-prefix? store file))
113 (eq? 'symlink (stat:type st))
114 (and (= 1 (stat:mtime st))
115 (zero? (logand #o222
116 (stat:mode st)))))))
117
118 (define bin
119 (string-append "." #$profile "/bin"))
120
121 (setenv "PATH"
122 (string-append #$%tar-bootstrap "/bin"))
123 (system* "tar" "xvf" #$tarball)
124 (mkdir #$output)
125 (exit
126 (and (file-exists? (string-append bin "/guile"))
127 (file-exists? store)
128 (every canonical?
129 (find-files "." (const #t)
130 #:directories? #t))
131 (string=? (string-append #$%bootstrap-guile "/bin")
132 (readlink bin))
133 (string=? (string-append ".." #$profile
134 "/bin/guile")
135 (readlink "bin/Guile")))))))))
136 (built-derivations (list check))))
137
138 (unless store (test-skip 1))
139 (test-assertm "self-contained-tarball + localstatedir" store 139 (test-assertm "self-contained-tarball + localstatedir" store
140 (mlet* %store-monad 140 (mlet* %store-monad
141 ((guile (set-guile-for-build (default-guile))) 141 ((guile (set-guile-for-build (default-guile)))