File DLS.spec of Package DLS

#
# This file is part of the Data Logging Service (DLS).
#
# DLS is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# DLS is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along
# with DLS. If not, see <http://www.gnu.org/licenses/>.
#
# vim: tw=78 spelllang=en
#

Name: dls
Version: 0 # set by set_version service
Release: 1

%define libver 6
%define data_dir /var/dls_data

%if 0%{?suse_version} >= 1210
%bcond_without systemd
%else
%bcond_with systemd
%endif

Summary: Data Logging Service
License: GPL-3.0-or-later
Vendor: Ingenieurgemeinschaft IgH GmbH
Group: Productivity/Scientific/Other
Url: http://etherlab.org/en/dls
Source0: %{name}-%{version}.tar.bz2
Source1: dls-rpmlintrc
PreReq: permissions
BuildRoot: %_tmppath/%name-%{version}-root

Requires(pre): shadow
Requires(post): %fillup_prereq
%if %{without systemd}
Requires(post): %insserv_prereq
%endif
Requires: cron
Requires: desktop-file-utils

BuildRequires: fftw3-devel
BuildRequires: fltk-devel
BuildRequires: fontconfig-devel
BuildRequires: gcc-c++
BuildRequires: libXext-devel
BuildRequires: libXft-devel
BuildRequires: libXinerama-devel
BuildRequires: libfltk1
BuildRequires: xorg-x11-proto-devel
BuildRequires: shared-mime-info
BuildRequires: desktop-file-utils
BuildRequires: liburiparser-devel
BuildRequires: libpdcom1-devel
BuildRequires: protobuf-devel
BuildRequires: libxml2-devel
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: libtool
BuildRequires: pcre-devel
BuildRequires: mercurial

%if 0%{?suse_version} == 1310
BuildRequires: libqt5-qtbase-devel
%else
BuildRequires: libqt5-qtbase-common-devel
BuildRequires: libQt5Core-devel
BuildRequires: libQt5Network-devel
BuildRequires: libQt5Widgets-devel
BuildRequires: libqt5-qtsvg-devel
BuildRequires: libQt5Test-devel
BuildRequires: libQt5Svg-devel
BuildRequires: libqt5-qttools-devel
BuildRequires: libQt5PrintSupport-devel
%endif

%if %{with systemd}
BuildRequires: systemd-rpm-macros
%{?systemd_requires}
%endif

%if ! %{defined _fillupdir}
%define _fillupdir /var/adm/fillup-templates
%endif

%description
DLS is a process data logging service, capable of capturing high-frequency
data over a long time and storing it in a compressed way. The aim is to allow
the user unlimited high-performance access to the data at any time. Be it a
year's overview or a small signal peak in fractions of a second.

%package -n dls-devel
Summary:        Development files for data logging service
Summary(de):    Entwickungsdateien für den DLS
Group:          Development/Libraries/C and C++
Requires:       %name = %version
Requires:       fftw3-devel
Requires:       zlib-devel

%description -n dls-devel
The %name-devel package contains the static libraries and header files
needed for development with %name.

%prep
%setup -n %{name}-%{version}
hg log --branch default --style=changelog > ChangeLog

%build
./bootstrap.sh
%configure
make %{?_smp_mflags}
cd widgets
qmake-qt5 PREFIX=%{_prefix} LIBDIR=%{_libdir}
make %{?_smp_mflags}
cd ..
cd gui
qmake-qt5 PREFIX=%{_prefix}
make %{?_smp_mflags}
cd ..

%install
make DESTDIR=${RPM_BUILD_ROOT} install

# apply settings to sysconfig file
sed -i s:#DLS_DIR=/vol/dls_data:DLS_DIR=%{data_dir}: \
    ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/dls
sed -i s:#DLS_USER=dls:DLS_USER=dls: \
    ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/dls

%if "%{_vendor}" == "suse"
    install -d ${RPM_BUILD_ROOT}%{_sbindir}
    install -d ${RPM_BUILD_ROOT}%{_fillupdir}
    mv ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/dls \
        ${RPM_BUILD_ROOT}%{_fillupdir}/sysconfig.dls
%endif

%if %{with systemd}
    install -D -m 644 script/dls.service %{buildroot}%{_unitdir}/dls.service
    rm  ${RPM_BUILD_ROOT}%{_sysconfdir}/init.d/dls
    %if "%{_vendor}" == "suse"
        ln -s service ${RPM_BUILD_ROOT}%{_sbindir}/rcdls
    %endif
%else
    %if "%{_vendor}" == "suse"
        ln -s %{_sysconfdir}/init.d/dls ${RPM_BUILD_ROOT}%{_sbindir}/rcdls
    %endif
%endif

# install cron file for quota service
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/cron.d
cat <<'EOF' > ${RPM_BUILD_ROOT}%{_sysconfdir}/cron.d/dls_quota
DOQUOTA=%{_bindir}/dls_quota
54 02 * * * dls test -x $DOQUOTA && $DOQUOTA -i 0 -d %{data_dir}
EOF

cd widgets
make install INSTALL_ROOT=${RPM_BUILD_ROOT}
cd ..
cd gui
make install INSTALL_ROOT=${RPM_BUILD_ROOT}
cd ..

%clean
%{__rm} -rf $RPM_BUILD_ROOT

%verifyscript
%verify_permissions -e /usr/bin/dls_ctl
%verify_permissions -e /usr/bin/dls_view
%verify_permissions -e /usr/bin/dlsgui
%verify_permissions -e /etc/cron.d/

%pre
%if %{with systemd}
%service_add_pre dls.service
%endif
getent group dls >/dev/null || groupadd -r dls
getent passwd dls >/dev/null || useradd -r -g dls -d %{data_dir} \
    -s /sbin/nologin -c "DLS user" dls
exit 0

%post
%if %{with systemd}
%{fillup_only dls}
%service_add_post dls.service
%else
%{fillup_and_insserv dls}
%endif
%set_permissions /usr/bin/dls_ctl
%set_permissions /usr/bin/dls_view
%set_permissions /usr/bin/dlsgui
%set_permissions /etc/cron.d/
/sbin/ldconfig
if ! test -d %{data_dir}; then
    mkdir -p %{data_dir}
    mkdir %{data_dir}/spool
    echo 100 > %{data_dir}/id_sequence
    chown -R dls:dls %{data_dir}
fi
/usr/bin/update-mime-database /usr/share/mime
touch /usr/share/icons/hicolor
/usr/bin/update-desktop-database

%preun
%if %{with systemd}
%service_del_preun dls.service
%endif
%stop_on_removal

%postun
%if %{with systemd}
%service_del_postun dls.service
%else
%insserv_cleanup
%endif
/sbin/ldconfig
/usr/bin/update-mime-database /usr/share/mime
touch /usr/share/icons/hicolor
/usr/bin/update-desktop-database
%restart_on_update

%files
%defattr(-,root,root)
%doc AUTHORS ChangeLog COPYING NEWS
%config %{_sysconfdir}/profile.d/dls.sh
%dir %{_sysconfdir}/cron.d
%config %{_sysconfdir}/cron.d/dls_quota
%if "%{_vendor}" == "suse"
%{_fillupdir}/sysconfig.dls
%endif
%if %{with systemd}
%{_unitdir}/dls.service
%else
%{_sysconfdir}/init.d/dls
%endif
%{_bindir}/dls*
%if "%{_vendor}" == "suse"
%{_sbindir}/rcdls
%endif
%{_datadir}/applications/*.desktop
%{_datadir}/mime/packages/*.xml
%{_datadir}/icons/hicolor
%{_libdir}/libdls.so.%{libver}.0.0
%{_libdir}/libDlsWidgets.so

%files -n dls-devel
%defattr(-,root,root,755)
%dir %{_includedir}/DlsWidgets
%{_includedir}/DlsWidgets/Graph.h
%{_includedir}/DlsWidgets/Layer.h
%{_includedir}/DlsWidgets/Model.h
%{_includedir}/DlsWidgets/Scale.h
%{_includedir}/DlsWidgets/Section.h
%{_includedir}/DlsWidgets/Translator.h
%{_includedir}/DlsWidgets/ValueScale.h
%dir %{_includedir}/LibDLS
%{_includedir}/LibDLS/Channel.h
%{_includedir}/LibDLS/ChannelPreset.h
%{_includedir}/LibDLS/Chunk.h
%{_includedir}/LibDLS/Data.h
%{_includedir}/LibDLS/Dir.h
%{_includedir}/LibDLS/Exception.h
%{_includedir}/LibDLS/Export.h
%{_includedir}/LibDLS/Job.h
%{_includedir}/LibDLS/JobPreset.h
%{_includedir}/LibDLS/Time.h
%{_includedir}/LibDLS/globals.h
%{_libdir}/libdls.a
%{_libdir}/libdls.la
%{_libdir}/libdls.so.%{libver}
%{_libdir}/libdls.so
%{_libdir}/qt5/plugins/designer
%{_libdir}/qt5/plugins/designer/libDlsWidgets.so

%changelog
* Tue Mar 27 2018 fp@igh.de
- Fixed cron file variables.
* Mon Mar 26 2018 fp@igh.de
- Removed package_version (set by set_version sevice)
- Add user, data directory and cronjob
* Tue Jan 8 2013 fp@igh-essen.com
- Added some BuildRequires
* Thu Jan 26 2012 fp@igh-essen.com
- Used macro dirs
- Added .desktop files
* Mon Jan 23 2012 fp@igh-essen.com
- Improved Url, BuildRoot, Source, BuildRequires.
openSUSE Build Service is sponsored by