GitHub repository. (smartmontools-update-smart-drivedb.patch, refactor smartmontools-drivedb_h-update.sh). - update-smart-drivedb: Do not overwrite files in /usr/share. Use /var/lib provided by --with-drivedbinstdir. - Add smartmontools-drivedb.h version 5894 from the branch 7.5. OBS-URL: https://build.opensuse.org/package/show/Base:System/smartmontools?expand=0&rev=146
277 lines
12 KiB
RPMSpec
277 lines
12 KiB
RPMSpec
#
|
|
# spec file for package smartmontools
|
|
#
|
|
# Copyright (c) 2025 SUSE LLC and contributors
|
|
#
|
|
# 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/
|
|
#
|
|
|
|
|
|
#Compat macro for new _fillupdir macro introduced in Nov 2017
|
|
%if ! %{defined _fillupdir}
|
|
%define _fillupdir /var/adm/fillup-templates
|
|
%endif
|
|
Name: smartmontools
|
|
Version: 7.5
|
|
Release: 0
|
|
Summary: Monitor for SMART devices
|
|
License: GPL-2.0-or-later
|
|
Group: Hardware/Other
|
|
URL: https://www.smartmontools.org/
|
|
Source: https://sourceforge.net/projects/smartmontools/files/smartmontools/%{version}/%{name}-%{version}.tar.gz
|
|
Source1: https://sourceforge.net/projects/smartmontools/files/smartmontools/%{version}/%{name}-%{version}.tar.gz.asc
|
|
Source2: smartmontools.sysconfig
|
|
Source3: %{name}-rpmlintrc
|
|
Source4: %{name}.keyring
|
|
# SOURCE-FEATURE-OPENSUSE smartmontools.generate_smartd_opts.in sbrabec@suse.cz -- sysconfig support for systemd.
|
|
Source5: %{name}.generate_smartd_opts.in
|
|
# SOURCE-FEATURE-SLE smartmontools-drivedb_h-update.sh bnc851276 sbrabec@suse.cz -- Supplementary script to update drivedb.h.
|
|
Source6: smartmontools-drivedb_h-update.sh
|
|
# SOURCE-FEATURE-UPSTREAM smartmontools-drivedb.h bnc851276 sbrabec@suse.cz -- Update of drivedb.h. (Following line is handled by smartmontools-drivedb_h-update.sh.)
|
|
Source7: smartmontools-drivedb.h
|
|
Source8: smartd_generate_opts.path
|
|
Source9: smartd_generate_opts.service
|
|
# PATCH-FEATURE-UPSTREAM smartmontools-update-smart-drivedb.patch sbrabec@suse.com -- Support download from smartmontools migrated to github (cummulative patch).
|
|
Patch1: smartmontools-update-smart-drivedb.patch
|
|
# PATCH-FEATURE-OPENSUSE smartmontools-suse-default.patch sbrabec@suse.cz -- Define smart SUSE defaults.
|
|
Patch4: smartmontools-suse-default.patch
|
|
# PATCH-FIX-OPENSUSE smartmontools-var-lock-subsys.patch sbrabec@suse.cz -- Do not use unsupported /var/lock/subsys.
|
|
Patch10: smartmontools-var-lock-subsys.patch
|
|
# PATCH-FIX-SLE smartd_service_dont_quit.patch bsc990406 bsc1167051 msuchanek@suse.de -- Do not quit when no drives are available.
|
|
Patch11: smartd_service_dont_quit.patch
|
|
Patch12: harden_smartd.service.patch
|
|
BuildRequires: gcc-c++
|
|
BuildRequires: libcap-ng-devel
|
|
BuildRequires: libselinux-devel
|
|
BuildRequires: pkgconfig
|
|
BuildRequires: pkgconfig(libsystemd)
|
|
BuildRequires: pkgconfig(systemd)
|
|
Requires(pre): %fillup_prereq
|
|
# Needed by generate_smartd_opt:
|
|
Requires(pre): coreutils
|
|
%{?systemd_requires}
|
|
|
|
%description
|
|
SMARTmontools controls and monitors storage devices using the
|
|
Self-Monitoring, Analysis, and Reporting Technology System (S.M.A.R.T.)
|
|
built into ATA, SATA and SCSI Hard Drives. This is used to check the
|
|
hard drive reliability and to predict drive failures. The suite
|
|
contains two utilities. The first, smartctl, is a command line utility
|
|
designed to perform simple S.M.A.R.T. tasks. The second, smartd, is a
|
|
daemon that periodically monitors the smart status and reports errors
|
|
to syslog. The package is compatible with the ATA/ATAPI-3 to -7
|
|
specification. The package is intended to incorporate as much "vendor
|
|
specific" and "reserved" information as possible about disk drives. The
|
|
commands man smartctl and man smartd will provide more information.
|
|
|
|
%prep
|
|
%autosetup -p1
|
|
cp -a %{SOURCE2} %{SOURCE5} .
|
|
# Following line is handled by smartmontools-drivedb_h-update.sh.
|
|
cp -a %{SOURCE7} drivedb.h.new
|
|
#
|
|
# PATCH-FEATURE-OPENSUSE (sed on smartd.service.in) sbrabec@suse.cz -- Use generated smartd_opts (from SUSE sysconfig file). Systemd smartd.service cannot be smart enough to parse SUSE sysconfig file and generate smartd_opts on fly. And we do not want to launch shell just for it in every boot.
|
|
sed "s:/usr/local/etc/sysconfig/smartmontools:%{_sharedstatedir}/smartmontools/smartd_opts:" <smartd.service.in >smartd.service.in.new
|
|
if cmp -s smartd.service.in smartd.service.in.new ; then
|
|
echo "Failed to modify smartd.service.in"
|
|
exit 1
|
|
fi
|
|
mv smartd.service.in.new smartd.service.in
|
|
#
|
|
# Check whether drivedb.h from the tarball is older than drivedb.h.new
|
|
# If yes, replace it. If not, fail.
|
|
# PACKAGERS: Don't delete this section. It prevents packaging of outdated smartmontools-drivedb.h.
|
|
get_db_release()
|
|
{
|
|
local v
|
|
v=`sed -n '/^[ {]*"VERSION: .*"/{
|
|
s,^[ {]*"VERSION: [1-9][.0-9]*\/\([1-9][0-9]*\)[ "].*$,\1,p
|
|
q
|
|
}' "$1"` || return 1
|
|
if test -z "$v" ; then v=0 ; fi
|
|
echo "$v"
|
|
}
|
|
if test -f drivedb.h.new ; then
|
|
UPD_RELEASE=$(get_db_release drivedb.h.new)
|
|
PCK_RELEASE=$(get_db_release drivedb.h)
|
|
if test $UPD_RELEASE -lt $PCK_RELEASE ; then
|
|
echo >&2 "Packaging error: Attached smartmontools-drivedb.h is older than the one from the release.
|
|
Please call \"bash ./smartmontools-drivedb_h-update.sh\" to fix it."
|
|
exit 1
|
|
fi
|
|
mv drivedb.h.new drivedb.h
|
|
fi
|
|
|
|
%build
|
|
export CFLAGS="%{optflags} $(getconf LFS_CFLAGS) -fPIE"
|
|
export CXXFLAGS="%{optflags} -fPIE $(getconf LFS_CFLAGS)"
|
|
export LDFLAGS="-pie"
|
|
%configure\
|
|
--docdir=%{_defaultdocdir}/%{name}\
|
|
--with-selinux\
|
|
--with-libsystemd\
|
|
--with-systemdsystemunitdir=%{_unitdir}\
|
|
--with-drivedbinstdir\
|
|
--with-savestates \
|
|
--with-attributelog \
|
|
--with-nvme-devicescan
|
|
|
|
%make_build BUILD_INFO='"(SUSE RPM)"'
|
|
SERVICE=%{_sbindir}/service
|
|
sed "s:@prefix@:%{_prefix}:g;s:@localstatedir@:%{_localstatedir}:g;s:@SERVICE@:$SERVICE:" <smartmontools.generate_smartd_opts.in >generate_smartd_opts
|
|
|
|
%install
|
|
%make_install
|
|
mkdir -p %{buildroot}%{_prefix}/lib/smartmontools
|
|
mkdir -p %{buildroot}%{_fillupdir}
|
|
cp smartmontools.sysconfig %{buildroot}%{_fillupdir}/sysconfig.smartmontools
|
|
mkdir -p %{buildroot}%{_sharedstatedir}/smartmontools
|
|
touch %{buildroot}%{_sharedstatedir}/smartmontools/smartd_opts
|
|
install generate_smartd_opts %{buildroot}%{_prefix}/lib/smartmontools/
|
|
cat >%{buildroot}%{_sysconfdir}/smart_drivedb.h <<EOF
|
|
/* smart_drivedb.h: Custom drive database. See also %{_datadir}/smartmontools/drivedb.h. */
|
|
EOF
|
|
cp smartd.service %{buildroot}/%{_unitdir}
|
|
cp %{SOURCE8} %{buildroot}/%{_unitdir}
|
|
cp %{SOURCE9} %{buildroot}/%{_unitdir}
|
|
# INSTALL file is intended only for packagers.
|
|
rm %{buildroot}%{_defaultdocdir}/%{name}/INSTALL
|
|
# Create empty ghost files for files created by update-smart-drivedb.
|
|
touch %{buildroot}%{_sharedstatedir}/smartmontools/drivedb.h{,.{asc,error,error.raw,error.raw.asc,lastcheck,old,old.raw,old.raw.asc,raw,raw.asc}}
|
|
|
|
# Check syntax of drivedb.h that may come from a later snapshot (code from update-smart-drivedb)
|
|
if ./smartctl -B drivedb.h -P showall >/dev/null; then :; else
|
|
echo "drivedb.h.error: rejected by smartctl, probably no longer compatible" >&2
|
|
exit 1
|
|
fi
|
|
# Intelligent drivedb.h update, part 0.
|
|
# Check that drivedb.h has well formed VERSION. We will need it for the intelligent update.
|
|
DRIVEDB_H_RELEASE_CHECK="$(sed -n 's/^.*VERSION: [0-9][0-9.]*\/\([0-9][0-9]*\).*$/\1/p' <%{buildroot}%{_datadir}/smartmontools/drivedb.h)"
|
|
# Fail if the file has broken release number.
|
|
test "$DRIVEDB_H_RELEASE_CHECK" -ge 0
|
|
# Fail if there is no default_branch= in update-smart-drivedb
|
|
grep -q "^default_branch=\"[^\"]*\"$" update-smart-drivedb
|
|
|
|
%pre
|
|
%service_add_pre smartd.service smartd_generate_opts.path smartd_generate_opts.service
|
|
# These files were generated by update-smart-drivedb before introduction of
|
|
# transactional updates, but not all were listed in spec as %%ghost.
|
|
# (16.1 and older updated to 7.5)
|
|
for EXT in asc error error.raw error.raw.asc lastcheck old old.raw old.raw.asc raw raw.asc ; do
|
|
rm -f %{_datadir}/smartmontools/drivedb.h.$EXT
|
|
done
|
|
# Intelligent drivedb.h update, part 1.
|
|
# Extract drivedb.h branch for installed version. We will need it in %%post.
|
|
if test -f %{_sharedstatedir}/smartmontools/drivedb.h -a -f %{_sbindir}/update-smart-drivedb ; then
|
|
BRANCH=
|
|
default_branch=
|
|
# BRANCH is old variable name up to 7.2. Starting by 7.3, it is default_branch.
|
|
eval $(grep "^\(BRANCH\|default_branch\)=\"[^\"]*\"$" %{_sbindir}/update-smart-drivedb)
|
|
if test -n "$default_branch$BRANCH" ; then
|
|
mkdir -p %{_sharedstatedir}/smartmontools
|
|
echo -n "$default_branch$BRANCH" >%{_sharedstatedir}/smartmontools/drivedb.h.branch.rpmtemp
|
|
fi
|
|
fi
|
|
|
|
%post
|
|
# First prepare sysconfig.
|
|
%fillup_only
|
|
# Up to Leap 42.3 and SLE 15 SP3 Maintenance Update there was a "Command" meta comment in the sysconfig file.
|
|
# It is not needed any more, but fillup does not delete it. Do it explicitly. (bsc#1195785, bsc#1196103)
|
|
sed -i '\@^##[[:space:]]*Command:[[:space:]]*%{_prefix}/lib/smartmontools/generate_smartd_opts$@d' %{_sysconfdir}/sysconfig/smartmontools
|
|
# Then generate initial %%{_sharedstatedir}/smartmontools/smartd_opts needed by smartd.service.
|
|
SMARTD_SKIP_INIT=1 %{_prefix}/lib/smartmontools/generate_smartd_opts
|
|
# No start by default here.. belongs to -presets packages
|
|
%service_add_post smartd.service smartd_generate_opts.path smartd_generate_opts.service
|
|
# This file may be kept from <= 7.4 or pre-GitHub 7.5. Drop it, as it is probably incompatible.
|
|
rm -f %{_datadir}/smartmontools/drivedb.h.rpmsave
|
|
# Intelligent drivedb.h update, part 2.
|
|
smartdb_purge() {
|
|
rm -f %{_sharedstatedir}/smartmontools/drivedb.h
|
|
for EXT in asc error error.raw error.raw.asc lastcheck old old.raw old.raw.asc raw raw.asc ; do
|
|
rm -f %{_sharedstatedir}/smartmontools/drivedb.h.$EXT
|
|
done
|
|
}
|
|
get_db_release()
|
|
{
|
|
local v
|
|
v=`sed -n '/^[ {]*"VERSION: .*"/{
|
|
s,^[ {]*"VERSION: [1-9][.0-9]*\/\([1-9][0-9]*\)[ "].*$,\1,p
|
|
q
|
|
}' "$1"` || return 1
|
|
if test -z "$v" ; then v=0 ; fi
|
|
echo "$v"
|
|
}
|
|
if test -f %{_sharedstatedir}/smartmontools/drivedb.h.branch.rpmtemp ; then
|
|
# Extract drivedb.h branch for installed version.
|
|
default_branch=
|
|
eval $(grep "default_branch=\"[^\"]*\"$" %{_sbindir}/update-smart-drivedb)
|
|
if test -n "$default_branch" ; then
|
|
if test "$default_branch" != "$(cat %{_sharedstatedir}/smartmontools/drivedb.h.branch.rpmtemp)" ; then
|
|
# incompatible branches
|
|
smartdb_purge
|
|
else
|
|
# Compare their release numbers.
|
|
DRIVEDB_H_RELEASE_RPM="$(get_db_release %{_datadir}/smartmontools/drivedb.h)"
|
|
DRIVEDB_H_RELEASE_UPD="$(get_db_release %{_sharedstatedir}/smartmontools/drivedb.h)"
|
|
if test "${DRIVEDB_H_RELEASE_RPM:-0}" -ge "${DRIVEDB_H_RELEASE_UPD:-0}" ; then
|
|
smartdb_purge
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
rm -f %{_sharedstatedir}/smartmontools/drivedb.h.branch.rpmtemp
|
|
# Before Leap 15 / SLE 15, there was a incorrect configuration of self tests (bsc#1073918).
|
|
# Perform a fix of this nonsense, even if the noreplace configuration file was edited.
|
|
if grep -q -F -- '-s S/../.././03 -s L/../(01|02|03|04|05|06|07)/7/01' %{_sysconfdir}/smartd.conf ; then
|
|
sed -i 's:-s S/\.\./\.\./\./03 -s L/\.\./(01|02|03|04|05|06|07)/7/01:-s (S/../.././03|L/../(01|02|03|04|05|06|07)/7/01):g' %{_sysconfdir}/smartd.conf
|
|
fi
|
|
|
|
%preun
|
|
%service_del_preun smartd.service smartd_generate_opts.path smartd_generate_opts.service
|
|
|
|
%postun
|
|
%service_del_postun smartd.service smartd_generate_opts.path smartd_generate_opts.service
|
|
# Clean all attrlogs and state files.
|
|
if test "$1" = 0 ; then
|
|
rm -rf %{_sharedstatedir}/smartmontools
|
|
fi
|
|
|
|
%files
|
|
%doc %{_docdir}/%{name}
|
|
%dir %{_datadir}/smartmontools
|
|
%verify(not md5 size mtime) %{_datadir}/smartmontools/drivedb.h
|
|
%{_mandir}/man*/*
|
|
%dir %{_sharedstatedir}/smartmontools
|
|
%ghost %{_sharedstatedir}/smartmontools/smartd_opts
|
|
%ghost %{_sharedstatedir}/smartmontools/drivedb.h
|
|
%ghost %{_sharedstatedir}/smartmontools/drivedb.h.asc
|
|
%ghost %{_sharedstatedir}/smartmontools/drivedb.h.error
|
|
%ghost %{_sharedstatedir}/smartmontools/drivedb.h.error.raw
|
|
%ghost %{_sharedstatedir}/smartmontools/drivedb.h.error.raw.asc
|
|
%ghost %{_sharedstatedir}/smartmontools/drivedb.h.lastcheck
|
|
%ghost %{_sharedstatedir}/smartmontools/drivedb.h.old
|
|
%ghost %{_sharedstatedir}/smartmontools/drivedb.h.old.raw
|
|
%ghost %{_sharedstatedir}/smartmontools/drivedb.h.old.raw.asc
|
|
%ghost %{_sharedstatedir}/smartmontools/drivedb.h.raw
|
|
%ghost %{_sharedstatedir}/smartmontools/drivedb.h.raw.asc
|
|
%{_prefix}/lib/smartmontools
|
|
%{_unitdir}/*
|
|
%{_sbindir}/*
|
|
%config(noreplace) %{_sysconfdir}/smart_drivedb.h
|
|
%config(noreplace) %{_sysconfdir}/smartd.conf
|
|
%config(noreplace) %{_sysconfdir}/smartd_warning.sh
|
|
%config %dir %{_sysconfdir}/smartd_warning.d
|
|
%{_fillupdir}/sysconfig.*
|
|
|
|
%changelog
|