all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
blob f058793160c4b77b0d01109498564f2b269f7e63 43428 bytes (raw)
name: gnu/packages/bash.scm 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
 
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2015, 2017 Leo Famulari <leo@famulari.name>
;;; Copyright © 2016, 2017, 2018, 2019 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2020 Zhu Zihao <all_but_last@163.com>
;;; Copyright © 2021 Marius Bakke <marius@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 bash)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (gnu packages)
  #:use-module (gnu packages admin)
  #:use-module (gnu packages base)
  #:use-module (gnu packages bison)
  #:use-module (gnu packages bootstrap)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages curl)
  #:use-module (gnu packages dns)
  #:use-module (gnu packages elf)
  #:use-module (gnu packages file)
  #:use-module (gnu packages freedesktop)
  #:use-module (gnu packages gawk)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages guile)
  #:use-module (gnu packages guile-xyz)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages libffi)
  #:use-module (gnu packages lsof)
  #:use-module (gnu packages ncurses)
  #:use-module (gnu packages networking)
  #:use-module (gnu packages pcre)
  #:use-module (gnu packages perl)
  #:use-module (gnu packages php)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages python)
  #:use-module (gnu packages python-xyz)
  #:use-module (gnu packages readline)
  #:use-module (gnu packages web)
  #:use-module (gnu packages xml)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix utils)
  #:use-module (guix gexp)
  #:use-module (guix monads)
  #:use-module (guix store)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system copy)
  #:use-module (guix build-system trivial)  
  #:autoload   (guix gnupg) (gnupg-verify*)
  #:autoload   (guix base32) (bytevector->nix-base32-string)

  ;; See <https://bugs.gnu.org/41457> for why not #:autoload here.
  #:use-module ((gcrypt hash) #:select (port-sha256))

  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-26)
  #:use-module (ice-9 format))

(define (patch-url seqno)
  "Return the URL of Bash patch number SEQNO."
  (format #f "mirror://gnu/bash/bash-5.1-patches/bash51-~3,'0d" seqno))

(define (bash-patch seqno sha256-bv)
  "Return the origin of Bash patch SEQNO, with expected hash SHA256-BV."
  (origin
    (method url-fetch)
    (uri (patch-url seqno))
    (sha256 sha256-bv)))

(define-syntax-rule (patch-series (seqno hash) ...)
  (list (bash-patch seqno (base32 hash))
        ...))

(define %patch-series-5.1
  ;; This is the current patches series for 5.0, generated using
  ;; 'download-patches' below.
  (patch-series
   (1 "1ymm8ppss6gyh9ifznjwiabrb4k91npd09c10y7mk66xp8yppc7b")
   (2 "1gjx9zqcm407am3n2sh44b8dxm48kgm15rzfiijqxr01m0hn3shm")
   (3 "1cdnpbfc64yhvkjj4d12s9ywp11g195vzfl1cab24sq55wkcrwi2")
   (4 "11iwhy6v562bv0kk7lwj7f5jj65ma9bblivy0v02h3ggcibbdbls")
   (5 "19bdyigdr81824nxvqr6a7k0cax60wq7376j6b91afbnwvlvbjyc")
   (6 "051x8wlwrqk0yr0zg378vh824iklfl5g9pkmcdf62qp8gn9pvqbm")
   (7 "0fir80pp1gmlpadmqcgkrv4y119pc7xllchjzg05fd7px73viz5c")
   (8 "1lfjgshk8i9vch92p5wgc9r90j3phw79aa7gbai89w183b2z6b7j")))

(define (download-patches store count)
  "Download COUNT Bash patches into store.  Return a list of
number/base32-hash tuples, directly usable in the 'patch-series' form."
  (unfold (cut > <> count)
          (lambda (number)
            (let* ((patch  (download-to-store store (patch-url number)))
                   (sig    (download-to-store store
                                              (string-append (patch-url number)
                                                             ".sig"))))
              (unless (eq? 'valid-signature (gnupg-verify* sig patch))
                (error "failed to verify signature" patch))

              (list number
                    (bytevector->nix-base32-string
                     (call-with-input-file patch port-sha256)))))
          1+
          1))

(define-public bash
  (let* ((cppflags (string-join '("-DDEFAULT_PATH_VALUE='\"/no-such-path\"'"
                                  "-DSTANDARD_UTILS_PATH='\"/no-such-path\"'"
                                  "-DNON_INTERACTIVE_LOGIN_SHELLS"
                                  "-DSSH_SOURCE_BASHRC")
                                " "))
         (configure-flags
          ``("--with-installed-readline"
             ,,(string-append "CPPFLAGS=" cppflags)
             ,(string-append
               "LDFLAGS=-Wl,-rpath -Wl,"
               (assoc-ref %build-inputs "readline")
               "/lib"
               " -Wl,-rpath -Wl,"
               (assoc-ref %build-inputs "ncurses")
               "/lib")))
         (version "5.1"))
    (package
     (name "bash")
     (source (origin
              (method url-fetch)
              (uri (string-append
                    "mirror://gnu/bash/bash-" version ".tar.gz"))
              (sha256
               (base32
                "1alv68wplnfdm6mh39hm57060xgssb9vqca4yr1cyva0c342n0fc"))
              (patch-flags '("-p0"))
              (patches (cons (search-patch "bash-linux-pgrp-pipe.patch")
                             %patch-series-5.1))))
     (version (string-append version "." (number->string (length %patch-series-5.1))))
     (build-system gnu-build-system)

     (outputs '("out"
                "doc"                         ;1.7 MiB of HTML and extra files
                "include"))                   ;headers used by extensions
     (inputs (list readline ncurses))             ;TODO: add texinfo
     (arguments
      `(;; When cross-compiling, `configure' incorrectly guesses that job
        ;; control is missing.
        #:configure-flags ,(if (%current-target-system)
                               `(cons* "bash_cv_job_control_missing=no"
                                       ,configure-flags)
                               configure-flags)

        ;; Bash is reportedly not parallel-safe.  See, for instance,
        ;; <http://patches.openembedded.org/patch/32745/> and
        ;; <http://git.buildroot.net/buildroot/commit/?h=79e2d802a>.
        #:parallel-build? #f
        #:parallel-tests? #f

        ;; XXX: The tests have a lot of hard-coded paths, so disable them
        ;; for now.
        #:tests? #f

        #:modules ((srfi srfi-26)
                   (guix build utils)
                   (guix build gnu-build-system))

        #:phases
        (modify-phases %standard-phases
          (add-after 'install 'install-sh-symlink
            (lambda* (#:key outputs #:allow-other-keys)
              ;; Add a `sh' -> `bash' link.
              (let ((out (assoc-ref outputs "out")))
                (with-directory-excursion (string-append out "/bin")
                  (symlink "bash" "sh")
                  #t))))

          (add-after 'install 'move-development-files
            (lambda* (#:key outputs #:allow-other-keys)
              ;; Move 'Makefile.inc' and 'bash.pc' to "include" to avoid
              ;; circular references among the outputs.
              (let ((out     (assoc-ref outputs "out"))
                    (include (assoc-ref outputs "include"))
                    (lib     (cut string-append <> "/lib/bash")))
                (mkdir-p (lib include))
                (rename-file (string-append (lib out)
                                            "/Makefile.inc")
                             (string-append (lib include)
                                            "/Makefile.inc"))
                (rename-file (string-append out "/lib/pkgconfig")
                             (string-append include
                                            "/lib/pkgconfig"))

                ;; Don't capture the absolute file name of 'install' to avoid
                ;; retaining a dependency on Coreutils.
                (substitute* (string-append (lib include)
                                            "/Makefile.inc")
                  (("^INSTALL =.*")
                   "INSTALL = install -c\n"))
                #t))))))

     (native-search-paths
      (list (search-path-specification            ;new in 4.4
             (variable "BASH_LOADABLES_PATH")
             (files '("lib/bash")))))

     (synopsis "The GNU Bourne-Again SHell")
     (description
      "Bash is the shell, or command-line interpreter, of the GNU system.  It
is compatible with the Bourne Shell, but it also integrates useful features
from the Korn Shell and the C Shell and new improvements of its own.  It
allows command-line editing, unlimited command history, shell functions and
aliases, and job control while still allowing most sh scripts to be run
without modification.")
     (license license:gpl3+)
     (home-page "https://www.gnu.org/software/bash/"))))

(define-public bash-minimal
  ;; A stripped-down Bash for non-interactive use.
  (package (inherit bash)
    (name "bash-minimal")
    (inputs '())                                ; no readline, no curses

    ;; No "include" output because there's no support for loadable modules.
    (outputs (delete "include" (package-outputs bash)))

    (arguments
     (substitute-keyword-arguments (package-arguments bash)
       ((#:modules _ '())
        '((guix build gnu-build-system)
          (guix build utils)
          (srfi srfi-1)
          (srfi srfi-26)))
       ((#:configure-flags flags '())
        `(list "--without-bash-malloc"
               "--disable-readline"
               "--disable-history"
               "--disable-help-builtin"
               "--disable-progcomp"
               "--disable-net-redirections"
               "--disable-nls"

               ;; Pretend 'dlopen' is missing so we don't build loadable
               ;; modules and related code.
               "ac_cv_func_dlopen=no"

               ,@(if (%current-target-system)
                     '("bash_cv_job_control_missing=no"
                       "bash_cv_getcwd_malloc=yes")
                     '())))
       ((#:phases phases)
        `(modify-phases ,phases
           ;; No loadable modules.
           (delete 'move-development-files)))))))

(define-public static-bash
  ;; Statically-linked Bash that contains nothing but the 'bash' binary and
  ;; 'sh' symlink, without any reference.
  (let ((bash (static-package bash-minimal)))
    (package
      (inherit bash)
      (name "bash-static")
      (arguments
       (substitute-keyword-arguments
           `(#:allowed-references ("out") ,@(package-arguments bash))
         ((#:phases phases)
          `(modify-phases ,phases
             (add-after 'strip 'remove-everything-but-the-binary
               (lambda* (#:key outputs #:allow-other-keys)
                 (let* ((out (assoc-ref outputs "out"))
                        (bin (string-append out "/bin")))
                   (remove-store-references (string-append bin "/bash"))
                   (delete-file (string-append bin "/bashbug"))
                   (delete-file-recursively (string-append out "/share"))
                   #t))))))))))

(define-public bash-with-syslog
  (package
    (inherit bash)
    (name "bash-with-syslog")
    (arguments
     (substitute-keyword-arguments (package-arguments bash)
       ((#:phases phases '%standard-phases)
        `(modify-phases ,phases
           (add-after 'unpack 'enable-syslogging
             (lambda _
               (substitute* "config-top.h"
                 (("/\\* #define SYSLOG_HISTORY \\*/")
                  "#define SYSLOG_HISTORY"))))))))
    (description
     "Bash is the shell, or command-line interpreter, of the GNU system.  This
variant logs the history to syslog.")))

(define-public bash-completion
  (package
    (name "bash-completion")
    (version "2.8")
    (source (origin
              (method url-fetch)
              (uri (string-append
                    "https://github.com/scop/" name "/releases/download/"
                    version "/" name "-" version ".tar.xz"))
              (sha256
               (base32
                "0kgmflrr1ga9wfk770vmakna3nj46ylb5ky9ipd0v2k9ymq5a7y0"))
              (patches
               (search-patches "bash-completion-directories.patch"))))
    (build-system gnu-build-system)
    (native-inputs (list util-linux))
    (arguments
     `(#:phases (modify-phases %standard-phases
                  (add-after
                   'install 'remove-redundant-completions
                   (lambda* (#:key
                             inputs native-inputs
                             outputs #:allow-other-keys)
                     ;; Util-linux comes with a bunch of completion files for
                     ;; its own commands which are more sophisticated and
                     ;; up-to-date than those of bash-completion.  Remove those
                     ;; from bash-completion.
                     (let* ((out         (assoc-ref outputs "out"))
                            (util-linux  (assoc-ref (or native-inputs inputs)
                                                    "util-linux"))
                            (completions (string-append out
                                                        "/share/bash-completion"
                                                        "/completions"))
                            (already     (find-files
                                          (string-append
                                           util-linux
                                           "/etc/bash_completion.d"))))
                       (with-directory-excursion completions
                         (for-each (lambda (file)
                                     (when (file-exists? file)
                                       (delete-file file)))
                                   (map basename already)))
                       #t))))))
    (synopsis "Bash completions for common commands")
    (description
     "This package provides extensions that allow Bash to provide adapted
completion for many common commands.")
    (home-page "https://github.com/scop/bash-completion")
    (license license:gpl2+)))

(define-public bash-tap
  (package
    (name "bash-tap")
    (version "1.0.2")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/illusori/bash-tap")
             (commit version)))
       (file-name (git-file-name name version))
       (sha256
        (base32 "13zz9h6bhhnk3hiwhlpafrnf2isws249h3fz785dcgymk02arz9c"))))
    ;; There is no compilation process to use this package, however, the bash
    ;; scripts installed by this package start with "#!/bin/bash".  To fix
    ;; these lines, we use the patch-shebangs of the GNU build system.  The
    ;; project does not use a Makefile.
    (build-system gnu-build-system)
    (arguments
     `(#:tests? #f ; There is no test suite.
       #:phases
       (modify-phases %standard-phases
         ;; Because there are no configure scripts or Makefile, we can
         ;; remove these phases.
         (delete 'configure)
         (delete 'build)
         ;; The installation involves manually copying the files to a location.
         ;; To make them easily accessible by setting PATH, we add the scripts
         ;; to the "bin" folder.
         (replace 'install
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((bin (string-append (assoc-ref outputs "out") "/bin")))
               (install-file "bash-tap" bin)
               (install-file "bash-tap-bootstrap" bin)
               (install-file "bash-tap-mock" bin)))))))
    (home-page "https://www.illusori.co.uk/projects/bash-tap/")
    (synopsis "Bash port of a Test::More/Test::Builder-style TAP-compliant
test library")
    (description "Bash TAP is a TAP-compliant Test::More-style testing library
for Bash shell scripts and functions.  Along with the Test::More-style testing
helpers it provides helper functions for mocking commands and in-process output
capturing.")
    (license license:expat)))

(define-public bats
  (package
    (name "bats")
    (version "1.2.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/bats-core/bats-core")
                    (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "0f59zh4d4pa1a7ybs5zl6h0csbqqv11lbnq0jl1dgwm1s6p49bsq"))))
    (inputs
     (list bash coreutils guile-3.0 ;for wrap-script
           grep))
    (arguments
     `(#:modules ((guix build utils))
       #:builder
       (begin
         (use-modules (guix build utils))
         (copy-recursively (assoc-ref %build-inputs "source") ".")
         (setenv "PATH"
                 (string-append (assoc-ref %build-inputs "bash") "/bin"
                                ":" (assoc-ref %build-inputs "coreutils") "/bin"
                                ":" (assoc-ref %build-inputs "grep") "/bin"
                                ":" (assoc-ref %build-inputs "guile") "/bin"
                                ":" (getenv "PATH")))
         (for-each (lambda (file) (patch-shebang file)) (find-files "."))
         (substitute* "bin/bats"
           (("export BATS_ROOT" line)
            (string-append "BATS_ROOT=\"${BATS_ROOT:-" %output "/libexec/bats-core}\"\n"
                           line)))
         ;; Install phase
         (invoke "./install.sh" %output)
         (wrap-script (string-append %output "/bin/bats")
                      #:guile (search-input-file %build-inputs "bin/guile")
                      (list "PATH" 'prefix (string-split (getenv "PATH")
                                                         #\:))))))
    (build-system trivial-build-system)
    (home-page "https://github.com/bats-core/bats-core/")
    (synopsis "Bash Automated Testing System")
    (description
     "Bats is a @acronym{TAP, Test Anything Protocol}-compliant testing
framework for Bash.  It provides a simple way to verify that the UNIX programs
you write behave as expected.  Bats is most useful when testing software written
in Bash, but you can use it to test any UNIX program.")
    (license license:expat)))

(define-public bash-ctypes
  (package
    (name "bash-ctypes")
    (version "1.2")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://github.com/taviso/ctypes.sh/releases/download/v"
                           version "/ctypes-sh-" version ".tar.gz"))
       (sha256
        (base32 "0s1sifqzqmr0dnciv06yqrpzgj11d7n0gy5zaxh6b3x8bx7k75l8"))))
    (build-system gnu-build-system)
    (inputs
     (list elfutils
           libelf
           libffi
           zlib
           ;; Require a bash with C plugin support to build.
           bash))
    (native-inputs
     (list pkg-config))
    (home-page "https://github.com/taviso/ctypes.sh")
    (synopsis "Foreign function interface for Bash")
    (description "Bash-ctypes is a Bash plugin that provides a foreign
function interface (FFI) directly in your shell.  In other words, it allows
you to call routines in shared libraries from within Bash.")
    (license license:expat)))

(define-public guile-bash-for-bash-coding-utils
  (let ((commit "1eabc563ca5692b3e08d84f1f0e6fd2283284469")
        (revision "0"))
    (package
      (inherit guile2.0-bash)
      (version (string-append "0.1.6-" revision "." (string-take commit 7)))
      (home-page (package-home-page guile2.0-bash))
      (name "guile-bash-for-bash-coding-utils")
      (source (origin
                (method git-fetch)
                (uri (git-reference
                      (commit commit)
                      (url home-page)))
                (sha256
                 (base32
                  "097vny990wp2qpjij6a5a5gwc6fxzg5wk56inhy18iki5v6pif1p"))
                (file-name (string-append name "-" version "-checkout"))
                (patches (search-patches "guile-bash-args-from-stdin.patch"))))
      (inputs
       `(("guile" ,guile-3.0-latest)
         ,@(assoc-remove! (package-inputs guile2.0-bash) "guile")))
      (propagated-inputs (list bash))
      (arguments
       `(#:tests? #f
         #:phases (modify-phases %standard-phases
                    (add-after 'install 'install-guile
                      (lambda* (#:key inputs outputs #:allow-other-keys)
                        (copy-recursively
                         (string-append (assoc-ref outputs "out")
                                        (assoc-ref inputs "guile") "/share")
                         (string-append (assoc-ref outputs "out") "/share"))
                      #t)))
         ,@(package-arguments guile2.0-bash))))))

(define org-html-themes/methuselah-0
  ;; XXX Bundles jquery and several other .js ‘libraries’ — problem?
  ;; XXX A form of https://github.com/fniessen/org-html-themes but not
  ;; drop-in compatible (using that would break the BCU docs).
  ;; ‘Ideally’ we'd re-render them but uugh.
  (let ((commit "8fff1d4c0879537b81f94d157a8c36485c790ee5")
        (revision "0"))
    (package
      (name "org-html-themes")
      (version (git-version "0.0.0" revision commit))
      (source
       (origin
         (method git-fetch)
         (uri (git-reference
               (commit commit)
               (url "https://gitlab.com/methuselah-0/org-html-themes.git")))
         (file-name (git-file-name name version))
         (sha256
          (base32 "1hddgfdry8r65a5zqm1pc0rgicv78ls6giavfr5g0rzx428i1j45"))))
      (build-system copy-build-system)
      (home-page "https://github.com/fniessen/org-html-themes") ; XXX
      (synopsis "Export Org mode files to HTML")
      (description
       "The Org-HMTL framework provides cross-browser themes for exporting Org
documents to cross-browser HTML mark-up.")
      (license license:cc-by-sa3.0))))

(define-public pydaemon
  (let ((commit "dae2798a2c1caa56025c6da69c0d464f70d9c79a")
        (revision "0"))
    (package
      (name "pydaemon")
      (version (git-version "0.0.0" revision commit))
      (source
       (origin
         (method git-fetch)
         (uri (git-reference
               (commit commit)
               (url "https://gitlab.com/methuselah-0/pydaemon.git")))
         (file-name (git-file-name name version))
         (sha256
          (base32 "1cbg48ljyjqw1vxcb0sqhg9cxx0vgs6ggsdg8yvj441s6gakp2sh"))))
      (build-system trivial-build-system)

      (inputs (list coreutils netcat python socat util-linux))
      (arguments
       (list #:modules '((guix build utils))
             #:builder
             #~(begin
                 (use-modules (guix build utils))
                   (with-directory-excursion #$(package-source this-package)
                     (mkdir-p (string-append (assoc-ref %outputs "out") "/bin"))
                     (copy-file "pydaemon.py"
                                (string-append (assoc-ref %outputs "out") "/bin/pydaemon.py"))
                     (copy-file "py-net-daemon.py"
                                (string-append (assoc-ref %outputs "out") "/bin/py-net-daemon.py"))
                     (copy-file "pydaemon.sh"
                                (string-append (assoc-ref %outputs "out") "/bin/pydaemon.sh"))

                     (substitute* (find-files (string-append #$output "/bin") "\\.sh$")
                       (("(flock) " library _)
                        (string-append #$(this-package-input "util-linux") "/bin/" library))
                       (("(socat) " library _)
                        (string-append #$(this-package-input "socat") "/bin/" library))
                       (("(nc) " library _)
                        (string-append #$(this-package-input "netcat") "/bin/" library))
                       (("( )(mkdir|cat|sleep|chown|id|kill|dirname) " all pre command _)
                        (string-append pre #$(this-package-input "coreutils") "/bin/" command " "))
                       (("(\\()(mkdir|cat|sleep|chown|id|kill|dirname) " all pre command _)
                        (string-append pre #$(this-package-input "coreutils") "/bin/" command " "))
                       (("(python3) " library _)
                        (string-append #$(file-append (this-package-input "python")
                                                      "/bin/python"
                                                      (version-major+minor
                                                       (package-version
                                                        (this-package-input
                                                         "python"))))
                                       " ")))))))
      (home-page "https://gitlab.com/methuselah-0/pydaemon")
      (synopsis "Use python from bash")
      (description "With pydaemon you can pipe strings of python code to one
or multiple persistent python processes that keeps state, and get the results
back as strings.  Can be used over either of a unix or tcp socket.")
      (license license:cc-by-sa3.0))))

(define-public bash-coding-utils
  (let ((commit "ce9e7a8910d7debe29a07b48aa0770913b1ecdaf")
        (revision "0"))
    (package
      (name "bash-coding-utils")
      (version (git-version "0.3.0" revision commit))
      (source
       (origin
         (method git-fetch)
         (uri
          (git-reference
           (commit commit)
           (url "https://git.sr.ht/~methuselah-0/bash-coding-utils")
           (recursive? #t))          )
         (sha256
          (base32 "0hgj0fy66bj5kbjs02fvjp5n9a5sz32fk45rc3id2bs0b2k9jrnx"))
         (file-name (git-file-name name version))))
      (build-system trivial-build-system)
      (arguments
       (list #:modules '((guix build utils))
             #:builder
             #~(begin
                 (use-modules (guix build utils)
                              (ice-9 ftw)
                              (ice-9 match)
                              (srfi srfi-26))
                 (let* ((bash #$(this-package-input "bash"))
                        (bin (string-append #$output "/bin"))
                        (bcu.sh (string-append bin "/bcu.sh"))
                        (share (string-append #$output "/share"))
                        (doc (string-append share "/doc/" #$name))
                        ;; Everything but bcu.sh itself is only ever accessed
                        ;; internally by bcu, so put it all in share/.
                        (bcu-root (string-append share "/bcu"))
                        ;; XXX We should honour the without-tests transformation!
                        (tests? (not #$(%current-target-system))))

                   ;; Copy the ‘source’ and submodules directly to the output.
                   (let ((source #$(package-source this-package)))
                     (with-directory-excursion source
                       (mkdir-p bcu-root)
                       (for-each (lambda (file)
                                   (copy-recursively file
                                                     (string-append bcu-root
                                                                    "/" file)))
                                 (list "bcu.sh"
                                       "dependency_paths.sh"
                                       "bcu-test.sh"
                                       "docs"
                                       "src"
                                       "submodules"))
                       ;; Moving docs/ out of bcu-root would break symlinks.
                       (mkdir-p (dirname doc))
                       (symlink (string-append bcu-root "/docs") doc)))

                   ;; Patch absolute file name references.
                   (let* ((original-path (getenv "PATH"))
                          (shebang-inputs '(#$@(map (lambda (name)
                                                      (this-package-input name))
                                                    '("guile"
                                                      "python"))))
                          (shebang-path (string-join
                                         (map (cut string-append <> "/bin")
                                              (cons bash shebang-inputs))
                                         ":")))
                     (setenv "PATH" shebang-path)
                     (for-each patch-shebang
                               (find-files #$output "\\.(sh|scm|py)$"))
                     (setenv "PATH" original-path))

                   ;; Add paths to dependencies - defined in
                   ;; dependency_paths.sh, except the libguile-bash.so
                   ;; file.
                   (substitute* (find-files #$output "\\.sh$")
                     (("[^ ]*(/lib/bash/libguile-bash\\.so)" _ library)
                      (string-append
                       #$(this-package-input "guile-bash-for-bash-coding-utils")
                       library)))

                   ;; TODO: use a PCRE regex to substitute invocations of coreutils
                   ;; commands
                   ;; TODO: condense below substitutions?
                   (substitute* (find-files #$output "dependency_paths\\.sh$")
                     (("export BCUCTYPES=(ctypes.sh)" _ library)
                      (string-append "export BCUCTYPES="
                                     #$(this-package-input "bash-ctypes")
                                     "/bin/" library))
                     (("export BCUDIFF=(diff)" _ library)
                      (string-append "export BCUDIFF="
                                     #$(this-package-input "diffutils")
                                     "/bin/" library))
                     (("export BCUPING=(ping)" _ library)
                      (string-append "export BCUPING=/run/setuid-programs/ping"))
                     (("export BCUPS=(ps)" _ library)
                      (string-append "export BCUPS="
                                     #$(this-package-input "procps")
                                     "/bin/" library))
                     (("export BCUFILE=(file)" _ library)
                      (string-append "export BCUFILE="
                                     #$(this-package-input "findutils")
                                     "/bin/" library))
                     (("export BCUFIND=(find)" _ library)
                      (string-append "export BCUFIND="
                                     #$(this-package-input "findutils")
                                     "/bin/" library))
                     (("export BCUFLOCK=(flock)" _ library)
                      (string-append "export BCUFLOCK="
                                     #$(this-package-input "util-linux")
                                     "/bin/" library))
                     (("export BCUGAWK=(gawk)" _ library)
                      (string-append "export BCUGAWK="
                                     #$(this-package-input "gawk")
                                     "/bin/" library))
                     (("export BCUGREP=(grep)" _ library)
                      (string-append "export BCUGREP="
                                     #$(this-package-input "grep")
                                     "/bin/" library))
                     (("export GUILE_LOAD_PATH=(.*)$")
                      (string-append "export GUILE_LOAD_PATH=\""
                                     (string-join
                                      '(#$@(map (lambda (name)
                                                  (file-append (this-package-input name)
                                                               "/share/guile/site/"
                                                               (version-major+minor
                                                                (package-version
                                                                 (this-package-input
                                                                  "guile")))))
                                                '("guile-bash-for-bash-coding-utils")))
                                      ":")
                                     "${GUILE_LOAD_PATH:+:}${GUILE_LOAD_PATH}\"\n"))
                     (("export BCUJQ=(jq)" _ library)
                      (string-append "export BCUJQ="
                                     #$(this-package-input "jq")
                                     "/bin/" library))
                     (("export BCULSOF=(lsof)" _ library)
                      (string-append "export BCULSOF="
                                     #$(this-package-input "lsof")
                                     "/bin/" library))
                     (("export BCUNMAP=(nmap)" _ library)
                      (string-append "export BCUNMAP="
                                     #$(this-package-input "nmap")
                                     "/bin/" library))
                     (("export BCUPCREGREP=(pcregrep)" _ library)
                      (string-append "export BCUPCREGREP="
                                     (assoc-ref %build-inputs "pcre:bin")
                                     "/bin/" library))
                     (("export BCUPERL=(perl)" _ library)
                      (string-append "export BCUPERL="
                                     #$(this-package-input "perl")
                                     "/bin/" library))
                     (("export BCUPHP=(php)" _ library)
                      (string-append "export BCUPHP="
                                     #$(this-package-input "php")
                                     "/bin/" library))
                     (("export BCUPS=(ps)" _ library)
                      (string-append "export BCUPS="
                                     #$(this-package-input "procps")
                                     "/bin/" library))
                     (("export BCUPYDAEMON=(pydaemon.sh)" _ library)
                      (string-append "export BCUPYDAEMON="
                                     #$(this-package-input "pydaemon")
                                     "/bin/" library))
                     (("export BCUPYTHONVERSION=(.*)$" _)
                      (string-append "export BCUPYTHONVERSION="
                                     #$(version-major+minor
                                        (package-version
                                         (this-package-input
                                          "python")))))
                     (("export BCUPYTHON=python(.*)$" _)
                      (string-append "export BCUPYTHON="
                                     #$(file-append (this-package-input "python")
                                                    "/bin/python"
                                                    (version-major+minor
                                                     (package-version
                                                      (this-package-input
                                                       "python"))))
                                     "\n"))
                     (("export PYTHONPATH=.*" all)
                      (string-append "export PYTHONPATH=\""
                                     (string-join
                                      '(#$@(map (lambda (name)
                                                  (file-append (this-package-input name)
                                                               "/lib/python"
                                                               (version-major+minor
                                                                (package-version
                                                                 (this-package-input
                                                                  "python")))
                                                               "/site-packages"))
                                                '("python"
                                                  "python-elementpath"
                                                  "python-lxml"
                                                  "python-netaddr")))
                                      ":")
                                     "${PYTHONPATH:+:}${PYTHONPATH}\"\n"))
                     (("export BCUSED=(sed)" _ library)
                      (string-append "export BCUSED="
                                     #$(this-package-input "sed")
                                     "/bin/" library))
                     (("export BCUSOCAT=(socat)" _ library)
                      (string-append "export BCUSOCAT="
                                     #$(this-package-input "socat")
                                     "/bin/" library))
                     (("export BCUTREE=(tree)" _ library)
                      (string-append "export BCUTREE="
                                     #$(this-package-input "tree")
                                     "/bin/" library))
                     (("export BCUWHICH=(which)" _ library)
                      (string-append "export BCUWHICH="
                                     #$(this-package-input "which")
                                     "/bin/" library))
                     (("export XDG_DATA_DIRS=(.*)$")
                      (string-append
                       "[[ -e /run/current-system/profile/share ]] && "
                       "export XDG_DATA_DIRS="
                       "/run/current-system/profile/share"
                       "${XDG_DATA_DIRS:+:}${XDG_DATA_DIRS}\n"))
                     (("export BCUXARGS=(xargs)" _ library)
                      (string-append "export BCUXARGS="
                                     #$(this-package-input "findutils")
                                     "/bin/" library))
                     (("export BCUXDGOPEN=(xdg-open)" _ library)
                      (string-append "export BCUXDGOPEN="
                                     #$(this-package-input "xdg-utils")
                                     "/bin/" library))
                     (("export BCUXMLLINT=(xmllint)" _ library)
                      (string-append "export BCUXMLLINT="
                                     #$(this-package-input "libxml2-xpath0")
                                     "/bin/" library)))

                   ;; Symlink to bcu.sh from the output bin directory.
                   (mkdir-p bin)
                   (symlink (string-append bcu-root "/bcu.sh") bcu.sh)
                   (chmod bcu.sh #o555)

                   ;; Disable network and gui tests, and one test for setopts which
                   ;; doesn't work inside the Guix build environment.
                   (with-output-to-file (string-append bcu-root "/disabled_tests.txt")
                     (lambda _
                       (format #t "~{~a~%~}"
                               (list "ip_of_test_1"
                                     "setopts_test_4"
                                     "web_media_server_test_1"
                                     "web_api_server_test_1"
                                     "find_gui_test_1"))))

                   ;; Set up a minimal test environment & run the tests.
                   (when tests?
                     (setenv "PATH" (string-append bin ":"
                                                   bash "/bin:"
                                                   (getenv "PATH")))
                     (setenv "SHELL"
                             (string-append bash "/bin/bash"))
                     (for-each (lambda (test-input)
                                 (setenv "PATH"
                                         (string-append
                                          (assoc-ref %build-inputs test-input)
                                          "/bin:" (getenv "PATH"))))
                               (list "coreutils"))
                     (setenv "HOME" "/tmp")
                     (with-directory-excursion bcu-root
                       (invoke "./bcu-test.sh")
                       ;; No need to keep passed tests in the final output
                       (for-each delete-file
                                 (list "bcu-test.sh"
                                       "disabled_tests.txt"))))))))
      (native-inputs
       `( ;; org-html-themes is bundled upstream as a git submodule,
         ;; but we package it separately and copy it manually above.
         ("org-html-themes" ,(package-source org-html-themes/methuselah-0))
         ("coreutils" ,coreutils) ;; Needed for tests.
         ;; TODO: unable to get the correct hash for pcre:bin output using
         ;; the new notation (see inputs list below)
         ("pcre:bin" ,pcre "bin")))
      (inputs (list bash
                    bash-ctypes
                    coreutils
                    diffutils
                    file
                    findutils
                    gawk
                    grep
                    guile-3.0
                    guile-bash-for-bash-coding-utils
                    jq
                    libxml2-xpath0
                    lsof
                    nmap
                    ;;`(,pcre "bin") ;; TODO doesn't work when calling
                    ;; #$(this-package-input pcre)!
                    perl
                    php
                    procps
                    pydaemon
                    python
                    python-elementpath
                    python-lxml
                    python-netaddr
                    python-yq
                    sed
                    socat
                    tree
                    which
                    xdg-utils
                    util-linux))
      (propagated-inputs
       `(("bash" ,bash))) ;; the bash shell needs to be the same version
      ;;as guile-bash is compiled against
      (home-page "https://git.sr.ht/~methuselah-0/bash-coding-utils")
      (synopsis "Functions and tools for software prototyping in Bash")
      (description
       "Bash-Coding-Utils is a library of Bash functions and wrappers that can
be useful when writing quick implementations of new programs.  It helps you
work with JSON, XML, API's and parallelization, and installs some helper
programs commonly used in Bash scripting.  Just run @command{. bcu.sh}, type
@command{bcu__}, hit @key{TAB} to see available functions and give any of them
the @code{--help} flag to see how to use it, or run @command{bcu__docs} for
the full HTML documentation.")
      (license license:gpl3))))

debug log:

solving f058793160 ...
found f058793160 in https://yhetil.org/guix/482320c017a2ab923b040cb83746e563@selfhosted.xyz/
found 72758560cd in https://git.savannah.gnu.org/cgit/guix.git
preparing index
index prepared:
100644 72758560cdee595b4e0ff078c52391abd863e44e	gnu/packages/bash.scm

applying [1/1] https://yhetil.org/guix/482320c017a2ab923b040cb83746e563@selfhosted.xyz/
diff --git a/gnu/packages/bash.scm b/gnu/packages/bash.scm
index 72758560cd..f058793160 100644

1:50: trailing whitespace.
  #:use-module (guix build-system trivial)  
Checking patch gnu/packages/bash.scm...
Applied patch gnu/packages/bash.scm cleanly.
warning: 1 line adds whitespace errors.

index at:
100644 f058793160c4b77b0d01109498564f2b269f7e63	gnu/packages/bash.scm

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.