f6e3028c2fdb5b92aa8aa0e21235a6843ee378ab
[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:          System/Base
8 Source0:        ftp://ftp.gnu.org/gnu/bash/%{name}-%{version}.tar.gz
9 Source1:        dot.bashrc
10 Source2:        dot.profile
11 BuildRequires:  autoconf
12 BuildRequires:  bison
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
26 %build
27 %configure --enable-largefile \
28             --without-bash-malloc \
29             --disable-nls \
30             --enable-alias \
31             --enable-readline  \
32             --enable-history
33
34 # Recycles pids is neccessary. When bash's last fork's pid was X
35 # and new fork's pid is also X, bash has to wait for this same pid.
36 # Without Recycles pids bash will not wait.
37 make "CPPFLAGS=-D_GNU_SOURCE -DDEFAULT_PATH_VALUE='\"/usr/local/bin:/usr/bin\"' -DRECYCLES_PIDS `getconf LFS_CFLAGS`"
38 %check
39 make check
40
41 %install
42 %make_install
43
44 mkdir -p %{buildroot}/etc
45
46 #mkdir -p %{buildroot}/%{_bindir}
47 #mv %{buildroot}/bin/* %{buildroot}/%{_bindir}/
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 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
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 mkdir -p %{buildroot}%{_sysconfdir}/skel
87 install -c -m644 %{SOURCE1} %{buildroot}%{_sysconfdir}/skel/.bashrc
88 install -c -m644 %{SOURCE2} %{buildroot}%{_sysconfdir}/skel/.bash_profile
89 LONG_BIT=$(getconf LONG_BIT)
90 mv %{buildroot}%{_bindir}/bashbug \
91    %{buildroot}%{_bindir}/bashbug-"${LONG_BIT}"
92
93 # Fix missing sh-bangs in example scripts (bug #225609).
94 for script in \
95   examples/scripts/krand.bash \
96   examples/scripts/bcsh.sh \
97   examples/scripts/precedence \
98   examples/scripts/shprompt
99 do
100   cp "$script" "$script"-orig
101   echo '#!/bin/bash' > "$script"
102   cat "$script"-orig >> "$script"
103   rm -f "$script"-orig
104 done
105
106 rm -rf %{buildroot}%{_bindir}/bashbug-*
107 chmod a-x doc/*.sh
108
109 %docs_package
110
111 %post -p <lua>
112 bashfound = false;
113 shfound = false;
114
115 f = io.open("/etc/shells", "r");
116 if f == nil
117 then
118   f = io.open("/etc/shells", "w");
119 else
120   repeat
121     t = f:read();
122     if t == "/bin/bash"
123     then
124       bashfound = true;
125     end
126     if t == "/bin/sh"
127     then
128       shfound = true;
129     end
130   until t == nil;
131 end
132 f:close()
133
134 f = io.open("/etc/shells", "a");
135 if not bashfound
136 then
137   f:write("/bin/bash\n")
138 end
139 if not shfound
140 then
141   f:write("/bin/sh\n")
142 end
143 f:close()
144
145 %postun
146 if [ "$1" = 0 ]; then
147     /bin/grep -v '^/bin/bash$' < /etc/shells | \
148       /bin/grep -v '^/bin/sh$' > /etc/shells.new
149     /bin/mv /etc/shells.new /etc/shells
150 fi
151
152
153
154 %files
155 %license COPYING
156 %{_bindir}/sh
157 %{_bindir}/bash
158 %{_sysconfdir}/skel