<?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>The weblog without a name</title>
	<atom:link href="http://www.pwan.org/wp/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.pwan.org/wp</link>
	<description>In this economy, all you get is tech posts...</description>
	<lastBuildDate>Thu, 02 Jun 2011 16:05:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>snippet management for puppet</title>
		<link>http://www.pwan.org/wp/?p=96</link>
		<comments>http://www.pwan.org/wp/?p=96#comments</comments>
		<pubDate>Thu, 02 Jun 2011 15:54:52 +0000</pubDate>
		<dc:creator>jude</dc:creator>
				<category><![CDATA[puppet]]></category>

		<guid isPermaLink="false">http://www.pwan.org/wp/?p=96</guid>
		<description><![CDATA[I&#8217;ve had some success using the emacs yasnippets package for Puppet snippet management. Yasnippet has conditional expansion support so I able to set up a number of snippets that expanded differently based on which puppet the cursor whenever I hit &#8220;&#60;backtic&#62;-&#60;backtic&#62;-&#60;tab&#62;&#8221;, which is pretty easy to bang out on my keyboard. The secret sauce was [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had some success using the emacs <a href="http://code.google.com/p/yasnippet/">yasnippets package</a> for Puppet <a href="http://en.wikipedia.org/wiki/Snippet_%28programming%29">snippet management</a>.</p>
<p>Yasnippet has <a href="http://yasnippet.googlecode.com/svn/trunk/doc/snippet-development.html#condition-snippet-condition">conditional expansion support</a> so I able to set up a number of snippets that expanded differently based on which puppet the cursor whenever I hit &#8220;&lt;backtic&gt;-&lt;backtic&gt;-&lt;tab&gt;&#8221;, which is pretty easy to bang out on my keyboard.</p>
<p>The secret sauce was to use the elisp function <a href="http://www.gnu.org/software/emacs/elisp/html_node/Regexp-Search.html">&#8216;looking-back&#8217; </a> to to search backwards from cursor point for something that looks like &#8216;puppet-type {&#8216;.</p>
<p>Here&#8217;s an example for cron:</p>
<pre># name : cron-quote
# key : ``
# condition : (looking-back "cron\s+\{[^\}]*")
# --
"${1:name}":
    command =&gt; "${2:command}",
    user =&gt; "${3:root}",
    hour =&gt; ${4:hour},
    minute =&gt; ${5:minute},
    $0;</pre>
<p>I&#8217;ve posted the rest of my puppet-mode snipprts on <a href="https://github.com/jude/yasnippets-puppet">github</a>.<br />
Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pwan.org/wp/?feed=rss2&#038;p=96</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>improbable-bug-number-in-closes : your bug count is less than 100</title>
		<link>http://www.pwan.org/wp/?p=78</link>
		<comments>http://www.pwan.org/wp/?p=78#comments</comments>
		<pubDate>Wed, 17 Nov 2010 14:38:24 +0000</pubDate>
		<dc:creator>jude</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[packaging]]></category>

		<guid isPermaLink="false">http://www.pwan.org/wp/?p=78</guid>
		<description><![CDATA[Wondering how to get around the &#8216;improbable-bug-number-in-closes&#8217;  warning from Lintian, and can&#8217;t find the tag description ? It is happening because your bug count is too low. Solution:  Open at least 100 tickets.  Get cracking.]]></description>
			<content:encoded><![CDATA[<p>Wondering how to get around the &#8216;improbable-bug-number-in-closes&#8217;  warning from Lintian, and can&#8217;t find the <a href="http://lintian.debian.org/tags.html">tag description</a> ?</p>
<p>It is happening because <a href="http://git.debian.org/?p=lintian/lintian.git;a=blob;f=checks/changelog-file;h=8147095aacdc425b2820e5ff77e5ab4242f7d900;hb=HEAD#l330">your bug count is too low</a>.</p>
<p>Solution:  Open at least 100 tickets.  Get cracking.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pwan.org/wp/?feed=rss2&#038;p=78</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using autoconf with Haskell FFI libraries</title>
		<link>http://www.pwan.org/wp/?p=64</link>
		<comments>http://www.pwan.org/wp/?p=64#comments</comments>
		<pubDate>Sun, 17 Oct 2010 16:38:07 +0000</pubDate>
		<dc:creator>jude</dc:creator>
				<category><![CDATA[haskell]]></category>

		<guid isPermaLink="false">http://www.pwan.org/wp/?p=64</guid>
		<description><![CDATA[(This is a long post that&#8217;s not going to make much sense unless you&#8217;re interested in FFI (foreign function interface) libraries for Haskell.    If you don&#8217;t care about Haskell FFI libraries, then go check out Banjo Cat.) I maintain a small Haskell library which provides Haskell bindings to the Augeas API.    Occasionally I put out [...]]]></description>
			<content:encoded><![CDATA[<p>(This is a long post that&#8217;s not going to make much sense unless you&#8217;re interested in FFI (foreign function interface) libraries for Haskell.    If you don&#8217;t care about Haskell FFI libraries, then go check out <a href="http://www.flickr.com/photos/20939975@N04/3077163961/">Banjo Cat</a>.)</p>
<p>I maintain <a href="http://hackage.haskell.org/package/augeas" target="_blank">a small Haskell library</a> which provides Haskell bindings to the <a href="http://augeas.net/index.html" target="_blank">Augeas</a> API.    Occasionally I put out a new version of the library when the  Augueas API changes.   Of course, it usually takes a couple months for  the API changes to surface in the<a href="https://launchpad.net/ubuntu/+source/augeas"> Ubuntu augeas package</a>,  so I need build the Augeas libraries from source in order to update my  library.  As a result, my Haskell library contains references to symbols  that will be unresolved unless my users also build their Augeas library  from source.</p>
<p>But, I want my users to be able to use the Haskell bindings with  whatever version they may have available, so I like  I&#8217;d like it better  if I didn&#8217;t have to force my users to also build Augeas from source.   Instead,  it would be better if somehow my build to somehow poll the  user&#8217;s system to see what API methods were available, and then only  compiled in support for the available methods.</p>
<p>The GNU autoconf tools can do this sort of library method polling,  and there&#8217;s an autoconfUserHooks function that can be used in Setup.hs.   Here&#8217;s how I tied the two of these together for my project.</p>
<p>I&#8217;m going to assume you have the autoconf tools available in your  development environment.  If you don&#8217;t have them installed, it shouldn&#8217;t  be too hard to find them for your distribution of choice, or you could  get <a href="http://www.gnu.org/software/autoconf/">the latest code from the folks at GNU.</a>.</p>
<h2>Step 1: Write a configure.ac file:</h2>
<p>The configure.ac file will be used by autoreconf to create your configure script.   Go through the template below and replace anything with &#8216;your-*&#8217; with the values from your project.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">## Replace yout-autoconf-vesion with your current autoconf version (autoconf --version)</span>
<span style="color: #666666; font-style: italic;">## It should be an unquoted decimal value, like 2.65</span>
AC_PREREQ<span style="color: #7a0874; font-weight: bold;">&#40;</span>your-autoconf-version<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Replace your-library with the name of your library</span>
<span style="color: #666666; font-style: italic;">## Replace your-version with the Version value from your cabal file</span>
AC_INIT<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>your-library<span style="color: #7a0874; font-weight: bold;">&#93;</span>,<span style="color: #7a0874; font-weight: bold;">&#91;</span>your-version<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Replace this with a file which should exist in your base source directory if you don't have a Setup.hs</span>
<span style="color: #666666; font-style: italic;">## Your cabal file might be a good choice.</span>
AC_CONFIG_SRCDIR<span style="color: #7a0874; font-weight: bold;">&#40;</span>Setup.hs<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## This is the name of an include file that the ./configure script will create.</span>
<span style="color: #666666; font-style: italic;">## I'll describe it more below</span>
AC_CONFIG_HEADERS<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>Config.h<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## autoconfUserHooks requires this</span>
AC_ARG_WITH<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>compiler<span style="color: #7a0874; font-weight: bold;">&#93;</span>,<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Check if your foreign library is available at all.</span>
<span style="color: #666666; font-style: italic;">## Replace your-sanity-check-function with a function name from the foreign library which should be available from the very first release of the library.</span>
<span style="color: #666666; font-style: italic;">## Replace your-foreign-library-name with the name of your foreign library</span>
<span style="color: #666666; font-style: italic;">## Replace you-foreign-include-filename with the name of an include file which should be installed on the system if the development version of the library is installed.</span>
<span style="color: #666666; font-style: italic;">## This block is first going to check if your base library is installed by checking if some 'should always exist' function can be found.</span>
<span style="color: #666666; font-style: italic;">## Then its going to check if it can find the include file associated with the library .</span>
<span style="color: #666666; font-style: italic;">## If it fails these tests, configure will return a non-zero value, and the build will fail.</span>
&nbsp;
<span style="color: #007800;">sanity_check</span>=no
<span style="color: #007800;">dev_check</span>=no
AC_SEARCH_LIBS<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>your-sanity-check-function<span style="color: #7a0874; font-weight: bold;">&#93;</span>,<span style="color: #7a0874; font-weight: bold;">&#91;</span>your-foreign-library-name<span style="color: #7a0874; font-weight: bold;">&#93;</span>,<span style="color: #7a0874; font-weight: bold;">&#91;</span>sanity-check=<span style="color: #c20cb9; font-weight: bold;">yes</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #ff0000;">&quot;x<span style="color: #007800;">${sanity_check}</span>&quot;</span> = <span style="color: #ff0000;">&quot;xyes&quot;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
AC_CHECK_HEADERS<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>your-foreign-include-file-name<span style="color: #7a0874; font-weight: bold;">&#93;</span>,<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #007800;">dev_check</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>,<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #007800;">dev_check</span>=no<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">else</span>
AC_MSG_ERROR<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>Unable to <span style="color: #c20cb9; font-weight: bold;">find</span> your-sanity-check-function <span style="color: #000000; font-weight: bold;">in</span> your-foreign-library-name library.<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #ff0000;">&quot;x<span style="color: #007800;">${dev_check}</span>&quot;</span> = <span style="color: #ff0000;">&quot;xno&quot;</span>; <span style="color: #000000; font-weight: bold;">then</span>
AC_MSG_ERROR<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>Unable to <span style="color: #c20cb9; font-weight: bold;">find</span> your-foreign-include-filename<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Checking for available symbols.</span>
<span style="color: #666666; font-style: italic;">## Go through your source and collect all the symbols you expect to be available in your foreign library.</span>
<span style="color: #666666; font-style: italic;">## Then for each of the foreign functions you expect to be available, call the HAS_EXTERNAL_FUNC macro with</span>
<span style="color: #666666; font-style: italic;">## the function name as the first argument, and the name for a unique macro definition you want written to your Config.h file</span>
<span style="color: #666666; font-style: italic;">##</span>
<span style="color: #666666; font-style: italic;">## Notes</span>
<span style="color: #666666; font-style: italic;">## (Yes, If I mad more m4-fu, I could probably write this as a single argument macro.  I leave this as an exercise for the reader.)</span>
&nbsp;
AC_DEFUN<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>HAS_EXTERNAL_FUNC<span style="color: #7a0874; font-weight: bold;">&#93;</span>,
<span style="color: #7a0874; font-weight: bold;">&#91;</span>
has_<span style="color: #007800;">$1</span>=no
AC_SEARCH_LIBS<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #007800;">$1</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>,<span style="color: #7a0874; font-weight: bold;">&#91;</span>your-foreign-library<span style="color: #7a0874; font-weight: bold;">&#93;</span>,<span style="color: #7a0874; font-weight: bold;">&#91;</span>has_<span style="color: #007800;">$1</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #ff0000;">&quot;x<span style="color: #007800;">${has_$1}</span>&quot;</span> = <span style="color: #ff0000;">&quot;xyes&quot;</span>; <span style="color: #000000; font-weight: bold;">then</span>
     AC_DEFINE<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #007800;">$2</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>,<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>,<span style="color: #7a0874; font-weight: bold;">&#91;</span>your-foreign-library has the <span style="color: #007800;">$1</span> function.<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
HAS_EXTERNAL_FUNC<span style="color: #7a0874; font-weight: bold;">&#40;</span>your-foreign-function-name,HAS_YOUR_FOREIGN_FUNCTION_NAME<span style="color: #7a0874; font-weight: bold;">&#41;</span>
HAS_EXTERNAL_FUNC<span style="color: #7a0874; font-weight: bold;">&#40;</span>your-foreign-function-name2,HAS_YOUR_FOREIGN_FUNCTION_NAME2<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #666666; font-style: italic;">## ...</span>
HAS_EXTERNAL_FUNC<span style="color: #7a0874; font-weight: bold;">&#40;</span>your-foreign-function-namez,HAS_YOUR_FOREIGN_FUNCTION_NAMEZ<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Builds an config.status file after ./configure is run</span>
AC_OUTPUT</pre></div></div>

<h2>Step 2:  Build the configure script from the configure.ac file.</h2>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&amp;</span>gt; autoreconf
<span style="color: #000000; font-weight: bold;">&amp;</span>gt; .<span style="color: #000000; font-weight: bold;">/</span>configure</pre></div></div>

<p>The configure script should create a Config.h file.  For each found symbol, Config.h should contain something like</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/*</span> your-foreign-library has the your-foreign-function function. <span style="color: #000000; font-weight: bold;">*/</span>
<span style="color: #666666; font-style: italic;">#define HAS_YOUR_FOREIGN_FUNCTION /**/</span></pre></div></div>

<p>For each missing symbol, Configu.h should include something like</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/*</span> your-foregn-library library has the missing function. <span style="color: #000000; font-weight: bold;">*/</span>
<span style="color: #000000; font-weight: bold;">/*</span> <span style="color: #666666; font-style: italic;">#undef HAS_MISSING */</span></pre></div></div>

<h2>Step 3: Uglify your Haskell source with conditional compilation.</h2>
<p>Include the CPP  pragma in your source.  You most likely already using ForeignFunctionInterface, so your pragma line should look something like below.  Also include the Config.h file that ./configure created</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;"><span style="color: #5d478b; font-style: italic;">{-# LANGUAGE CPP, ForeignFunctionInterface #-}</span>
&nbsp;
#ifndef <span style="color: #339933; font-weight: bold;">_</span>config<span style="color: #339933; font-weight: bold;">_</span>h
#include <span style="background-color: #3cb371;">&quot;../Config.h&quot;</span>
#define <span style="color: #339933; font-weight: bold;">_</span>config<span style="color: #339933; font-weight: bold;">_</span>h
#endif</pre></div></div>

<p>Then for portion of the source where a foreign function is used, wrap it in a &#8220;#ifdef HAS_FUNCTION&#8221; wrapper. Below is an example from the haskell-augeas source for the small aug_error function.<br />
Note if HAS_AUGEAS_ERROR isn&#8217;t defined, then the code compiles, but will report an error if called. There may be a better way to report the error, but this worked for my purposes.</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;"><span style="color: #5d478b; font-style: italic;">-- ---------</span>
<span style="color: #5d478b; font-style: italic;">-- aug_error</span>
<span style="color: #5d478b; font-style: italic;">-- ---------</span>
#ifdef HAS<span style="color: #339933; font-weight: bold;">_</span>AUGEAS<span style="color: #339933; font-weight: bold;">_</span>ERROR
foreign <span style="color: #06c; font-weight: bold;">import</span> ccall safe <span style="background-color: #3cb371;">&quot;augeas.h aug_error&quot;</span>
c<span style="color: #339933; font-weight: bold;">_</span>aug<span style="color: #339933; font-weight: bold;">_</span>error <span style="color: #339933; font-weight: bold;">::</span> Ptr Augeas               <span style="color: #5d478b; font-style: italic;">-- aug</span>
                <span style="color: #339933; font-weight: bold;">-</span>&amp;gt; <span style="color: #cccc00; font-weight: bold;">IO</span> <span style="color: green;">&#40;</span>AugErrCode<span style="color: green;">&#41;</span>       <span style="color: #5d478b; font-style: italic;">-- error code</span>
#endif
&nbsp;
<span style="color: #5d478b; font-style: italic;">{-|
Return a human-readable message for the error code */
-}</span>
aug<span style="color: #339933; font-weight: bold;">_</span>error <span style="color: #339933; font-weight: bold;">::</span> Ptr Augeas  <span style="color: #5d478b; font-style: italic;">-- ^ Augeas pointer</span>
               <span style="color: #339933; font-weight: bold;">-</span>&amp;gt; <span style="color: #cccc00; font-weight: bold;">IO</span> <span style="color: green;">&#40;</span>AugErrCode<span style="color: green;">&#41;</span> <span style="color: #5d478b; font-style: italic;">-- ^ return value</span>
aug<span style="color: #339933; font-weight: bold;">_</span>error aug<span style="color: #339933; font-weight: bold;">_</span>ptr <span style="color: #339933; font-weight: bold;">=</span>
#ifndef HAS<span style="color: #339933; font-weight: bold;">_</span>AUGEAS<span style="color: #339933; font-weight: bold;">_</span>ERROR
   <span style="color: #06c; font-weight: bold;">Prelude</span><span style="color: #339933; font-weight: bold;">.</span><span style="font-weight: bold;">error</span> <span style="background-color: #3cb371;">&quot;aug_error requires at least augeas version 0.6.0&quot;</span>
#else
   <span style="color: #06c; font-weight: bold;">do</span>
    ret &amp;lt;<span style="color: #339933; font-weight: bold;">-</span> c<span style="color: #339933; font-weight: bold;">_</span>aug<span style="color: #339933; font-weight: bold;">_</span>error aug<span style="color: #339933; font-weight: bold;">_</span>ptr
    <span style="font-weight: bold;">return</span><span style="color: green;">&#40;</span>ret<span style="color: green;">&#41;</span>
#endif</pre></div></div>

<p>Also remember to add the wrappers around any test code that&#8217;s using foreign function calls.</p>
<h2>Step 4:  Update your Setup.hs to call configure</h2>
<p>If you&#8217;re using defaultUserHooks or simpleUserHooks in your Setup.hs,  switch to autoconfUserHooks.   This way running runghc Setup.hs build will call the  ./configure script before compiling the source, so the Config.h include  file will already exist.  This was just a simple swap in my case.</p>
<h2>Step 5: Update your cabal file</h2>
<p>In order for the Setup.hs sdist target to create a package which can  be compiled from source, add the new configure.ac and configure scripts to the Extra-Sources-Files list in your cabal file.  Technically the configure script shouldn&#8217;t be included in the sdist package since it&#8217;s derived from the configure.ac file, but I think users expect there to already be a working configure script available out of the box.</p>
<p>Also add CPP to the Extentions list in the library block, otherwise  &#8216;runghc Setup.hs haddock&#8217; will give an &#8216;error ../Config.h: No such file or dictionary&#8217; error.</p>
<pre>Name: your-package
...
Extra-Source-Files: Makefile, configure.ac, configure, Config.h.in

library
        ...
        Extensions: CPP</pre>
<h2>Step 6:  Add configure.ac to the VCS</h2>
<p>The configure.ac file is a new source file, so don&#8217;t forgot to do your &#8216;darcs add&#8217; equivilent for whatever VCS you&#8217;re using.</p>
<h2>Step 7:  Maintenance</h2>
<p>A new method may  be added to the foreign library.  At   that point you&#8217;ll have to add support the new method in your library.  To update your configure script, add a new HAS_EXTERNAL_FUNCTION line to your configure.ac file, and run &#8216;autoreconf&#8217; to rebuild the configure script again.</p>
<p>And that&#8217;s all there is to it.  Hopefully you&#8217;ve found this helpful.   If you find any errors, or if you have a better way of handling  potentially missing symbols, please let me know about it.</p>
<p><em>(editted Dec 6th, 2010:  Updated step #5 to add Extensions:CPP for haddock support)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pwan.org/wp/?feed=rss2&#038;p=64</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How many bailouts are too many for a three year old ?</title>
		<link>http://www.pwan.org/wp/?p=52</link>
		<comments>http://www.pwan.org/wp/?p=52#comments</comments>
		<pubDate>Sat, 02 Jan 2010 18:40:08 +0000</pubDate>
		<dc:creator>jude</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.pwan.org/wp/?p=52</guid>
		<description><![CDATA[Playing &#8216;pretend store&#8217; with my three-year-old nephew &#8220;R&#8221; last night. R:  What do you want ? J:  Some fresh figs please. R:  Here are some fig. J:  How much do I owe you ? R:  $10,000,000 !!!! J:  What ?  I don&#8217;t need that much.  I need a bailout. R:  What&#8217;s that ? J:  A [...]]]></description>
			<content:encoded><![CDATA[<p>Playing &#8216;pretend store&#8217; with my three-year-old nephew &#8220;R&#8221; last night.</p>
<blockquote><p><em>R:  What do you want ?<br />
</em></p>
<p><em>J:  Some fresh figs please.<br />
</em></p>
<p><em>R:  Here are some fig. </em></p>
<p><em>J:  How much do I owe you ?</em></p>
<p><em>R:  $10,000,000 !!!!</em></p>
<p><em>J:  What ?  I don&#8217;t need that much.  I need a bailout.</em></p>
<p><em>R:  What&#8217;s that ?</em></p>
<p><em>J:  A wheelbarrow full of money.</em></p>
<p><em>R:  OK.  Here it is.  Tens of hundreds of million dollars !! What do you want next ?</em></p>
<p><em>J:  Another bailout.</em></p>
<p><em>R:  OK.  Here it is.  Hundred of million dollars !  What do you want now ?</em></p>
<p><em>J:  I ran out of money again.  Another bailout, please..</em></p>
<p><em>R:  What ! No ! Stop that ! </em></p>
<p><em>J:  OK, then I want a bonus.</em></p>
<p><em>R:  How much ?<br />
</em></p>
<p><em>J:  $10,000,000</em></p>
<p><em>R:  Too much ! What&#8217;s that for ? </em></p>
<p><em>J:  I&#8217;m too big to fail.</em></p>
<p><em>R:  Mooooooom !  Uncle Jude&#8217;s being silly again !</em></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.pwan.org/wp/?feed=rss2&#038;p=52</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PXE-E61: Media test failure, check cable</title>
		<link>http://www.pwan.org/wp/?p=50</link>
		<comments>http://www.pwan.org/wp/?p=50#comments</comments>
		<pubDate>Tue, 29 Dec 2009 01:14:12 +0000</pubDate>
		<dc:creator>jude</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[laptop]]></category>

		<guid isPermaLink="false">http://www.pwan.org/wp/?p=50</guid>
		<description><![CDATA[I was getting the message above on my laptop when I turned it on. Surprisingly, whacking the bottom 4 times fixed it.   Go figure.]]></description>
			<content:encoded><![CDATA[<p>I was getting the message above on my laptop when I turned it on.</p>
<p>Surprisingly, <a title="whack it good" href="http://www.nocrash.com/ncbbs/msgs/3247.shtml" target="_blank">whacking the bottom 4 times</a> fixed it.   Go figure.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pwan.org/wp/?feed=rss2&#038;p=50</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>-exclude-source-files with build_rpm</title>
		<link>http://www.pwan.org/wp/?p=47</link>
		<comments>http://www.pwan.org/wp/?p=47#comments</comments>
		<pubDate>Wed, 06 May 2009 12:29:16 +0000</pubDate>
		<dc:creator>jude</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.pwan.org/wp/?p=47</guid>
		<description><![CDATA[In setuptools, the bdist_egg command has an -exclude-source-files option that is missing in the bdist_rpm command. So what&#8217;s the selfish sod to do if he wants to keep from distributing his source in an RPM ? Including the install script below worked for me. python setup.py bdist_rpm --install-script=install.sh where install.sh is python setup.py install --root=$RPM_BUILD_ROOT [...]]]></description>
			<content:encoded><![CDATA[<p>In setuptools, the <a href="http://peak.telecommunity.com/DevCenter/setuptools#bdist-egg-create-a-python-egg-for-the-project">bdist_egg</a> command has an -exclude-source-files option that is missing in the bdist_rpm command.</p>
<p>So what&#8217;s the selfish sod to do if he wants to keep from distributing his source in an RPM ?</p>
<p>Including the install script below worked for me.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">python setup.py bdist_rpm --install-script=install.sh</pre></div></div>

<p>where install.sh is</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">python setup.py <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">--root</span>=<span style="color: #007800;">$RPM_BUILD_ROOT</span> <span style="color: #660033;">--record</span>=INSTALLED_FILES
&nbsp;
<span style="color: #666666; font-style: italic;">#goodbye py source</span>
<span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #007800;">$RPM_BUILD_ROOT</span> <span style="color: #660033;">-name</span> \<span style="color: #000000; font-weight: bold;">*</span>.py <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> \;
<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-i</span> <span style="color: #ff0000;">'/\.py$/d'</span> INSTALLED_FILES</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.pwan.org/wp/?feed=rss2&#038;p=47</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>warning: &#8216;sqlstm&#8217; defined but not used</title>
		<link>http://www.pwan.org/wp/?p=41</link>
		<comments>http://www.pwan.org/wp/?p=41#comments</comments>
		<pubDate>Thu, 30 Apr 2009 12:46:25 +0000</pubDate>
		<dc:creator>jude</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[workaround]]></category>

		<guid isPermaLink="false">http://www.pwan.org/wp/?p=41</guid>
		<description><![CDATA[At my current job, I had the misfortune of having to deal with some Oracle Pro*C code. Since I&#8217;m a -Werror weenie, I was annoyed that this code was spitting out a &#8216;warning: &#8216;sqlstm&#8217; defined but not used&#8217; warning in all the proc generated source. Here&#8217;s how I inhibited the warning. I added a new [...]]]></description>
			<content:encoded><![CDATA[<p>At my current job, I had the misfortune of having to deal with some Oracle Pro*C code.  Since I&#8217;m a -Werror weenie, I was annoyed that this code was spitting out a &#8216;warning: &#8216;sqlstm&#8217; defined but not used&#8217; warning in all the proc generated source.  Here&#8217;s how I inhibited the warning.   </p>
<p>I added a new pc_common.h file</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// If you know a better way to avoid the 'sqlstm' defined but not used warning, I tip my hat to you.</span>
<span style="color: #339933;">#define AVOID_THE_UNUSED_SQLSTM_WARNING(X) void avoid_the_sqlstm_defined_but_unused_warning_for_ ## X () { sqlstm = sqlstm; }</span></pre></div></div>

<p>Then in some sample.pc that&#8217;s generating the warning:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#ifndef ORA_PROC</span>
	<span style="color: #339933;">#include &quot;pc_common.h&quot;</span>
AVOID_THE_UNUSED_SQLSTM_WARNING<span style="color: #009900;">&#40;</span>sample<span style="color: #009900;">&#41;</span>
<span style="color: #339933;">#endif</span></pre></div></div>

<p>The problem is that the generated proc code includes a static struct named &#8216;sqlstm&#8217;,  but then the generated code never references this struct.  Instead it uses a local sqlstm variable whenever it&#8217;s used elsewhere in the generateed code.  </p>
<p>The workaround adds a hopefully-unused function to the source that uses the static sqlstm struct.   This is enough for the compiler to mark it as being used, even though the function itself is never used. </p>
<p>However, I did have to introduce the argument to the macro to force a unique name for these functions, since the linker will complain about there being multiple functions with the same signature in in different files.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pwan.org/wp/?feed=rss2&#038;p=41</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Haskell FFI bindings for Augeas</title>
		<link>http://www.pwan.org/wp/?p=33</link>
		<comments>http://www.pwan.org/wp/?p=33#comments</comments>
		<pubDate>Sun, 08 Mar 2009 00:05:52 +0000</pubDate>
		<dc:creator>jude</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://www.pwan.org/wp/?p=33</guid>
		<description><![CDATA[I&#8217;ve published my first Haskell project on hackage.  Augeas, is a FFI binding for the Augeas API. I wrote it mainly to learn about Haskell&#8217;s FFI, and to keep busy while I was between jobs.  Also the API was small enough that it was a managable project. Chapter 17 of Real World Haskell was very [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve published my first Haskell project on hackage.  <a href="http://hackage.haskell.org/cgi-bin/hackage-scripts/package/augeas">Augeas</a>, is a <a href="http://www.cse.unsw.edu.au/~chak/haskell/ffi/">FFI</a> binding for the <a href="http://augeas.net/index.html">Augeas API</a>. I wrote it mainly to learn about Haskell&#8217;s FFI, and to keep busy while I was between jobs.  Also the API was small enough that it was a managable project.</p>
<p><a href="http://book.realworldhaskell.org/read/interfacing-with-c-the-ffi.html">Chapter 17 of Real World Haskell</a> was very helpful during the project, however it didn&#8217;t cover file pointers, which were needed for the aug_print method.</p>
<p>The <a href="http://www.haskell.org/haskellwiki/The_Monad.Reader/Issue2/Bzlib2Binding">Bzlib2 Binding article</a> in issue 2 of the Monad Reader, showed me how to do the Handle to CFile conversions,  but I ran into some problems with their handleToCFile method during testing.</p>
<p>In my aug_print test, I was confused why I could no longer write to the Handle after calling aug_print.  Eventually I found out that handleToFD <a href="http://www.haskell.org/ghc/docs/latest/html/libraries/unix/System-Posix-IO.html#v%3AhandleToFd">closes the Handle passed to it</a>.</p>
<p>I got around this by calling hDuplicate on the handle, and then calling handleToFD on the duplicate instead.</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;">handleToCFile <span style="color: #339933; font-weight: bold;">::</span> Handle <span style="color: #339933; font-weight: bold;">-&gt;</span> <span style="color: #cccc00; font-weight: bold;">String</span> <span style="color: #339933; font-weight: bold;">-&gt;</span> <span style="color: #cccc00; font-weight: bold;">IO</span> <span style="color: green;">&#40;</span>Ptr CFile<span style="color: green;">&#41;</span>
handleToCFile h m <span style="color: #339933; font-weight: bold;">=</span>
 <span style="color: #06c; font-weight: bold;">do</span> iomode <span style="color: #339933; font-weight: bold;">&lt;-</span> newCString m
&nbsp;
    <span style="color: #5d478b; font-style: italic;">-- Duplicate the handle, so the original stays open</span>
    <span style="color: #5d478b; font-style: italic;">-- after the handleToFd call closes the duplicate</span>
    dup<span style="color: #339933; font-weight: bold;">_</span>h <span style="color: #339933; font-weight: bold;">&lt;-</span> hDuplicate h
    fd <span style="color: #339933; font-weight: bold;">&lt;-</span> handleToFd dup<span style="color: #339933; font-weight: bold;">_</span>h
    fdopen fd iomode</pre></div></div>

<p>Also, I made sure to close the Fd as well, which the Bzlib2 Bindings article did not show:</p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;">aug<span style="color: #339933; font-weight: bold;">_</span>print <span style="color: #339933; font-weight: bold;">::</span> Ptr Augeas  <span style="color: #5d478b; font-style: italic;">-- ^ Augeas pointer</span>
          <span style="color: #339933; font-weight: bold;">-&gt;</span> Handle      <span style="color: #5d478b; font-style: italic;">-- ^ Already opened file handle</span>
          <span style="color: #339933; font-weight: bold;">-&gt;</span> ByteString  <span style="color: #5d478b; font-style: italic;">-- ^ PATH</span>
          <span style="color: #339933; font-weight: bold;">-&gt;</span> <span style="color: #cccc00; font-weight: bold;">IO</span> <span style="color: green;">&#40;</span>AugRet<span style="color: green;">&#41;</span> <span style="color: #5d478b; font-style: italic;">-- ^ return value</span>
aug<span style="color: #339933; font-weight: bold;">_</span>print aug<span style="color: #339933; font-weight: bold;">_</span>ptr fptr<span style="color: #339933; font-weight: bold;">_</span>out bs<span style="color: #339933; font-weight: bold;">_</span>path <span style="color: #339933; font-weight: bold;">=</span>
    <span style="color: #06c; font-weight: bold;">do</span>
      useAsCString bs<span style="color: #339933; font-weight: bold;">_</span>path <span style="color: #339933; font-weight: bold;">$</span> \path <span style="color: #339933; font-weight: bold;">-&gt;</span> <span style="color: #06c; font-weight: bold;">do</span>
        out <span style="color: #339933; font-weight: bold;">&lt;-</span> handleToCFile fptr<span style="color: #339933; font-weight: bold;">_</span>out <span style="background-color: #3cb371;">&quot;w&quot;</span>
        ret <span style="color: #339933; font-weight: bold;">&lt;-</span> c<span style="color: #339933; font-weight: bold;">_</span>aug<span style="color: #339933; font-weight: bold;">_</span>print aug<span style="color: #339933; font-weight: bold;">_</span>ptr out path
        fflush out
        fclose out
        <span style="font-weight: bold;">return</span><span style="color: green;">&#40;</span>ret<span style="color: green;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.pwan.org/wp/?feed=rss2&#038;p=33</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>python-module-for-puppet</title>
		<link>http://www.pwan.org/wp/?p=29</link>
		<comments>http://www.pwan.org/wp/?p=29#comments</comments>
		<pubDate>Fri, 09 Jan 2009 21:41:53 +0000</pubDate>
		<dc:creator>jude</dc:creator>
				<category><![CDATA[open source]]></category>
		<category><![CDATA[puppet]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.pwan.org/wp/?p=29</guid>
		<description><![CDATA[I&#8217;ve been using the python-module-for-puppet to make sure my build environment machines have the python modules they need. The modules been working as advertised, but unfortunately some of machines need to be running older versions of a couple packages, so I forked the project and added support for an optional $version argument so the easy_install [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using the <a href="http://github.com/garthrk/python-module-for-puppet/tree/master">python-module-for-puppet</a> to make sure my build environment machines have the python modules they need.</p>
<p>The modules been working as advertised, but unfortunately some of machines need to be running older versions of a couple packages, so I <a href="http://github.com/jude/python-module-for-puppet/tree/master">forked the project</a> and added support for an optional $version argument so the easy_install command could use &#8220;name==version&#8221; style commands.</p>
<p>It&#8217;s the first time I&#8217;ve submitted changes via github, so I hope it did it right.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pwan.org/wp/?feed=rss2&#038;p=29</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>So your wonky Indiana time zone is not mentioned in tzsetup-udeb ?</title>
		<link>http://www.pwan.org/wp/?p=22</link>
		<comments>http://www.pwan.org/wp/?p=22#comments</comments>
		<pubDate>Wed, 07 Jan 2009 22:00:43 +0000</pubDate>
		<dc:creator>jude</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.pwan.org/wp/?p=22</guid>
		<description><![CDATA[A bunch of  wonky Indiana time zones, were added to pkg-glibc/tzdata over 19 months ago, (along with a number of other time zone changes) but they still haven&#8217;t surfaced in the tzsetup-udeb package, as of 1/7/2009. As a result, if you&#8217;re in one of these odd Indiana counties, the tzsetup portion of the installation won&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>A bunch of  <a href="http://en.wikipedia.org/wiki/Time_in_Indiana" target="_blank">wonky Indiana time zones</a>, were added to pkg-glibc/tzdata <a href="http://svn.debian.org/viewsvn/pkg-glibc?rev=2332&amp;view=rev">over 19 months ago</a>, (along with a number of other time zone changes) but they still haven&#8217;t surfaced in the <a href="http://svn.debian.org/viewsvn/d-i/trunk/packages/tzsetup/">tzsetup-udeb</a> package, as of 1/7/2009.</p>
<p>As a result, if you&#8217;re in one of these odd Indiana counties, the tzsetup portion of the installation won&#8217;t display your time zone, but you can set it to the correct time zone after the install finishes.</p>
<p>I filled <a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=511153">bug 511153</a> after asking about it on the debian-boot IRC channel on irc.debian.org</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pwan.org/wp/?feed=rss2&#038;p=22</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

