This change has various simplifications/improvements for

the port. Most importantly, it's currently installing the rc.d
script from the source, rather than the fixed one in files/.

1. Remove 6.x compatibility hack
2. Use the PORTDOCS macro
3. Actually install the rc.d script in files/
4. Simplify pkg-plist
5. For the rc.d script:
   a. Move it to the standard location, after LOGIN
   b. Add KEYWORD nojail per the script in the distfiles
   c. Put the standard arguments in their usual order/formats
   d. Simplify the assignments of pidfile and required_files
   e. Use command_args for required arguments, don't abuse _flags
   f. The test for -p in smartd_flags should be a start_precmd,
      we frown on running any code unconditionally.
      Also, improve this check if -p is first.
   g. Bring the reload and report options from the distfile version,
      and simplify them.

PR:		ports/165167
Submitted by:	me
Approved by:	Alex Samorukov <samm@os2.kiev.ua> (maintainer)
This commit is contained in:
Doug Barton 2012-02-15 08:46:57 +00:00
parent 32bad5bbda
commit 16b13f3515
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=291428
3 changed files with 55 additions and 47 deletions

View File

@ -7,7 +7,7 @@
PORTNAME= smartmontools
PORTVERSION= 5.42
PORTREVISION= 2
PORTREVISION= 3
CATEGORIES= sysutils
MASTER_SITES= SF
@ -19,8 +19,6 @@ LICENSE= GPLv2
CONFLICTS= smartmontools-devel-[0-9]*
USE_GMAKE= yes
# hack to prevent gmake failure on 6.xx
GMAKE= make
GNU_CONFIGURE= yes
CONFIGURE_ARGS= --disable-dependency-tracking \
--enable-drivedb --enable-sample \
@ -32,6 +30,8 @@ USE_RC_SUBR= smartd
MAN5= smartd.conf.5
MAN8= smartd.8 smartctl.8
PORTDOCS= *
CFLAGS:= ${CFLAGS:S/-O2/-O/} -Wno-write-strings
post-patch:
@ -40,7 +40,7 @@ post-patch:
post-install:
${MKDIR} ${PREFIX}/etc/periodic/daily
${INSTALL_SCRIPT} ${WRKDIR}/smart ${PREFIX}/etc/periodic/daily/smart
${INSTALL_SCRIPT} ${WRKSRC}/smartd.freebsd.initd ${PREFIX}/etc/rc.d/smartd
@${CAT} ${PKGMESSAGE}
.include <bsd.port.mk>

View File

@ -1,44 +1,70 @@
#!/bin/sh
# $FreeBSD$
#
# PROVIDE: smartd
# REQUIRE: DAEMON
# BEFORE: LOGIN
# KEYWORD: shutdown
# REQUIRE: LOGIN
# KEYWORD: shutdown nojail
#
# Define these smartd_* variables in one of these files:
# /etc/rc.conf
# /etc/rc.conf.local
# /etc/rc.conf.d/smartd
#
# DO NOT CHANGE THESE DEFAULT VALUES HERE
#
smartd_enable="${smartd_enable-NO}"
smartd_pidfile="/var/run/smartd.pid"
. /etc/rc.subr
name="smartd"
name=smartd
rcvar=smartd_enable
load_rc_config smartd
: ${smartd_enable:="NO"}
required_files=${smartd_config:="%%PREFIX%%/etc/smartd.conf"}
pidfile=${smartd_pidfile:="/var/run/smartd.pid"}
command="%%PREFIX%%/sbin/smartd"
command_args="-c ${required_files} -p ${pidfile}"
load_rc_config $name
extra_commands="reload report"
reload_cmd="smartd_reload"
report_cmd="smartd_report"
: ${smartd_config="%%PREFIX%%/etc/smartd.conf"}
: ${smartd_flags="-c ${smartd_config}"}
start_precmd=smartd_prestart
pidfile="${smartd_pidfile}"
required_files="${smartd_config}"
smartd_prestart()
{
case "${smartd_flags}" in
-p*|*-p*)
err 1 'smartd_flags includes the -p option, use smartd_pidfile instead'
;;
esac
}
case "${smartd_flags}" in
*-p\ *)
echo "ERROR: \$smartd_flags includes -p option." \
"Please use \$smartd_pidfile instead."
exit 1
;;
*)
smartd_flags="-p ${pidfile} ${smartd_flags}"
;;
esac
smartd_reload()
{
local status
if ! status=`run_rc_command status 2>&1`; then
echo $status
return 1
fi
echo 'Reloading smartd.'
kill -HUP $rc_pid
}
smartd_report()
{
local status
if ! status=`run_rc_command status 2>&1`; then
echo $status
return 1
fi
echo 'Checking SMART devices now.'
kill -USR1 $rc_pid
}
run_rc_command "$1"

View File

@ -1,28 +1,10 @@
@comment $FreeBSD$
@unexec /bin/echo "===>" Stopping smartd ...
@unexec /usr/bin/killall smartd 2>/dev/null || true
@stopdaemon smartd
etc/periodic/daily/smart
etc/smartd.conf.sample
sbin/smartctl
sbin/smartd
sbin/update-smart-drivedb
%%DOCSDIR%%/AUTHORS
%%DOCSDIR%%/CHANGELOG
%%DOCSDIR%%/COPYING
%%DOCSDIR%%/INSTALL
%%DOCSDIR%%/NEWS
%%DOCSDIR%%/README
%%DOCSDIR%%/TODO
%%DOCSDIR%%/WARNINGS
%%DOCSDIR%%/examplescripts/Example1
%%DOCSDIR%%/examplescripts/Example2
%%DOCSDIR%%/examplescripts/Example3
%%DOCSDIR%%/examplescripts/Example4
%%DOCSDIR%%/examplescripts/README
%%DOCSDIR%%/smartd.conf
%%DATADIR%%/drivedb.h
@dirrm %%DATADIR%%
@dirrm %%DOCSDIR%%/examplescripts
@dirrm %%DOCSDIR%%
@dirrmtry etc/periodic/daily
@dirrmtry etc/periodic