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