aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2022 Mathieu Othacehe <othacehe@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu compression)
  #:use-module (guix gexp)
  #:use-module (guix ui)
  #:use-module ((gnu packages compression) #:hide (zip))
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-9)
  #:use-module (ice-9 match)
  #:export (compressor
            compressor?
            compressor-name
            compressor-extension
            compressor-command
            %compressors
            lookup-compressor))

;; Type of a compression tool.
(define-record-type <compressor>
  (compressor name extension command)
  compressor?
  (name       compressor-name)      ;string (e.g., "gzip")
  (extension  compressor-extension) ;string (e.g., ".lz")
  (command    compressor-command))  ;gexp (e.g., #~(list "/gnu/store/…/gzip"
                                    ;                    "-9n" ))

(define %compressors
  ;; Available compression tools.
  (list (compressor "gzip"  ".gz"
                    #~(list #+(file-append gzip "/bin/gzip") "-9n"))
        (compressor "lzip"  ".lz"
                    #~(list #+(file-append lzip "/bin/lzip") "-9"))
        (compressor "xz"    ".xz"
                    #~(append (list #+(file-append xz "/bin/xz")
                                    "-e")
                              (%xz-parallel-args)))
        (compressor "bzip2" ".bz2"
                    #~(list #+(file-append bzip2 "/bin/bzip2") "-9"))
        (compressor "zstd" ".zst"
                    ;; The default level 3 compresses better than gzip in a
                    ;; fraction of the time, while the highest level 19
                    ;; (de)compresses more slowly and worse than xz.
                    #~(list #+(file-append zstd "/bin/zstd") "-3"
                            (format #f "--threads=~a" (parallel-job-count))))
        (compressor "none" "" #f)))

(define (lookup-compressor name)
  "Return the compressor object called NAME.  Error out if it could not be
found."
  (or (find (match-lambda
              (($ <compressor> name*)
               (string=? name* name)))
            %compressors)
      (leave (G_ "~a: compressor not found~%") name)))
+0100'>2021-12-06ci: Cross-build the 'guix' package....Ludovic Courtès 2021-10-12Merge remote-tracking branch 'origin/master' into core-updates-frozen.Mathieu Othacehe 2021-10-04ci: Allow manifests to contain any lowerable object....Ludovic Courtès 2021-09-27ci: Adjust 'channel-build-system' to monadic style....Ludovic Courtès 2021-07-10ci: Build commencement packages supported on the target system....Ludovic Courtès 2021-07-09ci: Add bootstrap packages to the core subset....Mathieu Othacehe 2021-07-09ci: Add bootstrap packages to the core subset....Mathieu Othacehe 2021-07-05ci: Change "core" subset to include the latest GCC and Guile....Ludovic Courtès 2021-07-03ci: Remove duplicate ".SYSTEM" extension for cross-compilation jobs....Ludovic Courtès 2021-05-25ci: Add derivation inputs....Mathieu Othacehe 2021-05-25ci: Add derivation inputs....Mathieu Othacehe 2021-04-28ci: Add custom subset....Mathieu Othacehe 2021-04-28ci: Add arguments->systems procedure....Mathieu Othacehe 2021-04-28ci: Factorize image->job procedure....Mathieu Othacehe 2021-04-18ci: tarball: Use "current-guix" as profile name....Mathieu Othacehe 2021-04-12ci: Fix system-tests subset....Mathieu Othacehe 2021-04-08ci: Introduce new subsets....Mathieu Othacehe 2021-04-08ci: Remove the job period argument....Mathieu Othacehe 2021-03-23ci: %cross-targets: Add powerpc64le-linux-gnu....Chris Marusich 2021-03-23ci: Change manifest argument type....Mathieu Othacehe 2021-03-14ci: Support packages with multiple channels....Mathieu Othacehe 2021-03-14ci: Add channel subset support....Mathieu Othacehe 2021-03-10ci: Remove hydra support....Mathieu Othacehe 2021-01-31ci: Remove the package version from the job name....Mathieu Othacehe 2021-01-29ci: Raise max-silent-time to 3600....Mathieu Othacehe 2020-12-03ci: Build novena-barebones-raw-image....Danny Milosavljevic 2020-12-01Revert "ci: Temporarily disable image-jobs."...Mathieu Othacehe 2020-11-29ci: Temporarily disable image-jobs....Mathieu Othacehe 2020-11-25ci: Limit image and system tests jobs periodicity....Mathieu Othacehe 2020-11-20image: Add pinebook-pro support....Mathieu Othacehe 2020-11-02ci: Restore license handling....Mathieu Othacehe 2020-11-02ci: Convert license to text....Mathieu Othacehe 2020-11-02ci: Ignore package license....Mathieu Othacehe