File epics-base.spec of Package epics-base

#
# spec file for package epics-base
#
# Copyright (c) 2022 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


%define epics_prefix %{_libdir}/epics
%define libepics_suffix %(echo %{version} | tr . _)

%ifarch aarch64 %arm
%define epics_host_arch linux-arm
%endif
%ifarch x86_64
%define epics_host_arch linux-x86_64
%endif
%ifarch %ix86
%define epics_host_arch linux-x86
%endif

Name:           epics-base
Version:        3.16.2
Release:        0
Summary:        Experimental Physics and Industrial Control System
License:        BSD-4-Clause
Group:          Productivity/Scientific/Physics
Url:            https://epics.anl.gov
Source0:        https://epics.anl.gov/download/base/base-%{version}.tar.gz
Source1:        iocLogServer.service
Source2:        caRepeater.service
Patch0:         0001-PCAS-fix-scope-of-tsDLList-when-used-in-other-classe.patch
BuildRequires:  fdupes
BuildRequires:  gcc
BuildRequires:  gcc-c++
BuildRequires:  gzip
BuildRequires:  make
BuildRequires:  perl
BuildRequires:  readline-devel
BuildRequires:  pkg-config
ExclusiveArch:  aarch64 %arm %ix86 x86_64

%description
EPICS (Experimental Physics and Industrial Control System) is a toolchain
allowing the user to create a professional control system infrastructure. EPICS
is developed by the Argonne National Laboratory located in Lemont, Illinois,
USA, the Berliner Elektronenspeicherring-Gesellschaft für Synchrotonstrahlung
mbH (BESSY) from Germany and others.

%package -n epics-catools
Summary:        Command line utilities for EPICS
Group:          Productivity/Scientific/Physics

%description -n epics-catools
EPICS utilities such as caget and caput as well as the caRepeater daemon.

%package -n epics-devel
Summary:        Development libraries and header files for for EPICS
Group:          Development/Libraries/C and C++
Requires:       libepics-%{libepics_suffix} = %{version}-%{release}

%description -n epics-devel
This package contains the header files and libraries for building
programs using EPICS.

%package -n perl-epics
Summary:        Perl bindings for EPICS
Group:          Development/Languages/Perl
Requires:       perl = %{perl_version}

%description -n perl-epics
This package contains the Perl bindings for EPICS.

%package -n epics-doc
Summary:        Documentation for EPICS
Group:          Documentation/Howto

%description -n epics-doc
This package contains documentation on using EPICS.

%package -n libepics-%{libepics_suffix}
Summary:        Experimental Physics and Industrial Control System
Group:          System/Libraries
Provides:       libepics = %{version}-%{release}

%description -n libepics-%{libepics_suffix}
EPICS (Experimental Physics and Industrial Control System) is a toolchain
allowing the user to create a professional control system infrastructure. EPICS
is developed by the Argonne National Laboratory located in Lemont, Illinois,
USA, the Berliner Elektronenspeicherring-Gesellschaft für Synchrotonstrahlung
mbH (BESSY) from Germany and others.

%package -n epics-iocLogServer
Summary:        Log recorder daemon for EPICS IOCS
Group:          Productivity/Scientific/Physics
Requires(pre):  pwdutils
%{?systemd_requires}

%description -n epics-iocLogServer
The IOC log server listens for network log messages sent from IOC. This is used
by the caputlog support module to collect messages relating to PV value
changes.

%package -n epics-caRepeater
Summary:        EPICS CA Repeater daemon
Group:          Productivity/Scientific/Physics
%{?systemd_requires}

%description -n epics-caRepeater
EPICS CA Repeater daemon

%prep
%autosetup -p1 -n base-%{version}

# Replace unreproducible timestamp
sed -i -e 's/localtime()/localtime(%ENV{"SOURCE_DATE_EPOCH"} || time)/' src/libCom/error/makeStatTbl.pl

%build
%ifarch %arm aarch64
# Upstream build system has missed soname setup for ARM architectures

cat >>configure/os/CONFIG_SITE.linux-arm.linux-arm <<EOF

STATIC_LDFLAGS_YES= -Wl,-Bstatic
STATIC_LDFLAGS_NO=
STATIC_LDLIBS_YES= -Wl,-Bdynamic
STATIC_LDLIBS_NO=

SHRLIB_LDFLAGS += -Wl,-h\$@
LOADABLE_SHRLIB_LDFLAGS += -Wl,-h\$@
EOF
%endif

LD_LIBRARY_PATH="${PWD}/lib/%{epics_host_arch}":${LD_LIBRARY_PATH} make %{?_smp_mflags} \
	EPICS_HOST_ARCH=%{epics_host_arch} \
	USR_CFLAGS="%optflags" \
	USR_CXXFLAGS="%optflags" \
	STATIC_BUILD=NO \
	LINKER_USE_RPATH=NO \
	FINAL_LOCATION=%{epics_prefix} \
	IOCS_APPL_TOP=%{epics_prefix} \
	EPICS_SITE_VERSION=%{version}

%install
LD_LIBRARY_PATH="${PWD}/lib/%{epics_host_arch}":${LD_LIBRARY_PATH} make %{?_smp_mflags} \
	EPICS_HOST_ARCH=%{epics_host_arch} \
	USR_CFLAGS="%optflags" \
	USR_CXXFLAGS="%optflags" \
	STATIC_BUILD=NO \
	LINKER_USE_RPATH=NO \
	INSTALL_LOCATION=%{buildroot}%{epics_prefix} \
	FINAL_LOCATION=%{epics_prefix} \
	IOCS_APPL_TOP=%{epics_prefix} \
	EPICS_SITE_VERSION=%{version} \
	install

mkdir -p %{buildroot}%{_bindir}
for I in caget cainfo camonitor caput caRepeater casw ascheck makeBaseApp.pl makeBaseExt.pl softIoc iocLogServer msi
do
	mv %{buildroot}%{epics_prefix}/bin/%{epics_host_arch}/$I %{buildroot}%{_bindir}/$I
done

for I in libCom libca libcas libdbCore libdbRecStd libgdd
do
	mv %{buildroot}%{epics_prefix}/lib/%{epics_host_arch}/$I.so.%{version} %{buildroot}%{_libdir}/$I.so.%{version}
	ln -s %{_libdir}/$I.so.%{version} %{buildroot}%{epics_prefix}/lib/%{epics_host_arch}/$I.so.%{version}
done

mkdir -p %{buildroot}%{_datadir}
mv %{buildroot}%{epics_prefix}/lib/pkgconfig %{buildroot}%{_datadir}/pkgconfig

# Drop static libraries
find %{buildroot}%{epics_prefix}/lib/%{epics_host_arch} -name *.a -delete

# Drop html (it goes to /usr/share/doc/packages)
rm -rf %{buildroot}%{epics_prefix}/html

# Perl
mkdir -p %{buildroot}%{perl_vendorlib}
mv %{buildroot}%{epics_prefix}/lib/perl/EPICS %{buildroot}%{perl_vendorlib}
mkdir -p %{buildroot}%{perl_vendorarch}
mv %{buildroot}%{epics_prefix}/lib/perl/CA.pm %{buildroot}%{perl_vendorarch}
mkdir -p %{buildroot}%{perl_vendorarch}/auto
mv %{buildroot}%{epics_prefix}/lib/perl/5.*/*/libCap5.so %{buildroot}%{perl_vendorarch}/auto/
find %{buildroot}%{epics_prefix} -name libCap5.so -delete

for I in S99caRepeater S99logServer caRepeater.service
do
	find %{buildroot}%{epics_prefix} -name $I -delete
done

install -D -m 0644 %{S:1} %{buildroot}%{_unitdir}/iocLogServer.service
install -D -m 0644 %{S:2} %{buildroot}%{_unitdir}/caRepeater.service

mkdir -p %{buildroot}%{_sbindir}
ln -s /sbin/service %{buildroot}%{_sbindir}/rciocLogServer
ln -s /sbin/service %{buildroot}%{_sbindir}/rccaRepeater

mkdir -p %{buildroot}%{_var}/log/epics

%fdupes %buildroot
find %{buildroot} -type f -name "*.pl" -exec sed -i "s|#!%{_bindir}/env perl|#!%{_bindir}/perl|" {} \;

%post -n libepics-%{libepics_suffix} -p /sbin/ldconfig

%postun -n libepics-%{libepics_suffix} -p /sbin/ldconfig

%pre -n epics-caRepeater
%service_add_pre caRepeater.service

%post -n epics-caRepeater
%service_add_post caRepeater.service

%preun -n epics-caRepeater
%service_del_preun caRepeater.service
%stop_on_removal caRepeater

%postun -n epics-caRepeater
%service_del_postun caRepeater.service
%restart_on_update caRepeater

%pre -n epics-iocLogServer
getent group epics || /usr/sbin/groupadd -r epics || :
getent passwd epics || /usr/sbin/useradd -g epics -s /bin/false -r -c "Log recorder daemon for EPICS IOCS" -d %{_var}/log/epics epics || :

%service_add_pre iocLogServer.service

%post -n epics-iocLogServer
%service_add_post iocLogServer.service

%preun -n epics-iocLogServer
%service_del_preun iocLogServer.service
%stop_on_removal iocLogServer

%postun -n epics-iocLogServer
%service_del_postun iocLogServer.service
%restart_on_update iocLogServer

%files -n epics-catools
%license LICENSE
%{_bindir}/caget
%{_bindir}/cainfo
%{_bindir}/camonitor
%{_bindir}/caput
%{_bindir}/casw

%files -n epics-devel
%license LICENSE
%dir %{epics_prefix}
%dir %{epics_prefix}/bin
%{epics_prefix}/bin/linux-*
%{epics_prefix}/configure
%{epics_prefix}/db
%{epics_prefix}/dbd
%{epics_prefix}/include
%{epics_prefix}/templates
%dir %{epics_prefix}/lib
%dir %{epics_prefix}/lib/linux-*
%{epics_prefix}/lib/linux-*/libCom.so
%{epics_prefix}/lib/linux-*/libCom.so.%{version}
%{epics_prefix}/lib/linux-*/libca.so
%{epics_prefix}/lib/linux-*/libca.so.%{version}
%{epics_prefix}/lib/linux-*/libcas.so
%{epics_prefix}/lib/linux-*/libcas.so.%{version}
%{epics_prefix}/lib/linux-*/libdbCore.so
%{epics_prefix}/lib/linux-*/libdbCore.so.%{version}
%{epics_prefix}/lib/linux-*/libdbRecStd.so
%{epics_prefix}/lib/linux-*/libdbRecStd.so.%{version}
%{epics_prefix}/lib/linux-*/libgdd.so
%{epics_prefix}/lib/linux-*/libgdd.so.%{version}
%{_datadir}/pkgconfig/epics-base-linux-*.pc
%{_datadir}/pkgconfig/epics-base.pc
%{_bindir}/ascheck
%{_bindir}/makeBaseApp.pl
%{_bindir}/makeBaseExt.pl
%{_bindir}/softIoc
%{_bindir}/msi
%dir %{epics_prefix}/lib/perl
%attr(0755,root,root) %{epics_prefix}/lib/perl/EpicsHostArch.pl
%{epics_prefix}/lib/perl/DBD
%{epics_prefix}/lib/perl/DBD.pm

%files -n perl-epics
%license LICENSE
%{perl_vendorlib}/EPICS
%{perl_vendorarch}/CA.pm
%{perl_vendorarch}/auto/*

%files -n epics-doc
%license LICENSE
%doc html README

%files -n libepics-%{libepics_suffix}
%license LICENSE
%{_libdir}/libCom.so.%{version}
%{_libdir}/libca.so.%{version}
%{_libdir}/libcas.so.%{version}
%{_libdir}/libdbCore.so.%{version}
%{_libdir}/libdbRecStd.so.%{version}
%{_libdir}/libgdd.so.%{version}

%files -n epics-caRepeater
%license LICENSE
%{_unitdir}/caRepeater.service
%{_bindir}/caRepeater
%{_sbindir}/rccaRepeater

%files -n epics-iocLogServer
%license LICENSE
%{_unitdir}/iocLogServer.service
%{_bindir}/iocLogServer
%{_sbindir}/rciocLogServer
%dir %attr(-,epics,epics) %{_var}/log/epics

%changelog
openSUSE Build Service is sponsored by