;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
;;; Copyright © 2012, 2013, 2016, 2021 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2019 Marius Bakke <mbakke@fastmail.com>
;;; Copyright © 2023 Janneke Nieuwenhuizen <janneke@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 packages attr)
  #:use-module (guix licenses)
  #:use-module (gnu packages perl)
  #:use-module (gnu packages gettext)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix build-system gnu)
  #:use-module (guix utils))

(define-public attr
  (package
    (name "attr")
    (version "2.5.1")
    (source (origin
              (method url-fetch)
              (uri (string-append "mirror://savannah/attr/attr-"
                                  version ".tar.gz"))
              (sha256
               (base32
                "1y6sibbkrcjygv8naadnsg6xmsqwfh6cwrqk01l0v2i5kfacdqds"))))
    (build-system gnu-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         ,@(if (target-hurd?)
               `((add-before 'configure 'skip-linux-syscalls
                   (lambda _
                     ;; Starting from 2.5.1, libattr includes Linux-specific
                     ;; calls to syscall(2).  Comment them out for GNU/Hurd
                     ;; and instead use the glibc-provided wrappers.
                     (substitute* "Makefile.in"
                       (("libattr/syscalls\\.c") "")
                       (("\tlibattr/la-syscalls\\.lo") "")
                       (("-Wl,[[:graph:]]+/libattr\\.lds") "")))))
               '())
         (replace 'check
           (lambda* (#:key target #:allow-other-keys)
             ;; Use the right shell.
             (substitute* "test/run"
               (("/bin/sh")
                (which "sh")))

             ;; When building natively, run the tests.
             ;;
             ;; Note that we use system* and unconditionally return #t here
             ;; to ignore the test result, because the tests will fail when
             ;; the build is performed on a file system without support for
             ;; extended attributes, and we wish to allow Guix to be built
             ;; on such systems.
             (unless target
               (system* "make" "tests" "-C" "test")))))))
    (inputs
     ;; Perl is needed to run tests; remove it from cross builds.
     (if (%current-target-system)
         '()
         `(("perl" ,perl))))
    (native-inputs
     `(("gettext" ,gettext-minimal)))

    (home-page "https://savannah.nongnu.org/projects/attr/")
    (synopsis "Library and tools for manipulating extended attributes")
    (description
     "Portable library and tools for manipulating extended attributes.")
    (license lgpl2.1+)))
field specifier, identifier")
("define-record-type* &amp; duplicate initializers"): Use it.


</td></tr>
<tr class='logheader'><td><span title='2020-01-16 18:30:57 +0100'>2020-01-16</span></td><td class='logsubject'><a href='/guix/commit/tests/records.scm?id=47212fc763788660ff9051ccee1f6fa8a0db7bdd'>records: Improve reporting of "invalid field specifier" errors.</a></td><td>Ludovic Courtès</td></tr>
<tr class='nohover-highlight'><td/><td colspan='3' class='logmsg'>
Previously users would just see:

  error: invalid field specifier

without source location or hints.

* guix/records.scm (expand): Add optional 'parent-form' parameter and
pass it to 'syntax-violation' when it is true.
(make-syntactic-constructor): Pass S as a third argument to
'report-invalid-field-specifier'.
* guix/ui.scm (report-load-error): For 'syntax-error', show SUBFORM or
FORM in the message.
* tests/records.scm ("define-record-type* &amp; wrong field specifier"): Add
a 'subform' parameter and adjust test accordingly.
("define-record-type* &amp; wrong field specifier, identifier"): New test.
* tests/guix-system.sh: Add test.


</td></tr>
<tr class='logheader'><td><span title='2019-03-30 11:08:39 +0100'>2019-03-30</span></td><td class='logsubject'><a href='/guix/commit/tests/records.scm?id=d2be7e3c4ba8d6d0dde9b4c0bff623ab85637424'>records: Support custom 'this' identifiers.</a></td><td>Ludovic Courtès</td></tr>
<tr class='nohover-highlight'><td/><td colspan='3' class='logmsg'>
This lets record users choose an identifier other than 'this-record'.

* guix/records.scm (make-syntactic-constructor): Add #:this-identifier.
[wrap-field-value]: Honor it.
(define-record-type*): Add form with extra THIS-IDENTIFIER and honor
it.
* tests/records.scm ("define-record-type* &amp; thunked &amp; inherit &amp; custom this"):
New test.


</td></tr>
<tr class='logheader'><td><span title='2019-03-25 23:37:06 +0100'>2019-03-25</span></td><td class='logsubject'><a href='/guix/commit/tests/records.scm?id=abd4d6b33dba4de228e90ad15a8efb456fcf7b6e'>records: Allow thunked fields to refer to 'this-record'.</a></td><td>Ludovic Courtès</td></tr>
<tr class='nohover-highlight'><td/><td colspan='3' class='logmsg'>
* guix/records.scm (this-record): New syntax parameter.
(make-syntactic-constructor)[wrap-field-value]: When F is thunked,
return a one-argument lambda instead of a thunk, and parameterize
THIS-RECORD.
(define-record-type*)[thunked-field-accessor-definition]: Pass X
to (real-get X).
* tests/records.scm ("define-record-type* &amp; thunked &amp; this-record")
("define-record-type* &amp; thunked &amp; default &amp; this-record")
("define-record-type* &amp; thunked &amp; inherit &amp; this-record"): New tests.


</td></tr>