2012/10/19

OS X 10.8.2: Java for OS X 2012-006

ソフトウエアアップデート
Java for OS X 2012-006
http://support.apple.com/kb/DL1572
About the security content of Java for OS X 2012-006 and Java for Mac OS X 10.6 Update 11
http://support.apple.com/kb/HT5549

ソフトウエアアップデートに出現しなかったので手動でダウンロード。

$ openssl sha1 JavaForOSX.dmg
SHA1(JavaForOSX.dmg)= eff777cdc39b4e3336b3477f60e8ad769ded8532


# 出現しなかった原因はおそらく下記を実行していた為。

$ sudo chmod 700 /System/Library/Java/Support/CoreDeploy.bundle/Contents/JavaAppletPlugin.plugin
$ sudo rm /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin


このアップデートで変更された Version 確認。

% grep -aR 1.6.0_37 /System/Library/Frameworks/JavaVM.framework/
/System/Library/Frameworks/JavaVM.framework//Commands/appletviewer:1.6.0_37-b06-434Unable to locate JRE meeting specification "%s"Error: main-class: attribute exceeds system limits
/System/Library/Frameworks/JavaVM.framework//Commands/appletviewer:1.6.0_37-b06-434Unable to locate JRE meeting specification "%s"Error: main-class: a
... 略 ...


このアップデートによって削除されたもの。

/System/Library/LaunchAgents/com.apple.mrt.uiagent.plist
/System/Library/LaunchDaemons/com.apple.mrt.plist
/System/Library/CoreServices/MRTAgent.app

/Applications/Utilities/Java\ Preferences.app/
/usr/libexec/MRT


参照:A look at Apple's Flashback removal tool | MacFixIt - CNET Reviews
http://reviews.cnet.com/8301-13727_7-57413354-263/a-look-at-apples-flashback-removal-tool/

このアップデートで削除されなかった plist File.

% ls /System/Library/LaunchAgents/com.apple.java.InstallOnDemand.plist
% ls /System/Library/LaunchAgents/com.apple.java.updateSharing.plist


このアップデートで unload された agent

% launchctl list | grep mrt
% 


このアップデートで unload されなかった agent

% launchctl list | grep java
-	0	com.apple.java.updatesharing
-	0	com.apple.java.installondemandagent
% 


このアップデート後に実行したこと。
# 一般ユーザ

launchctl unload -w /System/Library/LaunchAgents/com.apple.java.InstallOnDemand.plist
launchctl unload -w /System/Library/LaunchAgents/com.apple.java.updateSharing.plist


# 管理ユーザ

$ sudo chmod 700 /System/Library/Java/Support/CoreDeploy.bundle/Contents/JavaAppletPlugin.plugin
$ sudo mv /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin   ~/backup-java-pluguins/

2012/10/14

OS X 10.8.2: UserEventAgent <Error>:Could not look up channel-token:

またも不思議なエラーが...

Oct 14 08:59:59 osx.local UserEventAgent[133] <Error>: Could not get event name for stream/token: com.apple.time/24: 0x3: No such process
Oct 14 08:59:59 osx.local UserEventAgent[133] <Error>: Could not get event name for stream/token: com.apple.time/24: 0x3: No such process
--- last message repeated 1 time ---


なんなのかと探してみると
system log errors: Apple Support Communities
https://discussions.apple.com/thread/4376369?start=0&tstart=0

機種が違うのに同時刻に発生しているエラー

08:59:59

共通点は OS X 10.8.2 であること。
Mountan Lion にとってなにか意味のある時刻なのでしょうか魔の時間なのでしょうか。
# ただしうちでは 360 回も出現してない。
# スリープとこのエラーが関係あるような気がしなくもない。

[追記]
# 2012-10-15

$ syslog -k message seq "could" > ~/error.txt

# 08:59:59 | Sleep していない状態で 2つのエラーをあわせ 400行ほど繰り返した。

Oct 15 08:59:59 ... UserEventAgent ...  <Error>: Could not look up channel/token: com.apple.time ... No such process
Oct 15 08:59:59 ... UserEventAgent ...  <Error>: Could not get event name for stream/token: com.apple.time ... No such process


# 考えてみたこと。
# Spotlight metadata.mds、
# /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
# をオフにしている。

$ sudo launchctl list  | grep meta
-	0	com.apple.metadata.mds.spindump
-	0	com.apple.metadata.mds.scan
$ 

# なぜオフにしたかというと OS をインストールした後

$ mdutil -s /System/

# の返事が unknown 知らないだったから。*1

# しかし今改めて確認してみたら正しい返事がかえってきた。

$ mdutil -s /System/
Spotlight server is disabled.


Spotlight が動いている時はどういう状態かわからない知らないといわれ
止めると止まっているという。

[追記]
*1
$ sudo rm -rf /Library/Caches/com.apple.Spotlight
$ sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
$ sudo reboot
スポットライトが索引作成を終了した後に

$ mdutil -s /
/:
  Indexing enabled.
$ mdutil -s /System/
/System:
  Error: unknown indexing state.

# この時 System Preferences.app-> Spotlight のPrivacy に /System を加えていた
# 状態だから本来ならば indexing できない旨の返事があるべき。
#
# なわけで
# 変 metadata.mds daemon を unload にしたことによって
# 08:59:59 エラーが引き起こされたのか、そもそも metadata.mds と関係あるのかは不明。

# Spotlight はローカルネットワークにあるマウント可能なディスクの索引も
# 作るらしい。やりすぎだと思う。

2012/10/13

OS X 10.8.2: open -a

Ruby で書いたものの中から、
MacVim.app を呼び出しファイルを開けと命令し、
それが成功してもしなくても Ruby を終了する。
を実現する為に

begin
ensure
end

の中で

1) /usr/bin/osascript を使う
2) OS X の open コマンドを使う

のどちらかを使ってきたが
OS X 10.8 になっていよいよ 1) と 2) の時間的ひらきが決定的になったようなので、
# 1) は驚くほど遅い。10秒程かかった。OS X 10.6 でもこんなに遅いことはなかった。
OS X 10.8 では open コマンドを使うことに...。
# github.com/midore/xdiary.git

念のため

% man open

すると...

-e  Causes the file to be opened with /Applications/TextEdit

TextEdit.app は優遇されてる。

-t  Causes the file to be opened with the default text editor, as determined via LaunchServices


open コマンドが使うデフォルトの Editor は TextEdit.appだが、
デフォルトエディターを変更すれば open -t で好きなエディターが使えるようになるの
かと、試しに

export EDITOR='/usr/bin/vim'

を .bashrc に書いて

% source ~/.bashrc
% open -t like-vim.txt

してみたら...

わたしの予想に反し TextEdit.app が素早くファイルを開いた。

OS X 10.8.2: IntlFormats.prefPane Japanese.lproj Localizable.strings

http://midorex.blogspot.com/2012/10/os-x-1082-to-find-range-of-h-or-h-in.html
の続き。

% pwd
/System/Library/PreferencePanes/Localization.prefPane/Contents/Resources/IntlFormats.prefPane/Contents/Resources
% cp -a Japanese.lproj ~/jp
% cp -a English.lproj  ~/en
% cd
% plutil -convert xml1 ~/jp/Localizable.strings -o ~/jp-local.xml
% plutil -convert xml1 ~/en/Localizable.strings -o ~/en-local.xml


Japanese.lproj/Localizable.strings
関係ないのだろうが... よくみると </string> の前に Space が混在している行がある。
6, 8, 22行目

% cat -n jp-local.xml 
     1  <?xml version="1.0" encoding="UTF-8"?>
     2  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
     3  <plist version="1.0">
     4  <dict>
     5    <key>CustomLocaleFormat</key>
     6    <string>%@(%@)</string>
     7    <key>CustomLocaleVariantFormat</key>
     8    <string>%@(%@、%@)</string>
     9    <key>Day</key>
    10    <string>日</string>
    11    <key>Month</key>
    12    <string>月</string>
    13    <key>None</key>
    14    <string>なし</string>
    15    <key>Sample Day</key>
    16    <string>5</string>
    17    <key>Sample Month</key>
    18    <string>1</string>
    19    <key>Space</key>
    20    <string>スペース</string>
    21    <key>VariantFormat</key>
    22    <string>%@(%@)</string>
    23    <key>Year</key>
    24    <string>年</string>
    25  </dict>
    26  </plist>
% 


English.lproj/Localizable.strings
こちらの 6,8,22行目には </string> 前に Space なし。

% cat -n en-local.xml 
     1  <?xml version="1.0" encoding="UTF-8"?>
     2  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
     3  <plist version="1.0">
     4  <dict>
     5    <key>CustomLocaleFormat</key>
     6    <string>%@ (%@)</string>
     7    <key>CustomLocaleVariantFormat</key>
     8    <string>%@ (%@, %@)</string>
     9    <key>Day</key>
    10    <string>Day</string>
    11    <key>Month</key>
    12    <string>Month</string>
    13    <key>None</key>
    14    <string>None</string>
    15    <key>Sample Day</key>
    16    <string>5</string>
    17    <key>Sample Month</key>
    18    <string>1</string>
    19    <key>Space</key>
    20    <string>Space</string>
    21    <key>VariantFormat</key>
    22    <string>%@ (%@)</string>
    23    <key>Year</key>
    24    <string>Year</string>
    25  </dict>
    26  </plist>
% 


# ~/jp-local.xmlのオリジナル
# File:
# /System/Library/PreferencePanes/Localization.prefPane/Contents/Resources/IntlFormats.prefPane/Contents/Resources/Japanese.lproj/Localizable.strings

OS X 10.8.2: System Preferences - Language & Text - Region

http://midorex.blogspot.com/2012/10/os-x-1082-to-find-range-of-h-or-h-in.html
の続き

% pwd
/System/Library/PreferencePanes/Localization.prefPane/Contents/Resources/IntlFormats.prefPane/Contents/Resources
% cp -a Japanese.lproj ~/jp
% cp -a English.lproj  ~/en
% cd
% plutil -convert xml1 ~/jp/IntlFormats.nib  -o ~/jp-form.xml
% plutil -convert xml1 ~/en/IntlFormats.nib  -o ~/en-form.xml
% diff jp-form.xml en-form.xml

# ほぼ全行違っていてくらくらしたけど’時刻’がちらり。

% grep -R '時刻' jp-form.xml
jp-form.xml:    <string>時刻</string>
jp-form.xml:    <string>時刻を構成する項目</string>
jp-form.xml:    <string>独自の書式を作るには、表記したい文字を入力するか、時刻を構成する項目をドラッグしてください。</string>
jp-form.xml:    <string>時刻をカスタマイズします</string>
%


File: /System/Library/PreferencePanes/Localization.prefPane/Contents/Resources/IntlFormats.prefPane/Contents/Resources/Japanese.lproj/IntlFormats.nib
は、
システム環境設定-言語とテキスト-「地域」
(System Preferences - Language & Text - Region)

時刻(Time) 表示と関連深そうだけど手がかりなし。

OS X 10.8.2: Terminal.app Allow a different one for each document

システム環境設定
(System Preferences)
|__
言語とテキスト
(Language&Text)
|
入力ソース
(Input Sources)
|
「書類ごとに異なるものを使用」
(Allow a different one for each document)

を選択していても
Terminal.app は直前に使用したアプリケーションの入力ソースを使ってしまう。
非常に不便!


[暫定的解決方法]
Terminal.app
Menu
|_
「キーボード入力のセキュリティを保護」(Secure Keyboard Entry)
をOFFにしてみたら...

Terminal.app でも
「書類ごとに異なる入力ソース」を使用してくれるようになった。
つまり、ずっと英数字を維持してくれるようになった!

本当はTerminal.app の「キーボード入力のセキュリティを保護」をOFF にしたくない。

OS X 10.8.2: MenuExtras Clock.menu & Battery.menu

昨日 http://midorex.blogspot.com/2012/10/os-x-1082-to-find-range-of-h-or-h-in.html
からの続き。
$ sudo find で clock とか menu を探してみた。

# Menu バーClock.menu のリソースの中にあった日本語設定
% pwd
/System/Library/CoreServices/Menu Extras/Clock.menu/Contents/Resources/Japanese.lproj
% cp Localizable.strings ~/clocljp.strings
# ホームにコピーしたバイナリファイルが読めるように変換
% cd
% plutil -convert xml1 clocljp.strings -o ~/abc.strings
# 設定ファイルの中身
% cat abc.strings
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>OpenDateTimePref</key>
  <string>“日付と時刻”環境設定を開く...</string>
  <key>ParentalControlsBedtime</key>
  <string>就寝時間:</string>
  <key>ParentalControlsTimeRemaining</key>
  <string>残り時間:</string>
  <key>ParentalControlsTitle</key>
  <string>ペアレンタルコントロール</string>
  <key>ViewAsAnalog</key>
  <string>アナログで表示</string>
  <key>ViewAsDigital</key>
  <string>デジタルで表示</string>
</dict>
</plist>


# 残念なことにてがかりなし。下記も同様。

% pwd
/System/Library/CoreServices/Menu Extras/Battery.menu/Contents/Resources/Japanese.lproj
% cp Localizable.strings  ~/battery.strings
% cd
% plutil -convert xml1 battery.strings -o ~/bbb.strings
% cat ~/bbb.strings
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>AX_PERCENT_FULL</key>
  <string>%@ 充電済み</string>
  <key>BATS_CHARGED</key>
  <string>バッテリーは充電済み</string>
  <key>BATS_NOT_CHARGING</key>
  <string>バッテリーは充電できません</string>
  <key>BAT_CHARGED</key>
  <string>バッテリーは充電済み</string>
  <key>BAT_FINISHING_CHARGE_MENU_BAR</key>
  <string>間もなく充電完了...</string>
  <key>BAT_FINISH_PERC</key>
  <string>間もなく充電完了(%@ 充電済み)</string>
  <key>BAT_FINISH_TIME</key>
  <string>間もなく充電完了(充電完了まで %@)</string>
  <key>BAT_NOT_CHARGING</key>
  <string>バッテリーは充電できません</string>
  <key>BAT_NOT_CHARGING_MENU_BAR</key>
  <string>充電できません</string>
  <key>Battery menu.</key>
  <string>バッテリー:</string>
  <key>Battery:</key>
  <string>バッテリー:</string>
  <key>CALCULATING</key>
  <string>計算中...</string>
  <key>CALCULATING_TIME_REMAINING</key>
  <string>残り時間を計算中...</string>
  <key>CALCULATING_TIME_UNTIL_FULL</key>
  <string>充電完了までの時間を計算中...</string>
  <key>CHARGED</key>
  <string>充電済み</string>
  <key>CONDITION_NORMAL</key>
  <string>状態:正常</string>
  <key>CONDITION_REPLACE_NOW</key>
  <string>状態: 今すぐ交換</string>
  <key>CONDITION_REPLACE_SOON</key>
  <string>状態: 間もなく交換</string>
  <key>DISPLAY_PERCENT</key>
  <string>割合(%)</string>
  <key>DISPLAY_TIME</key>
  <string>時間</string>
  <key>HR</key>
  <string>時間</string>
  <key>ICON_ONLY_STATUS_FORMAT</key>
  <string>%@</string>
  <key>MIN</key>
  <string>分</string>
  <key>NONE</key>
  <string>アイコンのみ</string>
  <key>NO_BATS</key>
  <string>バッテリーがありません</string>
  <key>OPEN_ES</key>
  <string>“省エネルギー”環境設定を開く...</string>
  <key>PERCENT_FORMAT_MENU_ITEM</key>
  <string>%.0f%%</string>
  <key>PERCENT_FULL</key>
  <string>%@ 充電済み</string>
  <key>POWER_SOURCE_ADAPTER</key>
  <string>電源:電源アダプタ</string>
  <key>POWER_SOURCE_BATTERY</key>
  <string>電源:バッテリー</string>
  <key>POWER_SOURCE_UPS</key>
  <string>電源:UPS</string>
  <key>SERVICE_BATTERY</key>
  <string>バッテリーの交換修理</string>
  <key>SHOW</key>
  <string>表示</string>
  <key>SHOW_PERCENTAGE</key>
  <string>割合(%)を表示</string>
  <key>SINGLE_PERCENT_FORMAT</key>
  <string>%@</string>
  <key>TIME_REMAINING</key>
  <string>残り:%@</string>
  <key>TIME_UNTIL_FULL</key>
  <string>充電完了まで:%@</string>
  <key>UNKNOWN_TIME</key>
  <string>不明な時間</string>
  <key>UNKNOWN_TIME_REMAINING</key>
  <string>残り時間不明</string>
  <key>UPS menu.</key>
  <string>UPS メニュー</string>
  <key>UPS:</key>
  <string>UPS:</string>
  <key>UPS_CHARGED</key>
  <string>UPS は充電済み</string>
  <key>UPS_NOT_CHARGING</key>
  <string>UPS は充電できません</string>
  <key>VO_TIME_REMAINING</key>
  <string>あと %d 時間 %d 分 </string>
  <key>VO_TIME_UNTIL_FULL</key>
  <string>充電完了まで %d 時間 %d 分</string>
</dict>
</plist>


[メモ]
plutil コマンド
http://midorex.blogspot.com/2010/06/plutil.html

2012/10/12

OS X 10.8.2: <Warning>-"Impossible to find range of h or H in date format"

# OS X 10.8.2 追加アップデートで改善されるかと期待したが改善されなかった問題。

問題点:
システム環境設定-> 日付と時間や、言語とテキストを開くと

...SystemUIServer[715] <Warning>: Impossible to find range of h or H in date format.

このようなエラーが頻繁に syslog に出現。
システム環境設定-> 省エネルギーをクリックするだけで出現する場合もあった。
省エネルギーをメニューバーに表示する、しないを繰り返すと出現する場合もあった。
時間をおくとシステム環境設定を開いていないのに出現するようになった。

[推測]
Mountain Lion をインストールする際「主に日本語を使う」でインストールしたが、英語でインストールすればこのエラーはなくなるのではないか?
システム環境設定-> 言語とテキスト-> 地域の時間フォーマットに原因があるのではないか?

[実験]
PRAM クリア。マック拡張でフォーマット後
主に英語を使うで OS X 10.8 クリーンインストール。
10.8.2 , 10.8.2 追加アップデートおよび iTunes Update 終了。
セーフティーモードで起動しアクセス権限を修復。
ここまでのステップは、「主に日本語を使う」でインストールした場合と同様にした。

システム環境設定のすべてのパネルをクリックしエラーが出現しないかチェック。

[実験結果]
推測ビンゴ。上記のエラーは出現しなくなった。
環境設定.app -> 日付と時刻や言語とテキストを開いてみたがエラーは出現しなくなった!

[備考]

-- 「主に英語を使用」で 10.8 をインストールした場合 --

システム環境設定-> 言語とテキスト-> 地域
Time 欄に AM PM が表示されている。
日本語でインストールした時は AM PM という表示はカスタマイズボタンの中にしかなかった。

一般ユーザ設定ファイルの書式は日本語でインストールした時と異なり下記のようになっていた。

% defaults read ~/Library/Preferences/com.apple.menuextra.clock.plist
{
DateFormat = "EEE MMM d HH:mm:ss";
FlashDateSeparators = 0;
IsAnalog = 0;
}

--「主に日本語使用」で10.8 をインストールした場合 --

システム環境設定.app -> 言語とテキスト
[地域]の設定が使用する時間表示に関するフォーマットになにか問題があり
省エネルギー設定にまで影響している可能性も考えられる ↓

バッテリー「残り時間」を表示したい: Apple サポートコミュニティ
http://apple-japan-vm.hosted.jivesoftware.com/thread/10114753?start=0&tstart=0

続きはこちら
http://midorex.blogspot.com/2012/10/os-x-1082-intlformatsprefpane.html

OS X 10.8.2: disable-bluetooth

OS X 10.8.2 用

disable-bluetooth — Gist
https://gist.github.com/3870046
Public Clone URL: git://gist.github.com/3870046.git


disable-RemoteDesktop — Gist
https://gist.github.com/3870057
Public Clone URL: git://gist.github.com/3870057.git

OS X 10.8.2: git-KeychainAccess.app

Mountain Lion で git を使う為に .ssh と .gitconfig を配置した。
以前使用していた keychain をバックアップから取り戻す必要があるが面倒だったので...
% ssh git@github.com してみたら Keychain Access.app (キーチェインアクセス) が起動して git 用 ssh key を登録できた。

(% ps aux | grep ssh してみて /usr/bin/ssh-agent プロセスが残っていたら kill しておく)

% ssh git@github.com
=>
...(省略)
You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.

.ssh/.known_hosts が追加された。


早速 gist.github.com にアクセスして clone し手元で編集しpush ...

% git clone git://gist.github.com/3870057 ~/disable-remotedesktop
% cd ~/diable-remotedesktop
% git add disable-RemoteDesktop.sh
# ファイル名を変更したり space を削除したり...

% git commit -m 'change name'
% git stauts
% git push origin master
=>
fatal: remote error: 
  You can't push to git://github.com/3870057.git
  Use git@github.com:3870057.git

push できなかった!

% git remote add origin git@github.com:3870057.git 
=>
fatal: remote origin already exists.

すでに存在しているようなので...

% git push git@github.com:3870057.git


push できた!
(以前は gitst へも push origin master で push できていたような気がするのですが...?)

[追記]

% git clone git://gist.github.com/3870057 ~/disable-remotedesktop

で clone した為 git push origin master ができなかった。

正しく ↓ clone した場合

% git clone git@gist.github.com:3870057.git ~/disable-remotedesktop

普通に git push origin master できた。