diff options
author | dougb <dougb@FreeBSD.org> | 2012-02-15 16:46:57 +0800 |
---|---|---|
committer | dougb <dougb@FreeBSD.org> | 2012-02-15 16:46:57 +0800 |
commit | 8f6bd326a85f77ef30d22d03fd1d87de261eb29d (patch) | |
tree | a4f5b03e2de8044943e02985832c96c839d6f7cd /sysutils | |
parent | b518c0acf94819d10bd433b23d44db0cb9830c36 (diff) | |
download | freebsd-ports-gnome-8f6bd326a85f77ef30d22d03fd1d87de261eb29d.tar.gz freebsd-ports-gnome-8f6bd326a85f77ef30d22d03fd1d87de261eb29d.tar.zst freebsd-ports-gnome-8f6bd326a85f77ef30d22d03fd1d87de261eb29d.zip |
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)
Diffstat (limited to 'sysutils')
-rw-r--r-- | sysutils/smartmontools/Makefile | 8 | ||||
-rw-r--r-- | sysutils/smartmontools/files/smartd.in | 74 | ||||
-rw-r--r-- | sysutils/smartmontools/pkg-plist | 20 |
3 files changed, 55 insertions, 47 deletions
diff --git a/sysutils/smartmontools/Makefile b/sysutils/smartmontools/Makefile index f7095085536f..3530dfa025cf 100644 --- a/sysutils/smartmontools/Makefile +++ b/sysutils/smartmontools/Makefile @@ -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> diff --git a/sysutils/smartmontools/files/smartd.in b/sysutils/smartmontools/files/smartd.in index b90c99666892..c44f5bf72563 100644 --- a/sysutils/smartmontools/files/smartd.in +++ b/sysutils/smartmontools/files/smartd.in @@ -1,44 +1,70 @@ #!/bin/sh -# $FreeBSD$ +# $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}" + +extra_commands="reload report" +reload_cmd="smartd_reload" +report_cmd="smartd_report" + +start_precmd=smartd_prestart + +smartd_prestart() +{ + case "${smartd_flags}" in + -p*|*-p*) + err 1 'smartd_flags includes the -p option, use smartd_pidfile instead' + ;; + esac +} -load_rc_config $name +smartd_reload() +{ + local status -: ${smartd_config="%%PREFIX%%/etc/smartd.conf"} -: ${smartd_flags="-c ${smartd_config}"} + if ! status=`run_rc_command status 2>&1`; then + echo $status + return 1 + fi + echo 'Reloading smartd.' + kill -HUP $rc_pid +} -pidfile="${smartd_pidfile}" -required_files="${smartd_config}" +smartd_report() +{ + local status -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 + 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" diff --git a/sysutils/smartmontools/pkg-plist b/sysutils/smartmontools/pkg-plist index b799592b2a46..61881784b7b9 100644 --- a/sysutils/smartmontools/pkg-plist +++ b/sysutils/smartmontools/pkg-plist @@ -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 |