


<?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>CantRemembrances &#187; osx</title>
	<atom:link href="http://blog.cantremember.com/tag/osx/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.cantremember.com</link>
	<description>Memes of a technical vein discovered during CantRemember.com implementation</description>
	<lastBuildDate>Tue, 16 Feb 2010 06:36:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>logrotate Mac OS Launch Daemon with Legacy MacPort</title>
		<link>http://blog.cantremember.com/logrotate-mac-os-launch-daemon-with-legacy-macport/</link>
		<comments>http://blog.cantremember.com/logrotate-mac-os-launch-daemon-with-legacy-macport/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 07:04:06 +0000</pubDate>
		<dc:creator>dfoley</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[logrotate]]></category>
		<category><![CDATA[macports]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://blog.cantremember.com/?p=37</guid>
		<description><![CDATA[Everbody loves cron.  The classic basic scheduler, 80/20 flexibility, gets the job done.  So, when I started with OS X, I went looking for cron.
Yes, you can cron if you want to.  Or maybe, as the Mac children recommend, you can create Launch Daemons.  It&#8217;s simply a custom launchd.plist, an XML [...]]]></description>
			<content:encoded><![CDATA[<p>Everbody loves <a href="http://www.manpagez.com/man/8/cron/">cron</a>.  The classic basic scheduler, 80/20 flexibility, gets the job done.  So, when I started with OS X, I went looking for cron.</p>
<p>Yes, you can <em>cron</em> if you want to.  Or maybe, as the Mac children recommend, you can create <strong>Launch Daemons</strong>.  It&#8217;s simply a custom <a href="http://developer.apple.com/DOCUMENTATION/DARWIN/Reference/ManPages/man5/launchd.plist.5.html">launchd.plist</a>, an XML file to define tasks in Apple&#8217;s terms.  Sweet, I can do that&#8230;</p>
<h3>The logrotated.plist Daemon</h3>
<p>From what I could tell, out of the box, Leopard doesn&#8217;t give you <a href="http://linux.die.net/man/8/logrotate">logrotate</a>.  So, here it is as a Launch Daemon:</p>
<div class="pre_wrap">
<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
	&lt;key&gt;Disabled&lt;/key&gt;
	&lt;false/&gt;
	&lt;key&gt;Label&lt;/key&gt;
	&lt;string&gt;logrotate&lt;/string&gt;

	&lt;key&gt;ProgramArguments&lt;/key&gt;
	&lt;array&gt;
		&lt;string&gt;/opt/local/sbin/logrotate&lt;/string&gt;
		&lt;string&gt;-f&lt;/string&gt;
		&lt;string&gt;/etc/logrotate/*.conf&lt;/string&gt;
	&lt;/array&gt;
	&lt;key&gt;EnableGlobbing&lt;/key&gt;
	&lt;true/&gt;

	&lt;key&gt;KeepAlive&lt;/key&gt;
	&lt;false/&gt;
	&lt;key&gt;LaunchOnlyOnce&lt;/key&gt;
	&lt;false/&gt;
	&lt;key&gt;RunAtLoad&lt;/key&gt;
	&lt;false/&gt;
&lt;!--
causes 'Throttling respawn: Will start in 10 seconds' in system.log
	&lt;key&gt;OnDemand&lt;/key&gt;
	&lt;false/&gt;
--&gt;

&lt;!--
http://www.nabble.com/launchd-support-ranges-for-StartCalendarInterval - - td14857719.html
--&gt;
	&lt;key&gt;StartCalendarInterval&lt;/key&gt;
	&lt;!-- 3:05a, 3:05p --&gt;
	&lt;array&gt;
		&lt;dict&gt;
			&lt;key&gt;Hour&lt;/key&gt;
			&lt;integer&gt;3&lt;/integer&gt;
			&lt;key&gt;Minute&lt;/key&gt;
			&lt;integer&gt;05&lt;/integer&gt;
		&lt;/dict&gt;
		&lt;dict&gt;
			&lt;key&gt;Hour&lt;/key&gt;
			&lt;integer&gt;15&lt;/integer&gt;
			&lt;key&gt;Minute&lt;/key&gt;
			&lt;integer&gt;05&lt;/integer&gt;
		&lt;/dict&gt;
	&lt;/array&gt;
&lt;/dict&gt;
&lt;/plist&gt;</code></pre>
</div>
<p>Great.  So what do I do with it?  Name it anything &#8216;*.plist&#8217; &#8212; <code>logrotated.plist</code> perhaps &#8212; and put it here:</p>
<ul>
<li><code>/System/Library/LaunchDaemons</code> or</li>
<li><code>/Library/LaunchDaemons</code></li>
</ul>
<p>I tend to use System for any services I wan to launch on boot (<a href="http://linux.die.net/man/8/chkconfig">chkconfig</a>-ish), and anything that&#8217;s just a scheduled task is more pedestrian.</p>
<p>You register daemons through <a href="http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/launchctl.1.html">launchctl</a>.  When you change it, just:</p>
<div class="pre_wrap">
<pre><code>$ launchctl unload FILE.plist
$ launchctl load FILE.plist</code></pre>
</div>
<p>Sure, not a hard thing.  What I <em>did</em> want to point out were some of the things that I learned:</p>
<ul>
<li>
Provide each space-separated component of the command line as &lt;string /&gt; element in the ProgramArgument &lt;array /&gt;.  It&#8217;s the easiest way to go.
</li>
<li>
I tend to keep the <code>KeepAlive</code>, <code>LaunchOnlyOnce</code> and <code>RunAtLoad</code> all in sync for each daemon.  It seems to guarantee compatability.
</li>
<li>
I still haven&#8217;t gotten quite the hand of <code>OnDemand</code> (c&#8217;mon, I&#8217;m new to this).  When you are developing your daemons, keep a watch on <code>/var/log/system.log</code> &#8212; if you screw up, you&#8217;ll probably see it there in one fashion or another.
</li>
<li>
<code>StartCalendarInterval</code> is the equivalent of the cron schedule mask.  See the <a href="http://www.nabble.com/launchd-support-ranges-for-StartCalendarInterval">Nabble</a> post i commented above.  You can&#8217;t do ranges, but wildcards are do-able sorta by omission.  If you want mulltiple disparate schedules, as you see above, you need to pass in an &lt;array /&gt; of &lt;dict /&gt;s, not just a single &lt;dict /&gt; when you only need one mask.
</li>
<li>
Yes, datatypes matter!  I couldn&#8217;t figure out for the life of me why my daemon wouldn&#8217;t start, until I realized that my <code>Hour</code> and <code>Minute</code> values were configured as &lt;string /&gt;s &#8212; vs &lt;integer /&gt;s &#8212; because I&#8217;d been, well, you know, trying to do ranges and wildcards the cron-style way.  <code>launchctl</code> didn&#8217;t complain, it just didn&#8217;t &#8230; work.  So don&#8217;t do that.
</li>
<li>
Any daemon which has a schedule that fires off when the system is down will be automatically executed shortly after the system re-awakens.  I don&#8217;t know exactly how quickly, but I&#8217;ve seen it in action (though I&#8217;ve read some dispute about its efficacy in my searches).
</li>
</ul>
<h3>The Trials and Tribulations of MacPorts</h3>
<p>But of course this Epistle wouldn&#8217;t be any fun without a twist, right?  Well, lucky us, because it wasn&#8217;t <em>that easy</em>.</p>
<p>I&#8217;m using <a href="http://guide.macports.org/">MacPorts</a> as my <code>yum</code>-my package manager.  It&#8217;s great, and easy to set up, but it&#8217;s quite as stable as I&#8217;ve seen under Linux.  Or rather, I&#8217;ve seen a disproportionate number of issues in the times I&#8217;ve used it.  However, I&#8217;m eternally grateful because it saves me so much time &#8230; the successes far outweigh the problems.</p>
<p>When things do go bad, as they did when I built logrotate 3.7.7, you have to set up a custom Portfile and source repository so that you can effectively drive MacPorts to fetch and build your specific version.  logrotate 3.7.1_1 turned out to be much more stable.</p>
<p><a href="http://homepage.mac.com/simx/technonova/tips/using_experimental_macports_portfiles.html">Techonova</a> and <a href="http://journal.bitshaker.com/articles/2007/10/20/install-old-versions-of-ports-using-macports/">Joe Homs</a> go into very excellent and welcome detail in their posts on how to pull this off.  A summary of what you need to do is:</p>
<ul>
<li>
watch the build failure &#8212; debug with <code>port -d</code> &#8212; to identify where the dying source is located.  That&#8217;ll be PATH/TO/PROJECT
</li>
<li>
visit <code>http://trac.macosforge.org/projects<wbr>/macports/log/trunk/dports<wbr>/PATH/TO/PROJECT</code> and snag the Portfile.  That&#8217;s a MacPorts spec file, and you can tweak it to do your bidding.
</li>
<li>
create a source directory that you&#8217;ll keep around for a while (mine is <code>/Users/Shared/macports</code>).
</li>
<li>
register that directory &#8212; your local Portfile repository &#8212; with <code>/opt/local/etc/macports/sources.conf</code> (using <code>file://</code> protocol)
</li>
<li>
copy the Portfile into a PATH/TO/PROJECT sub-directory structure (eg. <code>sysutils/logrotate</code>).  Basically, the same path you&#8217;ll have snagged it from.
</li>
<li>
pull down a previous source revision and snapshot it locally.  That could come from SVN or git, tarball, whatever.  Start search from the <code>homepage</code> setting of the Portfile.
</li>
<li>
tweak the Portfile to &#8216;make sense&#8217; for the source you&#8217;ve pulled down.  If you based upon a close-enough version, it should be as easy as tweaking the version, etc. &#8212; no custom build tasks.  I&#8217;m glossing over when I say that it&#8217;s usually a matter of version-based naming conventions and MD5 checksums.
</li>
<li>
re-build the repository&#8217;s PortIndex (which you&#8217;ll need to do every time you make an addition / change)
</li>
</ul>
<p>Please feel free to consult the other two posts to fill in the details that I was so cavalier about.</p>
<h3>In Summary</h3>
<p>This was another one of those occasions when I was glad I kept track of what I was doing while I was in the moment. Pack your config files with comments, because they&#8217;re invaluable.  And drop READMEs around where you&#8217;re likely to find them &#8230; I filled in a lot of the extra details for this post from those breadcrumbs I left for myself, things I could have easily wasted 15-20m on re-discovering by braille :)</p>
<p>Peace.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cantremember.com/logrotate-mac-os-launch-daemon-with-legacy-macport/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Java SE 6 and Eclipse to play nicely on Mac OS X</title>
		<link>http://blog.cantremember.com/java-6-eclipse-os-x-leopard/</link>
		<comments>http://blog.cantremember.com/java-6-eclipse-os-x-leopard/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 23:44:16 +0000</pubDate>
		<dc:creator>dfoley</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://blog.cantremember.com/?p=19</guid>
		<description><![CDATA[Specifically, this post is about getting the standard pre-packaged install of Java SE 6 for OS X Leopard to play nicely with Eclipse 3.4 Ganymede.  If you wish to move to Java SE 6 for Tiger or a pre-10.5 release of OS X, you may want to consider using SoyLatte, as recommended by the [...]]]></description>
			<content:encoded><![CDATA[<p>Specifically, this post is about getting the standard pre-packaged install of Java SE 6 for OS X Leopard to play nicely with Eclipse 3.4 Ganymede.  If you wish to move to Java SE 6 for Tiger or a pre-10.5 release of OS X, you may want to consider using <a href="http://landonf.bikemonkey.org/static/soylatte/">SoyLatte</a>, as <a href="http://2tbsp.com/node/106">recommended by the 2 tablespoons blog</a>. I don&#8217;t imagine that any 3.x version of Eclipse would raise additional issues.</p>
<p>When you unpack the installer .dmg, it&#8217;s simply going to install the package.  It will not automatically assume that you want to use it (not such a bad assumption, as it turns out).  So there are a few caveats you need to deal with.  I&#8217;m taking the approach of addressing all the details I know of, regardless of how obvious this may all seem :)</p>
<p>Post-install, Java 5 will still be in active use:</p>
<div class="pre_wrap">
<pre><code>$ ls -l /usr/bin/java
/usr/bin/java -&gt; /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
$ Lunditer:~ root# java -version
java version "1.5.0_16"</code></pre>
</div>
<p>You&#8217;ll see something much like this under <code>/System/Library/Frameworks<wbr>/JavaVM.framework/Versions</code> :</p>
<div class="pre_wrap">
<pre><code>1.3 -&gt; 1.3.1
1.3.1
1.4 -&gt; 1.4.2
1.4.1 -&gt; 1.4
1.4.2
1.5 -&gt; 1.5.0
1.5.0
1.6.0
A
Current -&gt; A
CurrentJDK -&gt; 1.5</code></pre>
</div>
<p>Initially, I went and modified the symlink for CurrentJDK.  Modifying the symlink for Current brought me nothing but <em>pain</em>. You can get the results you want by making the following change:</p>
<div class="pre_wrap">
<pre><code>CurrentJDK -&gt; 1.6.0</code></pre>
</div>
<p>I&#8217;d had it set up that way until I wrote this post.  But Apple <a href="http://www.macosxhints.com/article.php?story=2005111606295344">highly discourages this practice</a>.  Instead, they recommend that you use the Java Preferences pane.  Get rid of all your symlink shenanigans, and simply drag the &#8216;Java SE 6&#8242; option to the top of the applet and application listings.  It works like a charm.  Start a new Terminal shell and you can confirm:</p>
<div class="pre_wrap">
<pre><code>$ /usr/bin/java -version
java version "1.6.0_07"
$ /usr/bin/javac -version
javac 1.6.0_07</code></pre>
</div>
<p>However &#8230; from my experience, this is a <em>user-specific</em> setting.  Which means if you run Java as <code>root</code>, you&#8217;ll still get Java SE 1.5.  Not a problem.  We&#8217;ll stick with the Apple-sanctioned solution here.</p>
<p>Hooray, Java SE 6!  Now let&#8217;s start Eclipse 3.4!  Hooray &#8230; oops?  Startup failure dialog:</p>
<div class="pre_wrap">
<pre><code>JVM terminated.
Exit code=-1
...
-vm /System/Library/Frameworks/JavaVM.framework
...</code></pre>
</div>
<p>This is a <strong>well documented</strong> issue.  Both the <a href="http://blog.kischuk.com/2008/05/08/running-eclipse-on-macbooks-with-java-6/">Rob Kischuk</a> and <a href="http://stackoverflow.com/questions/245803/jvm-terminates-when-launching-eclipse-mat-on-mac-os-with-j2se-60">Stack Overflow</a> blogs are very helpful in explaining that; Eclipse uses 32-bit SWT-Cocoa / Carbon, and Mac OS Java SE 6 only comes in a 64-bit flavor.  I have not looked into the SoyLatte option, as suggested above, though that may prove to be an alternative approach.</p>
<p>I had some struggles getting their approach to work (until now, that is).  Easiest way to start config testing is to run Eclipse from the command line:</p>
<div class="pre_wrap">
<pre><code>$ cd /Applications/eclipse/Eclipse.app/Contents/MacOS/
$ ./eclipse -vm /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Commands/java</code></pre>
</div>
<p>You can also provide <code>/System/Library/Frameworks<wbr>/JavaVM.framework/Versions/1.5.0</code>, which I extrapolated from the -vm setting in the failure message.  If you still get an error dialog, you may see multiple instances of -vm, but that&#8217;s a red herring; it will work once properly configured.</p>
<p>Great.  Once that&#8217;s working for you, let&#8217;s apply it to the App shortcut.  There&#8217;s two ways you can go about this:</p>
<p>The blogs above recommend that you modify the <code>Info.plist</code>:</p>
<ul>
<li>edit /Applications/eclipse/Eclipse.app/Contents/Info.plist</li>
<li>uncomment the following line:
<div class="pre_wrap">
<pre><code>&lt;string&gt;-vm&lt;/string&gt;&lt;string&gt;/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Commands/java&lt;/string&gt;</code></pre>
</div>
</li>
</ul>
<p>Alternately, you can modify <code>eclipse.ini</code>, where you might also configure your JVM memory configuration:</p>
<ul>
<li>edit /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse.ini</li>
<li>add the following line:
<div class="pre_wrap">
<pre><code>-vm /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Commands/java</code></pre>
</div>
</li>
</ul>
<p>Either dab will do ya.  But if you didn&#8217;t know before, now you know where <code>eclipse.ini</code> lives :)</p>
<p>Things should be grand now.  If they aren&#8217;t, I suggest trying some variations while running Eclipse from the command line.  It took me a while to get the right combination, even though this post and (the ones it references) may seem very cookie-cutter.  It <em>will</em> eventually work for you!</p>
<p>Now, I mentioned that the Apple-sanctioned approach seems to be user-specific.  And I run Tomcat as root.  So you will probably still want to add the traditional environment settings.</p>
<p>You can either make these changes to <code>/etc/profile</code>, or to the <code>~/.bashrc</code> of each relevant account.  No surprises here:</p>
<div class="pre_wrap">
<pre><code>export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
PATH="$JAVA_HOME/bin:$PATH"</code></pre>
</div>
<p>My experiments to get <code>/etc/paths</code> to inject something into the path before &#8216;/usr/bin&#8217; weren&#8217;t so useful, so I chose the brute force method.</p>
<p>If you&#8217;re going to use sudo to run Tomcat, you&#8217;ll want to make sure to load the bash environment.</p>
<div class="pre_wrap">
<pre><code>sudo su -</code></pre>
</div>
<p>to guarantee that root&#8217;s environment includes the custom /etc/profile overrides.  No dash, and it no work.  Tomcat Java 5 + App Java 6 =</p>
<div class="pre_wrap">
<pre><code>SEVERE: Error deploying web application directory ...
java.lang.UnsupportedClassVersionError: Bad version number in .class file</code></pre>
</div>
<p>With the environment in place, you should be good to go.</p>
<p>The writing of this post drove me to (a) drop the symlinks, (b) use Java Preferences pane and (c) get the right -vm config set up (since I&#8217;d been leaning entirely on the environment settings up to this point).  So there are definitely a few ways to skin this cat.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cantremember.com/java-6-eclipse-os-x-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
