<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Anil Gulecha&#039;s Musings &#187; dh_installsmf</title>
	<atom:link href="http://www.gulecha.org/tag/dh_installsmf/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gulecha.org</link>
	<description>Anil Gulecha&#039;s Musings</description>
	<lastBuildDate>Wed, 08 Sep 2010 05:44:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Adding SMF support to your debian package</title>
		<link>http://www.gulecha.org/2008/10/23/adding-smf-support-to-your-debian-package/</link>
		<comments>http://www.gulecha.org/2008/10/23/adding-smf-support-to-your-debian-package/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 16:22:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Nexenta]]></category>
		<category><![CDATA[Opensolaris]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[debhelper]]></category>
		<category><![CDATA[dh_installsmf]]></category>
		<category><![CDATA[smf]]></category>

		<guid isPermaLink="false">http://www.gulecha.org/?p=81</guid>
		<description><![CDATA[Services in Nexenta are handled using solaris SMF. This makes it very easy to start and stop services; you dont have to worry about it&#8217;s dependency on other services, which is taken care of by SMF automatically. This cheetsheet lists how easy it is to use SMF. dh_installsmf dh_installsmf is one of Nexenta&#8217;s addition to [...]]]></description>
			<content:encoded><![CDATA[<p>Services in Nexenta are handled using <a href="http://www.sun.com/bigadmin/content/selfheal/smf-quickstart.jsp" target="_blank">solaris SMF</a>. This makes it very easy to start and stop services; you dont have to worry about it&#8217;s dependency on other services, which is taken care of by SMF automatically. This <a href="http://docs.alkaloid.net/index.php/SMF_Cheatsheet" target="_blank">cheetsheet</a> lists how easy it is to use SMF.</p>
<p><strong>dh_installsmf</strong></p>
<p><em>dh_installsmf</em> is one of Nexenta&#8217;s addition to Debian&#8217;s debhelper scripts. This makes it trivial to add SMF support in a debian package that installs a service at /etc/init.d/&amp;lt;service&amp;gt;</p>
<p>We&#8217;ll take a look at how we can add support to such a package.</p>
<p><strong>XML Manifest file<br />
</strong></p>
<p>The SMF framework requires a manifest file, which is an XML file, that provides information regarding the service. This information includes the services that this particular service depends on (or configurations files, etc).</p>
<p>It also lists the commands that need to be run to enable, disable the service, or to set various other parameters. The format of the manifest file is explained <a href="http://www.sun.com/software/solaris/howtoguides/smfmanifesthowto.jsp" target="_blank">here</a>.</p>
<p>The Blastwave package has a good collection of <a href="http://www.blastwave.org/smf/manifests.php" target="_blank">manifest files</a> for various packages. Lets take a look at the manifest for <a href="http://www.gulecha.org/incoming/apache2.xml">apache2</a>:</p>
<blockquote><p>&lt;?xml version=&#8221;1.0&#8243;?&gt;<br />
&lt;!DOCTYPE service_bundle SYSTEM &#8220;/usr/share/lib/xml/dtd/service_bundle.dtd.1&#8243;&gt;</p>
<p>&lt;service_bundle type=&#8221;manifest&#8221; name=&#8221;apache2&#8243;&gt;<br />
&lt;service name=&#8221;network/apache2&#8243; type=&#8221;service&#8221; version=&#8221;4&#8243;&gt;<br />
&lt;create_default_instance enabled=&#8221;false&#8221;/&gt;<br />
&lt;single_instance/&gt;</p>
<p>&lt;!&#8211; First of all, if the config file is not present,<br />
then we needn&#8217;t bother with anything else.  &#8211;&gt;<br />
&lt;dependency name=&#8221;config-file&#8221; grouping=&#8221;require_all&#8221; restart_on=&#8221;none&#8221; type=&#8221;path&#8221;&gt;<br />
&lt;service_fmri value=&#8221;file:///etc/apache2/apache2.conf&#8221;/&gt;<br />
&lt;/dependency&gt;</p>
<p>&lt;!&#8211; If there&#8217;s no network, then there&#8217;s no point in running &#8211;&gt;<br />
&lt;dependency name=&#8221;loopback&#8221; grouping=&#8221;require_all&#8221; restart_on=&#8221;error&#8221; type=&#8221;service&#8221;&gt;<br />
&lt;service_fmri value=&#8221;svc:/network/loopback:default&#8221;/&gt;<br />
&lt;/dependency&gt;<br />
&lt;dependency name=&#8221;physical&#8221; grouping=&#8221;require_all&#8221; restart_on=&#8221;error&#8221; type=&#8221;service&#8221;&gt;<br />
&lt;service_fmri value=&#8221;svc:/network/physical:default&#8221;/&gt;<br />
&lt;/dependency&gt;<br />
&lt;dependency name=&#8221;fs-local&#8221; grouping=&#8221;require_all&#8221; restart_on=&#8221;none&#8221; type=&#8221;service&#8221;&gt;<br />
&lt;service_fmri value=&#8221;svc:/system/filesystem/local&#8221;/&gt;<br />
&lt;/dependency&gt;<br />
&lt;exec_method type=&#8221;method&#8221; name=&#8221;start&#8221; exec=&#8221;/lib/svc/method/apache2 start&#8221; timeout_seconds=&#8221;60&#8243;/&gt;<br />
&lt;exec_method type=&#8221;method&#8221; name=&#8221;stop&#8221; exec=&#8221;/lib/svc/method/apache2 stop&#8221; timeout_seconds=&#8221;60&#8243;/&gt;<br />
&lt;exec_method type=&#8221;method&#8221; name=&#8221;refresh&#8221; exec=&#8221;/lib/svc/method/apache2 refresh&#8221; timeout_seconds=&#8221;60&#8243;/&gt;<br />
&lt;stability value=&#8221;Unstable&#8221;/&gt;<br />
&lt;template&gt;<br />
&lt;common_name&gt;<br />
&lt;loctext xml:lang=&#8221;C&#8221;&gt;Apache2 web server&lt;/loctext&gt;<br />
&lt;/common_name&gt;<br />
&lt;documentation&gt;<br />
&lt;manpage title=&#8221;apache2&#8243; section=&#8221;7&#8243;/&gt;<br />
&lt;doc_link name=&#8221;apache.org&#8221; uri=&#8221;http://httpd.apache.org/docs/2.0&#8243;/&gt;<br />
&lt;/documentation&gt;<br />
&lt;/template&gt;<br />
&lt;/service&gt;<br />
&lt;/service_bundle&gt;</p></blockquote>
<p>In the above file, we see that apache2 has defined the following dependencies:</p>
<ul>
<li>The file <em>/etc/apache2/apache2.conf</em></li>
<li>The network service (and the physical interface being up)</li>
<li>The local filesystem</li>
</ul>
<p>It also defines three methods <em>start</em>, <em>stop</em> and <em>refresh</em>, which are commands for this particular service (start the webserver, stop the webserver, reload the webserver). They call a script /lib/svc/method/apache2, which brings us to dh_installsmf</p>
<p><strong>debian/rules</strong></p>
<p>The service script <em>/lib/svc/method/&amp;lt;package&amp;gt;</em> is generated by dh-installsmf, so when you create an SMF manifest file for Nexenta, make sure you call that file. dh_installsmf will create a script <em>/lib/svc/method/&amp;lt;package&amp;gt;</em> which is a wrapper over the /etc/init.d/&amp;lt;package&amp;gt; file.</p>
<p>So in our case the <em>debian/rules</em> file in the apache2 package will be modified as</p>
<blockquote><p>[snip]</p>
<p>rm -f debian/apache2-utils/usr/share/doc/apache2-utils/NEWS.Debian<br />
dh_installinit -a &#8211;no-start -r &#8211;name=apache2 &#8212; defaults 91 09<br />
<strong>dh_installsmf &#8211;service apache2 &#8211;manifest debian/apache2.xml -papache2.2-common</strong><br />
dh_installcron -a -r &#8211;name=apache2<br />
if [ "$(LSB_RELEASE)" = "Ubuntu" ]; then \<br />
dh_strip -a; \<br />
else \<br />
dh_strip -a &#8211;dbg-package=apache2-dbg -Napache2-mpm-worker -Napache2-mpm-event -Napache2-mpm-prefork -Napache2-dbg; \<br />
fi<br />
dh_link -a<br />
dh_compress -a<br />
[snip]</p></blockquote>
<p>The &#8211;service argument gives the name of the service, the &#8211;manifest points to the manifest file and -p tells it which package the smf changes go into. This is basically the package that provides the <em>/etc/init.d/&amp;lt;package&amp;gt;</em> file.</p>
<p>And that is how we generate SMFed debian packages.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gulecha.org/2008/10/23/adding-smf-support-to-your-debian-package/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
