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