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