Files
weewx/pkg/weewx.spec.in

139 lines
4.0 KiB
RPMSpec

# $Id$
# License: GPLv3
# Author: (c) 2013 Matthew Wall
# default configuration when OS is not known - this will fail. when it does,
# add a vendor section with an appropriate configuration.
%define layout unknown
# suse
%if 0%{?suse_version} || 0%{?sles_version}
%if 0%{?suse_version}
%define relos .suse%{suse_version}
%endif
%if 0%{?sles_version}
%define relos .sles%{sles_version}
%endif
%define layout suse
%define apacheconfdir %{_sysconfdir}/apache2/conf.d
%define apachecmd apache2
%endif
# redhat, fedora, centos
%if "%{_vendor}" == "redhat"
%define relos %{?dist:%{dist}}
%define layout redhat
%define apacheconfdir %{_sysconfdir}/httpd/conf.d
%define apachecmd httpd
%endif
%global relnum 1
%global release %{relnum}%{?relos:%{relos}}
%global dst_bin_dir %{_datadir}/%{name}
%global dst_doc_dir %{_defaultdocdir}/%{name}-%{version}
%global dst_cfg_dir %{_sysconfdir}/%{name}
Summary: weather software
Name: weewx
Version: WEEWX_VERSION
Release: %{release}
Group: Applications/Science
Source: http://sourceforge.net/projects/weewx/files/weewx/%{version}/%{name}-%{version}.tar.gz
URL: http://www.weewx.com
License: GPLv3
Requires: python, python-configobj, python-cheetah, python-imaging, pyserial, pyusb
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
BuildArch: noarch
BuildRequires: python2
%description
weewx interacts with a weather station to produce graphs, reports, and HTML
pages. weewx can upload data to the WeatherUnderground, PWSweather.com, or
CWOP.
%prep
%setup -q
%build
%install
rm -rf %{buildroot}
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{dst_bin_dir}
mkdir -p %{buildroot}%{dst_doc_dir}
mkdir -p %{buildroot}%{dst_cfg_dir}
mkdir -p %{buildroot}%{_initrddir}
# copy files from the source tree
cp -r bin/* %{buildroot}%{dst_bin_dir}
cp -r docs/* %{buildroot}%{dst_doc_dir}
cp -r skins %{buildroot}%{dst_cfg_dir}
# remove stuff that should not go out
rm %{buildroot}%{dst_cfg_dir}/skins/Standard/backgrounds/butterfly.jpg
rm %{buildroot}%{dst_cfg_dir}/skins/Standard/backgrounds/drops.gif
rm %{buildroot}%{dst_cfg_dir}/skins/Standard/backgrounds/flower.jpg
rm %{buildroot}%{dst_cfg_dir}/skins/Standard/backgrounds/leaf.jpg
rm %{buildroot}%{dst_cfg_dir}/skins/Standard/backgrounds/night.gif
# patch paths in files we care about
cat weewx.conf | sed \
-e 's%station_type =.*%station_type = Simulator%' \
-e 's%^WEEWX_ROOT =.*%WEEWX_ROOT = /%' \
-e 's%SKIN_ROOT =.*%SKIN_ROOT = /etc/weewx/skins%' \
-e 's%HTML_ROOT =.*%HTML_ROOT = /var/lib/weewx/html%' \
-e 's%archive/weewx.sdb%/var/lib/weewx/weewx.sdb%' \
-e 's%archive/stats.sdb%/var/lib/weewx/stats.sdb%' \
> %{buildroot}%{dst_cfg_dir}/weewx.conf
cat util/init.d/weewx.redhat | sed \
-e 's%WEEWX_BIN=.*%WEEWX_BIN=/usr/bin/weewxd%' \
-e 's%WEEWX_CFG=.*%WEEWX_CFG=/etc/weewx/weewx.conf%' \
> %{buildroot}%{_initrddir}/weewx
chmod 755 %{buildroot}%{_initrddir}/weewx
mkdir -p %{buildroot}%{apacheconfdir}
cat util/apache/conf.d/weewx.conf | sed \
-e 's%/home/weewx/public_html%/var/lib/weewx/html%' \
> %{buildroot}%{apacheconfdir}/weewx.conf
# create symlinks to the code entry points
ln -s ../share/weewx/weewxd.py %{buildroot}%{_bindir}/weewxd
ln -s ../share/weewx/runreports.py %{buildroot}%{_bindir}/wee-reports
ln -s ../share/weewx/config-database.py %{buildroot}%{_bindir}/wee-config-database
ln -s ../share/weewx/config-fousb.py %{buildroot}%{_bindir}/wee-config-fousb
ln -s ../share/weewx/config-vp.py %{buildroot}%{_bindir}/wee-config-vp
# pre-compile the python code
python -m compileall %{buildroot}%{dst_bin_dir}
%post
python -m compileall %{dst_bin_dir}
chkconfig weewx on
%{_initrddir}/weewx start
%{_initrddir}/%{apachecmd} restart
%preun
%{_initrddir}/weewx stop
chkconfig weewx off
%postun
%{_initrddir}/%{apachecmd} restart
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root)
%attr(755,root,root) %{_initrddir}/weewx
%{dst_bin_dir}/
%{_bindir}/weewxd
%{_bindir}/wee-reports
%{_bindir}/wee-config-database
%{_bindir}/wee-config-fousb
%{_bindir}/wee-config-vp
%doc %{dst_doc_dir}/
%config(noreplace) %{dst_cfg_dir}/
%config(noreplace) %{apacheconfdir}/weewx.conf
%changelog