Date: Wed, 15 Feb 2012 06:08:13 GMT From: Doug Barton <dougb@FreeBSD.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/165167: Updates for sysutils/smartmontools Message-ID: <201202150608.q1F68DI9044480@freefall.freebsd.org> Resent-Message-ID: <201202150610.q1F6AAFL044624@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 165167 >Category: ports >Synopsis: Updates for sysutils/smartmontools >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Feb 15 06:10:10 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Doug Barton >Release: FreeBSD 8.2-STABLE i386 >Organization: AAAG >Environment: DNA >Description: The attached patch 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 file/. The problem is that on 10-current the set_rcvar function has been removed from rc.subr. Since I had to look at it anyway (and since I use this port) I did a full cleanup for the script, and looked at the port more generally. 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. You might also consider removing the @stopdaemon from pkg-plist altogether. Unless there is a really good reason do so it's frowned on to stop the service when deinstalling it. More information on the rc.d changes: http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/rc-scripts.html >How-To-Repeat: DNA >Fix: Apply the following patch: Index: Makefile =================================================================== RCS file: /home/pcvs/ports/sysutils/smartmontools/Makefile,v retrieving revision 1.56 diff -u -r1.56 Makefile --- Makefile 1 Dec 2011 20:53:31 -0000 1.56 +++ Makefile 15 Feb 2012 05:52:59 -0000 @@ -7,7 +7,7 @@ PORTNAME= smartmontools PORTVERSION= 5.42 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= sysutils MASTER_SITES= SF @@ -19,8 +19,6 @@ 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 @@ 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-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> Index: pkg-plist =================================================================== RCS file: /home/pcvs/ports/sysutils/smartmontools/pkg-plist,v retrieving revision 1.7 diff -u -r1.7 pkg-plist --- pkg-plist 19 Oct 2010 11:31:13 -0000 1.7 +++ pkg-plist 15 Feb 2012 05:52:59 -0000 @@ -1,28 +1,10 @@ -@comment $FreeBSD: ports/sysutils/smartmontools/pkg-plist,v 1.7 2010/10/19 11:31:13 sunpoet Exp $ -@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 Index: files/smartd.in =================================================================== RCS file: /home/pcvs/ports/sysutils/smartmontools/files/smartd.in,v retrieving revision 1.3 diff -u -r1.3 smartd.in --- files/smartd.in 14 Jan 2012 08:57:06 -0000 1.3 +++ files/smartd.in 15 Feb 2012 05:52:59 -0000 @@ -1,44 +1,70 @@ #!/bin/sh -# $FreeBSD: ports/sysutils/smartmontools/files/smartd.in,v 1.3 2012/01/14 08:57:06 dougb Exp $ +# $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 -command="%%PREFIX%%/sbin/smartd" -load_rc_config $name +load_rc_config smartd + +: ${smartd_enable:="NO"} -: ${smartd_config="%%PREFIX%%/etc/smartd.conf"} -: ${smartd_flags="-c ${smartd_config}"} +required_files=${smartd_config:="%%PREFIX%%/etc/smartd.conf"} +pidfile=${smartd_pidfile:="/var/run/smartd.pid"} -pidfile="${smartd_pidfile}" -required_files="${smartd_config}" +command="%%PREFIX%%/sbin/smartd" +command_args="-c ${required_files} -p ${pidfile}" -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 +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 +} + +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" >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202150608.q1F68DI9044480>