bash: simplify expression, add withDocs option

This commit is contained in:
Jan Malakhovski 2018-04-01 00:00:01 +00:00
parent a809fdc8e1
commit 3c7f6572ce
3 changed files with 67 additions and 72 deletions

View file

@ -1,37 +1,33 @@
{ stdenv, buildPackages { stdenv, buildPackages
, fetchurl, readline70 ? null, texinfo ? null, binutils ? null, bison, autoconf , fetchurl, binutils ? null, bison, autoconf
, buildPlatform, hostPlatform , buildPlatform, hostPlatform
, interactive ? false
# patch for cygwin requires readline support
, interactive ? stdenv.isCygwin, readline70 ? null
, withDocs ? false, texinfo ? null
, self
}: }:
with stdenv.lib;
assert interactive -> readline70 != null; assert interactive -> readline70 != null;
assert withDocs -> texinfo != null;
assert hostPlatform.isDarwin -> binutils != null; assert hostPlatform.isDarwin -> binutils != null;
let let
version = "4.4"; upstreamPatches = import ./bash-4.4-patches.nix (nr: sha256: fetchurl {
realName = "bash-${version}"; url = "mirror://gnu/bash/bash-4.4-patches/bash44-${nr}";
shortName = "bash44"; inherit sha256;
sha256 = "1jyz6snd63xjn6skk7za6psgidsd53k05cr3lksqybi0q6936syq"; });
upstreamPatches =
let
patch = nr: sha256:
fetchurl {
url = "mirror://gnu/bash/${realName}-patches/${shortName}-${nr}";
inherit sha256;
};
in
import ./bash-4.4-patches.nix patch;
inherit (stdenv.lib) optional optionals optionalString;
in in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "${realName}-p${toString (builtins.length upstreamPatches)}"; name = "bash-${optionalString interactive "interactive-"}${version}-p${toString (builtins.length upstreamPatches)}";
version = "4.4";
src = fetchurl { src = fetchurl {
url = "mirror://gnu/bash/${realName}.tar.gz"; url = "mirror://gnu/bash/bash-${version}.tar.gz";
inherit sha256; sha256 = "1jyz6snd63xjn6skk7za6psgidsd53k05cr3lksqybi0q6936syq";
}; };
hardeningDisable = [ "format" ]; hardeningDisable = [ "format" ];
@ -50,18 +46,19 @@ stdenv.mkDerivation rec {
patchFlags = "-p0"; patchFlags = "-p0";
patches = upstreamPatches patches = upstreamPatches
++ optional hostPlatform.isCygwin ./cygwin-bash-4.4.11-2.src.patch
# https://lists.gnu.org/archive/html/bug-bash/2016-10/msg00006.html # https://lists.gnu.org/archive/html/bug-bash/2016-10/msg00006.html
++ optional (hostPlatform.libc == "musl") (fetchurl { ++ optional hostPlatform.isMusl (fetchurl {
url = "https://lists.gnu.org/archive/html/bug-bash/2016-10/patchJxugOXrY2y.patch"; url = "https://lists.gnu.org/archive/html/bug-bash/2016-10/patchJxugOXrY2y.patch";
sha256 = "1m4v9imidb1cc1h91f2na0b8y9kc5c5fgmpvy9apcyv2kbdcghg1"; sha256 = "1m4v9imidb1cc1h91f2na0b8y9kc5c5fgmpvy9apcyv2kbdcghg1";
}); });
postPatch = optionalString hostPlatform.isCygwin "patch -p2 < ${./cygwin-bash-4.4.11-2.src.patch}";
configureFlags = [ configureFlags = [
(if interactive then "--with-installed-readline" else "--disable-readline") (if interactive then "--with-installed-readline" else "--disable-readline")
] ++ optionals (hostPlatform != buildPlatform) [ ] ++ optionals (hostPlatform != buildPlatform) [
"bash_cv_job_control_missing=nomissing bash_cv_sys_named_pipes=nomissing bash_cv_getcwd_malloc=yes" "bash_cv_job_control_missing=nomissing"
"bash_cv_sys_named_pipes=nomissing"
"bash_cv_getcwd_malloc=yes"
] ++ optionals hostPlatform.isCygwin [ ] ++ optionals hostPlatform.isCygwin [
"--without-libintl-prefix --without-libiconv-prefix" "--without-libintl-prefix --without-libiconv-prefix"
"--with-installed-readline" "--with-installed-readline"
@ -75,8 +72,8 @@ stdenv.mkDerivation rec {
# Note: Bison is needed because the patches above modify parse.y. # Note: Bison is needed because the patches above modify parse.y.
depsBuildBuild = [ buildPackages.stdenv.cc ]; depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [bison] nativeBuildInputs = [ bison ]
++ optional (texinfo != null) texinfo ++ optional withDocs texinfo
++ optional hostPlatform.isDarwin binutils ++ optional hostPlatform.isDarwin binutils
++ optional (hostPlatform.libc == "musl") autoconf; ++ optional (hostPlatform.libc == "musl") autoconf;

View file

@ -1,5 +1,5 @@
--- origsrc/bash-4.4/bashline.c 2017-01-23 13:28:06.955247200 -0600 --- bashline.c 2017-01-23 13:28:06.955247200 -0600
+++ src/bash-4.4/bashline.c 2017-01-23 13:55:07.992877600 -0600 +++ bashline.c 2017-01-23 13:55:07.992877600 -0600
@@ -76,6 +76,16 @@ @@ -76,6 +76,16 @@
# include "pcomplete.h" # include "pcomplete.h"
#endif #endif
@ -104,8 +104,8 @@
r = file_isdir (fn); r = file_isdir (fn);
free (fn); free (fn);
--- origsrc/bash-4.4/builtins/read.def 2017-01-23 13:28:07.017686500 -0600 --- builtins/read.def 2017-01-23 13:28:07.017686500 -0600
+++ src/bash-4.4/builtins/read.def 2017-01-23 13:55:07.992877600 -0600 +++ builtins/read.def 2017-01-23 13:55:07.992877600 -0600
@@ -85,7 +85,6 @@ $END @@ -85,7 +85,6 @@ $END
#ifdef __CYGWIN__ #ifdef __CYGWIN__
@ -140,8 +140,8 @@
if ((skip_ctlesc == 0 && c == CTLESC) || (skip_ctlnul == 0 && c == CTLNUL)) if ((skip_ctlesc == 0 && c == CTLESC) || (skip_ctlnul == 0 && c == CTLNUL))
{ {
saw_escape++; saw_escape++;
--- origsrc/bash-4.4/builtins/set.def 2016-06-02 19:10:10.000000000 -0500 --- builtins/set.def 2016-06-02 19:10:10.000000000 -0500
+++ src/bash-4.4/builtins/set.def 2017-01-23 13:55:07.992877600 -0600 +++ builtins/set.def 2017-01-23 13:55:07.992877600 -0600
@@ -56,6 +56,13 @@ extern int dont_save_function_defs; @@ -56,6 +56,13 @@ extern int dont_save_function_defs;
#if defined (READLINE) #if defined (READLINE)
extern int no_line_editing; extern int no_line_editing;
@ -258,8 +258,8 @@
free (vname); free (vname);
} }
} }
--- origsrc/bash-4.4/builtins/shopt.def 2016-05-06 14:00:02.000000000 -0500 --- builtins/shopt.def 2016-05-06 14:00:02.000000000 -0500
+++ src/bash-4.4/builtins/shopt.def 2017-01-23 13:55:07.992877600 -0600 +++ builtins/shopt.def 2017-01-23 13:55:07.992877600 -0600
@@ -92,6 +92,10 @@ extern int glob_asciirange; @@ -92,6 +92,10 @@ extern int glob_asciirange;
extern int lastpipe_opt; extern int lastpipe_opt;
extern int inherit_errexit; extern int inherit_errexit;
@ -281,8 +281,8 @@
#if defined (READLINE) #if defined (READLINE)
{ "complete_fullquote", &complete_fullquote, (shopt_set_func_t *)NULL}, { "complete_fullquote", &complete_fullquote, (shopt_set_func_t *)NULL},
{ "direxpand", &dircomplete_expand, shopt_set_complete_direxpand }, { "direxpand", &dircomplete_expand, shopt_set_complete_direxpand },
--- origsrc/bash-4.4/config-top.h 2016-05-19 13:34:02.000000000 -0500 --- config-top.h 2016-05-19 13:34:02.000000000 -0500
+++ src/bash-4.4/config-top.h 2017-01-23 13:55:07.992877600 -0600 +++ config-top.h 2017-01-23 13:55:07.992877600 -0600
@@ -87,10 +87,10 @@ @@ -87,10 +87,10 @@
#define DEFAULT_BASHRC "~/.bashrc" #define DEFAULT_BASHRC "~/.bashrc"
@ -305,8 +305,8 @@
/* Define if you want the case-capitalizing operators (~[~]) and the /* Define if you want the case-capitalizing operators (~[~]) and the
`capcase' variable attribute (declare -c). */ `capcase' variable attribute (declare -c). */
--- origsrc/bash-4.4/doc/Makefile.in 2015-12-06 18:55:56.000000000 -0600 --- doc/Makefile.in 2015-12-06 18:55:56.000000000 -0600
+++ src/bash-4.4/doc/Makefile.in 2017-01-23 13:55:07.992877600 -0600 +++ doc/Makefile.in 2017-01-23 13:55:07.992877600 -0600
@@ -189,7 +189,7 @@ bashref.html: $(BASHREF_FILES) $(HSUSER) @@ -189,7 +189,7 @@ bashref.html: $(BASHREF_FILES) $(HSUSER)
$(MAKEINFO) --html --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi $(MAKEINFO) --html --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi
@ -329,8 +329,8 @@
-if test -f bash.info; then d=.; else d=$(srcdir); fi; \ -if test -f bash.info; then d=.; else d=$(srcdir); fi; \
$(INSTALL_DATA) $$d/bash.info $(DESTDIR)$(infodir)/bash.info $(INSTALL_DATA) $$d/bash.info $(DESTDIR)$(infodir)/bash.info
# run install-info if it is present to update the info directory # run install-info if it is present to update the info directory
--- origsrc/bash-4.4/doc/bash.1 2016-08-26 08:45:17.000000000 -0500 --- doc/bash.1 2016-08-26 08:45:17.000000000 -0500
+++ src/bash-4.4/doc/bash.1 2017-01-23 13:55:08.008447700 -0600 +++ doc/bash.1 2017-01-23 13:55:08.008447700 -0600
@@ -9607,6 +9607,10 @@ filenames. @@ -9607,6 +9607,10 @@ filenames.
This variable is set by default, which is the default bash behavior in This variable is set by default, which is the default bash behavior in
versions through 4.2. versions through 4.2.
@ -342,8 +342,8 @@
.B direxpand .B direxpand
If set, If set,
.B bash .B bash
--- origsrc/bash-4.4/doc/bashref.texi 2016-09-07 16:13:36.000000000 -0500 --- doc/bashref.texi 2016-09-07 16:13:36.000000000 -0500
+++ src/bash-4.4/doc/bashref.texi 2017-01-23 13:55:08.008447700 -0600 +++ doc/bashref.texi 2017-01-23 13:55:08.008447700 -0600
@@ -5123,6 +5123,10 @@ filenames. @@ -5123,6 +5123,10 @@ filenames.
This variable is set by default, which is the default Bash behavior in This variable is set by default, which is the default Bash behavior in
versions through 4.2. versions through 4.2.
@ -355,8 +355,8 @@
@item direxpand @item direxpand
If set, Bash If set, Bash
replaces directory names with the results of word expansion when performing replaces directory names with the results of word expansion when performing
--- origsrc/bash-4.4/doc/builtins.1 2012-02-21 13:32:05.000000000 -0600 --- doc/builtins.1 2012-02-21 13:32:05.000000000 -0600
+++ src/bash-4.4/doc/builtins.1 2017-01-23 13:55:08.008447700 -0600 +++ doc/builtins.1 2017-01-23 13:55:08.008447700 -0600
@@ -19,6 +19,6 @@ shift, shopt, source, suspend, test, tim @@ -19,6 +19,6 @@ shift, shopt, source, suspend, test, tim
ulimit, umask, unalias, unset, wait \- bash built-in commands, see \fBbash\fR(1) ulimit, umask, unalias, unset, wait \- bash built-in commands, see \fBbash\fR(1)
.SH BASH BUILTIN COMMANDS .SH BASH BUILTIN COMMANDS
@ -365,8 +365,8 @@
+.so man1/bash.1 +.so man1/bash.1
.SH SEE ALSO .SH SEE ALSO
bash(1), sh(1) bash(1), sh(1)
--- origsrc/bash-4.4/general.c 2016-08-11 10:16:56.000000000 -0500 --- general.c 2016-08-11 10:16:56.000000000 -0500
+++ src/bash-4.4/general.c 2017-01-23 13:55:08.008447700 -0600 +++ general.c 2017-01-23 13:55:08.008447700 -0600
@@ -48,6 +48,10 @@ @@ -48,6 +48,10 @@
#include <tilde/tilde.h> #include <tilde/tilde.h>
@ -388,8 +388,8 @@
result = savestring (pathbuf); result = savestring (pathbuf);
} }
#else #else
--- origsrc/bash-4.4/input.c 2015-09-24 18:49:23.000000000 -0500 --- input.c 2015-09-24 18:49:23.000000000 -0500
+++ src/bash-4.4/input.c 2017-01-23 13:55:08.008447700 -0600 +++ input.c 2017-01-23 13:55:08.008447700 -0600
@@ -44,6 +44,10 @@ @@ -44,6 +44,10 @@
#include "quit.h" #include "quit.h"
#include "trap.h" #include "trap.h"
@ -421,8 +421,8 @@
#if !defined (DJGPP) #if !defined (DJGPP)
return (bufstream_getc (buffers[bash_input.location.buffered_fd])); return (bufstream_getc (buffers[bash_input.location.buffered_fd]));
#else #else
--- origsrc/bash-4.4/lib/sh/pathphys.c 2013-05-28 14:33:58.000000000 -0500 --- lib/sh/pathphys.c 2013-05-28 14:33:58.000000000 -0500
+++ src/bash-4.4/lib/sh/pathphys.c 2017-01-23 13:55:08.008447700 -0600 +++ lib/sh/pathphys.c 2017-01-23 13:55:08.008447700 -0600
@@ -35,6 +35,7 @@ @@ -35,6 +35,7 @@
#include <stdio.h> #include <stdio.h>
#include <chartypes.h> #include <chartypes.h>
@ -453,8 +453,8 @@
double_slash_path = DOUBLE_SLASH (workpath); double_slash_path = DOUBLE_SLASH (workpath);
qbase += double_slash_path; qbase += double_slash_path;
--- origsrc/bash-4.4/lib/sh/tmpfile.c 2016-08-11 10:05:58.000000000 -0500 --- lib/sh/tmpfile.c 2016-08-11 10:05:58.000000000 -0500
+++ src/bash-4.4/lib/sh/tmpfile.c 2017-01-23 13:55:08.008447700 -0600 +++ lib/sh/tmpfile.c 2017-01-23 13:55:08.008447700 -0600
@@ -101,7 +101,7 @@ get_tmpdir (flags) @@ -101,7 +101,7 @@ get_tmpdir (flags)
if (tdir && (file_iswdir (tdir) == 0 || strlen (tdir) > PATH_MAX)) if (tdir && (file_iswdir (tdir) == 0 || strlen (tdir) > PATH_MAX))
tdir = 0; tdir = 0;
@ -464,8 +464,8 @@
tdir = get_sys_tmpdir (); tdir = get_sys_tmpdir ();
#if defined (HAVE_PATHCONF) && defined (_PC_NAME_MAX) #if defined (HAVE_PATHCONF) && defined (_PC_NAME_MAX)
--- origsrc/bash-4.4/mksyntax.c 2012-07-29 18:48:38.000000000 -0500 --- mksyntax.c 2012-07-29 18:48:38.000000000 -0500
+++ src/bash-4.4/mksyntax.c 2017-01-23 13:55:08.008447700 -0600 +++ mksyntax.c 2017-01-23 13:55:08.008447700 -0600
@@ -29,13 +29,13 @@ @@ -29,13 +29,13 @@
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
@ -483,8 +483,8 @@
#ifndef errno #ifndef errno
extern int errno; extern int errno;
#endif #endif
--- origsrc/bash-4.4/parse.y 2016-09-11 10:31:46.000000000 -0500 --- parse.y 2016-09-11 10:31:46.000000000 -0500
+++ src/bash-4.4/parse.y 2017-01-23 13:55:08.008447700 -0600 +++ parse.y 2017-01-23 13:55:08.008447700 -0600
@@ -1539,14 +1539,20 @@ yy_string_get () @@ -1539,14 +1539,20 @@ yy_string_get ()
string = bash_input.location.string; string = bash_input.location.string;
@ -509,8 +509,8 @@
} }
static int static int
--- origsrc/bash-4.4/subst.c 2017-01-23 13:28:06.955247200 -0600 --- subst.c 2017-01-23 13:28:06.955247200 -0600
+++ src/bash-4.4/subst.c 2017-01-23 13:55:08.008447700 -0600 +++ subst.c 2017-01-23 13:55:08.008447700 -0600
@@ -43,6 +43,7 @@ @@ -43,6 +43,7 @@
#include "posixstat.h" #include "posixstat.h"
#include "bashintl.h" #include "bashintl.h"
@ -562,8 +562,8 @@
old_pid = last_made_pid; old_pid = last_made_pid;
#if defined (JOB_CONTROL) #if defined (JOB_CONTROL)
old_pipeline_pgrp = pipeline_pgrp; old_pipeline_pgrp = pipeline_pgrp;
--- origsrc/bash-4.4/support/bashversion.c 2008-09-09 08:31:53.000000000 -0500 --- support/bashversion.c 2008-09-09 08:31:53.000000000 -0500
+++ src/bash-4.4/support/bashversion.c 2017-01-23 13:55:08.024037200 -0600 +++ support/bashversion.c 2017-01-23 13:55:08.024037200 -0600
@@ -26,6 +26,9 @@ @@ -26,6 +26,9 @@
#if defined (HAVE_UNISTD_H) #if defined (HAVE_UNISTD_H)
@ -584,8 +584,8 @@
extern char *dist_version; extern char *dist_version;
extern int patch_level; extern int patch_level;
--- origsrc/bash-4.4/support/mkversion.sh 2008-08-13 07:25:57.000000000 -0500 --- support/mkversion.sh 2008-08-13 07:25:57.000000000 -0500
+++ src/bash-4.4/support/mkversion.sh 2017-01-23 13:55:08.024037200 -0600 +++ support/mkversion.sh 2017-01-23 13:55:08.024037200 -0600
@@ -29,7 +29,7 @@ source_dir="." @@ -29,7 +29,7 @@ source_dir="."
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case "$1" in case "$1" in
@ -595,8 +595,8 @@
-s) shift; rel_status=$1; shift ;; -s) shift; rel_status=$1; shift ;;
-p) shift; patch_level=$1; shift ;; -p) shift; patch_level=$1; shift ;;
-d) shift; dist_version=$1; shift ;; -d) shift; dist_version=$1; shift ;;
--- origsrc/bash-4.4/variables.c 2016-06-15 15:05:52.000000000 -0500 --- variables.c 2016-06-15 15:05:52.000000000 -0500
+++ src/bash-4.4/variables.c 2017-01-23 13:55:08.024037200 -0600 +++ variables.c 2017-01-23 13:55:08.024037200 -0600
@@ -5239,6 +5239,7 @@ sv_winsize (name) @@ -5239,6 +5239,7 @@ sv_winsize (name)
/* Update the value of HOME in the export environment so tilde expansion will /* Update the value of HOME in the export environment so tilde expansion will
work on cygwin. */ work on cygwin. */

View file

@ -5841,15 +5841,13 @@ with pkgs;
runtimeShell = "${runtimeShellPackage}/bin/bash"; runtimeShell = "${runtimeShellPackage}/bin/bash";
runtimeShellPackage = bash; runtimeShellPackage = bash;
bash = lowPrio (callPackage ../shells/bash/4.4.nix { bash = lowPrio (callPackage ../shells/bash/4.4.nix { });
texinfo = null;
interactive = stdenv.isCygwin; # patch for cygwin requires readline support
});
# WARNING: this attribute is used by nix-shell so it shouldn't be removed/renamed # WARNING: this attribute is used by nix-shell so it shouldn't be removed/renamed
bashInteractive = appendToName "interactive" (callPackage ../shells/bash/4.4.nix { bashInteractive = callPackage ../shells/bash/4.4.nix {
interactive = true; interactive = true;
}); withDocs = true;
};
bash-completion = callPackage ../shells/bash/bash-completion { }; bash-completion = callPackage ../shells/bash/bash-completion { };