| 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 | (define-module (gnu packages bash)
|
| 26 | #:use-module ((guix licenses) #:prefix license:)
|
| 27 | #:use-module (gnu packages)
|
| 28 | #:use-module (gnu packages base)
|
| 29 | #:use-module (gnu packages bootstrap)
|
| 30 | #:use-module (gnu packages compression)
|
| 31 | #:use-module (gnu packages elf)
|
| 32 | #:use-module (gnu packages ncurses)
|
| 33 | #:use-module (gnu packages readline)
|
| 34 | #:use-module (gnu packages bison)
|
| 35 | #:use-module (gnu packages linux)
|
| 36 | #:use-module (gnu packages libffi)
|
| 37 | #:use-module (gnu packages pkg-config)
|
| 38 | #:use-module (gnu packages guile)
|
| 39 | #:use-module (guix packages)
|
| 40 | #:use-module (guix download)
|
| 41 | #:use-module (guix git-download)
|
| 42 | #:use-module (guix utils)
|
| 43 | #:use-module (guix gexp)
|
| 44 | #:use-module (guix monads)
|
| 45 | #:use-module (guix store)
|
| 46 | #:use-module (guix build-system gnu)
|
| 47 | #:use-module (guix build-system trivial)
|
| 48 | #:autoload (guix gnupg) (gnupg-verify*)
|
| 49 | #:autoload (guix base32) (bytevector->nix-base32-string)
|
| 50 |
|
| 51 | |
| 52 | #:use-module ((gcrypt hash) #:select (port-sha256))
|
| 53 |
|
| 54 | #:use-module (srfi srfi-1)
|
| 55 | #:use-module (srfi srfi-26)
|
| 56 | #:use-module (ice-9 format))
|
| 57 |
|
| 58 | (define (patch-url seqno)
|
| 59 | "Return the URL of Bash patch number SEQNO."
|
| 60 | (format #f "mirror://gnu/bash/bash-5.0-patches/bash50-~3,'0d" seqno))
|
| 61 |
|
| 62 | (define (bash-patch seqno sha256-bv)
|
| 63 | "Return the origin of Bash patch SEQNO, with expected hash SHA256-BV."
|
| 64 | (origin
|
| 65 | (method url-fetch)
|
| 66 | (uri (patch-url seqno))
|
| 67 | (sha256 sha256-bv)))
|
| 68 |
|
| 69 | (define-syntax-rule (patch-series (seqno hash) ...)
|
| 70 | (list (bash-patch seqno (base32 hash))
|
| 71 | ...))
|
| 72 |
|
| 73 | (define %patch-series-5.0
|
| 74 | |
| 75 | |
| 76 | (patch-series
|
| 77 | (1 "12bjfdy6bg8nhyw27bdgxn7h4paylx8d927skfmi9pxd1wgrxzpj")
|
| 78 | (2 "01w7yrzmz10mw06ys0546vhl7isv2v402ziyvfd7k67588spvs47")
|
| 79 | (3 "0ny81ridp5n0j69hb8ixrc7dmxybby54jbsz5hikly8kgg1wvssf")
|
| 80 | (4 "021gqqvgydixkrmqss64b6srfdlkvnx88lyfzpxfrn5d6bc7li0l")
|
| 81 | (5 "0xl2kyzm84nlyklrqzkn73ixabhzfhn9x91lzcmis89cppclvxav")
|
| 82 | (6 "0844749ixk1z60437nkznzms1f0nzh9an62kj7sny6r0zyk2k1fn")
|
| 83 | (7 "16xg37gp1b8zlj5969w8mcrparwqlcbj9695vn3qhgb7wdz1xd0p")
|
| 84 | (8 "1qyp19krjh8zxvb0jgwmyjz40djslwcf4xi7kc1ab0iaca44bipf")
|
| 85 | (9 "00yrjjqd95s81b21qq3ba1y7h879q8jaajlkjggc6grhcwbs4g7d")
|
| 86 | (10 "04ca5bjv456v538mkspzvn4xb2zdphh31r4fpvfm9p5my0jw7yyn")
|
| 87 | (11 "1sklyixvsv8993kxzs0jigacpdchjrq7jv5xpdx7kbqyp4rf6k9c")
|
| 88 | (12 "0cz21qg2gbr40lfgza7g02bqi2qknwqgxnq459pjj640d0cywhr9")
|
| 89 | (13 "16h9nwz3yzwj7fnxvlidjymdc4yr30h818433gh9j1x3in6igmzm")
|
| 90 | (14 "12gm5bvv2pd3m72z2ilj26pa08c61az253dsgfl24vpf2ijywvjx")
|
| 91 | (15 "0pm0px758w4i23s55wajcv6lqfiym7zgxvq0pxf6vclkv8nxy5x5")
|
| 92 | (16 "0vdha332km2iwx8g2ld15jy7d24cbplzgr1531dpzylr9ajxglgz")))
|
| 93 |
|
| 94 | (define (download-patches store count)
|
| 95 | "Download COUNT Bash patches into store. Return a list of
|
| 96 | number/base32-hash tuples, directly usable in the 'patch-series' form."
|
| 97 | (unfold (cut > <> count)
|
| 98 | (lambda (number)
|
| 99 | (let* ((patch (download-to-store store (patch-url number)))
|
| 100 | (sig (download-to-store store
|
| 101 | (string-append (patch-url number)
|
| 102 | ".sig"))))
|
| 103 | (unless (eq? 'valid-signature (gnupg-verify* sig patch))
|
| 104 | (error "failed to verify signature" patch))
|
| 105 |
|
| 106 | (list number
|
| 107 | (bytevector->nix-base32-string
|
| 108 | (call-with-input-file patch port-sha256)))))
|
| 109 | 1+
|
| 110 | 1))
|
| 111 |
|
| 112 | (define-public bash
|
| 113 | (let* ((cppflags (string-join '("-DDEFAULT_PATH_VALUE='\"/no-such-path\"'"
|
| 114 | "-DSTANDARD_UTILS_PATH='\"/no-such-path\"'"
|
| 115 | "-DNON_INTERACTIVE_LOGIN_SHELLS"
|
| 116 | "-DSSH_SOURCE_BASHRC")
|
| 117 | " "))
|
| 118 | (configure-flags
|
| 119 | ``("--with-installed-readline"
|
| 120 | ,,(string-append "CPPFLAGS=" cppflags)
|
| 121 | ,(string-append
|
| 122 | "LDFLAGS=-Wl,-rpath -Wl,"
|
| 123 | (assoc-ref %build-inputs "readline")
|
| 124 | "/lib"
|
| 125 | " -Wl,-rpath -Wl,"
|
| 126 | (assoc-ref %build-inputs "ncurses")
|
| 127 | "/lib")))
|
| 128 | (version "5.0"))
|
| 129 | (package
|
| 130 | (name "bash")
|
| 131 | (source (origin
|
| 132 | (method url-fetch)
|
| 133 | (uri (string-append
|
| 134 | "mirror://gnu/bash/bash-" version ".tar.gz"))
|
| 135 | (sha256
|
| 136 | (base32
|
| 137 | "0kgvfwqdcd90waczf4gx39xnrxzijhjrzyzv7s8v4w31qqm0za5l"))
|
| 138 | (patch-flags '("-p0"))
|
| 139 | (patches (cons (search-patch "bash-linux-pgrp-pipe.patch")
|
| 140 | %patch-series-5.0))))
|
| 141 | (version (string-append version "." (number->string (length %patch-series-5.0))))
|
| 142 | (build-system gnu-build-system)
|
| 143 |
|
| 144 | (outputs '("out"
|
| 145 | "doc" |
| 146 | "include")) |
| 147 | (inputs `(("readline" ,readline)
|
| 148 | ("ncurses" ,ncurses))) |
| 149 | (arguments
|
| 150 | `( |
| 151 | |
| 152 | #:configure-flags ,(if (%current-target-system)
|
| 153 | `(cons* "bash_cv_job_control_missing=no"
|
| 154 | ,configure-flags)
|
| 155 | configure-flags)
|
| 156 |
|
| 157 | |
| 158 | |
| 159 | |
| 160 | #:parallel-build? #f
|
| 161 | #:parallel-tests? #f
|
| 162 |
|
| 163 | |
| 164 | |
| 165 | #:tests? #f
|
| 166 |
|
| 167 | #:modules ((srfi srfi-26)
|
| 168 | (guix build utils)
|
| 169 | (guix build gnu-build-system))
|
| 170 |
|
| 171 | #:phases
|
| 172 | (modify-phases %standard-phases
|
| 173 | (add-after 'install 'install-sh-symlink
|
| 174 | (lambda* (#:key outputs #:allow-other-keys)
|
| 175 | |
| 176 | (let ((out (assoc-ref outputs "out")))
|
| 177 | (with-directory-excursion (string-append out "/bin")
|
| 178 | (symlink "bash" "sh")
|
| 179 | #t))))
|
| 180 |
|
| 181 | (add-after 'install 'move-development-files
|
| 182 | (lambda* (#:key outputs #:allow-other-keys)
|
| 183 | |
| 184 | |
| 185 | (let ((out (assoc-ref outputs "out"))
|
| 186 | (include (assoc-ref outputs "include"))
|
| 187 | (lib (cut string-append <> "/lib/bash")))
|
| 188 | (mkdir-p (lib include))
|
| 189 | (rename-file (string-append (lib out)
|
| 190 | "/Makefile.inc")
|
| 191 | (string-append (lib include)
|
| 192 | "/Makefile.inc"))
|
| 193 | (rename-file (string-append out "/lib/pkgconfig")
|
| 194 | (string-append include
|
| 195 | "/lib/pkgconfig"))
|
| 196 |
|
| 197 | |
| 198 | |
| 199 | (substitute* (string-append (lib include)
|
| 200 | "/Makefile.inc")
|
| 201 | (("^INSTALL =.*")
|
| 202 | "INSTALL = install -c\n"))
|
| 203 | #t))))))
|
| 204 |
|
| 205 | (native-search-paths
|
| 206 | (list (search-path-specification |
| 207 | (variable "BASH_LOADABLES_PATH")
|
| 208 | (files '("lib/bash")))))
|
| 209 |
|
| 210 | (synopsis "The GNU Bourne-Again SHell")
|
| 211 | (description
|
| 212 | "Bash is the shell, or command-line interpreter, of the GNU system. It
|
| 213 | is compatible with the Bourne Shell, but it also integrates useful features
|
| 214 | from the Korn Shell and the C Shell and new improvements of its own. It
|
| 215 | allows command-line editing, unlimited command history, shell functions and
|
| 216 | aliases, and job control while still allowing most sh scripts to be run
|
| 217 | without modification.")
|
| 218 | (license license:gpl3+)
|
| 219 | (home-page "https://www.gnu.org/software/bash/"))))
|
| 220 |
|
| 221 | (define-public bash-minimal
|
| 222 | |
| 223 | (package (inherit bash)
|
| 224 | (name "bash-minimal")
|
| 225 | (inputs '()) |
| 226 |
|
| 227 | |
| 228 | (outputs (delete "include" (package-outputs bash)))
|
| 229 |
|
| 230 | (arguments
|
| 231 | (substitute-keyword-arguments (package-arguments bash)
|
| 232 | ((#:modules _ '())
|
| 233 | '((guix build gnu-build-system)
|
| 234 | (guix build utils)
|
| 235 | (srfi srfi-1)
|
| 236 | (srfi srfi-26)))
|
| 237 | ((#:configure-flags flags '())
|
| 238 | `(list "--without-bash-malloc"
|
| 239 | "--disable-readline"
|
| 240 | "--disable-history"
|
| 241 | "--disable-help-builtin"
|
| 242 | "--disable-progcomp"
|
| 243 | "--disable-net-redirections"
|
| 244 | "--disable-nls"
|
| 245 |
|
| 246 | |
| 247 | |
| 248 | "ac_cv_func_dlopen=no"
|
| 249 |
|
| 250 | ,@(if (%current-target-system)
|
| 251 | '("bash_cv_job_control_missing=no"
|
| 252 | "bash_cv_getcwd_malloc=yes")
|
| 253 | '())))
|
| 254 | ((#:phases phases)
|
| 255 | `(modify-phases ,phases
|
| 256 | |
| 257 | (delete 'move-development-files)))))))
|
| 258 |
|
| 259 | (define-public static-bash
|
| 260 | |
| 261 | |
| 262 | (let ((bash (static-package bash-minimal)))
|
| 263 | (package
|
| 264 | (inherit bash)
|
| 265 | (name "bash-static")
|
| 266 | (arguments
|
| 267 | (substitute-keyword-arguments
|
| 268 | `(#:allowed-references ("out") ,@(package-arguments bash))
|
| 269 | ((#:phases phases)
|
| 270 | `(modify-phases ,phases
|
| 271 | (add-after 'strip 'remove-everything-but-the-binary
|
| 272 | (lambda* (#:key outputs #:allow-other-keys)
|
| 273 | (let* ((out (assoc-ref outputs "out"))
|
| 274 | (bin (string-append out "/bin")))
|
| 275 | (remove-store-references (string-append bin "/bash"))
|
| 276 | (delete-file (string-append bin "/bashbug"))
|
| 277 | (delete-file-recursively (string-append out "/share"))
|
| 278 | #t))))))))))
|
| 279 |
|
| 280 | (define-public bash-completion
|
| 281 | (package
|
| 282 | (name "bash-completion")
|
| 283 | (version "2.8")
|
| 284 | (source (origin
|
| 285 | (method url-fetch)
|
| 286 | (uri (string-append
|
| 287 | "https://github.com/scop/" name "/releases/download/"
|
| 288 | version "/" name "-" version ".tar.xz"))
|
| 289 | (sha256
|
| 290 | (base32
|
| 291 | "0kgmflrr1ga9wfk770vmakna3nj46ylb5ky9ipd0v2k9ymq5a7y0"))
|
| 292 | (patches
|
| 293 | (search-patches "bash-completion-directories.patch"))))
|
| 294 | (build-system gnu-build-system)
|
| 295 | (native-inputs `(("util-linux" ,util-linux)))
|
| 296 | (arguments
|
| 297 | `(#:phases (modify-phases %standard-phases
|
| 298 | (add-after
|
| 299 | 'install 'remove-redundant-completions
|
| 300 | (lambda* (#:key
|
| 301 | inputs native-inputs
|
| 302 | outputs #:allow-other-keys)
|
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 | (let* ((out (assoc-ref outputs "out"))
|
| 308 | (util-linux (assoc-ref (or native-inputs inputs)
|
| 309 | "util-linux"))
|
| 310 | (completions (string-append out
|
| 311 | "/share/bash-completion"
|
| 312 | "/completions"))
|
| 313 | (already (find-files
|
| 314 | (string-append
|
| 315 | util-linux
|
| 316 | "/etc/bash_completion.d"))))
|
| 317 | (with-directory-excursion completions
|
| 318 | (for-each (lambda (file)
|
| 319 | (when (file-exists? file)
|
| 320 | (delete-file file)))
|
| 321 | (map basename already)))
|
| 322 | #t))))))
|
| 323 | (synopsis "Bash completions for common commands")
|
| 324 | (description
|
| 325 | "This package provides extensions that allow Bash to provide adapted
|
| 326 | completion for many common commands.")
|
| 327 | (home-page "https://github.com/scop/bash-completion")
|
| 328 | (license license:gpl2+)))
|
| 329 |
|
| 330 | (define-public bash-tap
|
| 331 | (package
|
| 332 | (name "bash-tap")
|
| 333 | (version "1.0.2")
|
| 334 | (source
|
| 335 | (origin
|
| 336 | (method git-fetch)
|
| 337 | (uri (git-reference
|
| 338 | (url "https://github.com/illusori/bash-tap")
|
| 339 | (commit version)))
|
| 340 | (file-name (git-file-name name version))
|
| 341 | (sha256
|
| 342 | (base32 "13zz9h6bhhnk3hiwhlpafrnf2isws249h3fz785dcgymk02arz9c"))))
|
| 343 | |
| 344 | |
| 345 | |
| 346 | |
| 347 | (build-system gnu-build-system)
|
| 348 | (arguments
|
| 349 | `(#:tests? #f |
| 350 | #:phases
|
| 351 | (modify-phases %standard-phases
|
| 352 | |
| 353 | |
| 354 | (delete 'configure)
|
| 355 | (delete 'build)
|
| 356 | |
| 357 | |
| 358 | |
| 359 | (replace 'install
|
| 360 | (lambda* (#:key outputs #:allow-other-keys)
|
| 361 | (let ((bin (string-append (assoc-ref outputs "out") "/bin")))
|
| 362 | (install-file "bash-tap" bin)
|
| 363 | (install-file "bash-tap-bootstrap" bin)
|
| 364 | (install-file "bash-tap-mock" bin)))))))
|
| 365 | (home-page "https://www.illusori.co.uk/projects/bash-tap/")
|
| 366 | (synopsis "Bash port of a Test::More/Test::Builder-style TAP-compliant
|
| 367 | test library")
|
| 368 | (description "Bash TAP is a TAP-compliant Test::More-style testing library
|
| 369 | for Bash shell scripts and functions. Along with the Test::More-style testing
|
| 370 | helpers it provides helper functions for mocking commands and in-process output
|
| 371 | capturing.")
|
| 372 | (license license:expat)))
|
| 373 |
|
| 374 | (define-public bats
|
| 375 | (package
|
| 376 | (name "bats")
|
| 377 | (version "1.2.0")
|
| 378 | (source (origin
|
| 379 | (method git-fetch)
|
| 380 | (uri (git-reference
|
| 381 | (url "https://github.com/bats-core/bats-core")
|
| 382 | (commit (string-append "v" version))))
|
| 383 | (file-name (git-file-name name version))
|
| 384 | (sha256
|
| 385 | (base32
|
| 386 | "0f59zh4d4pa1a7ybs5zl6h0csbqqv11lbnq0jl1dgwm1s6p49bsq"))))
|
| 387 | (inputs
|
| 388 | `(("bash" ,bash)
|
| 389 | ("coreutils" ,coreutils)
|
| 390 | ("guile" ,guile-3.0) |
| 391 | ("grep" ,grep)))
|
| 392 | (arguments
|
| 393 | `(#:modules ((guix build utils))
|
| 394 | #:builder
|
| 395 | (begin
|
| 396 | (use-modules (guix build utils))
|
| 397 | (copy-recursively (assoc-ref %build-inputs "source") ".")
|
| 398 | (setenv "PATH"
|
| 399 | (string-append (assoc-ref %build-inputs "bash") "/bin"
|
| 400 | ":" (assoc-ref %build-inputs "coreutils") "/bin"
|
| 401 | ":" (assoc-ref %build-inputs "grep") "/bin"
|
| 402 | ":" (assoc-ref %build-inputs "guile") "/bin"
|
| 403 | ":" (getenv "PATH")))
|
| 404 | (for-each (lambda (file) (patch-shebang file)) (find-files "."))
|
| 405 | (substitute* "bin/bats"
|
| 406 | (("export BATS_ROOT" line)
|
| 407 | (string-append "BATS_ROOT=\"${BATS_ROOT:-" %output "/libexec/bats-core}\"\n"
|
| 408 | line)))
|
| 409 | |
| 410 | (invoke "./install.sh" %output)
|
| 411 | (wrap-script (string-append %output "/bin/bats")
|
| 412 | (list "PATH" 'prefix (string-split (getenv "PATH")
|
| 413 | #\:))))))
|
| 414 | (build-system trivial-build-system)
|
| 415 | (home-page "https://github.com/bats-core/bats-core/")
|
| 416 | (synopsis "Bash Automated Testing System")
|
| 417 | (description
|
| 418 | "Bats is a @acronym{TAP, Test Anything Protocol}-compliant testing
|
| 419 | framework for Bash. It provides a simple way to verify that the UNIX programs
|
| 420 | you write behave as expected. Bats is most useful when testing software written
|
| 421 | in Bash, but you can use it to test any UNIX program.")
|
| 422 | (license license:expat)))
|
| 423 |
|
| 424 | (define-public bash-ctypes
|
| 425 | (package
|
| 426 | (name "bash-ctypes")
|
| 427 | (version "1.2")
|
| 428 | (source
|
| 429 | (origin
|
| 430 | (method url-fetch)
|
| 431 | (uri (string-append "https://github.com/taviso/ctypes.sh/releases/download/v"
|
| 432 | version "/ctypes-sh-" version ".tar.gz"))
|
| 433 | (sha256
|
| 434 | (base32 "0s1sifqzqmr0dnciv06yqrpzgj11d7n0gy5zaxh6b3x8bx7k75l8"))))
|
| 435 | (build-system gnu-build-system)
|
| 436 | (inputs
|
| 437 | `(("elfutils" ,elfutils)
|
| 438 | ("libelf" ,libelf)
|
| 439 | ("libffi" ,libffi)
|
| 440 | ("zlib" ,zlib)
|
| 441 | |
| 442 | ("bash" ,bash)))
|
| 443 | (native-inputs
|
| 444 | `(("pkg-config" ,pkg-config)))
|
| 445 | (home-page "https://github.com/taviso/ctypes.sh")
|
| 446 | (synopsis "Foreign function interface for Bash")
|
| 447 | (description "Bash-ctypes is a Bash plugin that provides a foreign
|
| 448 | function interface (FFI) directly in your shell. In other words, it allows
|
| 449 | you to call routines in shared libraries from within Bash.")
|
| 450 | (license license:expat)))
|