summaryrefslogtreecommitdiff
path: root/tests/pack.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2021-07-18 16:05:21 +0200
committerLudovic Courtès <ludo@gnu.org>2021-07-18 19:50:01 +0200
commit0e47fcced442d8e7c1b05184fdc1c14f10ed04ec (patch)
tree4ae844bc0ec3c670f8697bdc24362c122fa718ad /tests/pack.scm
parente4b70bc55a538569465bcedee19d1f2607308e65 (diff)
parent8b1bde7bb3936a64244824500ffe60f123704437 (diff)
Merge branch 'master' into core-updates
Diffstat (limited to 'tests/pack.scm')
-rw-r--r--tests/pack.scm94
1 files changed, 93 insertions, 1 deletions
diff --git a/tests/pack.scm b/tests/pack.scm
index 8564939ee13..98bfedf21c9 100644
--- a/tests/pack.scm
+++ b/tests/pack.scm
@@ -1,6 +1,7 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org> 2;;; Copyright © 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
3;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net> 3;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
4;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
4;;; 5;;;
5;;; This file is part of GNU Guix. 6;;; This file is part of GNU Guix.
6;;; 7;;;
@@ -32,6 +33,7 @@
32 #:use-module ((gnu packages base) #:select (glibc-utf8-locales)) 33 #:use-module ((gnu packages base) #:select (glibc-utf8-locales))
33 #:use-module (gnu packages bootstrap) 34 #:use-module (gnu packages bootstrap)
34 #:use-module ((gnu packages compression) #:select (squashfs-tools)) 35 #:use-module ((gnu packages compression) #:select (squashfs-tools))
36 #:use-module ((gnu packages debian) #:select (dpkg))
35 #:use-module ((gnu packages guile) #:select (guile-sqlite3)) 37 #:use-module ((gnu packages guile) #:select (guile-sqlite3))
36 #:use-module ((gnu packages gnupg) #:select (guile-gcrypt)) 38 #:use-module ((gnu packages gnupg) #:select (guile-gcrypt))
37 #:use-module (srfi srfi-64)) 39 #:use-module (srfi srfi-64))
@@ -51,11 +53,13 @@
51(define %gzip-compressor 53(define %gzip-compressor
52 ;; Compressor that uses the bootstrap 'gzip'. 54 ;; Compressor that uses the bootstrap 'gzip'.
53 ((@ (guix scripts pack) compressor) "gzip" 55 ((@ (guix scripts pack) compressor) "gzip"
54 "gz" 56 ".gz"
55 #~(list #+(file-append %bootstrap-coreutils&co "/bin/gzip") "-6n"))) 57 #~(list #+(file-append %bootstrap-coreutils&co "/bin/gzip") "-6n")))
56 58
57(define %tar-bootstrap %bootstrap-coreutils&co) 59(define %tar-bootstrap %bootstrap-coreutils&co)
58 60
61(define %ar-bootstrap %bootstrap-binutils)
62
59 63
60(test-begin "pack") 64(test-begin "pack")
61 65
@@ -270,6 +274,94 @@
270 1) 274 1)
271 (pk 'guilelink (readlink "bin")))) 275 (pk 'guilelink (readlink "bin"))))
272 (mkdir #$output)))))))) 276 (mkdir #$output))))))))
277 (built-derivations (list check))))
278
279 (unless store (test-skip 1))
280 (test-assertm "deb archive with symlinks and control files" store
281 (mlet* %store-monad
282 ((guile (set-guile-for-build (default-guile)))
283 (profile (profile-derivation (packages->manifest
284 (list %bootstrap-guile))
285 #:hooks '()
286 #:locales? #f))
287 (deb (debian-archive
288 "deb-pack" profile
289 #:compressor %gzip-compressor
290 #:symlinks '(("/opt/gnu/bin" -> "bin"))
291 #:archiver %tar-bootstrap
292 #:extra-options
293 (list #:triggers-file
294 (plain-file "triggers"
295 "activate-noawait /usr/share/icons/hicolor\n")
296 #:postinst-file
297 (plain-file "postinst"
298 "echo running configure script\n"))))
299 (check
300 (gexp->derivation "check-deb-pack"
301 (with-imported-modules '((guix build utils))
302 #~(begin
303 (use-modules (guix build utils)
304 (ice-9 match)
305 (ice-9 popen)
306 (ice-9 rdelim)
307 (ice-9 textual-ports)
308 (rnrs base))
309
310 (setenv "PATH" (string-join
311 (list (string-append #+%tar-bootstrap "/bin")
312 (string-append #+dpkg "/bin")
313 (string-append #+%ar-bootstrap "/bin"))
314 ":"))
315
316 ;; Validate the output of 'dpkg --info'.
317 (let* ((port (open-pipe* OPEN_READ "dpkg" "--info" #$deb))
318 (info (get-string-all port))
319 (exit-val (status:exit-val (close-pipe port))))
320 (assert (zero? exit-val))
321
322 (assert (string-contains
323 info
324 (string-append "Package: "
325 #+(package-name %bootstrap-guile))))
326
327 (assert (string-contains
328 info
329 (string-append "Version: "
330 #+(package-version %bootstrap-guile)))))
331
332 ;; Sanity check .deb contents.
333 (invoke "ar" "-xv" #$deb)
334 (assert (file-exists? "debian-binary"))
335 (assert (file-exists? "data.tar.gz"))
336 (assert (file-exists? "control.tar.gz"))
337
338 ;; Verify there are no hard links in data.tar.gz, as hard
339 ;; links would cause dpkg to fail unpacking the archive.
340 (define hard-links
341 (let ((port (open-pipe* OPEN_READ "tar" "-tvf" "data.tar.gz")))
342 (let loop ((hard-links '()))
343 (match (read-line port)
344 ((? eof-object?)
345 (assert (zero? (status:exit-val (close-pipe port))))
346 hard-links)
347 (line
348 (if (string-prefix? "u" line)
349 (loop (cons line hard-links))
350 (loop hard-links)))))))
351
352 (unless (null? hard-links)
353 (error "hard links found in data.tar.gz" hard-links))
354
355 ;; Verify the presence of the control files.
356 (invoke "tar" "-xf" "control.tar.gz")
357 (assert (file-exists? "control"))
358 (assert (and (file-exists? "postinst")
359 (= #o111 ;script is executable
360 (logand #o111 (stat:perms
361 (stat "postinst"))))))
362 (assert (file-exists? "triggers"))
363
364 (mkdir #$output))))))
273 (built-derivations (list check))))) 365 (built-derivations (list check)))))
274 366
275(test-end) 367(test-end)