No specific user configuration
[platform/upstream/bash.git] / packaging / bash.spec
1 Name:           bash
2 Version:        4.3.30
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/Utilities
8 Source0:        %{name}-%{version}.tar.gz
9 Source1001:     bash.manifest
10 BuildRequires:  autoconf
11 BuildRequires:  bison
12 BuildRequires:  fdupes
13 Provides:       /bin/bash
14 Provides:       /bin/sh
15
16 %description
17 The GNU Bourne Again shell (Bash) is a shell or command language
18 interpreter that is compatible with the Bourne shell (sh). Bash
19 incorporates useful features from the Korn shell (ksh) and the C shell
20 (csh). Most sh scripts can be run by bash without modification.
21
22
23 %prep
24 %setup -q
25 cp %{SOURCE1001} .
26
27 %build
28 %configure --enable-largefile \
29             --without-bash-malloc \
30             --disable-nls \
31             --enable-alias \
32             --enable-readline  \
33             --enable-history
34
35 # Recycles pids is neccessary. When bash's last fork's pid was X
36 # and new fork's pid is also X, bash has to wait for this same pid.
37 # Without Recycles pids bash will not wait.
38 make "CPPFLAGS=-D_GNU_SOURCE -DDEFAULT_PATH_VALUE='\"/usr/local/bin:/usr/bin\"' -DRECYCLES_PIDS `getconf LFS_CFLAGS`"
39 %check
40 make check
41
42 %install
43 %make_install
44
45 mkdir -p %{buildroot}/etc/bash_completion.d
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 # '
60 for i in echo pwd test kill; do
61   perl -pi -e "s,$i,,g" man.pages
62   perl -pi -e "s,  , ,g" man.pages
63 done
64
65 install -c -m 644 builtins.1 %{buildroot}%{_mandir}/man1/builtins.1
66 install -c -m 644 bash.1 %{buildroot}%{_mandir}/man1/bash.1
67
68 for i in `cat man.pages` ; do
69   echo .so man1/builtins.1 > %{buildroot}%{_mandir}/man1/$i.1
70   chmod 0644 %{buildroot}%{_mandir}/man1/$i.1
71 done
72 popd
73
74 # Link bash man page to sh so that man sh works.
75 ln -s bash.1 %{buildroot}%{_mandir}/man1/sh.1
76
77 # Not for printf, true and false (conflict with coreutils)
78 rm -f %{buildroot}/%{_mandir}/man1/printf.1
79 rm -f %{buildroot}/%{_mandir}/man1/true.1
80 rm -f %{buildroot}/%{_mandir}/man1/false.1
81
82 pushd %{buildroot}
83 ln -sf bash ./usr/bin/sh
84 rm -f .%{_infodir}/dir
85 popd
86 LONG_BIT=$(getconf LONG_BIT)
87 mv %{buildroot}%{_bindir}/bashbug \
88    %{buildroot}%{_bindir}/bashbug-"${LONG_BIT}"
89
90 rm -rf %{buildroot}%{_bindir}/bashbug-*
91 chmod a-x doc/*.sh
92
93 # remove duplicate manpages
94 %fdupes -s %{buildroot}/%{_mandir}
95
96 %docs_package
97 %doc %{_datadir}/doc/%{name}/*
98
99 %post -p <lua>
100 bashfound = false;
101 shfound = false;
102
103 f = io.open("/etc/shells", "r");
104 if f == nil
105 then
106   f = io.open("/etc/shells", "w");
107 else
108   repeat
109     t = f:read();
110     if t == "/bin/bash"
111     then
112       bashfound = true;
113     end
114     if t == "/bin/sh"
115     then
116       shfound = true;
117     end
118   until t == nil;
119 end
120 f:close()
121
122 f = io.open("/etc/shells", "a");
123 if not bashfound
124 then
125   f:write("/bin/bash\n")
126 end
127 if not shfound
128 then
129   f:write("/bin/sh\n")
130 end
131 f:close()
132
133 %postun
134 if [ "$1" = 0 ]; then
135     /bin/grep -v '^/bin/bash$' < /etc/shells | \
136       /bin/grep -v '^/bin/sh$' > /etc/shells.new
137     /bin/mv /etc/shells.new /etc/shells
138 fi
139
140
141
142 %files
143 %manifest %{name}.manifest
144 %license COPYING
145 %{_bindir}/sh
146 %{_bindir}/bash
147 %dir %{_sysconfdir}/bash_completion.d
148