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 7
%define widgetslibver %{nil}
%define data_dir /var/dls_data


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

Requires(pre): shadow
Requires: desktop-file-utils
Recommends:    dlsgui

BuildRequires: fftw3-devel
BuildRequires: fltk-devel
BuildRequires: fontconfig-devel
BuildRequires: gcc-c++
BuildRequires: libXext-devel
BuildRequires: libXft-devel
BuildRequires: libXinerama-devel
BuildRequires: xorg-x11-proto-devel
BuildRequires: shared-mime-info
BuildRequires: desktop-file-utils
BuildRequires: libpdcom5-devel
BuildRequires: protobuf-devel
BuildRequires: libxml2-devel
BuildRequires: cmake
BuildRequires: pkg-config
BuildRequires: pcre-devel
BuildRequires: git
BuildRequires: hdf5-devel

%if 0%{?suse_version}

PreReq: permissions

Requires(post): %fillup_prereq

Requires: cron

BuildRequires: liburiparser-devel

%if 0%{?suse_version} > 1500
BuildRequires: abseil-cpp-devel
BuildRequires: libfltk1_3
%else
BuildRequires: libfltk1
%endif

BuildRequires: libqt5-linguist-devel
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

%else

# Fedora
BuildRequires: glibc-all-langpacks
BuildRequires: uriparser-devel
BuildRequires: fltk-devel
BuildRequires: fltk-fluid
BuildRequires: qt5-qtbase-devel
BuildRequires: qt5-qtsvg-devel
BuildRequires: qt5-qttools-devel
%undefine _hardened_build

%endif

BuildRequires: systemd-rpm-macros
%{?systemd_requires}

%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 dlsgui
Summary:        Graphical User Interface for Data Logging Service
Summary(de):    Grafische Benutzeroberfläche für den Data Logging Service


%description -n dlsgui
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.

This package contains a Qt-based GUI to view and export recorded data.

%package -n libdls%libver
Summary:        Library to interact with the Data Logging Service
Summary(de):    Bibilothek zur Interaktion mit dem Data Logging Service

%description -n libdls%libver
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.

This package contains a C++ library to access the data.

%package -n libDlsWidgets%{widgetslibver}
Summary:        Qt5 based widgets to view and export data from the Data Logging Service
Summary(de):    Qt5-basierte Widgetsammlung zum Zugriff auf die aufgezeichneten Daten des DLS

%description -n libDlsWidgets%{widgetslibver}
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.

This package contains a C++ library to access the data.



%package -n libdls-devel
Summary:        Development files for data logging service library
Summary(de):    Entwickungsdateien für die DLS Bibilothek
Group:          Development/Libraries/C and C++
Requires:       libdls%{libver} = %version
Requires:       fftw3-devel
Requires:       zlib-devel

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

%package -n libDlsWidgets-devel
Summary:        Development files for data logging service widgets
Summary(de):    Entwickungsdateien für die DLS Widgets
Group:          Development/Libraries/C and C++
Requires:       libDlsWidgets%{widgetslibver} = %version
Requires:       libdls-devel

%description -n libDlsWidgets-devel
The %name-devel package contains header files
needed for development with DLS widgets.

%prep
%setup -n %{name}-%{version}

# Write revision information (known here though set_version to file, so that
# revision.sh can find it.
echo %{version} >> revision

%build
%cmake -DCMAKE_INSTALL_SYSCONFDIR=%{_sysconfdir} -DVERSION=%{Version} \
    -DDLSD_INSTALL_SERVICE=%{_unitdir}/

%cmake_build

%install
%cmake_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
%else
    rm ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/dls
%endif

%if "%{_vendor}" == "suse"
    ln -s service ${RPM_BUILD_ROOT}%{_sbindir}/rcdls
%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

rm ${RPM_BUILD_ROOT}%{_libdir}/qt5/plugins/designer/libDlsWidgets.so
ln -s %{_libdir}/libDlsWidgets.so \
    ${RPM_BUILD_ROOT}%{_libdir}/qt5/plugins/designer/libDlsWidgets.so

%verifyscript
%verify_permissions -e %{_bindir}/dls_ctl
%verify_permissions -e %{_bindir}/dls_view
%verify_permissions -e %{_bindir}/dlsgui
%verify_permissions -e %{_sysconfdir}/cron.d/

%pre
%service_add_pre dls.service
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
%{fillup_only dls}
%service_add_post dls.service
%set_permissions %{_bindir}/dls_ctl
%set_permissions %{_bindir}/dls_view
%set_permissions %{_bindir}/dlsgui
%set_permissions %{_sysconfdir}/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
%{_bindir}/update-mime-database /usr/share/mime
touch /usr/share/icons/hicolor
%{_bindir}/update-desktop-database

%post -n dlsgui
%{_bindir}/update-mime-database /usr/share/mime
touch /usr/share/icons/hicolor
%{_bindir}/update-desktop-database

%preun
%service_del_preun dls.service

%postun
%service_del_postun dls.service
/sbin/ldconfig
%{_bindir}/update-mime-database /usr/share/mime
touch /usr/share/icons/hicolor
%{_bindir}/update-desktop-database
%restart_on_update dls

%post -n libdls%{libver} -p /sbin/ldconfig

%postun -n libdls%{libver} -p /sbin/ldconfig

%post -n libDlsWidgets%{widgetslibver} -p /sbin/ldconfig

%postun -n libDlsWidgets%{widgetslibver} -p /sbin/ldconfig

%files
%defattr(-,root,root)
%doc AUTHORS 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
%{_unitdir}/dls.service
%{_bindir}/dls
%attr(4755, root, root) %{_bindir}/dls_ctl
%{_bindir}/dlsd
%{_bindir}/dls_quota
%{_bindir}/dls_status
%{_bindir}/dls_view
%if "%{_vendor}" == "suse"
%{_sbindir}/rcdls
%endif
%{_datadir}/applications/dls_ctl.desktop
%{_datadir}/applications/dls_view.desktop
%{_datadir}/icons/hicolor

%files -n dlsgui
%defattr(-,root,root)
%{_bindir}/dlsgui
%{_datadir}/applications/dlsgui.desktop
%{_datadir}/mime/packages/dlsgui-mime.xml


%files -n libdls%{libver}
%defattr(-,root,root)
%{_libdir}/libdls.so.*

%files -n libDlsWidgets%{widgetslibver}
%defattr(-,root,root)
%{_libdir}/libDlsWidgets.so

%files -n libDlsWidgets-devel
%defattr(-,root,root)
%{_includedir}/DlsWidgets
%dir %{_libdir}/qt5/plugins/designer
%{_libdir}/qt5/plugins/designer/libDlsWidgets.so
%{_libdir}/cmake/DlsWidgets

%files -n libdls-devel
%defattr(-,root,root)
%{_includedir}/LibDLS
%{_libdir}/libdls.so
%{_libdir}/cmake/dls

%changelog
* Thu Oct 12 2023 vh@igh.de
- Use PdCom5
* Thu Mar 16 2023 vh@igh.de
- Switch to CMake
* 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