fdb97c72fd69c03771e6e5043ff2ad4be495068d
[external/bash.git] / packaging / bash.spec
1 Version: 4.1
2 Name: bash
3 Summary: The GNU Bourne Again shell
4 Release: 1
5 Group: System/Shells
6 License: GPLv2+
7 Url: http://www.gnu.org/software/bash
8 Source0: ftp://ftp.gnu.org/gnu/bash/%{name}-%{version}.tar.gz
9
10 # SLP patches
11 Patch0: bash41-001.patch
12 Patch1: bash41-002.patch
13 Patch2: bash41-003.patch
14 Patch3: bash41-004.patch
15 Patch4: bash41-005.patch
16 Patch5: deb-bash-config.patch
17 Patch6: privmode.patch
18 Patch7: bash-default-editor.patch
19 Patch8: bash-subst-param-length.patch
20 Patch9: pgrp-pipe.patch
21 Patch10: input-err.patch
22 Patch11: bash-aliases-repeat.patch
23 Patch12: builtins-declare-fix.patch
24
25 Requires(post): ncurses-libs
26
27 BuildRequires: bison
28 #BuildRequires: ncurses-devel
29 BuildRequires: autoconf
30
31 %description
32 The GNU Bourne Again shell (Bash) is a shell or command language
33 interpreter that is compatible with the Bourne shell (sh). Bash
34 incorporates useful features from the Korn shell (ksh) and the C shell
35 (csh). Most sh scripts can be run by bash without modification.
36
37 %package doc
38 Summary: Documentation files for %{name}
39 Group: Development/Languages
40 Requires: %{name} = %{version}-%{release}
41
42 %description doc
43 This package contains documentation files for %{name}.
44
45 %define pkgdocdir %{_datadir}/doc/%{name}-%{version}
46
47 %prep
48 %setup -q
49
50 %patch0 -p1 -b .bash41-001
51 %patch1 -p1 -b .bash41-002
52 %patch2 -p1 -b .bash41-003
53 %patch3 -p1 -b .bash41-004
54 %patch4 -p1 -b .bash41-005
55 %patch5 -p1 -b .deb-bash-config
56 %patch6 -p1 -b .privmode
57 %patch7 -p1 -b .bash-default-editor
58 %patch8 -p0 -b .bash-subst-param-length
59 %patch9 -p0 -b .pgrp-pipe
60 %patch10 -p0 -b .input-err
61 %patch11 -p0 -b .bash-aliases-repeat
62 %patch12 -p1 -b .builtins-declare-fix
63
64 %build
65 autoconf
66 %configure --enable-largefile --without-bash-malloc --disable-nls
67
68 # Recycles pids is neccessary. When bash's last fork's pid was X
69 # and new fork's pid is also X, bash has to wait for this same pid.
70 # Without Recycles pids bash will not wait.
71 make "CPPFLAGS=-D_GNU_SOURCE -DRECYCLES_PIDS `getconf LFS_CFLAGS`"
72 %check
73 make check
74
75 %install
76 rm -rf $RPM_BUILD_ROOT
77
78 if [ -e autoconf ]; then
79   # Yuck. We're using autoconf 2.1x.
80   export PATH=.:$PATH
81 fi
82
83 # Fix bug #83776
84 perl -pi -e 's,bashref\.info,bash.info,' doc/bashref.info
85
86 make DESTDIR=$RPM_BUILD_ROOT install
87
88 mkdir -p $RPM_BUILD_ROOT/etc
89
90 # make manpages for bash builtins as per suggestion in DOC/README
91 pushd doc
92 sed -e '
93 /^\.SH NAME/, /\\- bash built-in commands, see \\fBbash\\fR(1)$/{
94 /^\.SH NAME/d
95 s/^bash, //
96 s/\\- bash built-in commands, see \\fBbash\\fR(1)$//
97 s/,//g
98 b
99 }
100 d
101 ' builtins.1 > man.pages
102 for i in echo pwd test kill; do
103   perl -pi -e "s,$i,,g" man.pages
104   perl -pi -e "s,  , ,g" man.pages
105 done
106
107 install -c -m 644 builtins.1 ${RPM_BUILD_ROOT}%{_mandir}/man1/builtins.1
108
109 for i in `cat man.pages` ; do
110   echo .so man1/builtins.1 > ${RPM_BUILD_ROOT}%{_mandir}/man1/$i.1
111   chmod 0644 ${RPM_BUILD_ROOT}%{_mandir}/man1/$i.1
112 done
113 popd
114
115 # Link bash man page to sh so that man sh works.
116 ln -s bash.1 ${RPM_BUILD_ROOT}%{_mandir}/man1/sh.1
117
118 # Not for printf, true and false (conflict with coreutils)
119 rm -f $RPM_BUILD_ROOT/%{_mandir}/man1/printf.1
120 rm -f $RPM_BUILD_ROOT/%{_mandir}/man1/true.1
121 rm -f $RPM_BUILD_ROOT/%{_mandir}/man1/false.1
122
123 pushd $RPM_BUILD_ROOT
124 mkdir ./bin
125 mv ./usr/bin/bash ./bin
126 ln -sf bash ./bin/sh
127 rm -f .%{_infodir}/dir
128 popd
129 mkdir -p $RPM_BUILD_ROOT/etc/skel
130 #install -c -m644 %SOURCE1 $RPM_BUILD_ROOT/etc/skel/.bashrc
131 #install -c -m644 %SOURCE2 $RPM_BUILD_ROOT/etc/skel/.bash_profile
132 #install -c -m644 %SOURCE3 $RPM_BUILD_ROOT/etc/skel/.bash_logout
133 LONG_BIT=$(getconf LONG_BIT)
134 mv $RPM_BUILD_ROOT%{_bindir}/bashbug \
135    $RPM_BUILD_ROOT%{_bindir}/bashbug-"${LONG_BIT}"
136
137 # Fix missing sh-bangs in example scripts (bug #225609).
138 for script in \
139   examples/scripts/krand.bash \
140   examples/scripts/bcsh.sh \
141   examples/scripts/precedence \
142   examples/scripts/shprompt
143 do
144   cp "$script" "$script"-orig
145   echo '#!/bin/bash' > "$script"
146   cat "$script"-orig >> "$script"
147   rm -f "$script"-orig
148 done
149
150 rm -rf %{buildroot}%{_bindir}/bashbug-*
151 chmod a-x doc/*.sh
152
153 %clean
154 rm -rf $RPM_BUILD_ROOT
155
156 # ***** bash doesn't use install-info. It's always listed in %{_infodir}/dir
157 # to prevent prereq loops
158
159 # post is in lua so that we can run it without any external deps.  Helps
160 # for bootstrapping a new install.
161 # Jesse Keating 2009-01-29 (code from Ignacio Vazquez-Abrams)
162 %post -p <lua>
163 bashfound = false;
164 shfound = false;
165  
166 f = io.open("/etc/shells", "r");
167 if f == nil
168 then
169   f = io.open("/etc/shells", "w");
170 else
171   repeat
172     t = f:read();
173     if t == "/bin/bash"
174     then
175       bashfound = true;
176     end
177     if t == "/bin/sh"
178     then
179       shfound = true;
180     end
181   until t == nil;
182 end
183 f:close()
184  
185 f = io.open("/etc/shells", "a");
186 if not bashfound
187 then
188   f:write("/bin/bash\n")
189 end
190 if not shfound
191 then
192   f:write("/bin/sh\n")
193 end
194 f:close()
195
196 %postun
197 if [ "$1" = 0 ]; then
198     /bin/grep -v '^/bin/bash$' < /etc/shells | \
199       /bin/grep -v '^/bin/sh$' > /etc/shells.new
200     /bin/mv /etc/shells.new /etc/shells
201 fi
202
203
204 %docs_package
205
206 %files 
207 /bin/sh
208 /bin/bash
209