aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 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 installer dump)
  #:use-module (gnu installer utils)
  #:use-module (guix build utils)
  #:use-module (srfi srfi-11)
  #:use-module (ice-9 iconv)
  #:use-module (ice-9 match)
  #:use-module (ice-9 popen)
  #:use-module (ice-9 textual-ports)
  #:use-module (web client)
  #:use-module (web http)
  #:use-module (web response)
  #:use-module (webutils multipart)
  #:export (%core-dump
            prepare-dump
            make-dump
            send-dump-report))

;; The installer crash dump type.
(define %dump-type "installer-dump")

;; The core dump file.
(define %core-dump "/tmp/installer-core-dump")

(define (result->list result)
  "Return the alist for the given RESULT."
  (hash-map->list (lambda (k v)
                    (cons k v))
                  result))

(define* (prepare-dump key args #:key result)
  "Create a crash dump directory.  KEY and ARGS represent the thrown error.
RESULT is the installer result hash table.  Returns the created directory path."
  (define now (localtime (current-time)))
  (define dump-dir
    (format #f "/tmp/dump.~a"
            (strftime "%F.%H.%M.%S" now)))
  (mkdir-p dump-dir)
  (with-directory-excursion dump-dir
    ;; backtrace
    (call-with-output-file "installer-backtrace"
      (lambda (port)
        (display-backtrace (make-stack #t) port)
        (print-exception port
                         (stack-ref (make-stack #t) 1)
                         key args)))

    ;; installer result
    (call-with-output-file "installer-result"
      (lambda (port)
        (write (result->list result) port)))

    ;; syslog
    (copy-file "/var/log/messages" "syslog")

    ;; core dump
    (when (file-exists? %core-dump)
      (copy-file %core-dump "core-dump"))

    ;; dmesg
    (let ((pipe (open-pipe* OPEN_READ "dmesg")))
      (call-with-output-file "dmesg"
        (lambda (port)
          (dump-port pipe port)
          (close-pipe pipe)))))
  dump-dir)

(define* (make-dump dump-dir file-choices)
  "Create a crash dump archive from DUMP-DIR containing FILE-CHOICES.
Returns the archive path."
  (define output (string-append (basename dump-dir) ".tar.gz"))
  (with-directory-excursion (dirname dump-dir)
    (apply system* "tar" "-zcf" output
           (map (lambda (f)
                  (string-append (basename dump-dir) "/" f))
                file-choices)))
  (canonicalize-path (string-append (dirname dump-dir) "/" output)))

(define* (send-dump-report dump
                           #:key
                           (url "https://dump.guix.gnu.org"))
  "Turn the DUMP archive into a multipart body and send it to the Guix crash
dump server at URL."
  (define (match-boundary kont)
    (match-lambda
      (('boundary . (? string? b))
       (kont b))
      (x #f)))

  (define (response->string response)
    (bytevector->string
     (read-response-body response)
     "UTF-8"))

  (let-values (((body boundary)
                (call-with-input-file dump
                  (lambda (port)
                    (format-multipart-body
                     `((,%dump-type . ,port)))))))
    (false-if-exception
     (response->string
      (http-post
       (string-append url "/upload")
       #:keep-alive? #t
       #:streaming? #t
       #:headers `((content-type
                    . (multipart/form-data
                       (boundary . ,boundary))))
       #:body body)))))
okbook: Add 'use-modules' in gexp example....* doc/guix-cookbook.texi (A Scheme Crash Course): Add 'use-modules' line in gexp example. Ludovic Courtès 2023-08-15doc: cookbook: Link to "Package Modules"....* doc/guix-cookbook.texi (A Scheme Crash Course): Add link to "Package Modules". Ludovic Courtès 2023-07-14doc: Mention gexps in the "Scheme Crash Course"....* doc/guix-cookbook.texi (A Scheme Crash Course): Add note on gexps. Ludovic Courtès 2023-06-05doc: cookbook: Update example my-libgit2 package....* doc/guix-cookbook.texi (Packaging Tutorial): Improve the code quality of the example my-libgit2 package. Efraim Flashner 2023-06-04services: screen-locker-service-type: Configurable PAM and setuid....screen-locker-service-type by default does both define PAM entry and make program setuid binary. Normally both methods are mutually exclusive, if binary has setuid set it does not really needs PAM, otherway around also similar, if PAM is enabled binary should not relay on setuid. Recent swaylock package now compiled with PAM support. When PAM support is compiled in, swaylock rejects executing if binary is also setuid program. This change turns screen-locker-configuration from strict PAM AND setuid to more flexible PAM AND/OR setuid. Allowing swaylock to be configured properly while supporting other screen locker preferences. * gnu/services/xorg.scm (screen-locker-configuration): Switch from define-record-type to define-configuration. [using-pam?]: New field to control PAM entry existence. [using-setuid?]: New field to control setuid binary existence. (screen-locker-pam-services): Should not make unix-pam-service if using-pam? is set to #f. (screen-locker-setuid-programs): Should not make program setuid program if using-setuid? is set to #f. (screen-locker-generate-doc): Internal function to generate configuration documentation. (screen-locker-service): Adapt to new screen-locker-configuration. * gnu/services/desktop.scm (desktop-services-for-system): Adapt to new screen-locker-configuration. * doc/guix.texi: Reflect new changes to screen-locker-configuration. Signed-off-by: Josselin Poiret <dev@jpoiret.xyz> muradm 2023-05-31nls: Update translations....* doc/guix-cookbook.texi (Top): Mention Slovak. Florian Pelz 2023-05-06doc: cookbook: Remove outdated section about GUIX_PACKAGE_PATH....The section insisted on GUIX_PACKAGE_PATH, mentioned version 0.16, and didn't say much about channels, which made it look obsolete. * doc/guix-cookbook.texi (GUIX_PACKAGE_PATH): Remove section. (Guix channels): Rename to... (Channels): ... this. Merge most of the explanations previously in the GUIX_PACKAGE_PATH section. Say more about channels and add cross-references. Ludovic Courtès 2023-01-09doc: cookbook: Add "Installing Guix on a Cluster" chapter....This is derived from the article at <https://hpc.guix.info/blog/2017/11/installing-guix-on-a-cluster/>, with clarifications and updates. * doc/guix-cookbook.texi (Installing Guix on a Cluster): New chapter. Ludovic Courtès 2023-01-06doc: cookbook: Remove 404 link to mitpress.mit.edu....* doc/guix-cookbook.texi (A Scheme Crash Course): Remove 404 link to mitpress.mit.edu. Ludovic Courtès 2022-11-27doc: cookbook: Fix commands in example....Fixes <https://issues.guix.gnu.org/59463>. Reported by Luca Cirrottola <luca.cirrottola@inria.fr>. * doc/guix-cookbook.texi (Reproducible profiles): Make it work. Florian Pelz 2022-11-24doc: Add a security keys section to the cookbook....* doc/guix-cookbook.texi (Top): Register new menu. (System Configuration): Likewise. (Using security keys): New section. Maxim Cournoyer 2022-11-06doc: cookbook: Add section on MPD with bluealsa....* doc/guix-cookbook.texi (Music Server with Bluetooth Audio): New section under System Configuration. Ricardo Wurmus 2022-11-06doc: cookbook: Update detailed menu for "System Configuration"....* doc/guix-cookbook.texi: Update menu. Ricardo Wurmus 2022-10-13doc: Add chapter on containers to Cookbook....* doc/guix-cookbook.texi (Containers): New chapter. Ricardo Wurmus 2022-07-08doc: cookbook: Link to "A Scheme Primer"....* doc/guix-cookbook.texi (A Scheme Crash Course): Link to "A Scheme Primer". Group references in @quotation for clarity. Ludovic Courtès 2022-07-08doc: cookbook: Suggest 'guix shell'....* doc/guix-cookbook.texi (A Scheme Crash Course): Suggest 'guix shell' instead of 'guix environment'. (Customizing the Kernel, The benefits of manifests): Likewise. Ludovic Courtès 2022-06-01doc: cookbook: Refer to the "Writing Manifests" manual node....* doc/guix-cookbook.texi (Basic setup with manifests): Tweak introductory paragraph. Refer to the new "Writing Manifests" node of the manual. Ludovic Courtès 2022-04-08doc: cookbook: Fix cross-reference to SICP....Reported by Greg Hogan <code@greghogan.com>. * doc/guix-cookbook.texi (A Scheme Crash Course): Fix xref to SICP. Ludovic Courtès 2022-04-08doc: cookbook: Fix cross-reference to the manual....Reported by Greg Hogan <code@greghogan.com>. * doc/guix-cookbook.texi (Extended example): Fix node name in xref to "package Reference". Ludovic Courtès 2022-03-18doc: cookbook: Update Tor onion service name....* doc/guix-cookbook.texi: New variable. (Getting substitutes from Tor): Use it. Ludovic Courtès 2021-12-30doc: cookbook: Update custom kernel guide....* doc/guix-cookbook.texi (Customizing the Kernel): Adjust to new interface. Leo Famulari 2021-12-20doc: cookbook: Simplify inputs in examples....* doc/guix-cookbook.texi (Recursive importers, Inheritance): Use the simplified input style. Ludovic Courtès 2021-10-12Merge remote-tracking branch 'origin/master' into core-updates-frozen.Mathieu Othacehe 2021-10-04doc: cookbook: Mention translations of the cookbook....* doc/guix-cookbook.texi (Top): Add note about l10n. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Sarah Morgensen 2021-09-17Merge branch 'master' into core-updates-frozen... Conflicts: gnu/packages/bioinformatics.scm gnu/packages/chez.scm gnu/packages/docbook.scm gnu/packages/ebook.scm gnu/packages/gnome.scm gnu/packages/linux.scm gnu/packages/networking.scm gnu/packages/python-web.scm gnu/packages/python-xyz.scm gnu/packages/tex.scm gnu/packages/version-control.scm gnu/packages/xml.scm guix/build-system/dune.scm guix/build-system/go.scm guix/build-system/linux-module.scm guix/packages.scm Marius Bakke 2021-09-08doc: add clarifications to Linode cookbook recipe...* doc/guix-cookbook.texi: clarify Linode recipe Reword paragraph about adding the Guix device disk to Debian config. Improve example commands for sftp-ing files to the server. Minor wording fixes Signed-off-by: Ludovic Courtès <ludo@gnu.org> Grant Shangreaux 2021-09-07Merge branch 'master' into core-updates-frozenLudovic Courtès 2021-08-29Migrate to the new 'targets' field of bootloader-configuration....The old 'target' field is deprecated; adjust the sources to use the new 'targets' one instead. * doc/guix-cookbook.texi<target>: Replace by 'targets'. * gnu/bootloader/grub.scm: Likewise. * gnu/installer/parted.scm: Likewise. * gnu/machine/digital-ocean.scm: Likewise. * gnu/system/examples/asus-c201.tmpl: Likewise * gnu/system/examples/bare-bones.tmpl: Likewise * gnu/system/examples/bare-hurd.tmpl: Likewise * gnu/system/examples/beaglebone-black.tmpl: Likewise * gnu/system/examples/desktop.tmpl: Likewise * gnu/system/examples/docker-image.tmpl: Likewise * gnu/system/examples/lightweight-desktop.tmpl: Likewise * gnu/system/examples/vm-image.tmpl: Likewise * gnu/system/examples/yggdrasil.tmpl: Likewise * gnu/system/hurd.scm: Likewise * gnu/system/images/hurd.scm: Likewise * gnu/system/images/novena.scm: Likewise * gnu/system/images/pine64.scm: Likewise * gnu/system/images/pinebook-pro.scm: Likewise * gnu/system/images/rock64.scm: Likewise * gnu/system/install.scm: Likewise * gnu/system/vm.scm: Likewise * gnu/tests.scm: Likewise * gnu/tests/ganeti.scm: Likewise * gnu/tests/install.scm: Likewise * gnu/tests/nfs.scm: Likewise * gnu/tests/telephony.scm: Likewise * tests/boot-parameters.scm: Likewise * tests/system.scm: Likewise Maxim Cournoyer 2021-08-15Update copyright/name notices for Christine Lemmer-Webber....* doc/guix-cookbook.texi: Update copyright/name for Christine Lemmer-Webber. * gnu/build/image.scm: Likewise. * gnu/build/vm.scm: Likewise. * gnu/packages/admin.scm: Likewise. * gnu/packages/assembly.scm: Likewise. * gnu/packages/audio.scm: Likewise. * gnu/packages/backup.scm: Likewise. * gnu/packages/check.scm: Likewise. * gnu/packages/databases.scm: Likewise. * gnu/packages/emacs-xyz.scm: Likewise. * gnu/packages/finance.scm: Likewise. * gnu/packages/gnupg.scm: Likewise. * gnu/packages/guile-xyz.scm: Likewise. * gnu/packages/guile.scm: Likewise. * gnu/packages/haskell-xyz.scm: Likewise. * gnu/packages/linux.scm: Likewise. * gnu/packages/mail.scm: Likewise. * gnu/packages/password-utils.scm: Likewise. * gnu/packages/perl.scm: Likewise. * gnu/packages/python-web.scm: Likewise. * gnu/packages/python-xyz.scm: Likewise. * gnu/packages/python.scm: Likewise. * gnu/packages/sphinx.scm: Likewise. * gnu/packages/ssh.scm: Likewise. * gnu/packages/xdisorg.scm: Likewise. * gnu/services/networking.scm: Likewise. * gnu/system/vm.scm: Likewise. Christopher Lemmer Webber 2021-08-15doc: Fix typo....* doc/guix-cookbook.texi (GUIX_PACKAGE_PATH): Fix typo in file name. Reported-by: breathein on IRC. Ricardo Wurmus 2021-07-18Merge branch 'master' into core-updatesLudovic Courtès 2021-07-12doc: cookbook: Adjust example to simplified input style....* doc/guix-cookbook.texi (Extended example): Adjust example to new input style and adjust "Inputs" section. Ludovic Courtès 2021-07-12doc: cookbook: Remove trailing #t from extended example....* doc/guix-cookbook.texi (Extended example): Remove trailing #t from snippet and phases. Ludovic Courtès 2021-07-07doc: Add guide showing auto-login on a specific TTY to the cookbook....This is a follow-up to the discussion in <https://bugs.gnu.org/48974>. * doc/guix-cookbook.texi (System Configuration): Add a brief guide that explains auto login a user to one TTY. * doc/guix.texi (System Services): Add an texinfo anchor, so that the cookbook entry "Auto Login a User to a Specific TTY" can refer back to the precise point that the GNU Guix Reference manual. Also add a reference to the cookbook that shows how to auto login a specific user to one TTY. Signed-off-by: Leo Prikler <leo.prikler@student.tugraz.at> Joshua Branson 2021-01-21doc: cookbook: Add "Guix System Image API" section....* doc/guix-cookbook.texi (Guix System Image API): New section. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org> Joshua Branson 2021-01-20doc: Replace TP with Weblate mentions....* doc/contributing.texi: Replace link to TP with a link to Weblate. * doc/guix.texi: Replace link to TP with a link to Weblate. * doc/guix-cookbook.texi: Replace link to TP with a link to Weblate. Julien Lepiller 2020-12-23doc: cookbook: Fix "fiction-less" typo....* doc/guix-cookbook.texi (Guix Profiles in Practice): Change "friction-less" to "frictionless". Pierre Neidhardt