aboutsummaryrefslogtreecommitdiff
#! /bin/sh
# -*-scheme-*-
build_aux=$(dirname $0)
srcdir=$build_aux/..
export LC_ALL=en_US.UTF-8
export TZ=UTC0
exec guile --no-auto-compile -L $srcdir -C $srcdir -e main -s "$0" "$@"
!#

;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2024 Janneke Nieuwenhuizen <janneke@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; This program 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.
;;;
;;; This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.

;;;; Commentary:
;;;
;;; This script provides an xgettext wrapper to (re)set POT-Creation-Date from
;;; a Git timestamp.  Test doing something like:
;;;
;;; build-aux/xgettext.scm --files-from=po/guix/POTFILES.in --default-domain=test
;;;
;;;; Code:

(use-modules (srfi srfi-1)
             (srfi srfi-26)
             (ice-9 curried-definitions)
             (ice-9 match)
             (ice-9 popen)
             (ice-9 rdelim)
             (guix build utils))

(define ((option? name) option)
  (string-prefix? name option))

(define (get-option args name)
  (let ((option (find (option? name) args)))
    (and option
         (substring option (string-length name)))))

(define (pipe-command command)
  (let* ((port (apply open-pipe* OPEN_READ command))
         (output (read-string port)))
    (close-port port)
    output))


;;;
;;; Entry point.
;;;
(define (main args)
  (fluid-set! %default-port-encoding #f)
  (let* ((files-from (get-option args "--files-from="))
         (default-domain (get-option args "--default-domain="))
         (directory (or (get-option args "--directory=") "."))
         (xgettext (or (get-option args "--xgettext=") "xgettext"))
         (xgettext-args (filter (negate (option? "--xgettext=")) args))
         (command (match xgettext-args
                    ((xgettext.scm args ...)
                     `(,xgettext ,@args))))
         (result (apply system* command))
         (status (/ result 256)))
    (if (or (not (zero? status))
            (not files-from))
        (exit status)
        (let* ((text (with-input-from-file files-from read-string))
               (lines (string-split text #\newline))
               (files (filter (negate (cute string-prefix? "#" <>)) lines))
               (files (map (cute string-append directory "/" <>) files))
               (git-command `("git" "log" "--pretty=format:%ci" "-n1" ,@files))
               (timestamp (pipe-command git-command))
               (source-date-epoch (or (getenv "SOURCE_DATE_EPOCH") "1"))
               (timestamp (if (string-null? timestamp) source-date-epoch
                              timestamp))
               (po-file (string-append default-domain ".po")))
          (substitute* po-file
            (("(\"POT-Creation-Date: )[^\\]*" all header)
             (string-append header timestamp)))))))
pan title='2021-11-16 14:34:28 +0100'>2021-11-16daemon: Do not deduplicate files smaller than 8 KiB.Ludovic Courtès Files smaller than 8 KiB typically represent ~70% of the entries in /gnu/store/.links but only contribute to ~4% of the space savings afforded by deduplication. Not considering these files for deduplication speeds up file insertion in the store and, more importantly, leaves 'removeUnusedLinks' with fewer entries to traverse, thereby speeding it up proportionally. Partly fixes <https://issues.guix.gnu.org/24937>. * config-daemon.ac: Remove symlink hard link check and CAN_LINK_SYMLINK definition. * guix/store/deduplication.scm (%deduplication-minimum-size): New variable. (deduplicate)[loop]: Do not recurse when FILE's size is below %DEDUPLICATION-MINIMUM-SIZE. (dump-port): New procedure. (dump-file/deduplicate)[hash]: Turn into... [dump-and-compute-hash]: ... this thunk. Call 'deduplicate' only when SIZE is greater than %DEDUPLICATION-MINIMUM-SIZE; otherwise call 'dump-port'. * nix/libstore/gc.cc (LocalStore::removeUnusedLinks): Drop files where st.st_size < deduplicationMinSize. * nix/libstore/local-store.hh (deduplicationMinSize): New declaration. * nix/libstore/optimise-store.cc (deduplicationMinSize): New variable. (LocalStore::optimisePath_): Return when PATH is a symlink or smaller than 'deduplicationMinSize'. * tests/derivations.scm ("identical files are deduplicated"): Produce files bigger than %DEDUPLICATION-MINIMUM-SIZE. * tests/nar.scm ("restore-file-set with directories (signed, valid)"): Likewise. * tests/store-deduplication.scm ("deduplicate, below %deduplication-minimum-size"): New test. ("deduplicate", "deduplicate, ENOSPC"): Produce files bigger than %DEDUPLICATION-MINIMUM-SIZE. * tests/store.scm ("substitute, deduplication"): Likewise. 2021-10-01build: Don’t delete ‘guix-gc.timer’ file.Xinglu Chen Without this invoking ‘make clean’ would remove ‘guix-gc.timer’, and ‘make’ would fail with. make[2]: *** No rule to make target 'etc/guix-gc.timer', needed by 'all-am'. Stop. * nix/local.mk (nodist_systemdservice_DATA): Remove ‘guix-gc.timer’. 2021-09-20etc: Add systemd files for running ‘guix gc’ periodicallyThiago Jung Bauermann * etc/guix-gc.service.in: New file. * etc/guix-gc.timer: Likewise. * .gitignore: Ignore generated ‘guix-gc.service’. * nix/local.mk (nodist_systemdservice_DATA): Add ‘guix-gc.service’ and ‘guix-gc.timer’. (EXTRA_DIST): Add ‘guix-gc.service.in’ and ‘guix-gc.timer’. * doc/guix.texi (Binary Installation): Mention the new systemd files. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org> 2021-04-09daemon: 'guix substitute' replies on FD 4.Ludovic Courtès This avoids the situation where error messages would unintentionally go to stderr and be wrongfully interpreted as a reply by the daemon. Fixes <https://bugs.gnu.org/46362>. This is a followup to ee3226e9d54891c7e696912245e4904435be191c. * guix/scripts/substitute.scm (display-narinfo-data): Add 'port' parameter and honor it. (process-query): Likewise. (process-substitution): Likewise. (%error-to-file-descriptor-4?, with-redirected-error-port): Remove. (%reply-file-descriptor): New variable. (guix-substitute): Remove use of 'with-redirected-error-port'. Define 'reply-port' and pass it to 'process-query' and 'process-substitution'. * nix/libstore/build.cc (SubstitutionGoal::handleChildOutput): Swap 'builderOut' and 'fromAgent'. * nix/libstore/local-store.cc (LocalStore::getLineFromSubstituter): Likewise. * tests/substitute.scm <top level>: Set '%reply-file-descriptor' rather than '%error-to-file-descriptor-4?'. 2021-04-03daemon: Remove dead code.Ludovic Courtès Reported by Noisytoot on #guix. * nix/nix-daemon/shared.hh (showManPage): Remove. * nix/nix-daemon/nix-daemon.cc (printHelp, programId): Remove. 2021-03-30gnu: guix: Fix openrc init scripts.zimoun Fixes <https://bugs.gnu.org/46871>. * gnu/packages/package-management.scm (guix)[arguments]: Fix openrc init. * nix/local.mk (openrcservicedir): Likewise. Signed-off-by: Efraim Flashner <efraim@flashner.co.il> 2021-03-18daemon: Prevent privilege escalation with '--keep-failed' [security].Ludovic Courtès Fixes <https://bugs.gnu.org/47229>. Reported by Nathan Nye of WhiteBeam Security. * nix/libstore/build.cc (DerivationGoal::startBuilder): When 'useChroot' is true, add "/top" to 'tmpDir'. (DerivationGoal::deleteTmpDir): Adjust accordingly. When 'settings.keepFailed' is true, chown in two steps: first the "/top" sub-directory, and then rename "/top" to its parent. 2021-03-17daemon: Correctly handle '--discover' with no value.Ludovic Courtès Previously, we'd get: $ guix-daemon --discover error: basic_string::_M_construct null not valid * nix/nix-daemon/guix-daemon.cc (parse_opt): Change second argument to 'settings.set' to properly handle case where ARG is NULL. 2020-12-19daemon: Delegate deduplication to 'guix substitute'.Ludovic Courtès This removes the main source of latency between subsequent downloads. * nix/libstore/build.cc (SubstitutionGoal::tryToRun): Add a "deduplicate" key to ENV. (SubstitutionGoal::finished): Remove call to 'optimisePath'. * guix/scripts/substitute.scm (process-substitution)[destination-in-store?] [dump-file/deduplicate*]: New variables. Pass #:dump-file to 'restore-file'. * guix/scripts/substitute.scm (guix-substitute)[deduplicate?]: New variable. Pass #:deduplicate? to 'process-substitution'. * guix/serialization.scm (dump-file): Export and augment 'dump-file'. 2020-12-19daemon: Do not reset timestamps and permissions on substituted items.Ludovic Courtès 'guix substitute' now takes care of it via 'restore-file'. * nix/libstore/build.cc (SubstitutionGoal::finished): Remove call to 'canonicalisePathMetaData'. 2020-12-19daemon: Let 'guix substitute' perform hash checks.Ludovic Courtès This way, the hash of the store item can be computed as it is restored, thereby avoiding an additional file tree traversal ('hashPath' call) later on in the daemon. Consequently, it should reduce latency between subsequent substitute downloads. This is a followup to 5ff521452b9ec2aae9ed8e4bb7bdc250a581f203. * guix/scripts/substitute.scm (narinfo-hash-algorithm+value): New procedure. (process-substitution): Wrap INPUT into a hash input port, 'hashed', and read from it. Compare the actual and expected hashes, and print a "hash-mismatch" status line when they differ. When they match, print not just "success" but also the nar hash and size. * nix/libstore/build.cc (class SubstitutionGoal)[expectedHashStr]: Remove. (SubstitutionGoal::finished): Tokenize 'status'. Parse it and handle "success" and "hash-mismatch" accordingly. Call 'hashPath' only when the returned hash is not SHA256. (SubstitutionGoal::handleChildOutput): Remove 'expectedHashStr' handling. * tests/substitute.scm ("substitute, invalid hash"): Rename to... ("substitute, invalid narinfo hash"): ... this. ("substitute, invalid hash"): New test.