pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/mk/init



Module Name:    pkgsrc
Committed By:   jlam
Date:           Thu Jun  1 02:08:05 UTC 2017

Added Files:
        pkgsrc/mk/init: bsd.init-vars.mk bsd.init.mk rc.d.mk smf.mk
        pkgsrc/mk/init/tests: Kyuafile
        pkgsrc/mk/init/tests/rc.d: Kyuafile generate_test init_scripts_test
            install_test make_dirs_test test.mk test_common.sh
        pkgsrc/mk/init/tests/smf: Kyuafile manifest_generate_test
            manifest_install_test methods_generate_test methods_install_test
            test.mk test_common.sh

Log Message:
Add "init" framework for management of init scripts for packages.

${INIT_SYSTEM} is used to select the type of init system in use on
the system, and currently can be either "rc.d" for the NetBSD rc.d
system, or "smf" for the Solaris Service Management Facility
system.

pkgsrc/mk/init/smf.mk is pkgsrc/mk/smf.mk with some very minor
modifications to fit into the "init" framework.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 pkgsrc/mk/init/bsd.init-vars.mk \
    pkgsrc/mk/init/bsd.init.mk pkgsrc/mk/init/rc.d.mk pkgsrc/mk/init/smf.mk
cvs rdiff -u -r0 -r1.1 pkgsrc/mk/init/tests/Kyuafile
cvs rdiff -u -r0 -r1.1 pkgsrc/mk/init/tests/rc.d/Kyuafile \
    pkgsrc/mk/init/tests/rc.d/generate_test \
    pkgsrc/mk/init/tests/rc.d/init_scripts_test \
    pkgsrc/mk/init/tests/rc.d/install_test \
    pkgsrc/mk/init/tests/rc.d/make_dirs_test \
    pkgsrc/mk/init/tests/rc.d/test.mk \
    pkgsrc/mk/init/tests/rc.d/test_common.sh
cvs rdiff -u -r0 -r1.1 pkgsrc/mk/init/tests/smf/Kyuafile \
    pkgsrc/mk/init/tests/smf/manifest_generate_test \
    pkgsrc/mk/init/tests/smf/manifest_install_test \
    pkgsrc/mk/init/tests/smf/methods_generate_test \
    pkgsrc/mk/init/tests/smf/methods_install_test \
    pkgsrc/mk/init/tests/smf/test.mk pkgsrc/mk/init/tests/smf/test_common.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: pkgsrc/mk/init/bsd.init-vars.mk
diff -u /dev/null pkgsrc/mk/init/bsd.init-vars.mk:1.1
--- /dev/null   Thu Jun  1 02:08:05 2017
+++ pkgsrc/mk/init/bsd.init-vars.mk     Thu Jun  1 02:08:04 2017
@@ -0,0 +1,44 @@
+# $NetBSD: bsd.init-vars.mk,v 1.1 2017/06/01 02:08:04 jlam Exp $
+#
+# Copyright (c) 2017 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+# This Makefile fragment is included by bsd.prefs.mk and defines some
+# variables which must be defined earlier than where bsd.init.mk is
+# included.
+
+# System-settable variables:
+#
+# INIT_SYSTEM
+#      Type of system used to spawn processes as the last stage of
+#      the boot process.
+#
+#      Possible: rc.d, smf
+#      Default: rc.d
+#
+_SYS_VARS.init+=       INIT_SYSTEM
+_BUILD_DEFS+=          INIT_SYSTEM
+INIT_SYSTEM?=          rc.d
Index: pkgsrc/mk/init/bsd.init.mk
diff -u /dev/null pkgsrc/mk/init/bsd.init.mk:1.1
--- /dev/null   Thu Jun  1 02:08:05 2017
+++ pkgsrc/mk/init/bsd.init.mk  Thu Jun  1 02:08:04 2017
@@ -0,0 +1,34 @@
+# $NetBSD: bsd.init.mk,v 1.1 2017/06/01 02:08:04 jlam Exp $
+#
+# Copyright (c) 2017 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+# This Makefile fragment is included by bsd.pkg.mk and pulls in the
+# correct target and variable overrides for the selected init script
+# system.
+
+.sinclude "${INIT_SYSTEM}.mk"
Index: pkgsrc/mk/init/rc.d.mk
diff -u /dev/null pkgsrc/mk/init/rc.d.mk:1.1
--- /dev/null   Thu Jun  1 02:08:05 2017
+++ pkgsrc/mk/init/rc.d.mk      Thu Jun  1 02:08:04 2017
@@ -0,0 +1,139 @@
+# $NetBSD: rc.d.mk,v 1.1 2017/06/01 02:08:04 jlam Exp $
+#
+# Copyright (c) 2017 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+# Infrastructure support for the rc.d script system (pkgtools/rc.subr).
+#
+# Package-settable variables:
+#
+# RCD_SCRIPTS
+#      List of the basenames of the rc.d scripts.  The example rc.d
+#      script must be found in ${PREFIX}/share/examples/rc.d, and
+#      the script will be copied into ${RCD_SCRIPTS_DIR} with
+#      ${RCD_SCRIPTS_MODE} permissions.
+#
+# RCD_SCRIPTS_DIR
+#      The location of the copied rc.d scripts.
+#
+#      Possible: any path
+#      Default: /etc/rc.d
+#
+# RCD_SCRIPTS_EXAMPLEDIR
+#      The location of the example rc.d scripts.  This location must
+#      be a relative path to ${PREFIX}.
+#
+#      Possible: any path
+#      Default: share/examples/rc.d
+#
+# RCD_SCRIPTS_MODE
+#      The file mode of the copied rc.d scripts.
+#
+#      Possible: any file mode
+#      Default: 0755
+#
+# RCD_SCRIPTS_SHELL
+#      The shell used to run the rc.d scripts.
+#
+#      Possible: any shell path
+#      Default: ${SH}
+#
+# RCD_SCRIPT_SRC.<script>
+#      The source file for the rc.d script with basename <script>
+#      before installation; the source file is put through variable
+#      substitution to generate the target rc.d script.  If the
+#      source file is not present, then no rc.d script is generated.
+#
+#      Possible: any path
+#      Default: ${FILESDIR}/<script>.sh
+#
+_PKG_VARS.init+=       RCD_SCRIPTS RCD_SCRIPTS_MODE RCD_SCRIPTS_SHELL
+_PKG_VARS.init+=       RCD_SCRIPTS_DIR RCD_SCRIPTS_EXAMPLEDIRI
+_PKG_VARS.init+=       ${RCD_SCRIPTS:@s@RCD_SCRIPT_SRC.${s}@}
+
+RCD_SCRIPTS_DIR?=              /etc/rc.d
+RCD_SCRIPTS_EXAMPLEDIR?=       share/examples/rc.d
+RCD_SCRIPTS_MODE?=             0755
+RCD_SCRIPTS_SHELL?=            ${SH}
+
+FILES_SUBST+=          RCD_SCRIPTS_SHELL=${RCD_SCRIPTS_SHELL:Q}
+MESSAGE_SUBST+=                RCD_SCRIPTS_DIR=${RCD_SCRIPTS_DIR:Q}
+MESSAGE_SUBST+=                RCD_SCRIPTS_EXAMPLEDIR=${RCD_SCRIPTS_EXAMPLEDIR:Q}
+
+.PHONY: generate-rcd-scripts
+generate-rcd-scripts:  # do nothing
+
+# Hook into installation process via "post-install" target.
+.PHONY: install-rcd-scripts
+post-install: install-rcd-scripts
+install-rcd-scripts:   # do nothing
+
+# Add to MAKE_DIRS to ensure ${RCD_SCRIPTS_DIR} is created automatically.
+_MAKE_RCD_SCRIPTS_DIR= # empty
+
+.for _script_ in ${RCD_SCRIPTS}
+RCD_SCRIPT_SRC.${_script_}?=   ${FILESDIR}/${_script_}.sh
+_RCD_SCRIPT_WRK.${_script_}?=  ${WRKDIR}/.rc.d/${_script_}
+_RCD_SCRIPT_FILE.${_script_}?= ${RCD_SCRIPTS_EXAMPLEDIR}/${_script_}
+
+.  if !empty(RCD_SCRIPT_SRC.${_script_})
+generate-rcd-scripts: ${_RCD_SCRIPT_WRK.${_script_}}
+${_RCD_SCRIPT_WRK.${_script_}}: ${RCD_SCRIPT_SRC.${_script_}}
+       @${STEP_MSG} "Creating "${.TARGET:Q}
+       ${RUN}${MKDIR} ${.TARGET:H:Q}
+       ${RUN}${CAT} ${.ALLSRC:Q} | ${SED} ${FILES_SUBST_SED} > ${.TARGET:Q}
+       ${RUN}${CHMOD} +x ${.TARGET:Q}
+
+.PHONY: install-rcd-${_script_}
+install-rcd-scripts: install-rcd-${_script_}
+install-rcd-${_script_}: ${_RCD_SCRIPT_WRK.${_script_}}
+       ${RUN}${MKDIR} ${DESTDIR:Q}${PREFIX:Q}/${_RCD_SCRIPT_FILE.${_script_}:H:Q}
+       ${RUN}${INSTALL_SCRIPT} ${_RCD_SCRIPT_WRK.${_script_}} \
+               ${DESTDIR:Q}${PREFIX:Q}/${_RCD_SCRIPT_FILE.${_script_}:Q}
+.  endif
+
+# Hook into plist module to automatically add rc.d scripts into the
+# packing list.
+#
+GENERATE_PLIST+=       ${ECHO} ${_RCD_SCRIPT_FILE.${_script_}:Q};
+PRINT_PLIST_AWK+=      /^${_RCD_SCRIPT_FILE.${_script_}:S|/|\\/|g}/ { next; }
+
+# Hook into the pkgtasks module to copy rc.d scripts into place in
+# the package tasks.
+#
+_INIT_SCRIPTS+=                ${_RCD_SCRIPT_FILE.${_script_}} \
+                       ${RCD_SCRIPTS_DIR}/${_script_}
+_INIT_SCRIPTS_MODE=    ${RCD_SCRIPTS_MODE}
+
+# Only set this value if ${RCD_SCRIPTS} was non-empty.
+_MAKE_RCD_SCRIPTS_DIR= ${RCD_SCRIPTS_DIR}
+.endfor
+
+# Hook into the pkgtasks module to create ${RCD_SCRIPTS_DIR} in the
+# package tasks if there are rc.d scripts to copy into place.
+#
+MAKE_DIRS+=    ${_MAKE_RCD_SCRIPTS_DIR}
Index: pkgsrc/mk/init/smf.mk
diff -u /dev/null pkgsrc/mk/init/smf.mk:1.1
--- /dev/null   Thu Jun  1 02:08:05 2017
+++ pkgsrc/mk/init/smf.mk       Thu Jun  1 02:08:04 2017
@@ -0,0 +1,145 @@
+# $NetBSD: smf.mk,v 1.1 2017/06/01 02:08:04 jlam Exp $
+#
+# Infrastructure support for the Service Management Facility (SMF).  This
+# file will be sourced and used if INIT_SYSTEM is set to "smf".
+#
+# User-settable variables:
+#
+# SMF_PREFIX
+#      This is the global FMRI prefix that will be used in SMF.  The
+#      default is "pkgsrc", so the general URI will be of the form
+#      "svc:/pkgsrc/<package>:<instance>".
+#
+# Package-settable variables:
+#
+# SMF_SRCDIR
+#      The source directory containing manifest and method files.  This
+#      defaults to ${FILESDIR}/smf and can be set to a location under
+#      ${WRKSRC} if necessary (i.e. the source includes SMF files).
+#
+# SMF_NAME
+#      This sets the service name part of the FMRI, and defaults to the
+#      lower-case string of PKGBASE.
+#
+# SMF_MANIFEST
+#      The name of the XML file under SMF_SRCDIR which is to be used as
+#      this package's manifest.  The default name is "manifest.xml"
+#
+# SMF_INSTANCES
+#      The list of instances this manifest provides.  Manifests support
+#      multiple instances, the default is a single "default" instance.
+#
+# SMF_METHODS
+#      A list of SMF method scripts available under SMF_SRCDIR with
+#      ".sh" extensions to be generated and installed.
+#
+# SMF_METHOD_SRC.<method>
+#      Allows you to override the source file name for a particular
+#      method, if it does not follow the standard <method>.sh naming.
+#
+# SMF_METHOD_SHELL
+#      The default shell to use in method scripts.
+#
+
+.if !defined(SMF_MK)
+SMF_MK=                                # defined
+
+# Directory to hold the SMF manifest/method files
+PKG_SMF_DIR?=                  lib/svc
+PKG_SMF_MANIFEST_DIR?=         ${PKG_SMF_DIR}/manifest
+PKG_SMF_METHOD_DIR?=           ${PKG_SMF_DIR}/method
+
+# Prefix of SMF services FMRI
+SMF_PREFIX?=                   pkgsrc
+
+# Variables that can be overriden by the user on a package by package basis
+SMF_NAME?=                     ${PKGBASE:tl}
+SMF_INSTANCES?=                        default
+SMF_MANIFEST?=                 manifest.xml
+SMF_METHODS?=                  # empty
+SMF_METHOD_SHELL?=             /sbin/sh
+SMF_SRCDIR?=                   ${FILESDIR}/smf
+
+# Dynamically remove rc.d entries, primarily for pkgsrc-{joyent,wip}
+PLIST_AWK+=                    -f ${PKGSRCDIR}/mk/plist/plist-smf.awk
+
+# A manifest file is a pre-requisite for anything to happen.  We cannot test
+# for existance if the manifest is under WRKDIR as the source has not yet been
+# unpacked, so we assume it will exist later when required.
+.  if exists(${SMF_SRCDIR}/${SMF_MANIFEST}) || !empty(SMF_SRCDIR:M${WRKDIR}*)
+
+SMF_MANIFEST_SRC?=             ${SMF_SRCDIR}/${SMF_MANIFEST}
+_SMF_MANIFEST_WRK?=            ${WRKDIR}/.smf_${SMF_MANIFEST}
+SMF_MANIFEST_FILE?=            ${PKG_SMF_MANIFEST_DIR}/${SMF_NAME}.xml
+
+FILES_SUBST+=                  PKGMANDIR=${PKGMANDIR:Q}
+FILES_SUBST+=                  SMF_PREFIX=${SMF_PREFIX:Q}
+FILES_SUBST+=                  SMF_NAME=${SMF_NAME:Q}
+FILES_SUBST+=                  SMF_INSTANCES=${SMF_INSTANCES:Q}
+FILES_SUBST+=                  SMF_MANIFEST=${SMF_MANIFEST:Q}
+FILES_SUBST+=                  SMF_MANIFEST_FILE=${SMF_MANIFEST_FILE:Q}
+FILES_SUBST+=                  SMF_METHOD_SHELL=${SMF_METHOD_SHELL:Q}
+
+INSTALLATION_DIRS+=            ${PKG_SMF_MANIFEST_DIR}
+MULTIARCH_SKIP_DIRS.lib+=      ${PKG_SMF_DIR}
+
+.PHONY: generate-smf-manifest
+generate-smf-manifest: ${_SMF_MANIFEST_WRK}
+${_SMF_MANIFEST_WRK}: ${SMF_MANIFEST_SRC}
+       @${STEP_MSG} "Creating ${.TARGET}"
+       ${RUN}${MKDIR} ${.TARGET:H:Q}
+       ${RUN}${CAT} ${.ALLSRC} | ${SED} ${FILES_SUBST_SED} > ${.TARGET}
+
+# Hook into installation process via "post-install" target.
+.PHONY: install-smf-manifest
+post-install: install-smf-manifest
+install-smf-manifest: ${_SMF_MANIFEST_WRK}
+       ${RUN}${MKDIR} ${DESTDIR:Q}${PREFIX:Q}/${SMF_MANIFEST_FILE:H:Q}
+       ${INSTALL_DATA} ${_SMF_MANIFEST_WRK} ${DESTDIR}${PREFIX}/${SMF_MANIFEST_FILE}
+
+GENERATE_PLIST+=               ${ECHO} "${SMF_MANIFEST_FILE}";
+PRINT_PLIST_AWK+=              /^${SMF_MANIFEST_FILE:S|/|\\/|g}/ { next; }
+
+# Target to add the INSTALL script to auto-import SMF manifest using svccfg
+${WRKDIR}/.smfinstall: ${PKGSRCDIR}/mk/install/install-smf
+       ${RUN}${MKDIR} ${.TARGET:H:Q}
+       ${RUN}${CP} ${.ALLSRC:Q} ${.TARGET:Q}
+
+INSTALL_TEMPLATES+=            ${WRKDIR}/.smfinstall
+
+# Install optional SMF methods
+#
+.PHONY: generate-smf-methods
+generate-smf-methods:  # do nothing
+
+.PHONY: install-smf-methods
+post-install: install-smf-methods
+install-smf-methods:   # do nothing
+
+.    for _method_ in ${SMF_METHODS}
+SMF_METHOD_SRC.${_method_}?=   ${SMF_SRCDIR}/${_method_}.sh
+_SMF_METHOD_WRK.${_method_}?=  ${WRKDIR}/.smf_${_method_}
+SMF_METHOD_FILE.${_method_}?=  ${PKG_SMF_METHOD_DIR}/${_method_}
+
+FILES_SUBST+=  SMF_METHOD_FILE.${_method_}=${SMF_METHOD_FILE.${_method_}}
+
+.      if !empty(SMF_METHOD_SRC.${_method_})
+generate-smf-methods: ${_SMF_METHOD_WRK.${_method_}}
+${_SMF_METHOD_WRK.${_method_}}: ${SMF_METHOD_SRC.${_method_}}
+       @${STEP_MSG} "Creating ${.TARGET}"
+       ${RUN}${MKDIR} ${.TARGET:H:Q}
+       ${RUN}${CAT} ${.ALLSRC} | ${SED} ${FILES_SUBST_SED} > ${.TARGET}
+       ${RUN}${CHMOD} +x ${.TARGET}
+
+.PHONY: install-smf-${_method_}
+install-smf-methods: install-smf-${_method_}
+install-smf-${_method_}: ${_SMF_METHOD_WRK.${_method_}}
+       ${RUN}${MKDIR} ${DESTDIR:Q}${PREFIX:Q}/${SMF_METHOD_FILE.${_method_}:H:Q}
+       ${RUN}${INSTALL_SCRIPT} ${_SMF_METHOD_WRK.${_method_}} \
+               ${DESTDIR:Q}${PREFIX:Q}/${SMF_METHOD_FILE.${_method_}:Q}
+.      endif
+GENERATE_PLIST+=       ${ECHO} ${SMF_METHOD_FILE.${_method_}};
+PRINT_PLIST_AWK+=      /^${SMF_METHOD_FILE.${_method_}:S|/|\\/|g}/ { next; }
+.    endfor
+.  endif
+.endif

Index: pkgsrc/mk/init/tests/Kyuafile
diff -u /dev/null pkgsrc/mk/init/tests/Kyuafile:1.1
--- /dev/null   Thu Jun  1 02:08:05 2017
+++ pkgsrc/mk/init/tests/Kyuafile       Thu Jun  1 02:08:04 2017
@@ -0,0 +1,38 @@
+-- $NetBSD: Kyuafile,v 1.1 2017/06/01 02:08:04 jlam Exp $
+--[[-----------------------------------------------------------------------
+Copyright (c) 2017 The NetBSD Foundation, Inc.
+All rights reserved.
+
+This code is derived from software contributed to The NetBSD Foundation
+by Johnny C. Lam.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+--]]-----------------------------------------------------------------------
+
+-- Top-level Kyuafile for pkgsrc/init/tests.
+
+syntax( 2 )
+
+test_suite( "pkgsrc_init" )
+
+include( "rc.d/Kyuafile" )
+include( "smf/Kyuafile" )

Index: pkgsrc/mk/init/tests/rc.d/Kyuafile
diff -u /dev/null pkgsrc/mk/init/tests/rc.d/Kyuafile:1.1
--- /dev/null   Thu Jun  1 02:08:05 2017
+++ pkgsrc/mk/init/tests/rc.d/Kyuafile  Thu Jun  1 02:08:05 2017
@@ -0,0 +1,46 @@
+-- $NetBSD: Kyuafile,v 1.1 2017/06/01 02:08:05 jlam Exp $
+--[[-----------------------------------------------------------------------
+Copyright (c) 2017 The NetBSD Foundation, Inc.
+All rights reserved.
+
+This code is derived from software contributed to The NetBSD Foundation
+by Johnny C. Lam.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+--]]-----------------------------------------------------------------------
+--[[-----------------------------------------------------------------------
+
+       The following variables will be used if they are set.
+
+       PKGSRCDIR
+               The location of the pkgsrc directory tree.
+
+--]]-----------------------------------------------------------------------
+
+syntax( 2 )
+
+test_suite( "pkgsrc_init" )
+
+plain_test_program { name = "generate_test" }
+plain_test_program { name = "install_test" }
+plain_test_program { name = "init_scripts_test" }
+plain_test_program { name = "make_dirs_test" }
Index: pkgsrc/mk/init/tests/rc.d/generate_test
diff -u /dev/null pkgsrc/mk/init/tests/rc.d/generate_test:1.1
--- /dev/null   Thu Jun  1 02:08:05 2017
+++ pkgsrc/mk/init/tests/rc.d/generate_test     Thu Jun  1 02:08:05 2017
@@ -0,0 +1,76 @@
+#!/bin/sh
+#
+# $NetBSD: generate_test,v 1.1 2017/06/01 02:08:05 jlam Exp $
+#
+# Copyright (c) 2017 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+: ${PKGSRCDIR:=/usr/pkgsrc}
+
+. "${PKGSRCDIR}/mk/init/tests/rc.d/test_common.sh"
+
+setup()
+{
+       common_setup
+}
+
+teardown()
+{
+       common_teardown
+}
+
+run_test()
+{
+       : ${CMP:=cmp}
+       : ${ECHO:=echo}
+       : ${MAKE:=make}
+
+       ( cd work
+         ${ECHO} "Testing: generated script is correct"
+
+         local expected="daemond"
+         ${ECHO} ">>> expected"
+         ${CAT} "$expected"
+
+         ${MAKE} generate-rcd-scripts \
+               PKGSRCDIR="${PKGSRCDIR}" || return 1
+
+         local value="work/.rc.d/daemond"
+         if [ ! -f "$value" ]; then
+               ${ECHO} "!!! ERROR: $value is missing!"
+               return 1
+         fi
+         ${ECHO} ">>> value"
+         ${CAT} "$value"
+
+         ${CMP} "$expected" "$value" )
+}
+
+setup && run_test
+result=$?
+teardown
+exit $result
Index: pkgsrc/mk/init/tests/rc.d/init_scripts_test
diff -u /dev/null pkgsrc/mk/init/tests/rc.d/init_scripts_test:1.1
--- /dev/null   Thu Jun  1 02:08:05 2017
+++ pkgsrc/mk/init/tests/rc.d/init_scripts_test Thu Jun  1 02:08:05 2017
@@ -0,0 +1,75 @@
+#!/bin/sh
+#
+# $NetBSD: init_scripts_test,v 1.1 2017/06/01 02:08:05 jlam Exp $
+#
+# Copyright (c) 2017 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+: ${PKGSRCDIR:=/usr/pkgsrc}
+
+. "${PKGSRCDIR}/mk/init/tests/rc.d/test_common.sh"
+
+setup()
+{
+       common_setup
+}
+
+teardown()
+{
+       common_teardown
+}
+
+run_test()
+{
+       : ${CAT:=cat}
+       : ${CMP:=cmp}
+       : ${ECHO:=echo}
+       : ${MAKE:=make}
+
+       ( cd work
+         ${ECHO} "Testing: _INIT_SCRIPTS contains rc.d scripts"
+         ${ECHO} ">>> expected"
+         local expected_src="share/examples/rc.d/daemond"
+         local expected_target="/etc/rc.d/daemond"
+         ${ECHO} "$expected_src -> $expected_target"
+
+         ${ECHO} ">>> value"
+         ${MAKE} show-var VARNAME=_INIT_SCRIPTS PKGSRCDIR="${PKGSRCDIR}" |
+         ( read value_src value_target
+           ${ECHO} "$value_src -> $value_target"
+           if [ "$expected_src" = "$value_src" ] &&
+              [ "$expected_target" = "$expected_target" ]; then
+               return 0
+           else
+               return 1
+           fi ) )
+}
+
+setup && run_test
+result=$?
+teardown
+exit $result
Index: pkgsrc/mk/init/tests/rc.d/install_test
diff -u /dev/null pkgsrc/mk/init/tests/rc.d/install_test:1.1
--- /dev/null   Thu Jun  1 02:08:05 2017
+++ pkgsrc/mk/init/tests/rc.d/install_test      Thu Jun  1 02:08:05 2017
@@ -0,0 +1,61 @@
+#!/bin/sh
+#
+# $NetBSD: install_test,v 1.1 2017/06/01 02:08:05 jlam Exp $
+#
+# Copyright (c) 2017 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+: ${PKGSRCDIR:=/usr/pkgsrc}
+
+. "${PKGSRCDIR}/mk/init/tests/rc.d/test_common.sh"
+
+setup()
+{
+       common_setup
+}
+
+teardown()
+{
+       common_teardown
+}
+
+run_test()
+{
+       : ${ECHO:=echo}
+       : ${MAKE:=make}
+
+       ( cd work
+         ${ECHO} "Testing: script is installed"
+
+         ${MAKE} install-rcd-scripts PKGSRCDIR="${PKGSRCDIR}" &&
+         [ -x destdir/usr/pkg/share/examples/rc.d/daemond ] )
+}
+
+setup && run_test
+result=$?
+teardown
+exit $result
Index: pkgsrc/mk/init/tests/rc.d/make_dirs_test
diff -u /dev/null pkgsrc/mk/init/tests/rc.d/make_dirs_test:1.1
--- /dev/null   Thu Jun  1 02:08:05 2017
+++ pkgsrc/mk/init/tests/rc.d/make_dirs_test    Thu Jun  1 02:08:05 2017
@@ -0,0 +1,67 @@
+#!/bin/sh
+#
+# $NetBSD: make_dirs_test,v 1.1 2017/06/01 02:08:05 jlam Exp $
+#
+# Copyright (c) 2017 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+: ${PKGSRCDIR:=/usr/pkgsrc}
+
+. "${PKGSRCDIR}/mk/init/tests/rc.d/test_common.sh"
+
+setup()
+{
+       common_setup
+}
+
+teardown()
+{
+       common_teardown
+}
+
+run_test()
+{
+       : ${ECHO:=echo}
+       : ${MAKE:=make}
+
+       ( cd work
+         ${ECHO} "Testing: MAKE_DIRS contains \${RCD_SCRIPTS_DIR}"
+
+         ${MAKE} show-var VARNAME=MAKE_DIRS PKGSRCDIR="${PKGSRCDIR}" |
+         ( while read line; do
+               ${ECHO} "$line"
+               case $line in
+               /etc/rc.d) return 0 ;;
+               esac
+           done
+           return 1 ) )
+}
+
+setup && run_test
+result=$?
+teardown
+exit $result
Index: pkgsrc/mk/init/tests/rc.d/test.mk
diff -u /dev/null pkgsrc/mk/init/tests/rc.d/test.mk:1.1
--- /dev/null   Thu Jun  1 02:08:05 2017
+++ pkgsrc/mk/init/tests/rc.d/test.mk   Thu Jun  1 02:08:05 2017
@@ -0,0 +1,61 @@
+# $NetBSD: test.mk,v 1.1 2017/06/01 02:08:05 jlam Exp $
+#
+# Copyright (c) 2017 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+INIT_SYSTEM=   rc.d
+
+.include "${PKGSRCDIR}/mk/init/bsd.init-vars.mk"
+
+# Definitions used by rc.d.mk that are not assigned default values.
+CAT?=                  cat
+CHMOD?=                        chmod
+CP?=                   cp
+ECHO?=                 echo
+INSTALL_SCRIPT?=       ${CP}
+LOCALBASE?=            /usr/pkg
+MKDIR?=                        mkdir -p
+PREFIX?=               ${LOCALBASE}
+RUN?=                  # empty; show all commands executed
+SED?=                  sed
+SH?=                   /bin/sh
+STEP_MSG?=             ${ECHO} "!!!"
+
+# Turn ${FILES_SUBST} into a sed(1) script.
+FILES_SUBST_SED=       ${FILES_SUBST:S/=/@!/:S/$/!g/:S/^/ -e s!@/}
+
+# Override any other default definitions so that generated files go into
+# a work directory.
+#
+DESTDIR=       ${.CURDIR}/destdir
+FILESDIR=      ${.CURDIR}
+WRKDIR=                ${.CURDIR}/work
+
+# Target to write the value of a variable to standard output.
+.PHONY: show-var
+show-var:
+       @${ECHO} ${${VARNAME}:Q}
Index: pkgsrc/mk/init/tests/rc.d/test_common.sh
diff -u /dev/null pkgsrc/mk/init/tests/rc.d/test_common.sh:1.1
--- /dev/null   Thu Jun  1 02:08:05 2017
+++ pkgsrc/mk/init/tests/rc.d/test_common.sh    Thu Jun  1 02:08:05 2017
@@ -0,0 +1,68 @@
+# $NetBSD: test_common.sh,v 1.1 2017/06/01 02:08:05 jlam Exp $
+#
+# Copyright (c) 2017 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+common_setup()
+{
+       : ${CAT:=cat}
+       : ${ECHO:=echo}
+       : ${MKDIR:=mkdir}
+
+       ${MKDIR} work
+       ${CAT} > work/Makefile << 'EOF'
+.include "${PKGSRCDIR}/mk/init/tests/rc.d/test.mk"
+
+# Define the package-settable RCD_SCRIPTS variable.
+RCD_SCRIPTS=   daemond
+
+.include "${PKGSRCDIR}/mk/init/bsd.init.mk"
+EOF
+
+       ${CAT} > work/daemond_body << 'EOF'
+. /etc/rc.subr
+
+name="daemond"
+rcvar=$name
+command="/usr/pkg/sbin/daemond"
+load_rc_config $name
+run_rc_command "$1"
+EOF
+       # Example rc.d script.
+       ( ${ECHO} "#!@RCD_SCRIPTS_SHELL@"
+         ${CAT} work/daemond_body ) > work/daemond.sh
+       # Expected rc.d script.
+       ( ${ECHO} "#!/bin/sh"
+         ${CAT} work/daemond_body ) > work/daemond
+}
+
+common_teardown()
+{
+       : ${RM:=rm}
+
+       ${RM} -fr work
+}

Index: pkgsrc/mk/init/tests/smf/Kyuafile
diff -u /dev/null pkgsrc/mk/init/tests/smf/Kyuafile:1.1
--- /dev/null   Thu Jun  1 02:08:05 2017
+++ pkgsrc/mk/init/tests/smf/Kyuafile   Thu Jun  1 02:08:05 2017
@@ -0,0 +1,46 @@
+-- $NetBSD: Kyuafile,v 1.1 2017/06/01 02:08:05 jlam Exp $
+--[[-----------------------------------------------------------------------
+Copyright (c) 2017 The NetBSD Foundation, Inc.
+All rights reserved.
+
+This code is derived from software contributed to The NetBSD Foundation
+by Johnny C. Lam.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+--]]-----------------------------------------------------------------------
+--[[-----------------------------------------------------------------------
+
+       The following variables will be used if they are set.
+
+       PKGSRCDIR
+               The location of the pkgsrc directory tree.
+
+--]]-----------------------------------------------------------------------
+
+syntax( 2 )
+
+test_suite( "pkgsrc_init" )
+
+plain_test_program { name = "manifest_generate_test" }
+plain_test_program { name = "manifest_install_test" }
+plain_test_program { name = "methods_generate_test" }
+plain_test_program { name = "methods_install_test" }
Index: pkgsrc/mk/init/tests/smf/manifest_generate_test
diff -u /dev/null pkgsrc/mk/init/tests/smf/manifest_generate_test:1.1
--- /dev/null   Thu Jun  1 02:08:05 2017
+++ pkgsrc/mk/init/tests/smf/manifest_generate_test     Thu Jun  1 02:08:05 2017
@@ -0,0 +1,76 @@
+#!/bin/sh
+#
+# $NetBSD: manifest_generate_test,v 1.1 2017/06/01 02:08:05 jlam Exp $
+#
+# Copyright (c) 2017 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+: ${PKGSRCDIR:=/usr/pkgsrc}
+
+. "${PKGSRCDIR}/mk/init/tests/smf/test_common.sh"
+
+setup()
+{
+       common_setup
+}
+
+teardown()
+{
+       common_teardown
+}
+
+run_test()
+{
+       : ${CMP:=cmp}
+       : ${ECHO:=echo}
+       : ${MAKE:=make}
+
+       ( cd work
+         ${ECHO} "Testing: generated manifest is correct"
+
+         local expected="manifest.xml"
+         ${ECHO} ">>> expected"
+         ${CAT} "$expected"
+
+         ${MAKE} generate-smf-manifest \
+               PKGSRCDIR="${PKGSRCDIR}" || return 1
+
+         local value="work/.smf_manifest.xml"
+         if [ ! -f "$value" ]; then
+               ${ECHO} "!!! ERROR: $value is missing!"
+               return 1
+         fi
+         ${ECHO} ">>> value"
+         ${CAT} "$value"
+
+         ${CMP} "$expected" "$value" )
+}
+
+setup && run_test
+result=$?
+teardown
+exit $result
Index: pkgsrc/mk/init/tests/smf/manifest_install_test
diff -u /dev/null pkgsrc/mk/init/tests/smf/manifest_install_test:1.1
--- /dev/null   Thu Jun  1 02:08:05 2017
+++ pkgsrc/mk/init/tests/smf/manifest_install_test      Thu Jun  1 02:08:05 2017
@@ -0,0 +1,61 @@
+#!/bin/sh
+#
+# $NetBSD: manifest_install_test,v 1.1 2017/06/01 02:08:05 jlam Exp $
+#
+# Copyright (c) 2017 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+: ${PKGSRCDIR:=/usr/pkgsrc}
+
+. "${PKGSRCDIR}/mk/init/tests/smf/test_common.sh"
+
+setup()
+{
+       common_setup
+}
+
+teardown()
+{
+       common_teardown
+}
+
+run_test()
+{
+       : ${ECHO:=echo}
+       : ${MAKE:=make}
+
+       ( cd work
+         ${ECHO} "Testing: manifest is installed"
+
+         ${MAKE} install-smf-manifest PKGSRCDIR="${PKGSRCDIR}" &&
+         [ -f destdir/usr/pkg/lib/svc/manifest/smf-test.xml ] )
+}
+
+setup && run_test
+result=$?
+teardown
+exit $result
Index: pkgsrc/mk/init/tests/smf/methods_generate_test
diff -u /dev/null pkgsrc/mk/init/tests/smf/methods_generate_test:1.1
--- /dev/null   Thu Jun  1 02:08:05 2017
+++ pkgsrc/mk/init/tests/smf/methods_generate_test      Thu Jun  1 02:08:05 2017
@@ -0,0 +1,76 @@
+#!/bin/sh
+#
+# $NetBSD: methods_generate_test,v 1.1 2017/06/01 02:08:05 jlam Exp $
+#
+# Copyright (c) 2017 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+: ${PKGSRCDIR:=/usr/pkgsrc}
+
+. "${PKGSRCDIR}/mk/init/tests/smf/test_common.sh"
+
+setup()
+{
+       common_setup
+}
+
+teardown()
+{
+       common_teardown
+}
+
+run_test()
+{
+       : ${CMP:=cmp}
+       : ${ECHO:=echo}
+       : ${MAKE:=make}
+
+       ( cd work
+         ${ECHO} "Testing: generated method is correct"
+
+         local expected="daemond"
+         ${ECHO} ">>> expected"
+         ${CAT} "$expected"
+
+         ${MAKE} generate-smf-methods \
+               PKGSRCDIR="${PKGSRCDIR}" || return 1
+
+         local value="work/.smf_daemond"
+         if [ ! -f "$value" ]; then
+               ${ECHO} "!!! ERROR: $value is missing!"
+               return 1
+         fi
+         ${ECHO} ">>> value"
+         ${CAT} "$value"
+
+         ${CMP} "$expected" "$value" )
+}
+
+setup && run_test
+result=$?
+teardown
+exit $result
Index: pkgsrc/mk/init/tests/smf/methods_install_test
diff -u /dev/null pkgsrc/mk/init/tests/smf/methods_install_test:1.1
--- /dev/null   Thu Jun  1 02:08:05 2017
+++ pkgsrc/mk/init/tests/smf/methods_install_test       Thu Jun  1 02:08:05 2017
@@ -0,0 +1,61 @@
+#!/bin/sh
+#
+# $NetBSD: methods_install_test,v 1.1 2017/06/01 02:08:05 jlam Exp $
+#
+# Copyright (c) 2017 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+: ${PKGSRCDIR:=/usr/pkgsrc}
+
+. "${PKGSRCDIR}/mk/init/tests/smf/test_common.sh"
+
+setup()
+{
+       common_setup
+}
+
+teardown()
+{
+       common_teardown
+}
+
+run_test()
+{
+       : ${ECHO:=echo}
+       : ${MAKE:=make}
+
+       ( cd work
+         ${ECHO} "Testing: methods are installed"
+
+         ${MAKE} install-smf-methods PKGSRCDIR="${PKGSRCDIR}" &&
+         [ -x destdir/usr/pkg/lib/svc/method/daemond ] )
+}
+
+setup && run_test
+result=$?
+teardown
+exit $result
Index: pkgsrc/mk/init/tests/smf/test.mk
diff -u /dev/null pkgsrc/mk/init/tests/smf/test.mk:1.1
--- /dev/null   Thu Jun  1 02:08:05 2017
+++ pkgsrc/mk/init/tests/smf/test.mk    Thu Jun  1 02:08:05 2017
@@ -0,0 +1,66 @@
+# $NetBSD: test.mk,v 1.1 2017/06/01 02:08:05 jlam Exp $
+#
+# Copyright (c) 2017 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+INIT_SYSTEM=   smf
+
+.include "${PKGSRCDIR}/mk/init/bsd.init-vars.mk"
+
+# Definitions used by smf.mk that are not assigned default values.
+CAT?=                  cat
+CHMOD?=                        chmod
+CP?=                   cp
+ECHO?=                 echo
+INSTALL_DATA?=         ${CP}
+INSTALL_SCRIPT?=       ${CP}
+LOCALBASE?=            /usr/pkg
+MKDIR?=                        mkdir -p
+PKGMANDIR?=            share/man
+PREFIX?=               ${LOCALBASE}
+RUN?=                  # empty; show all commands executed
+SED?=                  sed
+SH?=                   /bin/sh
+STEP_MSG?=             ${ECHO} "!!!"
+VARBASE?=              /var
+
+# Turn ${FILES_SUBST} into a sed(1) script.
+FILES_SUBST+=          PREFIX=${PREFIX:Q}
+FILES_SUBST+=          VARBASE=${VARBASE:Q}
+FILES_SUBST_SED=       ${FILES_SUBST:S/=/@!/:S/$/!g/:S/^/ -e s!@/}
+
+# Override any other default definitions so that generated files go into
+# a work directory.
+#
+DESTDIR=       ${.CURDIR}/destdir
+FILESDIR=      ${.CURDIR}
+WRKDIR=                ${.CURDIR}/work
+
+# Target to write the value of a variable to standard output.
+.PHONY: show-var
+show-var:
+       @${ECHO} ${${VARNAME}:Q}
Index: pkgsrc/mk/init/tests/smf/test_common.sh
diff -u /dev/null pkgsrc/mk/init/tests/smf/test_common.sh:1.1
--- /dev/null   Thu Jun  1 02:08:05 2017
+++ pkgsrc/mk/init/tests/smf/test_common.sh     Thu Jun  1 02:08:05 2017
@@ -0,0 +1,105 @@
+# $NetBSD: test_common.sh,v 1.1 2017/06/01 02:08:05 jlam Exp $
+#
+# Copyright (c) 2017 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+common_setup()
+{
+       : ${CAT:=cat}
+       : ${ECHO:=echo}
+       : ${MKDIR:=mkdir}
+
+       ${MKDIR} work
+       ${MKDIR} work/smf
+       ${CAT} > work/Makefile << 'EOF'
+# Define PKGBASE used as default for ${SMF_NAME}.
+PKGBASE=       smf-test
+
+.include "${PKGSRCDIR}/mk/init/tests/smf/test.mk"
+
+SMF_METHODS=   daemond
+
+.include "${PKGSRCDIR}/mk/init/bsd.init.mk"
+EOF
+       # Example SMF manifest
+       ${CAT} > work/smf/manifest.xml << 'EOF'
+<?xml version='1.0'>
+<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
+<service_bundle type='manifest' name='export'>
+  <service name='@SMF_PREFIX@/@SMF_NAME@' type='service' version='1'>
+    <exec_method name='start' type='method' exec='@PREFIX@/@SMF_METHOD_FILE.daemond@ start' timeout_seconds='60'/>
+    <exec_method name='stop' type='method' exec=':kill' timeout_seconds='60'/>
+    <template>
+      <documentation>
+        <manpage title='daemond' section='1M' manpath='@PREFIX@/@PKGMANDIR@'/>
+      </documentation>
+    </template>
+  </service>
+</service_bundle>
+EOF
+       # Expected SMF manifest
+       ${CAT} > work/manifest.xml << 'EOF'
+<?xml version='1.0'>
+<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
+<service_bundle type='manifest' name='export'>
+  <service name='pkgsrc/smf-test' type='service' version='1'>
+    <exec_method name='start' type='method' exec='/usr/pkg/lib/svc/method/daemond start' timeout_seconds='60'/>
+    <exec_method name='stop' type='method' exec=':kill' timeout_seconds='60'/>
+    <template>
+      <documentation>
+        <manpage title='daemond' section='1M' manpath='/usr/pkg/share/man'/>
+      </documentation>
+    </template>
+  </service>
+</service_bundle>
+EOF
+       # Example SMF method.
+       ${CAT} > work/smf/daemond.sh << 'EOF'
+#!@SMF_METHOD_SHELL@
+PIDFILE=       @VARBASE@/run/daemond.pid
+case $1 in
+start)         @PREFIX@/sbin/daemond ;;
+restart)       [ ! -f "$PIDFILE" ] || kill -HUP `cat "$PIDFILE"` ;;
+esac
+EOF
+       # Expected SMF method.
+       ${CAT} > work/daemond << 'EOF'
+#!/sbin/sh
+PIDFILE=       /var/run/daemond.pid
+case $1 in
+start)         /usr/pkg/sbin/daemond ;;
+restart)       [ ! -f "$PIDFILE" ] || kill -HUP `cat "$PIDFILE"` ;;
+esac
+EOF
+}
+
+common_teardown()
+{
+       : ${RM:=rm}
+
+       ${RM} -fr work
+}



Home | Main Index | Thread Index | Old Index