+# Prereq: /usr/sbin/useradd , /sbin/chkconfig , /sbin/service
+Prereq: shadow-utils, chkconfig, initscripts
+BuildRequires: perl gzip sed docbook-utils
+Conflicts: junkbuster-raw junkbuster-blank
+
+%description
+Internet Junkbuster is a web proxy with advanced filtering
+capabilities for protecting privacy, filtering web page content,
+managing cookies, controlling access, and removing ads, banners,
+pop-ups and other obnoxious Internet Junk. Junkbuster has a very
+flexible configuration and can be customized to suit individual needs
+and tastes. Internet Junkbuster has application for both stand-alone
+systems and multi-user networks.
+
+%prep
+%setup -q -c -n ijbswa
+
+%build
+%configure
+make
+make redhat-dok
+
+## Explicitily stripping is not recomended.
+## This is handled altomaticaly by RPM, and can couse troubles if
+## anyone wants to build an unstriped version - morcego
+#strip %{name}
+
+%pre
+/usr/sbin/useradd -d /etc/%{name} -r %{name} -s "" > /dev/null 2>&1 || /bin/true
+
+%install
+[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
+mkdir -p %{buildroot}%{_sbindir} \
+ %{buildroot}%{_mandir}/man8 \
+ %{buildroot}%{_localstatedir}/log/%{name} \
+ %{buildroot}%{ijbconf}/templates \
+ %{buildroot}%{_sysconfdir}/logrotate.d \
+ %{buildroot}%{_sysconfdir}/rc.d/init.d
+
+## Manual gziping of manpages should not be done, once it can
+## break the building on some distributions. Anyway, rpm does it
+## automagicaly these days
+## Gziping the documentation files is not recomended - morcego
+#gzip README AUTHORS ChangeLog %{name}.1 || /bin/true
+
+install -s -m 744 %{name} %{buildroot}%{_sbindir}/%{name}
+
+## We need to change the man section internaly on the manpage
+## -- morcego (sugestion by Hal Burgiss)
+#cp -f %{name}.1 %{buildroot}%{_mandir}/man8/%{name}.8
+sed -e 's@^.TH JUNKBUSTER 1@.TH JUNKBUSTER 8@g' %{name}.1 > %{buildroot}%{_mandir}/man8/%{name}.8
+cp -f *.action %{buildroot}%{ijbconf}/
+cp -f re_filterfile %{buildroot}%{ijbconf}/re_filterfile
+cp -f trust %{buildroot}%{ijbconf}/trust
+cp -f templates/* %{buildroot}%{ijbconf}/templates/
+cp -f %{name}.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
+install -m 755 %{name}.init %{buildroot}%{_sysconfdir}/rc.d/init.d/%{name}
+install -m 711 -d %{buildroot}%{_localstatedir}/log/%{name}
+
+# verify all file locations, etc. in the config file
+# don't start with ^ or commented lines are not replaced
+## Changing the sed paramter delimiter to @, so we don't have to
+## escape the slashes
+cat config | \
+ sed 's@^confdir.*@confdir %{_sysconfdir}/%{name}@g' | \
+# sed 's/^permissionsfile.*/permissionsfile \/etc\/%{name}\/permissionsfile/g' | \
+# sed 's/^re_filterfile.*/re_filterfile \/etc\/%{name}\/re_filterfile/g' | \
+# sed 's/^logfile.*/logfile \%{_localstatedir}\/log\/%{name}\/logfile/g' | \
+# sed 's/^jarfile.*/jarfile \%{_localstatedir}\/log\/%{name}\/jarfile/g' | \
+# sed 's/^forward.*/forward \/etc\/%{name}\/forward/g' | \
+# sed 's/^aclfile.*/aclfile \/etc\/%{name}\/aclfile/g' > \
+ sed 's@^logdir.*@logdir %{_localstatedir}/log/%{name}@g' > \
+ %{buildroot}%{ijbconf}/config
+perl -pe 's/{-no-cookies}/{-no-cookies}\n\.redhat.com/' ijb.action >\
+ %{buildroot}%{ijbconf}/ijb.action
+
+## Macros are expanded even on commentaries. So, we have to use %%
+## -- morcego
+#%%makeinstall
+
+%post
+# for upgrade from 2.0.x
+[ -f %{_localstatedir}/log/%{name}/%{name} ] &&\
+ mv -f %{_localstatedir}/log/%{name}/%{name} %{_localstatedir}/log/%{name}/logfile || /bin/true
+chown -R %{name}:%{name} %{_localstatedir}/log/%{name} 2>/dev/null
+chown -R %{name}:%{name} /etc/%{name} 2>/dev/null
+if [ "$1" = "1" ]; then
+ /sbin/chkconfig --add %{name}
+ /sbin/service %{name} condrestart > /dev/null 2>&1
+fi
+# 01/09/02 HB, getting rid of any user=junkbust
+grep junkbust: /etc/passwd >/dev/null && userdel junkbust || /bin/true
+
+%preun
+if [ "$1" = "0" ]; then
+ /sbin/service %{name} stop > /dev/null 2>&1 ||:
+ /sbin/chkconfig --del %{name}
+fi
+
+%postun
+#if [ "$1" -ge "1" ]; then
+# /sbin/service %{name} condrestart > /dev/null 2>&1
+#fi
+
+%clean
+[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
+
+%files
+%defattr(0644,root,root,0755)
+%doc README AUTHORS ChangeLog
+# Where are the webserver/{developer,user}-manual files ?
+%doc doc/text/developer-manual.txt doc/text/user-manual.txt
+%doc doc/webserver/developer-manual
+%doc doc/webserver/user-manual
+#%doc %{name}.weekly %{name}.monthly AUTHORS
+
+%dir %{ijbconf}
+%dir %{ijbconf}/templates
+%attr(0744,%{name},%{name}) %dir %{_localstatedir}/log/%{name}
+
+%attr(0744,%{name},%{name})%{_sbindir}/%{name}
+
+# We should not use wildchars here. This could mask missing files problems
+# -- morcego
+%config %{ijbconf}/config
+%config %{ijbconf}/ijb-advanced.action
+%config %{ijbconf}/ijb-basic.action
+%config %{ijbconf}/ijb-intermediate.action
+%config %{ijbconf}/ijb.action
+%config %{ijbconf}/re_filterfile
+%config %{ijbconf}/trust
+
+%config %{ijbconf}/templates/blocked
+%config %{ijbconf}/templates/blocked-compact
+%config %{ijbconf}/templates/cgi-error-404
+%config %{ijbconf}/templates/cgi-error-bad-param
+%config %{ijbconf}/templates/cgi-error-disabled
+%config %{ijbconf}/templates/cgi-error-file
+%config %{ijbconf}/templates/cgi-error-modified
+%config %{ijbconf}/templates/cgi-error-parse
+%config %{ijbconf}/templates/connect-failed
+%config %{ijbconf}/templates/default
+%config %{ijbconf}/templates/edit-actions-add-url-form
+%config %{ijbconf}/templates/edit-actions-for-url
+%config %{ijbconf}/templates/edit-actions-list
+%config %{ijbconf}/templates/edit-actions-list-section
+%config %{ijbconf}/templates/edit-actions-list-url
+%config %{ijbconf}/templates/edit-actions-remove-url-form
+%config %{ijbconf}/templates/edit-actions-url-form
+%config %{ijbconf}/templates/no-such-domain
+%config %{ijbconf}/templates/show-request
+%config %{ijbconf}/templates/show-status
+%config %{ijbconf}/templates/show-status-file
+%config %{ijbconf}/templates/show-url-info
+%config %{ijbconf}/templates/show-version
+%config %{ijbconf}/templates/toggle
+%config %{ijbconf}/templates/toggle-mini
+%config %{ijbconf}/templates/untrusted
+
+%config %{_sysconfdir}/logrotate.d/%{name}
+%config %attr(0744,root,root) %{_sysconfdir}/rc.d/init.d/%{name}
+
+%{_mandir}/man8/%{name}.8*