<?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"
	>

<channel>
	<title>smithj's blog</title>
	<atom:link href="http://blog.freethemallocs.com/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.freethemallocs.com/wordpress</link>
	<description></description>
	<pubDate>Tue, 10 Jun 2008 18:59:52 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>procmail, maildir, and marking as read</title>
		<link>http://blog.freethemallocs.com/wordpress/2008/06/09/procmail-maildir-and-marking-as-read/</link>
		<comments>http://blog.freethemallocs.com/wordpress/2008/06/09/procmail-maildir-and-marking-as-read/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 19:54:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.freethemallocs.com/wordpress/?p=11</guid>
		<description><![CDATA[Googling for &#8220;procmail maildir mark as read&#8221; yields a number of solutions, the most compact of which seems to be using INCLUDERC or SWITCHRC as explained here: http://blog.raamdev.com/2007/11/14/using-procmail-to-mark-as-read/
However, in my experience, this solution is noticeably racey. When using IMAP with the IDLE command set, some mail clients (thunderbird, probably others) will under certain circumstances immediately [...]]]></description>
			<content:encoded><![CDATA[<p>Googling for &#8220;procmail maildir mark as read&#8221; yields a number of solutions, the most compact of which seems to be using INCLUDERC or SWITCHRC as explained here: http://blog.raamdev.com/2007/11/14/using-procmail-to-mark-as-read/</p>
<p>However, in my experience, this solution is noticeably <a href="http://en.wikipedia.org/wiki/Race_condition" target="_self">racey</a>. When using IMAP with the IDLE command set, some mail clients (thunderbird, probably others) will under certain circumstances immediately tell the mail server to mark the message as unread and not new. In maildir, this moves the message for new/ to cur/. Thus, if this happens before the server gets around to executing the mv command, the move fails and the message is not marked as read.</p>
<p>Truthfully, procmail should be enhanced to allow you to process a message marked as read in an atomic fashion. But that doesn&#8217;t seem likely, so the hack is to tell the mv command to look in both the cur/ and new/ directory. Doing so is straightforward:</p>
<p>Put this in ~/.procmailrc_mark_as_read_maildir:</p>
<p style="padding-left: 30px;">:0<br />
{<br />
:0c # store as new<br />
$folder/</p>
<p style="padding-left: 30px;">:0 # move to cur/ and append a ,S to mark as read<br />
* LASTFOLDER ?? /\/[^/]+$<br />
{ tail=$MATCH }</p>
<p style="padding-left: 30px;">TRAP=&#8221;mv -v $LASTFOLDER $folder/cur/$tail 2&gt; /dev/null ; mv -v $folder/cur/${tail}* $folder/cur/$tail:2,S&#8221;</p>
<p style="padding-left: 30px;">HOST<br />
}</p>
<p>Then in your normal procmailrc, the usage is this:</p>
<p style="padding-left: 30px;">:0<br />
* someregexhere<br />
{<br />
folder=Maildir/.myfolder<br />
SWITCHRC=$HOME/.procmailrc_mark_as_read_maildir<br />
}</p>
<p>Now it will mark the message read whether or not your client is IDLEing in that folder. It will also log that it has done so, if you have logging enabled.</p>
<p>The solution isn&#8217;t perfect, as if you mark the message read inbetween the moves, it will log bogus errors; at least it will now mark the mail correctly.</p>
<p>UPDATE:</p>
<p>I&#8217;ve been asked by a few people how a remote host running IMAP can possibly win the race with procmail executing mv sequentially after initially creating the file. My IMAP server, <a href="http://www.dovecot.org/">dovecot</a>, uses <a href="http://en.wikipedia.org/wiki/Inotify">inotify</a> to watch for new messages in maildirs. So when the kernel writes out the file, it notifies dovecot who immediately notifies its clients who mark the message as unread but not new (assuming they&#8217;re IDLEing that folder). Now, true, there is some network latency, but since dovecot notices the new mail immediately it is plausible that the network latency will be less than the system latency in exec()ing a new command, especially if load is moderate or high.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.freethemallocs.com/wordpress/2008/06/09/procmail-maildir-and-marking-as-read/feed/</wfw:commentRss>
		</item>
		<item>
		<title>update schemes for software appliances</title>
		<link>http://blog.freethemallocs.com/wordpress/2008/05/19/9/</link>
		<comments>http://blog.freethemallocs.com/wordpress/2008/05/19/9/#comments</comments>
		<pubDate>Mon, 19 May 2008 18:57:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.freethemallocs.com/wordpress/?p=9</guid>
		<description><![CDATA[Xiaowen recently posted an article in which she claimed that the traditional OS&#8217;s update mechanism is rendered obsolete by software appliances.
I don&#8217;t agree.
Her implied assumption is that configuration data is easily separated from the OS, an assumption that is suspect, at best. In UNIXy systems, all configuration data is supposedly stored in /etc, and /etc [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Xiaowen" href="http://xiaowenx.blogspot.com/" target="_self">Xiaowen</a> recently posted an article in which she <a href="http://xiaowenx.blogspot.com/2008/05/amazon-ec2-makes-traditional-updates.html" target="_self">claimed that the traditional OS&#8217;s update mechanism is rendered obsolete by software appliances</a>.</p>
<p>I don&#8217;t agree.</p>
<p>Her implied assumption is that configuration data is easily separated from the OS, an assumption that is suspect, at best. In UNIXy systems, all configuration data is supposedly stored in /etc, and /etc is supposed to contain only configuration data. In reality, that line is hard to draw, and harder still to enforce.</p>
<p>Consider cron jobs (regularly executed scripts and programs) stored in /etc/cron*. I&#8217;m sure Windows has a similar concept. Some cronjobs are scheduled by administrators, some by users, and some by OS distributors. Some which are shipped by the OS, such as logwatch, are often modified by administrators. Modifying system configuration files and settings is difficult under a read-only OS scheme.</p>
<p>Presumably it should be possible to merge such changes via a read-write layer on top of the read-only system files, via UnionFS or similar. This is harder than it seems; to do the merge, the update mechanism needs to know the state of the file as shipped with the older version of OS, as modified by the user, and as shipped with the newer version of the OS. An update mechanism which relies solely on image-based updates would not have access to that information. Contrast with conary, which has access to a networked repository containing every version of every file ever shipped in a given OS. This allows conary to do intelligent merging of changes, preventing a new  (and potentially critically important) configuration option from either the OS or the user from being lost on update.</p>
<p>There are some ways to mitigate this failing of image-based update schemes. The OS can be redesigned to have, as Linux distro maintainers call them, dot-d directories for every possible configuration option. So, instead of having a single file, you have a directory (usually ending in .d, hence the name) which can contain both user- and system-defined options. However, this clutters the filesystem and doesn&#8217;t address what would happen should the filenames ever collide. Another option is to redesign every system component so the OS defaults are built in to the programs themselves, leaving /etc only for user-defined configuration. That would be *alot* of work, and would make it harder for users to see which config options the system is using by default. Presumably this is what folks like TiVO do, but the number of user-configurable options TiVO has is laughable compared with the options needed by an enterprise (or even a small/medium business) deploying a software appliance. Enterprises need to be able to change things like login schemes, security and auditing models, configuring for external databases, SAN- and NAS-based storage, etc. Addressing all these intelligently in an image-based setup would be very difficult.</p>
<p>An image-based solution simply can&#8217;t keep up with my needs. So, for now, I&#8217;m very happy using conary to manage my appliances&#8230; long live conary!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.freethemallocs.com/wordpress/2008/05/19/9/feed/</wfw:commentRss>
		</item>
		<item>
		<title>hg makes distro hacking simpler&#8230; part 2</title>
		<link>http://blog.freethemallocs.com/wordpress/2008/02/14/hg-makes-distro-hacking-simpler-part-2/</link>
		<comments>http://blog.freethemallocs.com/wordpress/2008/02/14/hg-makes-distro-hacking-simpler-part-2/#comments</comments>
		<pubDate>Thu, 14 Feb 2008 08:58:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.freethemallocs.com/wordpress/2008/02/14/hg-makes-distro-hacking-simpler-part-2/</guid>
		<description><![CDATA[I must confess something&#8230; I appear to have unintentionally fibbed in my last post, when I said &#8220;This method has the added benefit of making patches cleaner.&#8221; It has come to my attention that when using the script on files which have already been patched, manually applying a patch on top (as you might do [...]]]></description>
			<content:encoded><![CDATA[<p>I must confess something&#8230; I appear to have unintentionally fibbed in my last <a href="http://http://blog.freethemallocs.com/wordpress/2007/12/05/hg-makes-distro-hacking-simpler/" title="last post" target="_blank">post</a>, when I said &#8220;This method has the added benefit of making patches cleaner.&#8221; It has come to my attention that when using the script on files which have already been patched, manually applying a patch on top (as you might do if only part of a patch you want to port is rejected) can lead to cruft in the final patch.</p>
<p>The &#8220;patch&#8221; command basically assumes that we have no version control. Thus, if it detects anything even slightly amiss (such as a line number offset) it makes a backup of the file, even if it successfully patches the original. This backup usually ends in a ~, giving, for example, &#8220;Makefile~&#8221; as the backup of a patched &#8220;Makefile&#8221;. When mercurial adds the files to the repo, it includes *~. So if the patch you want to port touches any of the same files, it will modify the *~ file, causing mercurial to believe that a valid change was made, and thus to include that change in the diff it produces after you&#8217;re finished hacking on the sources.</p>
<p>The fix is very simple:</p>
<p>#!/bin/sh<br />
# start up the repo<br />
hg init<br />
# remove files who&#8217;s existence is only due to patch doing backups<br />
find . -name &#8216;*~&#8217; -delete<br />
# add all files to the repo, but don&#8217;t be overly verbose about it<br />
hg addremove &gt; /dev/null<br />
# commit all files to the repo<br />
hg ci -m &#8220;initial commit&#8221;</p>
<p>Of course, this also has the benefit of making the checkout a wee bit cleaner while working on it <img src='http://blog.freethemallocs.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.freethemallocs.com/wordpress/2008/02/14/hg-makes-distro-hacking-simpler-part-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>hg makes distro hacking simpler</title>
		<link>http://blog.freethemallocs.com/wordpress/2007/12/05/hg-makes-distro-hacking-simpler/</link>
		<comments>http://blog.freethemallocs.com/wordpress/2007/12/05/hg-makes-distro-hacking-simpler/#comments</comments>
		<pubDate>Wed, 05 Dec 2007 13:04:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.freethemallocs.com/wordpress/2007/12/05/hg-makes-distro-hacking-simpler/</guid>
		<description><![CDATA[Once, I offhandedly mentioned to Michael K Johnson that I often use hg to help me hack on distro packages. He said he thought it was neat and I should blog about it. So, half a year later when I finally bothered to set up a real blog&#8230;
The problem I was having was one of [...]]]></description>
			<content:encoded><![CDATA[<p>Once, I offhandedly mentioned to <a href="http://blogs.conary.com/index.php/mkj" title="mkj">Michael K Johnson</a> that I often use hg to help me hack on distro packages. He said he thought it was neat and I should blog about it. So, half a year later when I finally bothered to set up a real blog&#8230;</p>
<p>The problem I was having was one of control. When approaching a bug in a package who&#8217;s codebase was unfamiliar, as I was often required to do,  it would naturally take a number of attempts to get a bugfix correct. My build dir was often getting overwritten, causing my changes to unintentionally disappear. Further, when making changes, it was a pain to copy around build trees to get good diffs, especially on large packages, and it was impossible to undo something if I made a mistake.</p>
<p>Enter mercurial. Because hg has a totally distributed model, it is trivial to set up repositories, allowing one to use them essentially as scratch space. Now, every time I work on a package, I &#8220;cvc cook &#8211;prep&#8221; it to get the sources, and then run this script (if, indeed, you can call it that):</p>
<p>#!/bin/sh<br />
hg init<br />
hg addremove &gt; /dev/null # addremove is overly verbose<br />
hg ci -m &#8220;initial commit&#8221;</p>
<p>Then I hack on the package to my heart&#8217;s content without worrying what I&#8217;m screwing up in the process. I save &#8220;checkpoints&#8221; by doing hg commits, then later I can generate a diff from the initial commit all the way to tip, or to any point in the tree. When I&#8217;m done, I generate a patch and commit it to the conary repo. The hg tree is blown away by the next cvc cook, or by a tmpwatch cronjob that watches over my build dir. This allows me to not worry about forgetting parts of the changes I&#8217;ve made as it is all in the repo, and allows me to not worry about whether upstream patches or other applied patches conflict as they are all included in the first hg commit.</p>
<p>This method has the added benefit of making patches cleaner. Hg always generates a minimal unified level 1 diff. Always. No matter where you are in the tree or what nastiness you&#8217;ve done, making the patch both easier for humans to read and easier for cvc to apply.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.freethemallocs.com/wordpress/2007/12/05/hg-makes-distro-hacking-simpler/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
