あらゆるMailプラグインをとりあえず最新OSに対応させる

毎度のことだけど、またしてもGrowMailとLetterboxを有効にするのに手間取ってしまった...。

  • ここで言うMailプラグインとは、~/Library/Mail/Bundles 直下にインストールされる.mailbundleのこと。
  • GrowlMailとか、Letterbox、WideMail等がそれらに該当する。

最新バージョンを確認する

  • 既に最新のOSXに対応したバージョンが配布されている可能性もある。
  • 対応バージョンが出ていれば、それをインストールするのがベストである。
  • 以下の手順は、対応していない状況で、暫定的に使えるようにする方法である。

バックアップ

  • マシン環境全体をバックアップする。
  • そもそも、最新のOSX未対応のMailプラグインを強引に使ってしまう訳なので、人柱となる恐れもある。
  • 最悪の状況を考えて、Time Machine等*1で過去のマシン環境に確実に戻せるようにしておく必要あり。*2

~/Library/Mail/Bundles(使用停止中の)/XXXX.mailbundle を ~/Library/Mail/Bundles/XXXX.mailbundle へ移動

  • OSXのバージョンアップによって ~/Library/Mail/Bundles(使用停止中の) に移動されてしまった.mailbundleファイルを ~/Library/Mail/Bundles へ戻す。
  • 場合によっては、~/Library/Mail/Bundles(使用停止中の 1)のように数字が付加されている可能性もある。
  • ユーザー個別の設定ではなく、全ユーザー共通の設定としている場合は、ルート直下の /Library/Mail/Bundles... を見る。

おまじないのコマンド二つ

defaults write ~/Library/Mail/Bundles/XXXX.mailbundle/Contents/Info SupportedPluginCompatibilityUUIDs -array-add `defaults read /Applications/Mail.app/Contents/Info PluginCompatibilityUUID`

defaults write ~/Library/Mail/Bundles/XXXX.mailbundle/Contents/Info SupportedPluginCompatibilityUUIDs -array-add `defaults read /System/Library/Frameworks/Message.framework/Versions/B/Resources/Info PluginCompatibilityUUID`
  • XXXXの部分を対応させたいmailbundleに応じて変更する。
    • 例:GrowlMail、Letterbox など。
  • コマンドを実行するのは、1回だけにしておくこと。(状況を理解せずに、むやみに2回、3回と実行するのは好ましくない)

確認

  • 以下のコマンド(太字の部分)3つを実行する。
$ defaults read ~/Library/Mail/Bundles/Letterbox.mailbundle/Contents/Info SupportedPluginCompatibilityUUIDs
(
    "225E0A48-2CDB-44A6-8D99-A9BB8AF6BA04",
    "B3F3FC72-315D-4323-BE85-7AB76090224D",
    "2610F061-32C6-4C6B-B90A-7A3102F9B9C8",
    "99BB3782-6C16-4C6F-B910-25ED1C1CB38B",
    "2F0CF6F9-35BA-4812-9CB2-155C0FDB9B0F",
    "0CB5F2A0-A173-4809-86E3-9317261F1745",
    "B842F7D0-4D81-4DDF-A672-129CA5B32D57",
    "E71BD599-351A-42C5-9B63-EA5C47F7CE8E",
    "BDD81F4D-6881-4A8D-94A7-E67410089EEB",
    "857A142A-AB81-4D99-BECC-D1B55A86D94E"
)
$ defaults read /Applications/Mail.app/Contents/Info PluginCompatibilityUUID
BDD81F4D-6881-4A8D-94A7-E67410089EEB
$ defaults read /System/Library/Frameworks/Message.framework/Versions/B/Resources/Info PluginCompatibilityUUID
857A142A-AB81-4D99-BECC-D1B55A86D94E
  • 最初のコマンドの実行結果の末尾2行が、2番目と3番目のコマンドの実行結果になっていればOK。

Mail.appの再起動

  • Mail.appを再起動すれば、使用停止中にされてしまったXXXX.mailbundleは有効になるはず。
  • OSXのバージョンアップによる影響を受けていなければ、以前と同じように利用できるはず。
  • 運悪く何らかの問題を感じたら、使用を中止して、以前の環境に戻しておいた方が良さそう。
  • ちなみに、自分はこの暫定対応をOSX 10.6になってから続けているが、特に問題が起こったことはまだない。

AppleScriptにまとめる

  • せっかく書いても、コマンドは忘れてしまう。
  • 今回も、トライ&エラーで何度か繰り返した...。
  • 0.0.1バージョンアップの度に検索して、どうだったかなと読み返して、何度か失敗して、ようやく暫定利用可能になる。
  • そんなことをOSX 10.6になってから5回繰り返している。
  • そんな状況を脱するために、AppleScriptに手順をまとめて見た。
  • enable_mailbundle_アシスタント.scptは、mailbundle有効化前の事前チェック。
    • 主な仕事は~/Library/Mail/bundleをFinderで開くこと。
  • enable_mailbundle.scptは、選択したmailbundleを有効にする処理をする。
    • Bundle(使用停止中)フォルダから、Bundleフォルダへファイルを移動して、
    • 必要なuuidを検索して、選択したmailbundleに書き込む。
enable_mailbundle_アシスタント.scpt


tell application "Finder"
"最新バージョンを確認しましたか?"
display dialog result buttons {"キャンセル", "確認済み"} default button "キャンセル"
"作業前にマシン環境をバックアップしていますか?"
display dialog result buttons {"キャンセル", "バックアップ済み"} default button "キャンセル"
activate
open (path to home folder as text) & "Library:Mail:Bundles(使用停止中の)"
set Finder window 1's current view to column view
"使用可能にしたい.mailbundleを選択して、スクリプトメニューからenable_mailbundleを実行してください。"
display dialog result
end tell

enable_mailbundle.scpt


tell application "Finder"
repeat with an_item in (selection as list) set f to an_item as alias
try
set lib_mail_bundle_disable_path to f's folder as alias
set lib_mail_path to lib_mail_bundle_disable_path's folder as alias
set lib_mail_bundle_path to (lib_mail_path as text) & "Bundles" as alias
if (lib_mail_bundle_path as text) does not end with "Library:Mail:Bundles:" then error
on error
beep
"エラー
選択されたファイルは mailbundle ではありません。
処理を中止しました"
display dialog result buttons {"OK"} giving up after 10
return
end try
try
move f to lib_mail_bundle_path without replacing
on error
beep
"エラー
すでに有効な " & f's name & " が存在しているようです。"
display dialog result buttons {"OK"} giving up after 10
return
end try
try
my add_on_supported_uuids(f's POSIX path) f's name & " を有効にしました。"
display dialog result buttons {"OK"} giving up after 5
on error
beep
"エラー
" & f's name & " は有効に出来ませんでした。"
display dialog result buttons {"OK"} giving up after 10
my undo() end try
end repeat
end tell

--mailbundle_pathは、"/Users/USERNAME/Library/Mail/Bundles/GrowlMail.mailbundle"のようなUNIX形式のパス
on add_on_supported_uuids(mailbundle_path) set mail_uuid to do shell script "defaults read /Applications/Mail.app/Contents/Info PluginCompatibilityUUID"
set framework_uuid to do shell script "defaults read /System/Library/Frameworks/Message.framework/Versions/B/Resources/Info PluginCompatibilityUUID"
set supported_uuids to do shell script "defaults read '" & mailbundle_path & "Contents/Info' SupportedPluginCompatibilityUUIDs"
if mail_uuid is not in supported_uuids then
do shell script "defaults write '" & mailbundle_path & "Contents/Info' SupportedPluginCompatibilityUUIDs -array-add " & mail_uuid
end if
if framework_uuid is not in supported_uuids then
do shell script "defaults write '" & mailbundle_path & "Contents/Info' SupportedPluginCompatibilityUUIDs -array-add " & framework_uuid
end if
end add_on_supported_uuids

on undo() tell application "System Events"
tell process "Finder"
keystroke "z" using {command down} --操作の取り消し
end tell
end tell
end undo


果たしてうまくいくのか?!OSX 10.6.6のバージョンアップが楽しみになってきた。

*1:ディスクユーティリティやCarbon Copy Clonerでハードディスクを丸ごとコピーしてもOK。時間は相当かかるけど。

*2:何らかのバージョンアップする時は、常に同じ心構えが必要である。このような状況でTime Machineは最高のツールになる。