LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File awstats.spec of Package awstats (Project network:utilities)

# spec file for package awstats
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/

Name:           awstats
Summary:        Advanced Web Statistics
License:        GPL-3.0
Group:          Productivity/Networking/Web/Utilities
Version:        7.7
Release:        0
Url:            http://awstats.sourceforge.net
%if 0%{?suse_version}
BuildRequires:  apache2-devel
Requires:       apache2
%define apache_mmn %(%{_libdir}/apache2_MMN | sed 's/apache_mmn_//')
# Needed perl modules for the plugins
Recommends:     perl-Net-DNS
Recommends:     perl-Net-IP
Recommends:     perl-Storable
Recommends:     perl-Geo-IP
Recommends:     %{name} = %{version}
%if 0%{?suse_version} > 1020
BuildRequires:  fdupes
%if 0%{?fedora_version}
BuildRequires:  httpd-devel
Requires:       httpd
%define apache_mmn %(rpm -q --provides httpd | grep mmn | awk -F " = " '{print $2}')
Requires:       cron
Requires:       logrotate
Requires:       perl >= 5.00.503
Requires:       perl-URI
Source:         awstats-%{version}.tar.gz
Source4:        cron.d.awstats
Source5:        awstats-update
Source6:        awstats-update.8
Source7:        awstats.logrotate
Source8:        awstats-rpmlintrc
Source9:        awstats.README
Patch2:         %{name}-3473378-urldecode.patch
# PATCH-FIX-OPENSUSE awstats-fix_css_icon_path.patch -- fix path to icons inside the css
Patch3:         %{name}-fix_css_icon_path.patch
BuildArch:      noarch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%define         apache_htdocsdir %(/usr/sbin/apxs2 -q HTDOCSDIR)
%define         apache_sysconfdir %(/usr/sbin/apxs2 -q SYSCONFDIR)
%define         apache_cgidir %(/usr/sbin/apxs2 -q CGIDIR)
%if             0%{?apache_mmn} >= 20120211
%define         apache_access Require all granted
%define         apache_access Order allow,deny\
        Allow from all

Advanced Web Statistics (AWStats) is a powerful Web server log file
analyzer (Perl script) that shows Web statistics including visitors,
pages, hits, hours, search engines, keywords used to find your site,
broken links, robots, and more.

This log analyzer works as a CGI or from command line and shows you
all possible information your log contains, in few graphical web
pages like visits, unique vistors, authenticated users, pages,
domains/countries, OS busiest times, robot visits, type of files,
search engines,keywords and keyphrases used, visits duration,
cluster balancing, HTTP errors and also screen size, web browser
java,flash,etc support and more...
Statistics can be updated from a browser or your scheduler.
AWStats uses a partial information file to be able to process large
log files, often and quickly.

It can analyze log files from IIS (W3C log format), Apache log files
(NCSA combined/XLF/ELF log format or common/CLF log format), WebStar
and most of all web, proxy, wap, streaming servers (and ftp servers
or mail logs).
The program also supports virtual servers, plugins and a lot of

%package doc
Summary:        Documentation package for awstat
Group:          Productivity/Networking/Web/Utilities
Provides:       w3af-gtk = %{version}
Obsoletes:      w3af-gtk < %{version}
Requires:       %{name} = %{version}

%description doc
This package contains the documentation for awstats

%setup -q
%patch2 -p1
%patch3 -p1

# if the following command fails, then apache dependencies are not met
/usr/sbin/apxs2 -q datadir >/dev/null

function create_config(){
	# Using sed rather than a diff here, to make sure all relevant
	# options are checked (upstream defaults have moved around in
	# the past)MiscTrackerUrl="/js
	sed -e "s|^LogFile.*|LogFile=\"$LOGFILE\"|g" \
    -e 's|^LogFormat.*|LogFormat=1|g' \
    -e "s|^LogType.*|LogType=$LOGTYPE|g" \
    -e 's|^DNSLookup.*|DNSLookup=1|g' \
    -e 's|^DirData.*|DirData="%{_var}/cache/awstats"|g' \
    -e 's|^DirIcons.*|DirIcons="/awstats/icon"|g' \
    -e 's|^DirLang.*|DirLang=%{_datadir}/awstats/lang"|g' \
    -e 's|^ErrorMessages.*|ErrorMessages="An error occurred. Contact your Administrator"|g' \
    -e 's|^HostAliases.*|HostAliases="localhost"|g' \
    -e 's|^#Include\s*|Include="%{_sysconfdir}/awstats/awstats.conf.local"|g' \
    -e 's|^NotPageList.*|NotPageList="css js class gif jpg jpeg png bmp ico rss xml swf"|g' \
	-e 's|^MiscTrackerUrl.*|MiscTrackerUrl="/awstats/js/awstats_misc_tracker.js"|g' \
    -e 's|^ShowFlagLinks.*|ShowFlagLinks="de en es fr nl"|g' \
    -e 's|^StyleSheet.*|StyleSheet="/awstats/css/awstats_bw.css"|g' \
    -e 's|^AllowToUpdateStatsFromBrowser.*|AllowToUpdateStatsFromBrowser=1|g' \
    -e 's|^EnableLockForUpdate.*|EnableLockForUpdate=1|g' \
    -e 's|^SaveDatabaseFilesWithPermissionsForEveryone.*|SaveDatabaseFilesWithPermissionsForEveryone=1|g' \
    wwwroot/cgi-bin/awstats.model.conf > %{buildroot}%{_sysconfdir}/awstats/$CONFNAME
#    -e 's|^AllowAccessFromWebToAuthenticatedUsersOnly.*|AllowAccessFromWebToAuthenticatedUsersOnly=1|g' \
	for pluginname in $PLUGINS; do
		sed -i "s|^#LoadPlugin\s*=\s*\"$pluginname\"|LoadPlugin=\"$pluginname\"|g" %{buildroot}%{_sysconfdir}/awstats/$CONFNAME

# create the directories needed for installation
mkdir -p %{buildroot}%{cgidir}/classes
mkdir -p %{buildroot}%{_sysconfdir}/awstats
mkdir -p %{buildroot}%{apache_sysconfdir}/conf.d/
mkdir -p %{buildroot}%{apache_cgidir}/classes
mkdir -p %{buildroot}%{_datadir}/awstats/classes
mkdir -p %{buildroot}%{_var}/cache/awstats
mkdir -p %{buildroot}%{_defaultdocdir}/%{name}/examples
# create some example configs
create_config "%{_var}/log/apache2/awstats.log" "W" "awstats.web.conf" "tooltips ipv6 hashfiles"
create_config "%{_var}/log/vsftpd.log" "F" "awstats.vsftp.conf" "tooltips ipv6"
create_config "%{_var}/log/mail" "M" "awstats.smtp.conf" "tooltips ipv6"
# install the files
cp -r wwwroot/{icon,css,js}              %{buildroot}%{_datadir}/awstats/
cp -r wwwroot/cgi-bin/{lang,lib,plugins} %{buildroot}%{_datadir}/awstats/
cp -r wwwroot/classes/*.jar              %{buildroot}%{_datadir}/awstats/classes/
install -Dm755 wwwroot/cgi-bin/awstats.pl         %{buildroot}%{apache_cgidir}/

# fix permissions
chmod -x %{buildroot}%{_datadir}/awstats/plugins/*.pm
chmod -x %{buildroot}%{_datadir}/awstats/lang/*.txt

# fix wrong line encoding (dos)
for file in $(find %{buildroot}%{apache_cgidir}/plugins/ -type f -name "*.pm"); do
	sed -i 's/\r$//' $file
for file in $(find docs/* -maxdepth 1 -type f); do
	sed -i 's/\r$//' $file

# install additional sources
install -Dm644 %{SOURCE4} %{buildroot}%{_sysconfdir}/cron.d/suse.de-awstats
install -Dm755 %{SOURCE5} %{buildroot}%{_sbindir}/awstats-update
install -Dm644 %{SOURCE6} %{buildroot}%{_mandir}/man8/awstats-update.8
install -Dm644 %{SOURCE7} %{buildroot}/etc/logrotate.d/awstats
cat > %{buildroot}%{apache_sysconfdir}/conf.d/awstats.conf << EOF
# The location and format of the access logfile (Common Logfile Format).
# If you do not define any access logfiles within a <VirtualHost>
# container, they will be logged here.  Contrariwise, if you *do*
# define per-<VirtualHost> access logfiles, transactions will be
# logged therein and *not* in this file. In this case you have to
# modify awstats yourself to point to the correct, combined log file.
<IfDefine AWSTATS>
    CustomLog /var/log/apache2/awstats.log combined

    Alias /awstats/icon/ "%{_datadir}/awstats/icon/"
    <Directory "%{_datadir}/awstats/icon">
        Options Indexes MultiViews
        AllowOverride None

    Alias /awstats/lang/ "%{_datadir}/awstats/lang/"
    <Directory "%{_datadir}/awstats/lang">
        AllowOverride None

    Alias /awstats/css/ "%{_datadir}/awstats/css/"
    <Directory "%{_datadir}/awstats/css/">
        AllowOverride None

    Alias /awstatsclasses "%{_datadir}/awstats/classes"
    <Directory "%{_datadir}/awstats/classes">
        AllowOverride None

    Alias /awstats/js/ "%{_datadir}/awstats/js/"
    <Directory "%{_datadir}/awstats/js/">
        AllowOverride None

# install docu
mkdir -p %{buildroot}%{_defaultdocdir}/%{name}/examples
# install the scripts in tools into the examples dir
mv %{buildroot}%{_datadir}/awstats/plugins/example/* %{buildroot}%{_defaultdocdir}/%{name}/examples/
rm -rf %{buildroot}%{_datadir}/awstats/plugins/example
for file in $(find tools/ -name *.pl); do
	sed -e 's/\r$//' $file > %{buildroot}%{_defaultdocdir}/%{name}/examples/$(basename $file)
	chmod +x %{buildroot}%{_defaultdocdir}/%{name}/examples/$(basename $file)
install -m644 README.md %{buildroot}%{_defaultdocdir}/%{name}/
cp -r docs %{buildroot}%{_defaultdocdir}/%{name}/
chmod -x   %{buildroot}%{_defaultdocdir}/%{name}/docs/*.pdf
chmod -x   %{buildroot}%{_defaultdocdir}/%{name}/docs/*.html
chmod -x   %{buildroot}%{_defaultdocdir}/%{name}/docs/images/*
chmod -x   %{buildroot}%{_defaultdocdir}/%{name}/docs/*.txt 
install -m644 wwwroot/cgi-bin/awstats.model.conf %{buildroot}%{_defaultdocdir}/%{name}/
install -m644 %{SOURCE9} %{buildroot}%{_defaultdocdir}/%{name}/README.SUSE
rm %{buildroot}%{_defaultdocdir}/%{name}/docs/COPYING.TXT

%if 0%{?suse_version} > 1020
%fdupes -s %{buildroot}%{_defaultdocdir}/%{name}


# workaround for incomplete fix of CVE-2017-1000501
if [ ! -f %{_sysconfdir}/awstats/awstats.conf ]; then
    cat > %{_sysconfdir}/awstats/awstats.conf << EOF
# The existence of this file prevents awstats from attempting to parse
# arbitrary absolute paths as awstats configurations.
# https://github.com/eldy/awstats/issues/90
# You may replace this file with your own configuration.

%doc %{_mandir}/man8/awstats-update.8.gz
%dir %{_sysconfdir}/awstats
%dir %{apache_sysconfdir}/conf.d
%dir %{_datadir}/awstats
%config(noreplace) %{_sysconfdir}/logrotate.d/awstats
%config(noreplace) %{apache_sysconfdir}/conf.d/awstats.conf
%config(noreplace) %{_sysconfdir}/cron.d/suse.de-awstats
%config(noreplace) %{_sysconfdir}/awstats/awstats.web.conf
%config(noreplace) %{_sysconfdir}/awstats/awstats.vsftp.conf
%config(noreplace) %{_sysconfdir}/awstats/awstats.smtp.conf
%dir %{_var}/cache/awstats

%files doc
%defattr(0644,root,root, 0755)
%doc %{_defaultdocdir}/%{name}