| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 |
|
| 19 | (define-module (gnu compression)
|
| 20 | #:use-module (guix gexp)
|
| 21 | #:use-module (guix ui)
|
| 22 | #:use-module ((gnu packages compression) #:hide (zip))
|
| 23 | #:use-module (srfi srfi-1)
|
| 24 | #:use-module (srfi srfi-9)
|
| 25 | #:use-module (ice-9 match)
|
| 26 | #:export (compressor
|
| 27 | compressor?
|
| 28 | compressor-name
|
| 29 | compressor-extension
|
| 30 | compressor-command
|
| 31 | %compressors
|
| 32 | lookup-compressor))
|
| 33 |
|
| 34 | |
| 35 | (define-record-type <compressor>
|
| 36 | (compressor name extension command)
|
| 37 | compressor?
|
| 38 | (name compressor-name) |
| 39 | (extension compressor-extension) |
| 40 | (command compressor-command)) |
| 41 | |
| 42 |
|
| 43 | (define %compressors
|
| 44 | |
| 45 | (list (compressor "gzip" ".gz"
|
| 46 | #~(list #+(file-append gzip "/bin/gzip") "-9n"))
|
| 47 | (compressor "lzip" ".lz"
|
| 48 | #~(list #+(file-append lzip "/bin/lzip") "-9"))
|
| 49 | (compressor "xz" ".xz"
|
| 50 | #~(append (list #+(file-append xz "/bin/xz")
|
| 51 | "-e")
|
| 52 | (%xz-parallel-args)))
|
| 53 | (compressor "bzip2" ".bz2"
|
| 54 | #~(list #+(file-append bzip2 "/bin/bzip2") "-9"))
|
| 55 | (compressor "zstd" ".zst"
|
| 56 | |
| 57 | |
| 58 | |
| 59 | #~(list #+(file-append zstd "/bin/zstd") "-3"
|
| 60 | (format #f "--threads=~a" (parallel-job-count))))
|
| 61 | (compressor "none" "" #f)))
|
| 62 |
|
| 63 | (define (lookup-compressor name)
|
| 64 | "Return the compressor object called NAME. Error out if it could not be
|
| 65 | found."
|
| 66 | (or (find (match-lambda
|
| 67 | (($ <compressor> name*)
|
| 68 | (string=? name* name)))
|
| 69 | %compressors)
|
| 70 | (leave (G_ "~a: compressor not found~%") name)))
|