aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; 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 (test-rpm)
  #:use-module (guix rpm)
  #:use-module (rnrs bytevectors)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-26)
  #:use-module (srfi srfi-64)
  #:use-module (srfi srfi-71))

;; For white-box testing.
(define-syntax-rule (expose-internal name)
  (define name (@@ (guix rpm) name)))

(expose-internal RPMTAG_ARCH)
(expose-internal RPMTAG_LICENSE)
(expose-internal RPMTAG_NAME)
(expose-internal RPMTAG_OS)
(expose-internal RPMTAG_RELEASE)
(expose-internal RPMTAG_SUMMARY)
(expose-internal RPMTAG_VERSION)
(expose-internal header-entry-count)
(expose-internal header-entry-tag)
(expose-internal header-entry-value)
(expose-internal header-entry?)
(expose-internal make-header)
(expose-internal make-header-entry)
(expose-internal make-header-index+data)

(test-begin "rpm")

(test-equal "lead must be 96 bytes long"
  96
  (length (generate-lead "hello-2.12.1")))

(define header-entries
  (list (make-header-entry RPMTAG_NAME 1 "hello")
        (make-header-entry RPMTAG_VERSION 1 "2.12.1")
        (make-header-entry RPMTAG_RELEASE 1 "0")
        (make-header-entry RPMTAG_SUMMARY 1
                           "Hello, GNU world: An example GNU package")
        (make-header-entry RPMTAG_LICENSE 1 "GPL 3 or later")
        (make-header-entry RPMTAG_OS 1 "Linux")
        (make-header-entry RPMTAG_ARCH 1 "x86_64")))

(define expected-header-index-length
  (* 16 (length header-entries)))       ;16 bytes per index entry

(define expected-header-data-length
  (+ (length header-entries)            ;to account for null bytes
     (fold + 0 (map (compose string-length (cut header-entry-value <>))
                    header-entries))))

(let ((index data (make-header-index+data header-entries)))
  (test-equal "header index"
    expected-header-index-length
    (length index))

  ;; This test depends on the fact that only STRING entries are used, and that
  ;; they are composed of single byte characters and the delimiting null byte.
  (test-equal "header data"
    expected-header-data-length
    (length data)))

(test-equal "complete header section"
  (+ 16                                 ;leading magic + count bytes
     expected-header-index-length expected-header-data-length)
  (length (make-header header-entries)))

(test-end)
s O_CLOEXEC. 2022-04-10services: shepherd: Do not unload transient services.Ludovic Courtès Fixes <https://issues.guix.gnu.org/54812>. Starting with Shepherd 0.9.0 and the use of 'make-inetd-constructor' in commit 808b9e850491c7b1d867a5f1f4d5ee6f61f345d4, systems might be running transient Shepherd services such as those corresponding to SSH connections. Before this change, 'shepherd-service-upgrade' would have those transient services in the list of services to unload; concretely, that would lead all SSH connections to be closed upon 'guix system reconfigure'. * gnu/services/shepherd.scm (shepherd-service-upgrade): Remove transient services to TO-UNLOAD. 2022-04-07services: shepherd: Default to version 0.9.Ludovic Courtès * gnu/services/shepherd.scm (scm->go): Define 'shepherd&co' and pass it to 'with-extensions'. (shepherd-configuration-file): Call 'start-in-the-background' when it is defined. (<shepherd-configuration>)[shepherd]: Default to SHEPHERD-0.9. * gnu/system.scm (hurd-default-essential-services): Use SHEPHERD-0.8. 2021-11-30services: Accept <inferior-package>s in lieu of <package>s.Tobias Geerinckx-Rice * gnu/services/authentication.scm (fprintd-configuration) (nslcd-configuration): Substitute file-like objects for package ones. * gnu/services/cgit.scm (cgit-configuration, opaque-cgit-configuration): Likewise. * gnu/services/cups.scm (package-list?, cups-configuration): Likewise. * gnu/services/dns.scm (verify-knot-configuration) (ddclient-configuration): Likewise. * gnu/services/docker.scm (docker-configuration): Likewise. * gnu/services/file-sharing.scm (transmission-daemon-configuration): Likewise. * gnu/services/getmail.scm (getmail-configuration): Likewise. * gnu/services/mail.scm (dovecot-configuration) (opaque-dovecot-configuration): Likewise. * gnu/services/messaging.scm (prosody-configuration) (opaque-prosody-configuration): Likewise. * gnu/services/monitoring.scm (zabbix-server-configuration) (zabbix-agent-configuration): Likewise. * gnu/services/networking.scm (opendht-configuration): Likewise. * gnu/services/pm.scm (tlp-configuration): Likewise. * gnu/services/telephony.scm (jami-configuration): Likewise. * gnu/services/virtualization.scm (libvirt-configuration) (qemu-guest-agent-configuration): Likewise. * gnu/services/vpn.scm (openvpn-client-configuration): Likewise. 2021-03-03services: shepherd: Make 'assert-valid-graph' public.Andrew Tropin * gnu/services/shepherd.scm (assert-valid-graph): Make public. Signed-off-by: Ludovic Courtès <ludo@gnu.org> 2021-02-25services: shepherd: Make /run/booted-system a symlink to the store item.Ludovic Courtès Fixes <https://bugs.gnu.org/46767>. Previously /run/booted-system would end up referring to /var/guix/profiles/system-NNN-link; consequently, the booted system would not be GC-protected. * gnu/services/shepherd.scm (shepherd-boot-gexp): Call 'canonicalize-path' instead of 'readlink'. 2021-01-30services: shepherd: Allow custom 'shepherd' package.Maxime Devos * gnu/services/shepherd.scm (<shepherd-configuration>): New record. (shepherd-boot-gexp, shepherd-root-service-type): Use it. (scm->go, shepherd-configuration-file): Allow passing custom shepherd package. * gnu/system.scm (operating-system-shepherd-service-names): Use the new record. * guix/scripts/system.scm (export-shepherd-graph): Adjust accordingly. * doc/guix.texi (Shepherd Services). Document it. Co-authored-by: Ludovic Courtès <ludo@gnu.org> 2021-01-13services: shepherd: 'shepherd-service-type' requires documentation.Ludovic Courtès * gnu/services/shepherd.scm (shepherd-service-type): Require a 'description' form. * gnu/services/base.scm (root-file-system-service-type) (rngd-service-type, host-name-service-type): (virtual-terminal-service-type, console-keymap-service-type) (syslog-service-type, swap-service-type) (kmscon-service-type): Add description. * gnu/services/networking.scm (dhcp-client-service-type): Likewise. * gnu/system/install.scm (cow-store-service-type): Likewise. * gnu/system/linux-container.scm (dummy-networking-service-type): Likewise. * gnu/system/mapped-devices.scm (device-mapping-service-type): Likewise. * tests/guix-system.sh: Likewise. 2020-11-18services: shepherd: Map all the invalid store characters to dash.Ludovic Courtès Fixes a regression introduced in 977eb5d023cfdf8e336f1896480eea9cef5c04e9 whereby file system services would now have a different name. * gnu/services/base.scm (file-system->shepherd-service-name): Revert changes introduced in 977eb5d023cfdf8e336f1896480eea9cef5c04e9. * gnu/services/shepherd.scm (%store-characters): New variable (shepherd-service-file-name): Map all the characters outside %STORE-CHARACTERS to #\-.