Blob Blame Raw
%if 0%{?rhel}
%global apxs /usr/sbin/apxs
%endif
%if 0%{?fedora}
%global apxs /usr/bin/apxs
%endif
%global mirrorbrain_user mirrorbrain
%global mirrorbrain_group mirrorbrain
%global apache apache
%global apache_libexecdir %(%{apxs} -q LIBEXECDIR)
%global apache_sysconfdir %(%{apxs} -q SYSCONFDIR)
%global apache_includedir %(%{apxs} -q INCLUDEDIR)
%global apache_serverroot %(%{apxs} -q PREFIX)
%global apache_localstatedir %(%{apxs} -q LOCALSTATEDIR)

Name:		mirrorbrain
Summary:	A download redirector and metalink generator
Url:		http://mirrorbrain.org/
Version:	2.18.1
Release:	2%{?dist}
# ASL licensed files are: mod_autoindex_mb.c, mod_mirrorbrain.c, null-rsync
# Other files are licensed under the GPLv2
License:	ASL 2.0 and GPLv2
Group:		Applications/Internet
Source:		http://mirrorbrain.org/files/releases/mirrorbrain-%{version}.tar.gz
# Mirrorbrain ships a modified version of the zsync library.
Patch0:         zsync_modified_version.patch 
Requires(pre):	shadow-utils	

BuildRequires:	httpd-devel
BuildRequires:	geoip
BuildRequires:	geoip-devel
BuildRequires:	mod_form
BuildRequires:	python2-devel

%description
This apache module redirects clients to mirror servers, using an SQL backend,
and generates metalinks.

%package doc
License:        ASL 2.0 and GPLv2
Summary:        MirrorBrain redirector Apache module
Group:          Applications/Internet
Requires:	%{name}%{?_isa} = %{version}-%{release}

%description doc
MirrorBrain is a scalable download redirector.

This package contains the documentation.


%package -n mod_mirrorbrain
License:	ASL 2.0 and GPLv2
Summary:	MirrorBrain redirector Apache module
Group:		Applications/Internet
Requires:	httpd
Requires:	apr-util-pgsql
Requires:	geoip
Requires:	mod_geoip
Requires:	mod_form
Requires:	%{name}%{?_isa} = %{version}-%{release}


%description -n mod_mirrorbrain
MirrorBrain is a scalable download redirector.

This package contains mod_mirrorbrain, the Apache module which represents the
core of MirrorBrain.


%package -n mod_autoindex_mb
License:	ASL 2.0 and GPLv2
Summary:	Apache module generating directory indexes for MirrorBrain
Group:		Applications/Internet
Requires:	mod_mirrorbrain
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description -n mod_autoindex_mb

This package contains mod_autoindex_mb, the Apache module which represents the
core of MirrorBrain.

This package contains mod_autoindex_mb, which is a patched mod_autoindex. It
adds a little further capability as index option.

It adds these two options:

        <IfModule mod_autoindex_mb.c>
            IndexOptions Metalink
            IndexOptions Mirrorlist
        </IfModule>

The Metalink option adds a link named "Metalink" to the index, which links to
the same file but with ".metalink" appended.

The MirrorList option adds a link named "Mirrors" to the index, which links to
the same resources but with "?mirrorlist" appended.


%package tools
License:	ASL 2.0 and GPLv2
Summary:	MirrorBrain commandline tools
Group:		Applications/Internet
Requires:	python-mb
Requires:	python-cmdln
Requires:	python-sqlobject
Requires:	python-psycopg2
Requires:	geoip
Requires:	logrotate
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description tools
MirrorBrain is a scalable download redirector.

This package contains utilities provided by the MirrorBrain framework to
maintain the database and scan mirrors.


%package -n python-mb
License:	ASL 2.0 and GPLv2
Summary:	Python module used by the MirrorBrain commandline tools
Group:		Applications/Internet
Requires:	python-sqlobject
Requires:	python-psycopg2
Requires:	geoip
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description -n python-mb
MirrorBrain is a scalable download redirector.

This package contains a Python module (named "mb") for easily maintaining
MirrorBrain.


%package scanner
License:	ASL 2.0 and GPLv2
Summary:	MirrorBrain scanner
Group:		Applications/Internet
Requires:	perl(Config::IniFiles)
Requires:	perl(Digest::MD4)
Requires:	perl(DBD::Pg)
Requires:	perl-TimeDate
Requires:	perl-libwww-perl
Requires:       perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version))
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description scanner
MirrorBrain is a scalable download redirector.

This package contains the mirror scanner.


%prep
%setup -q -n mirrorbrain-%{version}
%patch0 -p1

%build
cd mod_mirrorbrain
%{apxs} -c -Wc,"%{optflags}" -lm mod_mirrorbrain.c
cd ../mod_autoindex_mb
%{apxs} -c -Wc,"%{optflags}" mod_autoindex_mb.c
cd ../tools
gcc %{optflags} -Wall -o geoiplookup_continent geoiplookup_continent.c -lGeoIP
gcc %{optflags} -Wall -o geoiplookup_city geoiplookup_city.c -lGeoIP
cd ../mb
CFLAGS="%{optflags}" \
%{__python2} setup.py build


%install
mkdir -p %{buildroot}/%{apache_libexecdir}
cp -p mod_mirrorbrain/.libs/mod_mirrorbrain.so %{buildroot}/%{apache_libexecdir}
cp -p mod_autoindex_mb/.libs/mod_autoindex_mb.so %{buildroot}/%{apache_libexecdir}
# tools
install -D -p -m 755 tools/geoiplookup_continent %{buildroot}/%{_bindir}/geoiplookup_continent
install -D -p -m 755 tools/geoiplookup_city %{buildroot}/%{_bindir}/geoiplookup_city
install -D -p -m 755 tools/bdecode %{buildroot}/%{_bindir}/bdecode
install -D -p -m 755 tools/rsyncinfo %{buildroot}/%{_bindir}/rsyncinfo
install -D -p -m 755 tools/rsyncusers %{buildroot}/%{_bindir}/rsyncusers
install -D -p -m 755 tools/geoip-lite-update %{buildroot}/%{_bindir}/geoip-lite-update
install -D -p -m 755 tools/create_timestamp %{buildroot}/%{_bindir}/create_timestamp
install -D -p -m 755 tools/null-rsync %{buildroot}/%{_bindir}/null-rsync
install -D -p -m 755 tools/scanner.pl %{buildroot}/%{_bindir}/scanner
install -D -p -m 755 mirrorprobe/mirrorprobe.py %{buildroot}/%{_bindir}/mirrorprobe
install -D -p -m 644 tools/mirrorprobe-logrotate %{buildroot}/%{_sysconfdir}/logrotate.d/mirrorprobe

# Python mb module
cd mb
%{__python2} setup.py install --prefix=%{_prefix} --root %{buildroot}

# Icons
mkdir -p %{buildroot}/%{_datadir}/mirrorbrain
cp -a famfamfam_flag_icons %{buildroot}/%{_datadir}/mirrorbrain/

# log directory
mkdir -p %{buildroot}/%{_localstatedir}/log/mirrorbrain

# Fix permissions on the python-mb file
chmod a+x %{buildroot}%{python2_sitearch}/mb/*
chmod 644 %{buildroot}%{python2_sitearch}/mb/zsync.so

%pre
getent group %{mirrorbrain_group} >/dev/null || groupadd -r %{mirrorbrain_group}
getent passwd %{mirrorbrain_user} >/dev/null || useradd -r -g %{mirrorbrain_group} -M -s /sbin/nologin %{mirrorbrain_user}
exit 0

%files
%doc COPYING FAQ TODO 
%doc mod_autoindex_mb/NOTICE
%doc mod_mirrorbrain/*.conf
%dir %attr(750,%{mirrorbrain_user},%{mirrorbrain_group}) %{_localstatedir}/log/mirrorbrain

%files doc
%doc docs
%doc sql

%files -n mod_mirrorbrain
%{apache_libexecdir}/mod_mirrorbrain.so

%files -n mod_autoindex_mb
%{apache_libexecdir}/mod_autoindex_mb.so

%files tools
%{_bindir}/bdecode
%{_bindir}/create_timestamp
%{_bindir}/geoip-lite-update
%{_bindir}/geoiplookup_city
%{_bindir}/geoiplookup_continent
%{_bindir}/mirrorprobe
%{_bindir}/null-rsync
%{_bindir}/rsyncinfo
%{_bindir}/rsyncusers
%config(noreplace) %{_sysconfdir}/logrotate.d/mirrorprobe
%{_datadir}/mirrorbrain

%files -n python-mb
%{_bindir}/mb
%{python2_sitearch}/mb*

%files scanner
%{_bindir}/scanner

%changelog 
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.18.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Tue Feb 04 2014 Andrea Veri <averi@fedoraproject.org> 2.18.1-1
- New upstream release.

* Thu Dec 05 2013 Andrea Veri <averi@fedoraproject.org> 2.17.0-3
- Added a note about what files are licensed under the ASL 2.0.
- Moved shadow-utils as a Require(pre)
- Add a zsync_modified_version patch, we're shipping zsync.so on 
  python_sitearch/mb given this specific zsync release just contains
  the code needed for the checksums to happen.

* Thu Dec 05 2013 Andrea Veri <averi@fedoraproject.org> 2.17.0-2
- Make use of optflags.
- Don't mix $-style and %-style.
- Make sure each package depends on the base package.
- Put the docs that exceed 1M on their own package.
- Fix permissions on the python-mb's files.

* Thu Nov 28 2013 Andrea Veri <averi@fedoraproject.org> 2.17.0-1 
- First package release.