summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2021-06-15 10:21:50 -0400
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2021-06-29 14:53:21 -0400
commit82daab42811a2e3c7684ebdf12af75ff0fa67b99 (patch)
treeef4bad3e82d6d13dc8d37daa30af883a95659520 /tests
parent8108c266dc2fbc70602b2aa5c6887bf17bed16e8 (diff)
pack: Add support for the deb format.
* .dir-locals.el (scheme-mode)[gexp->derivation]: Define indentation rule. * guix/scripts/pack.scm (debian-archive): New procedure. (%formats): Register the new deb format. (show-formats): Add it to the usage string. * tests/pack.scm (%ar-bootstrap): New variable. (deb archive with symlinks): New test. * doc/guix.texi (Invoking guix pack): Document it. * NEWS: Add news entry.
Diffstat (limited to 'tests')
-rw-r--r--tests/pack.scm75
1 files changed, 75 insertions, 0 deletions
diff --git a/tests/pack.scm b/tests/pack.scm
index ae6247a1d51..9473d4f384d 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 Ludovic Courtès <ludo@gnu.org> 2;;; Copyright © 2017, 2018, 2019, 2020 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))
@@ -56,6 +58,8 @@
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,77 @@
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" 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 "deb-pack" profile
288 #:compressor %gzip-compressor
289 #:symlinks '(("/opt/gnu/bin" -> "bin"))
290 #:archiver %tar-bootstrap))
291 (check
292 (gexp->derivation "check-deb-pack"
293 (with-imported-modules '((guix build utils))
294 #~(begin
295 (use-modules (guix build utils)
296 (ice-9 match)
297 (ice-9 popen)
298 (ice-9 rdelim)
299 (ice-9 textual-ports)
300 (rnrs base))
301
302 (setenv "PATH" (string-join
303 (list (string-append #+%tar-bootstrap "/bin")
304 (string-append #+dpkg "/bin")
305 (string-append #+%ar-bootstrap "/bin"))
306 ":"))
307
308 ;; Validate the output of 'dpkg --info'.
309 (let* ((port (open-pipe* OPEN_READ "dpkg" "--info" #$deb))
310 (info (get-string-all port))
311 (exit-val (status:exit-val (close-pipe port))))
312 (assert (zero? exit-val))
313
314 (assert (string-contains
315 info
316 (string-append "Package: "
317 #+(package-name %bootstrap-guile))))
318
319 (assert (string-contains
320 info
321 (string-append "Version: "
322 #+(package-version %bootstrap-guile)))))
323
324 ;; Sanity check .deb contents.
325 (invoke "ar" "-xv" #$deb)
326 (assert (file-exists? "debian-binary"))
327 (assert (file-exists? "data.tar.gz"))
328 (assert (file-exists? "control.tar.gz"))
329
330 ;; Verify there are no hard links in data.tar.gz, as hard
331 ;; links would cause dpkg to fail unpacking the archive.
332 (define hard-links
333 (let ((port (open-pipe* OPEN_READ "tar" "-tvf" "data.tar.gz")))
334 (let loop ((hard-links '()))
335 (match (read-line port)
336 ((? eof-object?)
337 (assert (zero? (status:exit-val (close-pipe port))))
338 hard-links)
339 (line
340 (if (string-prefix? "u" line)
341 (loop (cons line hard-links))
342 (loop hard-links)))))))
343
344 (unless (null? hard-links)
345 (error "hard links found in data.tar.gz" hard-links))
346
347 (mkdir #$output))))))
273 (built-derivations (list check))))) 348 (built-derivations (list check)))))
274 349
275(test-end) 350(test-end)