Sync from SUSE:SLFO:Main smartmontools revision 37d1c6123e0431a8c27b5075e48fa4a1

This commit is contained in:
Adrian Schröter 2024-05-04 00:41:36 +02:00
commit 7e1a63a7f8
16 changed files with 1787 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

View File

@ -0,0 +1,21 @@
Index: smartmontools-7.4/smartd.service.in
===================================================================
--- smartmontools-7.4.orig/smartd.service.in
+++ smartmontools-7.4/smartd.service.in
@@ -7,6 +7,16 @@ Documentation=man:smartd(8) man:smartd.c
ConditionVirtualization=no
[Service]
+# added automatically, for details please see
+# https://en.opensuse.org/openSUSE:Security_Features#Systemd_hardening_effort
+ProtectSystem=full
+ProtectHome=true
+ProtectHostname=true
+ProtectKernelModules=true
+ProtectKernelLogs=true
+ProtectControlGroups=true
+RestrictRealtime=true
+# end of automatic additions
Type=notify
EnvironmentFile=-/usr/local/etc/sysconfig/smartmontools
ExecStart=/usr/local/sbin/smartd -n -q never $smartd_opts

11
smartd_generate_opts.path Normal file
View File

@ -0,0 +1,11 @@
[Unit]
Description=Watch for changes in smartmontools sysconfig file
After=local-fs.target
[Path]
Unit=smartd_generate_opts.service
PathChanged=/etc/sysconfig/smartmontools
[Install]
WantedBy=default.target

View File

@ -0,0 +1,21 @@
[Unit]
Description=Update smartd options
Wants=local-fs.target
[Service]
# added automatically, for details please see
# https://en.opensuse.org/openSUSE:Security_Features#Systemd_hardening_effort
ProtectSystem=full
ProtectHome=true
ProtectHostname=true
ProtectKernelModules=true
ProtectKernelLogs=true
ProtectControlGroups=true
RestrictRealtime=true
# end of automatic additions
Type=oneshot
ExecStart=/usr/lib/smartmontools/generate_smartd_opts
[Install]
WantedBy=default.target

View File

@ -0,0 +1,13 @@
Index: smartmontools-7.4/smartd.service.in
===================================================================
--- smartmontools-7.4.orig/smartd.service.in
+++ smartmontools-7.4/smartd.service.in
@@ -9,7 +9,7 @@ ConditionVirtualization=no
[Service]
Type=notify
EnvironmentFile=-/usr/local/etc/sysconfig/smartmontools
-ExecStart=/usr/local/sbin/smartd -n $smartd_opts
+ExecStart=/usr/local/sbin/smartd -n -q never $smartd_opts
ExecReload=/bin/kill -HUP $MAINPID
[Install]

BIN
smartmontools-7.4.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,16 @@
-----BEGIN PGP SIGNATURE-----
iQIcBAABAgAGBQJkyOXyAAoJEAowgS7/Ou/1yocP/1wKzrSB7rYuqNrjcOKd2IDQ
sp4JlOXheoy6Y6PgYGjHAFtf3E8YBR1OjeJsf57BwdNa8mW52ctrXuUDdt2vMaMf
WAgBFCIGdMH2gvcIYTOTdn3MFMP9KuJD7CvWtvZpWEVWgeEbk1gopusKFL4L0u9T
iFIcYoN2AjFOPtNmQYrpjTpJ6/LYtx20UBdP8sMbM8fq++vREjZEu466zooWPTYF
70EILbxy+K8sB6Z+WdttwTqasYdMFwiSZNExxmykYB3M8MeHcA+Y4Je6xiaSVFIp
HOdgZjQJDyoMNFrETNm8lj07NBrtMf2TAJ25AVxZPFmdjzVVxOSap/4UzPjR9Rfz
MDPKxRqiktII+cwE3ReuZz6Av1fLkOW3BJSFzU6SeVL4WHK0Z5p+6gyNxtWhWJ0S
DRvTpUblUZDX2otkNHyCj4+0mkpufjY7TXybcgtYGwfBuuvGouHtWdyPeMoq3wBW
y1znPhZcXvKc6ecUPb9FFdP5MLP9oNZE+sGjCRqbl6r4GjjfS4f5fnp+NptAwv9N
w6ESTd6rQH+RrwBiECPyFefNvmW/Z3esSrsmQFobkBJKD61bpP+LeGoAS9N6k9/T
6yhwzZboQPsPALYGcCyN8gcBHGCziyKkr9ELlpEaD57VQtvmMmXItJUyjx+CgC0X
P9hd8uy9uOXXEzNt2IM3
=vpX/
-----END PGP SIGNATURE-----

View File

@ -0,0 +1,114 @@
#!/bin/bash
# Packaged drivedb.h/smartmontools-drivedb.h update script.
# Usage: bash ./smartmontools-drivedb_h-update.sh
# Exit codes:
# O: Changes performed. You should commit.
# 1: No changes performed.
# 2: Internal error.
set -o errexit
VERSION=`sed -n 's/^Version:[[:space:]]*//p' <smartmontools.spec`
WORKDIR="smartmontools-drivedb_h-update.tmp"
rm -rf "$WORKDIR"
mkdir "$WORKDIR"
cd "$WORKDIR"
tar -zxf ../smartmontools-$VERSION.tar.gz smartmontools-$VERSION/update-smart-drivedb.in smartmontools-$VERSION/configure smartmontools-$VERSION/drivedb.h
# There can be script update.
# TODO: This patch can be generated automatically.
if test -f ../smartmontools-update-smart-drivedb.patch ; then
patch -p0 <../smartmontools-update-smart-drivedb.patch
fi
# Extract expression that derives DRIVEDB_BRANCH from the version string
# (from configure, to not include autoconf square brackets):
eval "$(sed -n -e '/^[^ ]*drivedb_version=/p; /^DRIVEDB_BRANCH=/,/`/p' <smartmontools-$VERSION/configure)"
if test -z "$DRIVEDB_BRANCH"; then
echo "Unable to derive DRIVEDB_BRANCH from VERSION=$VERSION."
cd - >/dev/null
rm -r "$WORKDIR"
exit 2
fi
BRANCHNAME=$DRIVEDB_BRANCH
PCK_TIME=$(date -d "$(sed -n 's/^.*$Id: drivedb.h [0-9][0-9]* \([^ ]* [^ ]*\) .*$/\1/p' <smartmontools-$VERSION/drivedb.h)" +%s)
echo "Updating drivedb.h for branch $DRIVEDB_BRANCH."
# Generate and call specially crafted update-smart-drivedb.
sed "
/^PACKAGE=/i rm update-smart-drivedb-wd
s:@PACKAGE@:smartmontools:g
s:@VERSION@:$VERSION:g
s:@DRIVEDB_BRANCH@:$DRIVEDB_BRANCH:g
s:@ENABLE_SCRIPTPATH_TRUE@:#:g
s:@ENABLE_SCRIPTPATH_FALSE@::g
s:@gnupg@:/usr/bin/gpg:
s:^DRIVEDB=.*$:DRIVEDB=smartmontools-drivedb.h:
s:@drivedbdir@:.:g
s:@os_dltools@:curl wget lynx:g
" <smartmontools-$VERSION/update-smart-drivedb.in >update-smart-drivedb-wd
chmod +x update-smart-drivedb-wd
# Verification of the downloaded drivedb.h has to be done by the packaged smartctl.
# Skip it on the host system, and run it as part of %build stage.
./update-smart-drivedb-wd -u trac -s -
rm -f "$DEST.lastcheck"
rm -f "$DEST.old"
# Compare time (file in the drivedb branch can be older) and compare
# files without Id (files can be equal but committed in two commits).
UPD_TIME=$(date -d "$(sed -n 's/^.*$Id: drivedb.h [0-9][0-9]* \([^ ]* [^ ]*\) .*$/\1/p' <../smartmontools-drivedb.h)" +%s)
sed '/^.*$Id:/d' <smartmontools-$VERSION/drivedb.h >drivedb-noid.h
sed '/^.*$Id:/d' <../smartmontools-drivedb.h >smartmontools-drivedb-noid.h
if cmp -s drivedb-noid.h smartmontools-drivedb-noid.h ; then
EQUAL=true
else
EQUAL=false
fi
# Return to the OSC repository and perform needed changes.
cd - >/dev/null
if test $EQUAL = true -o \( $UPD_TIME -le $PCK_TIME \) ; then
echo "No drivedb.h update available."
if test -f smartmontools-drivedb.h ; then
osc rm --force smartmontools-drivedb.h
fi
sed 's/^Source[0-9]*:[ ]*smartmontools-drivedb.h$/#&/;s/^cp -a .* drivedb\.h\.new$/#&/' <smartmontools.spec >"$WORKDIR/smartmontools.spec"
if ! cmp -s smartmontools.spec "$WORKDIR/smartmontools.spec" ; then
echo "Removing smartmontools-drivedb.h from spec file."
osc vc -m "Remove smartmontools-drivedb.h. No update available in the
upstream branch $BRANCHNAME."
mv "$WORKDIR/smartmontools.spec" ./
fi
else
if test -f smartmontools-drivedb.h ; then
if cmp -s "$WORKDIR/smartmontools-drivedb.h" smartmontools-drivedb.h ; then
echo "smartmontools-drivedb.h is up to date. Nothing to be done."
rm -r "$WORKDIR"
exit 1
else
echo "smartmontools-drivedb.h updated."
mv "$WORKDIR/smartmontools-drivedb.h" ./
osc vc -m "Update smartmontools-drivedb.h to the latest version from the
upstream branch $BRANCHNAME."
fi
else
sed 's/^#\(Source[0-9]*:[ ]*smartmontools-drivedb.h\)$/\1/;s/^#\(cp -a .* drivedb\.h\.new\)$/\1/' <smartmontools.spec >"$WORKDIR/smartmontools.spec"
if ! cmp -s smartmontools.spec "$WORKDIR/smartmontools.spec" ; then
echo "Adding smartmontools-drivedb.h to the spec file."
osc vc -m "Add smartmontools-drivedb.h, the latest version from the upstream
branch $BRANCHNAME."
mv "$WORKDIR/smartmontools.spec" ./
mv "$WORKDIR/smartmontools-drivedb.h" ./
osc add smartmontools-drivedb.h
fi
fi
fi
echo "Consider submitting of changes that just were done."
rm -r "$WORKDIR"

6
smartmontools-rpmlintrc Normal file
View File

@ -0,0 +1,6 @@
# Two .h files are config files in C include file format
addFilter("devel-file-in-non-devel-package")
# Use the name registered by LANANA
addFilter("incoherent-init-script-name smartd")
# Still valid for SLE10
addFilter("obsolete-suse-version-check 1020")

View File

@ -0,0 +1,20 @@
Index: smartd.conf
===================================================================
--- a/smartd.conf
+++ b/smartd.conf
@@ -9,6 +9,15 @@
# device per line. Text after a hash (#) is ignored, and you may use
# spaces and tabs for white space. You may use '\' to continue lines.
+# SUSE default:
+# -d removable: Prevent error messages after disconnecting of
+# monitored removable discs.
+# -s S/: Run Short Self Test every day in the deep night.
+# (Takes several minutes.)
+# -s L/: Run Extended Self Test every first Sunday in the
+# month. (Start earlier, it could take tens of hours.)
+DEFAULT -d removable -s (S/../.././03|L/../(01|02|03|04|05|06|07)/7/01)
+
# The word DEVICESCAN will cause any remaining lines in this
# configuration file to be ignored: it tells smartd to scan for all
# ATA and SCSI devices. DEVICESCAN may be followed by any of the

View File

@ -0,0 +1,13 @@
Index: smartmontools-5.42/smartd.initd.in
===================================================================
--- smartmontools-5.42.orig/smartd.initd.in
+++ smartmontools-5.42/smartd.initd.in
@@ -50,7 +50,7 @@ if [ -f /etc/redhat-release -o -f /etc/y
RETVAL=0
prog=smartd
- pidfile=/var/lock/subsys/smartd
+ pidfile=/var/run/smartd.pid
config=/etc/smartd.conf
start()

1109
smartmontools.changes Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,54 @@
#! /bin/bash
# smartmontools sysconfig command line options generator
# Copyright (C) 2012 Stanislav Brabec <sbrabec@suse.cz>
# This program 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 2, or (at your option) any later
# version.
# You should have received a copy of the GNU General Public License (for
# example COPYING); if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# Following code should be in sync with sysv init script for older distros!
# source configuration file.
smartd_opts=
[ -r @localstatedir@/lib/smartmontools/smartd_opts ] && . @localstatedir@/lib/smartmontools/smartd_opts
smartd_opts_old="$smartd_opts"
[ -r /etc/sysconfig/smartmontools ] && . /etc/sysconfig/smartmontools
smartd_opts=
if test -n "$SMARTD_CHECK_INTERVAL" -a "$SMARTD_CHECK_INTERVAL" != 1800 ; then
smartd_opts=" -i $SMARTD_CHECK_INTERVAL"
fi
if test -n "$SMARTD_LOG_FACILITY" -a "$SMARTD_LOG_FACILITY" != "daemon" ; then
smartd_opts="$smartd_opts -l $SMARTD_LOG_FACILITY"
fi
if test -n "$SMARTD_DRIVEDB" ; then
smartd_opts="$smartd_opts -B $SMARTD_DRIVEDB"
fi
if test "$SMARTD_SAVESTATES" = "no" ; then
smartd_opts="$smartd_opts -s -"
fi
if test "$SMARTD_ATTRLOG" = "no" ; then
smartd_opts="$smartd_opts -A -"
fi
if test -n "$SMARTD_EXTRA_OPTS" ; then
smartd_opts="$smartd_opts $SMARTD_EXTRA_OPTS"
fi
if test "$smartd_opts" = "$smartd_opts_old" ; then
exit 0
fi
mkdir -p @localstatedir@/lib/smartmontools
echo "# Generated by @prefix@/lib/smartmontools/generate_smartd_opts
smartd_opts=\"$smartd_opts\"" >@localstatedir@/lib/smartmontools/smartd_opts
# SMARTD_SKIP_INIT is used during installation.
if test -z "$SMARTD_SKIP_INIT" ; then
# Behavior of both "Command" and "ServiceRestart" is undefined. Restart service here.
@SERVICE@ smartd try-restart
fi

60
smartmontools.keyring Normal file
View File

@ -0,0 +1,60 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
Comment: Hostname:
Version: Hockeypuck ~unreleased
xsFNBF/gs9YBEADyn0P5OLnlgjujm1VsVyltEqFm3iOtniHoeiUAZYhBdG0b9gQE
G/NFMtyd5h9WY4ZWUu3rlD30cHKK52IHz1zvHFoscz+T32hBAPN6xG+990PCRtZ7
9qZRt6KlfV/7gCQk31W5BBUOaQaquhP5Ud1m+VFUjShta4r0bXya00PZvfI02Ky2
l+9mwrD5FsGP3ri7Yf81Lx2xLmiW2BwphDYmqJ0uzGBKeJgi5myUjqTbfWTRAsaX
ji0n570Pd6xtEvCjWdPU7q+/3XmD8rIoizOB0ChGoLLQc5cjNCzAeuiExFd9ule2
RomO+czylB2rsmxbw2vUlkcZ2LmRBvZskMAZWmc0z9LGnGQA9RZZFyEOTC10cC69
YMae5JHp+veS/2qw/5UOsR6RfbT+BUPLLJW+/RrUvgfxs36oG/DCxSNqrQpRuvlk
gGsmrl+W8s+pxL8dn5F1W4mkkiR6g5P5xVrYckkQn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
EuVJ1WflWnoyQ1GOWx0CWEOLt3Jgm/eqmu0pcsC/n1BFNVGInpz4Lj18fbuwioEG
nEMdwsFcBBMBAgAGBQJf4LPgAAoJEOp0qyVyEELFzOkQAMNwL9FpgNeEECarxe6L
6CrtwhXBTqMze8KVGEHcDQv5B0RWNEHmEpkUfY0Ycmt4g6na7Us7j1r1sq1MAmcu
ESFq7lWx2+2HjGh+aFngr77czZuL4Xs/NaTwuRt3IR4kHoSfExrxIHIigxuUle1H
pcIcZmgkSsRYryZ8DNcbb6swATA4e/taeNeXS1aTK3nq2+g4PSTensAk1Sos7AkY
y238Lbn5YK0+m5vR0+lg/ctD7KpiC/50Qt/aLPMqos9GIB7EV2wKa2V/XcHUgakK
qW3qTGMSUJs+LCViLoDx6RMETsQ4JEABG8UvCV94Ih5H9NYhBFN8uZExPek6avp/
ch9jivlZ0YrcRAn0JexTC/nmLud0PEqdA4+WRYslUbMdvfPTJt7wtCzXu1xo1q9b
TCQRrPKN3PwBbXgERRi8z0x0RVpicqVicdXLFX42DlXiqWBdoUT84MX/XIaf23fU
W25HGCjjLE4j/OlVChx1E84+zLD6zd4JFX8NlU0rtHKR+cSdV8AB8d6dCM1cMmZy
BwgMDVwbRFaXZ50ell/iH4A8Q3dqxwkse2HfwqieaF57cx7SyJZN6kGG0aDfydco
hgWrRCXn4ooC68zNHTrPk2YCaEh2DecjnMz8NXnVQhH0Eaku/gY5awFcKx/4VfIa
tzwtU0yGYRfROALZz8CtVwDq
=oCbP
-----END PGP PUBLIC KEY BLOCK-----

251
smartmontools.spec Normal file
View File

@ -0,0 +1,251 @@
#
# spec file for package smartmontools
#
# Copyright (c) 2023 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/
#
#Compat macro for new _fillupdir macro introduced in Nov 2017
%if ! %{defined _fillupdir}
%define _fillupdir /var/adm/fillup-templates
%endif
Name: smartmontools
Version: 7.4
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-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:%{_localstatedir}/lib/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.
if test -f drivedb.h.new ; then
UPD_TIME=$(date -d "$(sed -n 's/^.*$Id: drivedb.h [0-9][0-9]* \([^ ]* [^ ]*\) .*$/\1/p' <drivedb.h.new)" +%s)
PCK_TIME=$(date -d "$(sed -n 's/^.*$Id: drivedb.h [0-9][0-9]* \([^ ]* [^ ]*\) .*$/\1/p' <drivedb.h)" +%s)
if test $UPD_TIME -lt $PCK_TIME ; 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-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}%{_localstatedir}/lib/smartmontools
touch %{buildroot}%{_localstatedir}/lib/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}
ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rcsmartd
# 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}%{_datadir}/smartmontools/drivedb.h.{error,lastcheck,old}
# 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 svn RELEASE. We will need it for the intelligent update.
DRIVEDB_H_RELEASE_CHECK="$(sed -n 's/^.*$Id: drivedb.h \([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
# Intelligent drivedb.h update, part 1.
# Extract drivedb.h branch for installed version. We will need it in %%post.
if test -f %{_sbindir}/update-smart-drivedb ; then
BRANCH=
eval $(grep "^BRANCH=\"[^\"]*\"$" %{_sbindir}/update-smart-drivedb)
if test -n "$BRANCH" ; then
echo -n "$BRANCH" >%{_datadir}/smartmontools/drivedb.h.branch.rpmtemp
fi
fi
# Save installed drivedb.h. Maybe the sysadmin called update-smart-drivedb,
# and the installed drivedb.h may be even newer than the new packaged one.
if test -f %{_datadir}/smartmontools/drivedb.h ; then
# Be on safe side, remove any potential drivedb.h.rpmsave.
rm -f %{_datadir}/smartmontools/drivedb.h.rpmsave
ln %{_datadir}/smartmontools/drivedb.h %{_datadir}/smartmontools/drivedb.h.rpmsave
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 %%{_localstatedir}/lib/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
# Intelligent drivedb.h update, part 2.
# Now we have the old system drivedb.h.rpmsave and the new packaged drivedb.h.
if test -f %{_datadir}/smartmontools/drivedb.h.rpmsave ; then
# Compare their release numbers.
DRIVEDB_H_RELEASE_RPM="$(sed -n 's/^.*$Id: drivedb.h \([0-9][0-9]*\) .*$/\1/p' <%{_datadir}/smartmontools/drivedb.h)"
DRIVEDB_H_RELEASE_SAVED="$(sed -n 's/^.*$Id: drivedb.h \([0-9][0-9]*\) .*$/\1/p' <%{_datadir}/smartmontools/drivedb.h.rpmsave)"
# Note: The SAVED release number may be broken. The test syntax must cover it and replace old file.
if test "$DRIVEDB_H_RELEASE_RPM" -lt "${DRIVEDB_H_RELEASE_SAVED:-0}" ; then
# If it is an update to the new branch, always replace the database.
# Extract drivedb.h branch for the new version to default_branch.
eval $(grep "^default_branch=\"[^\"]*\"$" %{_sbindir}/update-smart-drivedb)
OLD_BRANCH=
if test -f %{_datadir}/smartmontools/drivedb.h.branch.rpmtemp ; then
OLD_BRANCH=$(<%{_datadir}/smartmontools/drivedb.h.branch.rpmtemp)
fi
if test "$default_branch" = "$OLD_BRANCH" ; then
# It is safe to keep later version of installed database.
mv %{_datadir}/smartmontools/drivedb.h.rpmsave %{_datadir}/smartmontools/drivedb.h
else
# Saved file needs to be replaced.
rm %{_datadir}/smartmontools/drivedb.h.rpmsave
# We returned to the vanilla packages, remove files created by update-smart-drivedb.
rm -f %{_datadir}/smartmontools/drivedb.h.{error,lastcheck,old}
echo >&2 "%{name} updated to a version that requires new branch of drivedb.h"
echo >&2 "Replacing your custom drivedb.h."
echo >&2 "You may need to call update-smart-drivedb."
fi
else
# Saved file is older or equal, or saved file has broken release number.
rm %{_datadir}/smartmontools/drivedb.h.rpmsave
# We returned to the vanilla packages, remove files created by update-smart-drivedb.
rm -f %{_datadir}/smartmontools/drivedb.h.{error,lastcheck,old}
fi
fi
rm -f %{_datadir}/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 %{_localstatedir}/lib/smartmontools
fi
%files
%doc %{_docdir}/%{name}
%dir %{_datadir}/smartmontools
%verify(not md5 size mtime) %{_datadir}/smartmontools/drivedb.h
%ghost %{_datadir}/smartmontools/drivedb.h.error
%ghost %{_datadir}/smartmontools/drivedb.h.lastcheck
%ghost %{_datadir}/smartmontools/drivedb.h.old
%{_mandir}/man*/*
%dir %{_localstatedir}/lib/smartmontools
%ghost %{_localstatedir}/lib/smartmontools/smartd_opts
%{_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

52
smartmontools.sysconfig Normal file
View File

@ -0,0 +1,52 @@
## Path: Hardware/S.M.A.R.T.
## Description: Hard disc health monitoring
## Type: integer(10:)
## Default: 1800
#
# Interval between disk checks in seconds
#
SMARTD_CHECK_INTERVAL="1800"
## Type: list(local0,local1,local2,local3,local4,local5,local6,local7,daemon)
## Default: daemon
#
# Syslog facility used to log messages from smartd
#
SMARTD_LOG_FACILITY="daemon"
## Type: string
## Default:
#
# Read and replace drive database from specified file instead of
# system files. Prepend "+" to read and add drive database from
# specified file.
#
SMARTD_DRIVEDB=""
## Type: yesno
## Default: yes
#
# Preserve SMART attributes in files and read them when smartd starts.
# This feature is now ATA only, so you may want to disable it to supress
# warnings. See smartd(8) option -s for details.
#
SMARTD_SAVESTATES="yes"
## Type: yesno
## Default: yes
#
# Enable or disable SMART attribute logging.
# If you don't consider this log useful for you, you can disable it.
# This feature is now ATA only, so you may want to disable it to supress
# warnings. See smartd(8) option -s for details.
#
SMARTD_ATTRLOG="yes"
## Type: string
## Default:
#
# Arbitrary options passed to the smart daemon in addition to above. See
# smartd(8) for the full list of options.
#
SMARTD_EXTRA_OPTS=""