enable history
[platform/upstream/bash.git] / packaging / bash.spec
1 Name:           bash
2 Version:        4.2
3 Release:        1
4 License:        GPL-3.0+
5 Summary:        The GNU Bourne Again shell
6 Url:            http://www.gnu.org/software/bash
7 Group:          System/Shells
8 Source0:        ftp://ftp.gnu.org/gnu/bash/%{name}-%{version}.tar.gz
9 BuildRequires:  autoconf
10 BuildRequires:  bison
11 Provides:       /bin/bash
12 Provides:       /bin/sh
13
14 %description
15 The GNU Bourne Again shell (Bash) is a shell or command language
16 interpreter that is compatible with the Bourne shell (sh). Bash
17 incorporates useful features from the Korn shell (ksh) and the C shell
18 (csh). Most sh scripts can be run by bash without modification.
19
20
21 %prep
22 %setup -q
23
24 %build
25 %configure --enable-largefile \
26             --without-bash-malloc \
27             --disable-nls \
28             --enable-alias \
29             --enable-readline  \
30             --enable-history
31
32 # Recycles pids is neccessary. When bash's last fork's pid was X
33 # and new fork's pid is also X, bash has to wait for this same pid.
34 # Without Recycles pids bash will not wait.
35 make "CPPFLAGS=-D_GNU_SOURCE -DDEFAULT_PATH_VALUE='\"/usr/local/bin:/usr/bin\"' -DRECYCLES_PIDS `getconf LFS_CFLAGS`"
36 %check
37 make check
38
39 %install
40 %make_install
41
42 mkdir -p %{buildroot}/etc
43
44 #mkdir -p %{buildroot}/%{_bindir}
45 #mv %{buildroot}/bin/* %{buildroot}/%{_bindir}/
46
47 # make manpages for bash builtins as per suggestion in DOC/README
48 pushd doc
49 sed -e '
50 /^\.SH NAME/, /\\- bash built-in commands, see \\fBbash\\fR(1)$/{
51 /^\.SH NAME/d
52 s/^bash, //
53 s/\\- bash built-in commands, see \\fBbash\\fR(1)$//
54 s/,//g
55 b
56 }
57 d
58 ' builtins.1 > man.pages
59 for i in echo pwd test kill; do
60   perl -pi -e "s,$i,,g" man.pages
61   perl -pi -e "s,  , ,g" man.pages
62 done
63
64 install -c -m 644 builtins.1 %{buildroot}%{_mandir}/man1/builtins.1
65
66 for i in `cat man.pages` ; do
67   echo .so man1/builtins.1 > %{buildroot}%{_mandir}/man1/$i.1
68   chmod 0644 %{buildroot}%{_mandir}/man1/$i.1
69 done
70 popd
71
72 # Link bash man page to sh so that man sh works.
73 ln -s bash.1 %{buildroot}%{_mandir}/man1/sh.1
74
75 # Not for printf, true and false (conflict with coreutils)
76 rm -f %{buildroot}/%{_mandir}/man1/printf.1
77 rm -f %{buildroot}/%{_mandir}/man1/true.1
78 rm -f %{buildroot}/%{_mandir}/man1/false.1
79
80 pushd %{buildroot}
81 ln -sf bash ./usr/bin/sh
82 rm -f .%{_infodir}/dir
83 popd
84 mkdir -p %{buildroot}%{_sysconfdir}/skel
85 #install -c -m644 %{SOURCE1} %{buildroot}%{_sysconfdir}/skel/.bashrc
86 #install -c -m644 %{SOURCE2} %{buildroot}%{_sysconfdir}/skel/.bash_profile
87 #install -c -m644 %{SOURCE3} %{buildroot}%{_sysconfdir}/skel/.bash_logout
88 LONG_BIT=$(getconf LONG_BIT)
89 mv %{buildroot}%{_bindir}/bashbug \
90    %{buildroot}%{_bindir}/bashbug-"${LONG_BIT}"
91
92 # Fix missing sh-bangs in example scripts (bug #225609).
93 for script in \
94   examples/scripts/krand.bash \
95   examples/scripts/bcsh.sh \
96   examples/scripts/precedence \
97   examples/scripts/shprompt
98 do
99   cp "$script" "$script"-orig
100   echo '#!/bin/bash' > "$script"
101   cat "$script"-orig >> "$script"
102   rm -f "$script"-orig
103 done
104
105 rm -rf %{buildroot}%{_bindir}/bashbug-*
106 chmod a-x doc/*.sh
107
108 %docs_package
109
110 %post -p <lua>
111 bashfound = false;
112 shfound = false;
113
114 f = io.open("/etc/shells", "r");
115 if f == nil
116 then
117   f = io.open("/etc/shells", "w");
118 else
119   repeat
120     t = f:read();
121     if t == "/bin/bash"
122     then
123       bashfound = true;
124     end
125     if t == "/bin/sh"
126     then
127       shfound = true;
128     end
129   until t == nil;
130 end
131 f:close()
132
133 f = io.open("/etc/shells", "a");
134 if not bashfound
135 then
136   f:write("/bin/bash\n")
137 end
138 if not shfound
139 then
140   f:write("/bin/sh\n")
141 end
142 f:close()
143
144 %postun
145 if [ "$1" = 0 ]; then
146     /bin/grep -v '^/bin/bash$' < /etc/shells | \
147       /bin/grep -v '^/bin/sh$' > /etc/shells.new
148     /bin/mv /etc/shells.new /etc/shells
149 fi
150
151
152
153 %files
154 %{_bindir}/sh
155 %{_bindir}/bash
156