Skip to content

Commit

Permalink
Allow to specify a separate install location for drivedb.h.
Browse files Browse the repository at this point in the history
This prevents that update-smart-drivedb overwrites the package
installed file (Debian Bug 976696, Ubuntu Bug 1893202).

configure.ac, Makefile.am: Add '--with-drivedbinstdir' option.
update-smart-drivedb.in: Add '--install' option.
update-smart-drivedb.8.in: Document new functionality.
smartctl.8.in, smartd.8.in: Adjust path names.

git-svn-id: https://svn.code.sf.net/p/smartmontools/code/trunk/smartmontools@5318 4ea69e1a-61f1-4043-bf83-b5c94c648137
  • Loading branch information
chrfranke committed Feb 18, 2022
1 parent 10323b2 commit ff6b7e1
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 20 deletions.
11 changes: 11 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
$Id$

2022-02-18 Christian Franke <[email protected]>

Allow to specify a separate install location for drivedb.h.
This prevents that update-smart-drivedb overwrites the package
installed file (Debian Bug 976696, Ubuntu Bug 1893202).

configure.ac, Makefile.am: Add '--with-drivedbinstdir' option.
update-smart-drivedb.in: Add '--install' option.
update-smart-drivedb.8.in: Document new functionality.
smartctl.8.in, smartd.8.in: Adjust path names.

2022-02-16 Douglas Gilbert <[email protected]>

smartctl.cpp: add new --log=tapedevstat to print out SCSI
Expand Down
12 changes: 9 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ endif


if ENABLE_DRIVEDB
drivedb_DATA = drivedb.h
drivedbinst_DATA = drivedb.h
endif

update-smart-drivedb: update-smart-drivedb.in config.status
Expand Down Expand Up @@ -591,7 +591,7 @@ smartd.service: smartd.service.in Makefile
# Create empty directories if configured.
# Default install rules no longer create empty directories since automake 1.11.
installdirs-local:
@for d in '$(smartdplugindir)' '$(savestatesdir)' '$(attributelogdir)'; do \
@for d in '$(smartdplugindir)' '$(drivedbdir)' '$(savestatesdir)' '$(attributelogdir)'; do \
test -n "$$d" || continue; \
echo " $(MKDIR_P) '$(DESTDIR)$$d'"; \
$(MKDIR_P) "$(DESTDIR)$$d" || exit 1; \
Expand Down Expand Up @@ -619,10 +619,16 @@ MAN_FILTER = { \
-e 's|/usr/bin/mail|/usr/bin/$(os_mailer)|g' \
-e 's|RELEASE_6_0_DRIVEDB|$(DRIVEDB_BRANCH)|g' | \
if test -n '$(drivedbdir)'; then \
sed 's|/usr/local/share/smartmontools/drivedb\.h|$(drivedbdir)/drivedb.h|g' ; \
sed -e 's|/usr/local/share/smartmontools/drivedb\.h|$(drivedbinstdir)/drivedb.h|g' \
-e 's|/usr/local/var/lib/smartmontools/drivedb\.h|$(drivedbdir)/drivedb.h|g' ; \
else \
sed '/^\.\\" %IF ENABLE_DRIVEDB/,/^\.\\" %ENDIF ENABLE_DRIVEDB/ s,^,.\\"\# ,' ; \
fi | \
if test '$(drivedbinstdir)' != '$(drivedbdir)'; then \
cat; \
else \
sed '/^\.\\" %IF ENABLE_DB_INSTALL/,/^\.\\" %ENDIF ENABLE_DB_INSTALL/ s,^,.\\"\# ,' ; \
fi | \
if test '$(with_update_smart_drivedb)' = 'yes'; then \
cat; \
else \
Expand Down
19 changes: 18 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,23 @@ AC_ARG_WITH(exampledir,
AC_SUBST(exampledir)

drivedbdir='${datadir}/${PACKAGE}'
drivedbinstdir=
AC_ARG_WITH(drivedbinstdir,
[AS_HELP_STRING([--with-drivedbinstdir@<:@=DIR|yes|no@:>@],
[Optional separate install location of drive database file [no] (yes=DATADIR/smartmontools)])],
[ case "$withval" in
no) ;;
yes) drivedbinstdir=$drivedbdir; drivedbdir='${localstatedir}/lib/${PACKAGE}' ;;
*) drivedbinstdir=$withval; drivedbdir='${localstatedir}/lib/${PACKAGE}' ;;
esac
])

AC_ARG_WITH(drivedbdir,
[AS_HELP_STRING([--with-drivedbdir@<:@=DIR|yes|no@:>@], [Location of drive database file [DATADIR/smartmontools]])],
[AS_HELP_STRING([--with-drivedbdir@<:@=DIR|yes|no@:>@],
[Location of drive database file [DATADIR/smartmontools or LOCALSTATEDIR/lib/smartmontools if separate INSTDIR]])],
[case "$withval" in yes) ;; no) drivedbdir= ;; *) drivedbdir="$withval" ;; esac])
test -n "$drivedbinstdir" || drivedbinstdir=$drivedbdir
AC_SUBST(drivedbinstdir)
AC_SUBST(drivedbdir)
AM_CONDITIONAL(ENABLE_DRIVEDB, [test -n "$drivedbdir"])

Expand Down Expand Up @@ -893,6 +907,9 @@ info=`
echo "doc file install path: \`eval eval eval echo $docdir\`"
echo "examples install path: \`eval eval eval echo $exampledir\`"
if test -n "$drivedbdir"; then
if test "$drivedbinstdir" != "$drivedbdir"; then
echo "installed drivedb file: \`eval eval eval echo $drivedbinstdir\`/drivedb.h"
fi
echo "drive database file: \`eval eval eval echo $drivedbdir\`/drivedb.h"
if test "$with_update_smart_drivedb" = "yes"; then
echo "database update script: \`eval eval eval echo $sbindir\`/update-smart-drivedb"
Expand Down
6 changes: 3 additions & 3 deletions smartctl.8.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.ig
Copyright (C) 2002-10 Bruce Allen
Copyright (C) 2004-21 Christian Franke
Copyright (C) 2004-22 Christian Franke
SPDX-License-Identifier: GPL-2.0-or-later
Expand Down Expand Up @@ -1933,7 +1933,7 @@ if this option is not specified.
.Sp
If
.\" %IF NOT OS Windows
\fB/usr/local/share/smartmontools/drivedb.h\fP
\fB/usr/local/var/lib/smartmontools/drivedb.h\fP
.\" %ENDIF NOT OS Windows
.\" %IF OS ALL
(Windows: \fBEXEDIR/drivedb.h\fP)
Expand Down Expand Up @@ -2431,7 +2431,7 @@ done
full path of this executable.
.\" %IF ENABLE_DRIVEDB
.TP
.B /usr/local/share/smartmontools/drivedb.h
.B /usr/local/var/lib/smartmontools/drivedb.h
drive database (see \*(Aq\-B\*(Aq option).
.\" %ENDIF ENABLE_DRIVEDB
.TP
Expand Down
2 changes: 1 addition & 1 deletion smartd.8.in
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ plugin directory for smartd warning script (see \*(Aq\-m\*(Aq directive on
.\" %ENDIF ENABLE_SMARTDPLUGINDIR
.\" %IF ENABLE_DRIVEDB
.TP
.B /usr/local/share/smartmontools/drivedb.h
.B /usr/local/var/lib/smartmontools/drivedb.h
drive database (see \*(Aq\-B\*(Aq option).
.\" %ENDIF ENABLE_DRIVEDB
.TP
Expand Down
36 changes: 25 additions & 11 deletions update-smart-drivedb.8.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.ig
Copyright (C) 2013 Hannes von Haugwitz <[email protected]>
Copyright (C) 2014-21 Christian Franke
Copyright (C) 2014-22 Christian Franke
SPDX-License-Identifier: GPL-2.0-or-later
Expand Down Expand Up @@ -41,7 +41,7 @@ update-smart-drivedb \- update smartmontools drive database
.\" %ENDIF NOT OS ALL
.B update-smart-drivedb
updates
.B /usr/local/share/smartmontools/drivedb.h
.B /usr/local/var/lib/smartmontools/drivedb.h
or
.I DESTFILE
from branches/RELEASE_6_0_DRIVEDB of smartmontools SVN repository.
Expand Down Expand Up @@ -84,7 +84,7 @@ The form \*(Aq\-s \-\*(Aq disables the syntax check.
The default is
.BR /usr/local/sbin/smartctl .
.TP
.B \-t [/DIR/]TOOL, \-\-tool [/DIR/]TOOL
.B \-t [DIR/]TOOL, \-\-tool [DIR/]TOOL
Use TOOL for download.
TOOL is one of:
.I curl wget lynx
Expand Down Expand Up @@ -134,6 +134,15 @@ exist unless \*(Aq\-\-no\-verify\*(Aq is also specified.
Copy from local FILE.
A valid OpenPGP/GPG signature \*(AqFILE.raw.asc\*(Aq must also exist
unless \*(Aq\-\-no\-verify\*(Aq is also specified.
.\" %IF ENABLE_DB_INSTALL
.TP
.B \-\-install
[NEW EXPERIMENTAL UPDATE-SMART-DRIVEDB FEATURE]
Copy from originally installed drive database file.
This is the same as:
.br
\*(Aq\-\-no\-verify \-\-file /usr/local/share/smartmontools/drivedb.h\*(Aq
.\" %ENDIF ENABLE_DB_INSTALL
.TP
.B \-\-trunk
Download from SVN trunk.
Expand Down Expand Up @@ -186,14 +195,14 @@ Print help text.
Regular update:
.Vb 2
# update-smart-drivedb
/usr/local/share/smartmontools/drivedb.h 7.2/5225 updated to 7.2/5237
/usr/local/var/lib/smartmontools/drivedb.h 7.2/5225 updated to 7.2/5237
.Ve
.PP
Revert to previous version:
.Vb 2
# update-smart-drivedb --force \e
--file /usr/local/share/smartmontools/drivedb.h.old
/usr/local/share/smartmontools/drivedb.h 7.2/5237 downgraded to 7.2/5225
--file /usr/local/var/lib/smartmontools/drivedb.h.old
/usr/local/var/lib/smartmontools/drivedb.h 7.2/5237 downgraded to 7.2/5225
.Ve
.PP
Download the database from SVN trunk to current directory:
Expand All @@ -214,23 +223,28 @@ full path of this script.
.TP
.B /usr/local/sbin/smartctl
used to check syntax of new drive database.
.\" %IF ENABLE_DB_INSTALL
.TP
.B /usr/local/share/smartmontools/drivedb.h
originally installed drive database.
.\" %ENDIF ENABLE_DB_INSTALL
.TP
.B /usr/local/var/lib/smartmontools/drivedb.h
current drive database.
.TP
.B /usr/local/share/smartmontools/drivedb.h.raw
.B /usr/local/var/lib/smartmontools/drivedb.h.raw
current drive database with unexpanded SVN Id string.
.TP
.B /usr/local/share/smartmontools/drivedb.h.raw.asc
.B /usr/local/var/lib/smartmontools/drivedb.h.raw.asc
signature file.
.TP
.B /usr/local/share/smartmontools/drivedb.h.*old*
.B /usr/local/var/lib/smartmontools/drivedb.h.*old*
previous files.
.TP
.B /usr/local/share/smartmontools/drivedb.h.*error*
.B /usr/local/var/lib/smartmontools/drivedb.h.*error*
new files if rejected due to errors.
.TP
.B /usr/local/share/smartmontools/drivedb.h.lastcheck
.B /usr/local/var/lib/smartmontools/drivedb.h.lastcheck
empty file created if downloaded file was identical.
.Sp
.SH AUTHORS
Expand Down
17 changes: 16 additions & 1 deletion update-smart-drivedb.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ exec_prefix="@exec_prefix@"
sbindir="@sbindir@"
datarootdir="@datarootdir@"
datadir="@datadir@"
localstatedir="@localstatedir@"
drivedbinstdir="@drivedbinstdir@"
drivedbdir="@drivedbdir@"

# Download tools
Expand Down Expand Up @@ -57,7 +59,7 @@ Usage: $myname [OPTIONS] [DESTFILE]
-s, --smartctl SMARTCTL
Use SMARTCTL for syntax check ('-s -' to disable)
[default: $default_smartctl]
-t, --tool [/DIR/]TOOL
-t, --tool [DIR/]TOOL
Use TOOL for download: $os_dltools
[default: first one found in $pathinfo]
-u, --url-of LOCATION
Expand All @@ -69,6 +71,13 @@ Usage: $myname [OPTIONS] [DESTFILE]
trac (Trac code browser)
--url URL Download from URL
--file FILE Copy from local FILE
EOF
test "$drivedbinstdir" = "$drivedbdir" || cat <<EOF
--install Copy from originally installed drive database file
This is the same as:
'--no-verify --file $drivedbinstdir/drivedb.h'
EOF
cat <<EOF
--trunk Download from SVN trunk (requires '--no-verify')
--branch X.Y Download from branches/RELEASE_X_Y_DRIVEDB
--cacert FILE Use CA certificates from FILE to verify the peer
Expand Down Expand Up @@ -603,6 +612,12 @@ while true; do case $1 in
check_optarg "$@"; shift
file=$1 ;;

--install)
test "$drivedbinstdir" != "$drivedbdir" \
|| error "'$1' is not supported in this configuration"
file="$drivedbinstdir/drivedb.h"
no_verify=t ;;

--dryrun)
dryrun=t ;;

Expand Down

0 comments on commit ff6b7e1

Please sign in to comment.