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