Bookmark this site!

2008-04-30

Starting over: MacPorts

As a long-term Fink user, I've found it hard to summon up the energy to move to Macports (previously known as Darwin Ports), until now. A dead disk provided the necessary impetus to overcome this energy barrier.

MacPorts—so I am told by friends I trust—is closer to the Mac zeitgeist, and has more packages available in fresher versions.

My first experience was not good. I tried the standard install from .dmg with two fresh, fully updated installs of Leopard + x11 + XCode Tools—one on my ageing MBP; one on a sparking new MacBook Air. Neither succeeded in creating the code>.profile that is supposed to adjust the PATH environment variable.

You should start with a standard install as it does almost everything—and may even do it all, for some it succeeds.

In the environment of a shell accessing packages installed by MacPorts, PATH should include /opt/local/bin:/opt/local/sbin and MANPATH should include /opt/local/share/man. The standard install is meant to create a .profile to achieve this. It didn't.

Googling macports leopard profile led to various suggestions (as usual, others have encountered this problem before me). One of these works—others don't.

Do not add the new paths to /etc/paths and /etc/manpaths.

Do not add new files named macports or MacPorts, containing the new paths, to /etc/paths.d/ and /etc/manpaths.d/.

Do create a file ~/.profile containing the following code:

export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH

Then you can type sudo port -d update in a fresh terminal window, to update your MacPorts installation, and sudo port install emacs-app, for example, to install a Cocoa version of emacs.

You'll find the Emacs installed as a regular application in /Applications/MacPorts/.

Note: If you already have a .bash_profile or .bash_login, you can and should append the commands above to that file, and optionally rename rename that file as .profile, instead of creating a new .profile.

Explanation: (for the full story try man bash)

When bash is invoked as an interactive login shell, or as a non-inter-active shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.

2008-04-28

Fixing mail.app’s IMAP date problem

Using imapsync to migrate mail from one IMAP server to another, I hit a problem. Google led me to the following description of the same issue:

The IMAP Date problem is the result of how mail.app figures out the Date Received time for an email. Rather than using the Date: header in the email it uses the time the file was written to the file system. This becomes a problem when files are copied to a new location on the server and the creation time of the file is changed.

Not mail.app's problem!

The solution is to use imapsync with the flag --syncinternaldates

I am now using

/usr/bin/imapsync --syncinternaldates \
     --host1 mail.inf.ed.ac.uk --user1 mfourman --ssl1 \
     --host2 imap.staffmail.ed.ac.uk --user2 mfourman -ssl2 \
     --noauthmd5
to finish the transfer of about 4GB of mail history.

To start, try it out on a small folder --folder Test

First test with --dry :

/usr/bin/imapsync --syncinternaldates  --folder Test \
     --host1 mail.inf.ed.ac.uk --user1 mfourman --ssl1 \
     --host2 imap.staffmail.ed.ac.uk --user2 mfourman -ssl2 \
     --noauthmd5 --delete --dry
If everything looks OK then run
/usr/bin/imapsync --syncinternaldates  --folder Test \
     --host1 mail.inf.ed.ac.uk --user1 mfourman --ssl1 \
     --host2 imap.staffmail.ed.ac.uk --user2 mfourman -ssl2 \
     --noauthmd5 --delete
Expunge from the source by hand (in Mail.app Mailbox > Erase Deleted Messages).

Using the --expunge flag upsets other users of the IMAP server:

Currently it is processing folder which is 100MB in size, it is deleting (and then expunging) one message at a time. The way that is implemented on the server, is that the message is deleted, and then the whole file is written out again with that one message removed. This is leading to a lot of disk IO.

That's the short story. The actual story was more involved and also included using my gmail IMAP account as a temporary buffer to recover from some false starts. (Free 6.5GB quota - thank you Google!)

2008-04-26

Opaque Leopard Menu Bar

Many find the translucent menu bar in Leopard disconcerting. There are several tips posted elsewhere suggesting various hacks involving obscure environment variables to turn off this feature.

Apple did it for you! (since 10.5.2)

Go to System Preferences > Desktop and Screen Saver. Uncheck the Translucent Menu Bar checkbox. You're done!

emacs: Fatal malloc_jumpstart() error

Emacs fails with the error Fatal malloc_jumpstart() error

Black Magic

In a Terminal window type

$ sudo mv /usr/bin/emacs-i386 /usr/bin/emacs-i386.backup
$ sudo /usr/libexec/dumpemacs -d
$ emacs --version
GNU Emacs 22.1.1
...
(Here, $ is the shell prompt.)

Once youve checked all is OK you can remove the backup

$ sudo rm /usr/bin/emacs-i386.backup

2008-04-13

Time Capsule

Setup

Time Capsule is an airport extreme base station (802.11 a, b, g, n) with built-in hard drive for backup.

You set up the base station as usual, using AirPort Utility.

You can use your old base station to create a WDS network and extend your wifi coverage to attic or garden – or share with a neighbor. In any case, APPL say, you should make the Time Capsule your main base station – the one directly connected to your ISP.

If you just have 802.11n-capable access points you can let your network autoconfigure. Choose a common Network Name, Wireless Security and Password. Under Airport > Wireless set the main base station to Create a wireless network; set the other base stations to Extend a wireless network.

A domestic ISP typically gives you internet access via a single IP address. Depending on your ADSL or cable hardware you have various options for setting up your system to distribute local IP addresses to clients on your local network.

My ADSL modem is a speedtouch router. It provides a DHPC server with optional MAC authentication. WDS setup is simple: each base station is configured to get its own IP address as a DHCP client, and to act as a bridge passing wifi client traffic to and from the ADSL modem.

If your ADSL or cable modem isn't set up as a DHCP server, you can get the Time Capsule (or any Airport base station) to do this. Set the main base station to "Share a public IP Address" (under Internet).

If your modem provides a range of addresses that clients can select manually, you can set the main base station to distribute these. Select "Distribute a range of IP addresses."

Backup

Time Machine sometimes gets confused and can't mount the backup disk. Apple say the volume name should be shorter than 27 characters. Elsewhere they say it should be purely alphanumeric [0-9,a-z,A-Z]*