File open-cas-linux.spec of Package open-cas-linux
#
# Copyright(c) 2020-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
#
# This is a template SPEC file for generating OpenCAS RPMs automatically.
# It contains tags in form of <TAG> which are substituted with particular
# values in the build time.
#
%global __python %{__python3}
%define debug_package %{nil}
%define kver %(uname -r)
%define kver_filename k%{expand:%(kname="%{kver}"; echo "${kname%.*}" | sed -r "y/-/_/;")}
Name: open-cas-linux
Version: 22.12.0.0848.master
Release: 1%{?dist}
Summary: Open Cache Acceleration Software
Group: System/Filesystems
Vendor: Intel Corporation
License: BSD-3-Clause
URL: https://open-cas.github.io
Source0: https://github.com/Open-CAS/open-cas-linux/releases/download/v%{version}/%{name}-%{version}.tar.gz
# kernel_module_package
BuildRequires: coreutils, gawk, gcc, make, %kernel_module_package_buildreqs
BuildRequires: systemd-rpm-macros
Requires: open-cas-linux-modules-%{version}, python3, sed, python3-PyYAML
Requires: udev
%if (0%{?sle_version} >= 150600) || (0%{?suse_version} >= 1600)
BuildRequires: python3, util-linux-systemd
BuildRequires: procps, udev, dracut, openSUSE-release
BuildRequires: stgit, polkit, filesystem, systemd
Requires: stgit systemd kmod kernel-default
%endif
%description
Open Cache Acceleration Software (Open CAS) is an open source project
encompassing block caching software libraries, adapters, tools and more.
The main goal of this cache acceleration software is to accelerate a
backend block device(s) by utilizing a higher performance device(s).
This package contains tools and utilities for managing CAS and monitor
running cache instances.
%package modules_%{kver_filename}
Summary: Open Cache Acceleration Software kernel modules
Group: System/Filesystems
Requires: kmod
Provides: open-cas-linux-modules-%{version}
%description modules_%{kver_filename}
Open Cache Acceleration Software (Open CAS) is an open source project
encompassing block caching software libraries, adapters, tools and more.
The main goal of this cache acceleration software is to accelerate a
backend block device(s) by utilizing a higher performance device(s).
This package contains only CAS kernel modules.
%prep
%setup -q
%build
./configure
%make_build
%install
rm -rf $RPM_BUILD_ROOT
/usr/bin/make install_files DESTDIR=$RPM_BUILD_ROOT UDEVRULES_DIR=%{_udevrulesdir}
%pre
%service_add_pre open-cas-shutdown.service
%service_add_pre open-cas.service
%post
%service_add_post open-cas-shutdown.service
%service_add_post open-cas.service
%preun
if [ $1 -eq 0 ]; then
%service_del_preun open-cas-shutdown.service
%service_del_preun open-cas.service
rm -rf /lib/opencas/{__pycache__,*.py[co]} &>/dev/null
fi
%postun
if [ $1 -eq 0 ]; then
%service_del_postun open-cas-shutdown.service
%service_del_postun open-cas.service
fi
%post modules_%{kver_filename}
depmod
. /etc/os-release
# Determine the exact location of installed modules to add them to weak-modules
for file in $(rpm -ql $(rpm -qa | grep open-cas-linux-modules)); do
if [[ "$file" =~ .*\.ko$ ]]; then
# realpath to resolve any possible symlinks (needed for weak-modules)
modules+=( $(realpath "$file") )
fi
done
if [[ ! "$ID_LIKE" =~ suse|sles ]]; then
printf "%s\n" "${modules[@]}" | weak-modules --no-initramfs --add-modules
else
for version in $(echo "${modules[@]}" | tr " " "\n" | cut -d"/" -f4 | sort | uniq); do
# run depmod for all kernel versions for which the modules installed
depmod $version
done
fi
%service_add_post open-cas.service
%preun modules_%{kver_filename}
if [ $1 -eq 0 ]; then
. /etc/os-release
if [[ ! "$ID_LIKE" =~ suse|sles ]]; then
# Search for all CAS modules to remove them from weak-modules
# Use realpath to resolve any possible symlinks (needed for weak-modules)
realpath $(find /lib/modules/%{kver}/extra/block/opencas -name "*.ko") >/var/run/rpm-open-cas-linux-modules
fi
fi
%postun modules_%{kver_filename}
if [ $1 -eq 0 ]; then
. /etc/os-release
if [[ ! "$ID_LIKE" =~ suse|sles ]]; then
modules=( $(cat /var/run/rpm-open-cas-linux-modules) )
rm -f /var/run/rpm-open-cas-linux-modules
printf "%s\n" "${modules[@]}" | weak-modules --no-initramfs --remove-modules
fi
depmod
fi
%files
%defattr(-, root, root, 755)
%license LICENSE
%doc README.md
%dir %{_sysconfdir}/opencas/
%dir /lib/opencas/
%dir %{_sharedstatedir}/opencas
%config %{_sysconfdir}/opencas/opencas.conf
%config %{_sysconfdir}/opencas/ioclass-config.csv
%config %{_sysconfdir}/dracut.conf.d/opencas.conf
%{_sharedstatedir}/opencas/cas_version
/lib/opencas/casctl
/lib/opencas/open-cas-loader.py
/lib/opencas/opencas.py
%{_udevrulesdir}/60-persistent-storage-cas-load.rules
%{_udevrulesdir}/60-persistent-storage-cas.rules
/sbin/casadm
/sbin/casctl
/usr/lib/systemd/system-shutdown/open-cas.shutdown
%{_unitdir}/open-cas-shutdown.service
%{_unitdir}/open-cas.service
%{_mandir}/man5/opencas.conf.5.gz
%{_mandir}/man8/casadm.8.gz
%{_mandir}/man8/casctl.8.gz
%ghost /var/log/opencas.log
%ghost /lib/opencas/opencas.pyc
%ghost /lib/opencas/opencas.pyo
%ghost /lib/opencas/__pycache__
%files modules_%{kver_filename}
%defattr(644, root, root, 755)
%license LICENSE
/lib/modules/%{kver}
%changelog
* Mon Jun 17 2024 Aaron Williams <aaron.w2@gmail.com> - 22.12-1
- Update modules for OpenSUSE
- Use macros for files
- Force install to place udev rules in correct directory
- Fix rpmlint warnings
* Mon Mar 21 2022 Rafal Stefanowski <rafal.stefanowski@intel.com> - 22.03-1
- Update modules destination directory and permissions
- Add license to modules package
- Fix resolving of weak-modules symlinks
* Mon Nov 22 2021 Michal Mielewczyk <michal.mielewczyk@intel.com> - 21.06-1
- Update dependencies
* Mon Feb 8 2021 Rafal Stefanowski <rafal.stefanowski@intel.com> - 21.03-1
- Improve python files handling
* Tue Jan 5 2021 Rafal Stefanowski <rafal.stefanowski@intel.com> - 20.12-1
- Fix resolving modules path for weak-modules
* Fri Sep 11 2020 Rafal Stefanowski <rafal.stefanowski@intel.com> - 20.09-1
- SLES related modifications
- Add some missing info about a package
* Thu Jul 30 2020 Rafal Stefanowski <rafal.stefanowski@intel.com> - 20.09-1
- Improve adding and removing modules with weak-modules
* Wed Jun 10 2020 Rafal Stefanowski <rafal.stefanowski@intel.com> - 20.06-1
- Add cas_version file
- Join Release into Version
- Simplify prep setup
* Tue Feb 25 2020 Rafal Stefanowski <rafal.stefanowski@intel.com> - 20.3-1
- Minor improvements in SPEC file
- Update files list for releases > 20.1
* Thu Feb 06 2020 Rafal Stefanowski <rafal.stefanowski@intel.com> - 20.1-1
- Create this SPEC file for OpenCAS release 20.1