Portupgrade on FreeBSD

Ran into a “pkgdb.db: unexpected file type or format” during a portupgrade on FreeBSD. Here’s the fix.

I’m using FreeBSD, and keeping it up to date with the ports collection is normally a fairly simple thing to do.

  1. Make sure DNS is working (check you /etc/resolve.conf file)
  2. # portsnap fetch
  3. # portsnap update
  4. # portupgrade -a

Only, today I got a strange error message doing the portupgrade:
/var/db/pkg/pkgdb.db: unexpected file type or format — Invalid argument

Whether something broke, got disconnected, terminated in the middle of processing, or the database format or version changed, I dunno.

However, the fix is easy. Get rid of the problem files, and let portupgrade rebuild them.

# rm /var/db/pkg/pkgdb.db
# rm /usr/ports/INDEX*.db
# portupgrade -a

WordPress Tilde Hack for Home Directories

WordPress has a problem when it is run from a user’s home directory. Apache will honor a tilde (~) or a hex code (%7E) in a URL, getting to the correct directory, but that’s where things break down: WordPress sees those two strings as logically different. And that poses some serious problems for applications that are trying to do the safest course of action. HACK WORKAROUND PROVIDED.

While browsing through the preferences of NetNewsWire, I noticed in the preferences there was a way to blog a entry of an RSS feed. To do this, the application shelled out to another application to do the heavy lifting.

That application was MarsEdit, a tool that was supposed to make blogging as easy as writing an email.

Problem was, when I went to open my blog in MarsEdit, I ran into a bit of a problem. MarsEdit was inserting %7E in the url, which is obviously the safe hex representation for the tilde sign. (Note, it’s tilde, with an ‘e’, not tilda.)

Look at your web browser’s URL for just a second. You should see something that looks like this: http://www.wwco.com/~wls/blog/

The tilde is a short hand notation that says to use my home directory. The default install of Apache allows this, because user home pages are in physically separate locations from the actual site’s webpages.

MarsEdit was trying to do the safe thing, by encoding something that should always work. And, Apache did the right thing by going to the right web page. Problem is, WordPress does the wrong thing — it reads the URL as-is and doesn’t realize %7E is the same as ~.

MarsEdit is not the only application that does this, many others do: it is the correct behavior. Even links from Digg, will do this on occasion.

I failed to find a decent solution to fix the problem, too. Discussions on the WordNet site seemed to ignore the fact that this was a problem, pointing people to Apache’s pages. Solutions that worked for others, didn’t work for me. Remember, Apache was delivering content, specifically WordPress content, and WordPress couldn’t deduce the entry to show, so it showed it’s own 404. This further supports the problem being WordPress’s.

I tried some mod_rewrite tricks, and those didn’t work. I even tried muddling inside the functions of WordPress, but it seemed that no matter where I made my changes, they either didn’t take or something broke. The page selection code was happening far to upstream, and I was getting bitten by it.

So I resorted to the final hack I knew would work. All WordPress requests go to the index.php file to start with, and it is Apache’s REQUEST_URI which is correctly preserving the encoded string. So, I figured before any other script of function could get its hands on it, I’d change that string.

Inside the <?php?> tags, I added this one line:
$_SERVER['REQUEST_URI'] = preg_replace( "/%7[Ee]/", "~", $_SERVER['REQUEST_URI'] );

This simply substitutes the %7E back into a tilde, so WordPress gets a familiar string to work with.

This solved my problem instantly. It’s ugly, but it works.

Please if you suffer from this problem because you’re using WordPress in your home directory, make a little notice to the authors, but while you’re at it, express some gratitude too at what a nice system they’ve made.

Over 55 Hand Picked Apps for OS X that You Must Have

I’ve hand selected over 55 applications that represented the best-of-the-best software for OS in over 15 categories, providing links to every one.

This list of over 55 hand-picked OS X applications represents what I consider the best-of-the-best software for the Apple Macintosh. And it all runs on the new Intel systems.

Believe me, there are many more applications that did not make the cut. This is not intended to be a comprehensive list, but a Walt’s personal favorites that have shown high quality, value, and utility. This is the ultimate selection in Walt’s Desktop for OS X.

I cover productivity, security, customization, photography, multimedia, movie production, drawing, business applications, browsing, communication, file sharing, astronomy, cameras, cataloging, and software development. Everything the ubergeek would want.

Please note, I have not limited the software to just free, shareware, or open source. Commercial packages are included as well, and I recommend supporting them, obtaining legal licenses – they’re worth it.

Enjoy.

Walt gives the software on this list a thumbs up.

…if you happen to have a favorite package that you think is better than what I’ve posted, perhaps I don’t know about it. Drop me a line.

Review: Norton Ghost 10

A review of Norton Ghost 10 … let’s cut to the chase, it sucks, just like virtually everything else with the Norton or Symantec name these days.

Let’s keep this short.

Bought Norton Ghost 10, installed it (which required a license activation – why?!?), and was even able to make backups to a remote drive. So far so good, eh?

Went to do a restore, it required a boot CD. Okay… Used the boot CD, and it instantly blue screened at boot time.

Searching on Google seemed to report that others also have this problem and that the boot CD seems to have problem with SATA drives. Argh.

Seems you can make all the backups you want, but not boot the restoration program.

Walt gives Norton Ghost two thumbs down.

Update: Went to use Acronis TrueImage – cheaper, no licensing, and it just worked.

Update: Seems it might be that Dell configured the SATA drives as RAID 0, and Norton Ghost couldn’t handle booting a RAID array.

Fixing Subversion (Permission Denied)

After installing Subversion from source on a new installation of Fedora Core 6, having it compile and install without complaint, I got this error message while trying to run it: error while loading shared libraries: /usr/local/lib/libsvn_ra_dav-1.so.0: cannot restore segment prot after reloc: Permission denied

Here’s how to fix it.

I went to install the latest Subversion 1.4.0 from scratch on a pristine Fedora Core 6 installation by building directly from source, an activity I’ve done many times in the past.

The code build and installed fun, but running svn, produced this mysterious error message:
error while loading shared libraries: /usr/local/lib/libsvn_ra_dav-1.so.0: cannot restore segment prot after reloc: Permission denied

Here’s how to fix the problem.

The message appears to be related to permission problems involving protections after relocation. What specifically this is all about, I’m not sure. However.

Fedora Core ships by default with something called SELinux, a security enhanced extension that introduces additional access control policies that confine user programs to the minimum amount of privileges required to do their jobs, which in turn improves security if a compromised program tries to extend its reach beyond what it’s suppose to touch. [See the Fedora Wiki page on SELinux]

Most people, however, don’t need it and find that it often gets in the way. Web masters encounter this as existing files in a web directory can be served, but new ones created can not be served — although all permissions and httpd.conf settings look right. When weird messages about permissions crop up, suspect SELinux.

Turning off SELinux, however, is quite simple. As root, edit /etc/selinux/config, find the line that says SELINUX= and set its value to disabled. I always find rebooting at this point is a good thing.

Anyhow, that fixed my subversion installation and running problem.

Update: If you think you may want SELinux, try permissive instead of disabled. This will let the access happen, but log the problem.

Fedora Core 6 on MS Virtual Server 2005 RC2

Got Fedora Core 6 (i386) working under Microsoft Virtual Server 2005 RC2. Hints follow.

Just wanting to report success using Fedora Core 6 on Microsoft Virtual Server 2005 RC2.

Naturally, there were some hiccups.

First, when one installs MS Virtual Server 2005 RC2, it is very important to install the Admin web pages. Seems that there is no admin application executable, so you’re basically stuck using a web interface.

This creates the obvious problem that a new Dell box doesn’t come with IIS installed. You’re gonna need to mess with the Windows components to do that.

Second, I couldn’t for the life of me get the Virtual Machine to boot from the DVD drive. Yes, I know you use the admin screen to attach it to the physical drive. Yes, I know the virtual machine has to be off in order for changes to take place. Yes, I know media must be in the drive when starting the virtual machine. It simply did not work.

The solution was to beam the FC-6-i386-DVD.iso over to the host operating and attach the virtual CD/DVD drive to that. This solution does work, and quick expeditiously I might add.

Third, Fedora Core’s installation in graphical mode seriously confused the remote viewer application. It did not handle the graphic mode well at all. So instead, I installed via text mode, and this worked beautifully.

Torrents: FC-6-i386-DVD.iso (torrent portal), FC-6-i386-DVD.iso (torrent reactor), FC-6-i386-DVD.iso (mini nova)

Walt’s Desktop: SYSINFO Like Detection

Walt gives Belarc Advices a thumbs up, as a sysinfo tool for his desktop of recommended software.

Back in the good old DOS days there were several software packages that would provide system information such as what hardware was in the machine, what drivers were running, what TSRs had crept into memory, and what applications you had. My all time favorite was SYSINFO, it was the magical hardware probing that I was after. I’d create a special boot disk and instantly be able to tell what was in a friend’s machine.

Problem is, as Windows got bigger and “better” that kind of direct hardware probing became forbidden by the operating system. I’ve been searching for its equal ever since for the Windows world.

Sure, there’s a handful of tools that come with Windows or Office, but all seem to be lacking, and nothing that just generates a single pretty report. systeminfo and msinfo just don’t cut it for me.

A friend turn me on to Belarc Advisor. This thing is amazing. It will do everything from tell me what kind of memory is in which slot on my motherboard to exposing the software keys to the software I have installed. It produces a sleek report viewable by any HTML browser, very nice.

Walt gives Belarc Advisor a thumbs up!

If you happen to know of any other favorites that do the same kind of thing, I’d love to hear from you.

Java EE in a nutshell for total newbies

Someone just jumping into Java may look at the SDK and the EE and wonder why they aren’t included together or why one version seems always behind the times. This article explains to the Java newbie what J2EE (or now Java EE 5) really is in terms a procedural programmer might understand.

One of the biggest hurdles in getting a procedural developer to even try an object-oriented language is to break a bunch of misconceptions. Perhaps the largest one has to do with language syntax. When a procedural person sees something that looks like a structure with code in it, they instantly think that each structure “carries” its own copy of the code around with it — which is clearly inefficient.

Once you explain that, no, there is only one place the code exists, and that the notation is defining scope, not structure, it becomes obvious how the compiler is accomplishing its magic. In fact, it’s quite trivial, impressive, and elegant.

In some ways, I wish someone had explained to me long ago what was up with selecting a Java environment, because Java loves to rename itself, bust its environments into pieces, invent new terminology for old things, and in general make a whole confusing mess to anyone who didn’t come along for the ride since day one. I’m about to explain to non-Java newbies just what J2EE / Java EE is in a simple matter you could explain to your grandmother. Assuming, of course, your grandmother wrote code.

If you hop over to the java site and poke around, you’ll see on the right hand side three things: the JRE, the SDK, and something called EE.

Let’s recap. JRE is the runtime environment, it’s for when you want to run programs, but have no need to compile them. The JDK (Java Development Kit) got renamed to the SDK (Software Development Kit) when more than just the Java compiler got packaged with it. Java, Java 2, and Java 5 are all the result of marketing names, having some relationship to the actual version number scheme: v1.2 is Java 2, but so is v1.3, v1.4. Java 5 is v1.5. Thanks Sun, this isn’t helping.

But what is EE, the Enterprise Edition? What does Enterprise mean? What is business logic? Why is it different than the SDK? Why isn’t it included with the JDK? What’s up with a client piece and a server piece? Why is it always seemingly a version or so behind the SDK? And, why, oh why, can’t Sun just give me one huge thing to download with everything in it?!?

To date, I’ve seen no one give clear cut answers to the above. And I’m about to. And the reason you don’t have those answers is because if you’re asking those questions, then you’ve got some serious misconceptions about what’s going on. Don’t blame yourself though, often people who want to be part of something exclusive make things seem more complicated than it really is and then disguise that fact with strange terminology. All is about to be clear.

The primary misconception is that the SDK is what you use to develop client applications, and that the EE version is what you use to develop server applications. Now anyone who’s done any socket programming will totally roll their eyes at the fact that the library has been split depending on which side initiated the connection, and they’ll do it in much the same way as someone who looks at a object oriented class does when they erroneously think code is being put in a structure.

What’s happened is that the terms client and server have been changed out from under you without warning. And, happily, the SDK is capable of doing both the client and server side of a socket connection. That’s not what EE is about.

J2EE (the Java 2 version) and Java EE 5 (the Java 5 version) are nothing more than specifications. That’s right, concepts on paper.

Let’s go back for just a second and look at some of those other fancy words.
Enterprise = a service or application should be scalable and distributable
Business Logic = code …that’s right… just code, like you’ve always written

Now you’re smart, you could write a framework for your application that would use threads, thread pools, data marshaling between systems, load balancers, and so forth. But that wouldn’t be getting the real work done, that’s just the infrastructure. Let’s face it, if you use C++ you use the Standard Template Libraries; if you do encryption, you don’t roll your own data structures and algorithms. Why should you? Domain experts with tons of field experience have carefully crafted highly optimized and well tested code for you. There’s no reason to re-invent the wheel, especially when there are people dedicated to building, maintaining, and improving the best wheels out there.

An application server is a running environment that dynamically loads classes, and provides scalable and distributable services laid out in the specification.

Java Enterprise Edition is the set of library classes that converse with an implementation of an application server that is compliant. In short, it’s programming by contract, just like everything else. Because there are several specification versions, there are several EE environments. Because EE is a large set of additional classes, you don’t need them if you are not running an application server that you need to talk to. Grabbing the Java EE will get you the SDK – all of it.

Now, here’s the catch. Because more people use the SDK than the EE, you’ll see patches and minor version updates for the SDK before you see that SDK pre-bundled with the Enterprise Edition. Nothing stops you from grabbing EE and snagging the latest patched SDK.

So, in order to run the Java enterprise environment, you need four things: 1) The compiler and tools of the SDK. 2) An application server like JBoss or the Sun Java System Application Server. 3) The Java EE application interfaces that are conforming to the application server you intend on running. 4) A clear understanding the services your application provides in addition to how to configure, start, stop, and deploy Java code that you write to it.

NetBeans, Suns interactive development environment (IDE), has a bundle that includes the IDE, the SDK, the EE, an application server (JBoss), and will install it and configure it for you.

So, to summarize: Java EE are additional classes that let you converse with an application server, which is a separate program that is compliant to a Java EE specification. The majority of people don’t use enterprise services for regular programs, and those that do need to have a class library that matches the application server they’ve elected to use — as such, it is not bloat or complexity that keeps it out of the JDK, but that putting one in can be problematic if there is a mismatch with the ‘server’ end of things.

Curious now as to what Java EE provides?

Well, it handles .JSP pages (like PHP allows scripting in web pages, instead the language used is Java). It handles Servlets (programs that respond to POST and GET requests), which is actually what a .JSP turns into if you think about it. It handles JavaBeans (classes with agreed upon properties, called interfaces, that let them be manipulated by a graphical IDE); it handles Enterprise JavaBeans that allow your code’s classes to run in a distributed manner — and, yes, it was horrible to name it so similar. It has naming services to find your code, no matter which machine it’s on. It can handle concurrency, scalability, transactions, logging, message queues, security policies, database connectivity and pooling, persistence and mapping of objects to relational databases, and so forth. …everything you could write yourself, but benefit from not having to.

Apple Mail Won’t Quit

Apple’s Mail program… does it just hang on you for no reason when you quit? Or, could it be it really does have a good reason for being busy and you don’t know how to lift the hood… Learn how to see what’s going on when mail is busy and how to tell it to stop quickly with a simple, gentle request on your part, never needing to Force Quit again.

I had the opportunity to use Apple Mail from a hotel room that had a rather slow ethernet connection. When I went to quit Apple Mail, the application appeared to hang.

Under normal situations, I’d blame the server or the connection, perform a Force Quit by either right clicking the Mail icon or perhaps using Command-Option-Escape and blasting it that way, resorting to the good old Unix kill command if that didn’t work, followed by a reboot.

Turns out this isn’t necessary at all. Apple was smart enough to include a way to watch what mail is doing.

When Mail is up, select Window / Activity Viewer (also Command-Zero wll open it). I now run with this window open all the time.

When Mail shuts down, it tries to do so cleanly. This means that it sychronizes what’s on your system with what’s on the server. And, if you’re like me, you got a lot of folders sitting in your IMAP account. Sometimes a sychronization takes a while.

Seeing mail show you that it’s really trying to do something before it completes your Quit request invokes a good feeling that things are really busy for good reason, and not just hung.

Additionally, Apple has put big red stop buttons next to each of those tasks. You are more than welcome to click on them, telling the Mac to skip that step and do it later. This has helped me shutdown mail really quickly without screwing up my mailbox.

Violent shutdowns of mail can result in your local cache getting out of sync, giving the appearance that some messages don’t go with the right header.

If you are ever in doubt as to the integrity of your mailbox, Apple has thought of tweak for this too: Mailbox / Rebuild. Naturally, you’ll want the Activity Window open so you can watch as it downloads your mail again.

Mac Address Book: Fixing My Picture

New phone, new software, and new problems with Mac Addressbook. Easily fixed, though I didn’t find anywhere online that told how. Here’s the steps.

The other day my original T-Mobile color Sidekick gave up the ghost from many years of beloved use. I depressed the wheel button, and it sank into the device, as if the little axle it spun on had broken. No amount of twiddling was able to fix it, and I had to admit to myself that it was finally time for a new phone. As it was, the backlight had pretty much all but given out anyhow.

I picked up the T-Mobile Sidekick 3 and transfering my SIMM and account could not have been easier. The process took about 5 minutes from phone selection to leaving the store.

I was not happy with the fact that I lost my applications such as the SSH Terminal. I guess I couldn’t complain, given that I got in when those applications were free. Now that I’m working for a company that thinks having Internet access is a good thing, I really haven’t had need for it anyhow. Sigh; I’ll still miss it.

I was surprised to learn that my phone also served as a camera. The old Sidekick had this little camera device you plugged into the side. This one was built in. And it was better. And the phone has a memory stick, so you can store your photos there. Neat. The phone also has the ability to hook up to the computer, act as a hard drive, and store MP3s there as well. Nifty!

This more than made up for the fact the keyboard layout had changed and it felt like typing inside of a deeply recessed box. I’ll get used to it.

But my real excitement perked up when I saw the phone was BlueTooth enabled, and I was even more happier when the Mac was able to pair up with the phone with virtually no effort and certainly no problems. My hopes, however, were dashed as I saw the phone offered no services my computer could take care of.

Turns out the solution was The Missing Sync, which takes the Mac OS X calendar, address books, and to do lists and beams them to the T-Mobile server, making my phone match my address book …and my address book match my phone.

The first problem I had there was that the Sync failed with a really obscure and useless error message. A little research showed that T-Mobil’s server gets really unhappy if the First and Last names are both blank. At least one has to be filled in, and this is not necessarily the case with any Company records. So I munged my Address Book on my Mac into conformance.

The sync worked. But it also brought in “duplicate” records from my phone, which was expected.

So, I spent a while combining records so that I had the superset of all information, trying to get everything with the most recent information. A second sync worked great.

But that’s when I noticed that my icon for my record in the address book had changed. It defaulted to one of the standard OS X icons, instead of my photo.

I tried to change it back by taking my picture with the built-in iSight. Nope, though it did update my login account picture. Then I tried dragging an image file to it. Again, it changed my login image under Preferences, but it did not change my address book picture. I tried changing my image from the login preferences screen, and that didn’t work either.

Eventually I stumbled on the solution, after finding relatively little on Apple’s support site.

Click the picture, press Delete, and it will disappear. Then use any of the methods above to put a new picture in that spot. Worked great.